diff options
Diffstat (limited to 'src/main/java/net/minecraft')
5 files changed, 66 insertions, 10 deletions
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java index 8d790184..40a2b91d 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java @@ -6,6 +6,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.Set; // CraftBukkit start @@ -16,6 +17,7 @@ import org.bukkit.craftbukkit.util.LongHashset; import org.bukkit.craftbukkit.util.LongHashtable; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; +import org.bukkit.generator.BlockPopulator; // CraftBukkit end public class ChunkProviderServer implements IChunkProvider { @@ -172,6 +174,20 @@ public class ChunkProviderServer implements IChunkProvider { chunk.done = true; if (this.chunkProvider != null) { this.chunkProvider.getChunkAt(ichunkprovider, i, j); + + // Craftbukkit start + BlockSand.a = true; + Random random = new Random(); + random.setSeed(world.getSeed()); + long xRand = random.nextLong() / 2L * 2L + 1L; + long zRand = random.nextLong() / 2L * 2L + 1L; + random.setSeed((long) i * xRand + (long) j * zRand ^ world.getSeed()); + for (BlockPopulator populator : world.getWorld().getPopulators()) { + populator.populate(world.getWorld(), random, chunk.bukkitChunk); + } + BlockSand.a = false; + // Craftbukkit end + chunk.f(); } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index cfd527ef..98221345 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -166,10 +166,10 @@ public class MinecraftServer implements Runnable, ICommandListener { int dimension = j == 0 ? 0 : -1; if (j == 0) { - world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, dimension, i, org.bukkit.World.Environment.getEnvironment(dimension)); // CraftBukkit + world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, dimension, i, org.bukkit.World.Environment.getEnvironment(dimension), null); // CraftBukkit } else { String name = s + "_" + Environment.getEnvironment(dimension).toString().toLowerCase(); - world = new SecondaryWorldServer(this, new ServerNBTManager(new File("."), name, true), name, dimension, i, worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension)); // CraftBukkit + world = new SecondaryWorldServer(this, new ServerNBTManager(new File("."), name, true), name, dimension, i, worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension), null); // CraftBukkit } world.tracker = new EntityTracker(this, dimension); diff --git a/src/main/java/net/minecraft/server/SecondaryWorldServer.java b/src/main/java/net/minecraft/server/SecondaryWorldServer.java index 06159cda..d36af3f8 100644 --- a/src/main/java/net/minecraft/server/SecondaryWorldServer.java +++ b/src/main/java/net/minecraft/server/SecondaryWorldServer.java @@ -1,9 +1,11 @@ package net.minecraft.server; +import org.bukkit.generator.ChunkGenerator; + public class SecondaryWorldServer extends WorldServer { // CraftBukkit start - public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j, WorldServer worldserver, org.bukkit.World.Environment env) { - super(minecraftserver, idatamanager, s, i, j, env); + public SecondaryWorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j, WorldServer worldserver, org.bukkit.World.Environment env, ChunkGenerator gen) { + super(minecraftserver, idatamanager, s, i, j, env, gen); // CraftBukkit end this.z = worldserver.z; } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index a5f954b2..259ccdcf 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -9,6 +9,7 @@ import java.util.Set; import java.util.TreeSet; // CraftBukkit start +import org.bukkit.generator.ChunkGenerator; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.event.CraftEventFactory; @@ -65,12 +66,17 @@ public class World implements IBlockAccess { private int O; private List P; public boolean isStatic; + public ChunkGenerator generator; // Craftbukkit public WorldChunkManager getWorldChunkManager() { return this.worldProvider.b; } - public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider) { + // Craftbukkit start - changed signature + public World(IDataManager idatamanager, String s, long i, WorldProvider worldprovider, ChunkGenerator gen) { + this.generator = gen; + // Craftbukkit end + this.O = this.random.nextInt(12000); this.P = new ArrayList(); this.isStatic = false; @@ -118,7 +124,8 @@ public class World implements IBlockAccess { int j; - for (j = 0; !this.worldProvider.a(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) { + // Craftbukkit + for (j = 0; !canSpawn(i, j); j += this.random.nextInt(64) - this.random.nextInt(64)) { i += this.random.nextInt(64) - this.random.nextInt(64); } @@ -126,6 +133,16 @@ public class World implements IBlockAccess { this.isLoading = false; } + // Craftbukkit start + private boolean canSpawn(int x, int z) { + if (generator != null) { + return this.generator.canSpawn(((WorldServer)this).getWorld(), x, z); + } else { + return this.worldProvider.a(x, z); + } + } + // Craftbukkit end + public int a(int i, int j) { int k; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index cc933aeb..14006ee8 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -5,8 +5,14 @@ import java.util.List; // CraftBukkit start import org.bukkit.BlockChangeDelegate; +import org.bukkit.generator.ChunkGenerator; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.generator.CustomChunkGenerator; +import org.bukkit.craftbukkit.generator.InternalChunkGenerator; +import org.bukkit.craftbukkit.generator.NetherChunkGenerator; +import org.bukkit.craftbukkit.generator.NormalChunkGenerator; +import org.bukkit.craftbukkit.generator.SkyLandsChunkGenerator; import org.bukkit.event.weather.LightningStrikeEvent; public class WorldServer extends World implements BlockChangeDelegate { @@ -19,13 +25,13 @@ public class WorldServer extends World implements BlockChangeDelegate { private EntityList G = new EntityList(); // CraftBukkit start - change signature - public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j, org.bukkit.World.Environment env) { - super(idatamanager, s, j, WorldProvider.a(env.getId())); + public WorldServer(MinecraftServer minecraftserver, IDataManager idatamanager, String s, int i, long j, org.bukkit.World.Environment env, ChunkGenerator gen) { + super(idatamanager, s, j, WorldProvider.a(env.getId()), gen); this.server = minecraftserver; this.dimension = i; this.cserver = minecraftserver.server; - this.world = new CraftWorld(this); + this.world = new CraftWorld(this, gen); this.pvpMode = minecraftserver.pvpMode; this.manager = new PlayerManager(minecraftserver, dimension, minecraftserver.propertyManager.getInt("view-distance", 10)); } @@ -64,7 +70,22 @@ public class WorldServer extends World implements BlockChangeDelegate { protected IChunkProvider b() { IChunkLoader ichunkloader = this.w.a(this.worldProvider); - this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.worldProvider.b()); + // Craftbukkit start + InternalChunkGenerator gen; + + if (this.generator != null) { + gen = new CustomChunkGenerator(this, this.getSeed(), this.generator); + } else if (this.worldProvider instanceof WorldProviderHell) { + gen = new NetherChunkGenerator(this, this.getSeed()); + } else if (this.worldProvider instanceof WorldProviderSky) { + gen = new SkyLandsChunkGenerator(this, this.getSeed()); + } else { + gen = new NormalChunkGenerator(this, this.getSeed()); + } + + this.chunkProviderServer = new ChunkProviderServer(this, ichunkloader, gen); + // Craftbukkit end + return this.chunkProviderServer; } |