Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix MCPC+ compatibility when used as a Bukkit plugin

Terrain Control now accepts more orders in which methods can be called.

You can't use TC as a Forge mod at the moment on MCPC+, but that will be
fixed soon.
  • Loading branch information...
commit 0f0d271f3770dc20a45a2ebdc5de2b018432b20f 1 parent bc6fe08
@rutgerkok rutgerkok authored
View
2  platforms/bukkit/src/main/java/com/khorn/terraincontrol/bukkit/BukkitWorld.java
@@ -696,7 +696,7 @@ public void enable(org.bukkit.World world)
this.netherFortress = new NetherFortressGen();
case NotGenerate:
case TerrainTest:
- this.generator.Init(this);
+ this.generator.onInitialize(this);
break;
case Default:
break;
View
31 platforms/bukkit/src/main/java/com/khorn/terraincontrol/bukkit/TCChunkGenerator.java
@@ -17,12 +17,34 @@
private ArrayList<BlockPopulator> BlockPopulator = new ArrayList<BlockPopulator>();
private boolean NotGenerate = false;
private TCPlugin plugin;
+
public TCChunkGenerator(TCPlugin _plugin)
{
this.plugin = _plugin;
}
- public void Init(BukkitWorld _world)
+ /**
+ * Initializes the world if it hasn't already been initialized.
+ *
+ * @param world
+ * The world of this generator.
+ */
+ private void makeSureWorldIsInitialized(World world)
+ {
+ if (this.chunkProviderTC == null)
+ {
+ // Not yet initialized, do it now
+ this.plugin.onWorldInit(world);
+ }
+ }
+
+ /**
+ * Called whenever a BukkitWorld instance becomes available.
+ *
+ * @param _world
+ * The BukkitWorld instance.
+ */
+ public void onInitialize(BukkitWorld _world)
{
this.chunkProviderTC = new ChunkProviderTC(_world.getSettings(), _world);
@@ -38,14 +60,15 @@ public void Init(BukkitWorld _world)
@Override
public List<BlockPopulator> getDefaultPopulators(World world)
{
- this.plugin.onWorldInit(world);
+ makeSureWorldIsInitialized(world);
+
return this.BlockPopulator;
}
@Override
public boolean canSpawn(World world, int x, int z)
{
- this.plugin.onWorldInit(world);
+ makeSureWorldIsInitialized(world);
Material material = world.getHighestBlockAt(x, z).getType();
return material.isSolid();
@@ -54,6 +77,8 @@ public boolean canSpawn(World world, int x, int z)
@Override
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes)
{
+ makeSureWorldIsInitialized(world);
+
if (this.NotGenerate)
return new byte[16][];
byte[] BlockArray = this.chunkProviderTC.generate(x, z);
Please sign in to comment.
Something went wrong with that request. Please try again.