From 2cfb7bc80cea8c816a81c2edff852ed760b6b44d Mon Sep 17 00:00:00 2001 From: damagefilter Date: Thu, 23 May 2013 22:07:23 +0200 Subject: [PATCH] Preparations for custom worldgen, addresses #21 Renamed ChunkProviderServer to ChunkProvider. We're going to use it to implement custom generator logic. --- ...ProviderServer.java => ChunkProvider.java} | 35 +++++++++++++++++-- .../java/net/canarymod/api/world/World.java | 4 +-- 2 files changed, 34 insertions(+), 5 deletions(-) rename src/main/java/net/canarymod/api/world/{ChunkProviderServer.java => ChunkProvider.java} (63%) diff --git a/src/main/java/net/canarymod/api/world/ChunkProviderServer.java b/src/main/java/net/canarymod/api/world/ChunkProvider.java similarity index 63% rename from src/main/java/net/canarymod/api/world/ChunkProviderServer.java rename to src/main/java/net/canarymod/api/world/ChunkProvider.java index 31550c35..07962a5d 100644 --- a/src/main/java/net/canarymod/api/world/ChunkProviderServer.java +++ b/src/main/java/net/canarymod/api/world/ChunkProvider.java @@ -1,7 +1,18 @@ package net.canarymod.api.world; - -public interface ChunkProviderServer { +/** + * Chunk Provider interface. This has two purposes.
+ * One is to wrap the ChunkProviderServer in the NMS implementation. + *
+ * The other, much more interesting purpose is to be implemented by Plugins, + * then mapped to dimension types - in order to provide custom world generation.
+ *

Custom World Generation

+ * This is the interface everything related to world generation boils down to. + * A world will use this to create its terrain and call the provideChunk methid. + * @author Chris (damagefilter) + * + */ +public interface ChunkProvider { /** * Check if this chunk provider is allowed to save chunks @@ -31,7 +42,25 @@ public interface ChunkProviderServer { public Chunk loadChunk(int x, int z); /** - * Load the given chunk if it is not loaded + * Is called after the large-scale generation is done to populate the world with details. + * For instance glowstone blocks + * The x/z must be chunk coordinates, that means right-shifted by 4 + * @param provider + * @param x + * @param z + */ + public void populate(ChunkProvider provider, int x, int z); + + /** + * Return a String that displays the statistics for this ChunkProvider. + * This will be shown in the servers GUI for instance.
+ * The default NMS method returns the size of the Chunk Cache and the number of dropped chunks + * @return + */ + public String getStatistics(); + + /** + * Reload the given chunk. * The x/z must be chunk coordinates, that means right-shifted by 4 * * @return true when successful, false otherwise diff --git a/src/main/java/net/canarymod/api/world/World.java b/src/main/java/net/canarymod/api/world/World.java index 3776dbd5..03370186 100644 --- a/src/main/java/net/canarymod/api/world/World.java +++ b/src/main/java/net/canarymod/api/world/World.java @@ -352,11 +352,11 @@ public static GameMode fromId(int id) { public Player getClosestPlayer(Entity entity, int distance); /** - * Return this worlds {@link ChunkProviderServer} + * Return this worlds {@link ChunkProvider} * * @return */ - public ChunkProviderServer getChunkProvider(); + public ChunkProvider getChunkProvider(); /** * Check if the chunk where that block is, is loaded