Skip to content

Commit

Permalink
Fix MCPC+ compatibility when used as a Bukkit plugin
Browse files Browse the repository at this point in the history
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
rutgerkok committed Feb 12, 2014
1 parent bc6fe08 commit 0f0d271
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Expand Up @@ -696,7 +696,7 @@ public void enable(org.bukkit.World world)
this.netherFortress = new NetherFortressGen(); this.netherFortress = new NetherFortressGen();
case NotGenerate: case NotGenerate:
case TerrainTest: case TerrainTest:
this.generator.Init(this); this.generator.onInitialize(this);
break; break;
case Default: case Default:
break; break;
Expand Down
Expand Up @@ -17,12 +17,34 @@ public class TCChunkGenerator extends ChunkGenerator
private ArrayList<BlockPopulator> BlockPopulator = new ArrayList<BlockPopulator>(); private ArrayList<BlockPopulator> BlockPopulator = new ArrayList<BlockPopulator>();
private boolean NotGenerate = false; private boolean NotGenerate = false;
private TCPlugin plugin; private TCPlugin plugin;

public TCChunkGenerator(TCPlugin _plugin) public TCChunkGenerator(TCPlugin _plugin)
{ {
this.plugin = _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); this.chunkProviderTC = new ChunkProviderTC(_world.getSettings(), _world);


Expand All @@ -38,14 +60,15 @@ public void Init(BukkitWorld _world)
@Override @Override
public List<BlockPopulator> getDefaultPopulators(World world) public List<BlockPopulator> getDefaultPopulators(World world)
{ {
this.plugin.onWorldInit(world); makeSureWorldIsInitialized(world);

return this.BlockPopulator; return this.BlockPopulator;
} }


@Override @Override
public boolean canSpawn(World world, int x, int z) public boolean canSpawn(World world, int x, int z)
{ {
this.plugin.onWorldInit(world); makeSureWorldIsInitialized(world);


Material material = world.getHighestBlockAt(x, z).getType(); Material material = world.getHighestBlockAt(x, z).getType();
return material.isSolid(); return material.isSolid();
Expand All @@ -54,6 +77,8 @@ public boolean canSpawn(World world, int x, int z)
@Override @Override
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes)
{ {
makeSureWorldIsInitialized(world);

if (this.NotGenerate) if (this.NotGenerate)
return new byte[16][]; return new byte[16][];
byte[] BlockArray = this.chunkProviderTC.generate(x, z); byte[] BlockArray = this.chunkProviderTC.generate(x, z);
Expand Down

0 comments on commit 0f0d271

Please sign in to comment.