Overhauled Tick Sending by CommonTickHandler
Overhauled the way in which CommonTickHandler triggers tick-based actions such as Limbo decay, spawning Monoliths, and regenerating rifts. Now CommonTickHandler implements an interface called IRegularTickSender, which indicates that it will periodically call on classes that implement IRegulatTickReceiver to perform some task. I added classes for each regularly scheduled task we were performing: MonolithSpawner and RiftRegenerator, plus converted LimboDecay to a normal class instead of a static class. Modified several classes so that they have access to the MonolithSpawner instance to request MonolithSpawning when needed. This improves the structure of our code and gets us away from the way we did things before, which was accessing a public static list inside CommonTickHandler from other classes and adding arrays to specify chunk coordinates. We should not be exposing the internal state of classes like that! And we should be using clearly defined objects to pass information.
This commit is contained in:
@@ -1,41 +1,29 @@
|
||||
package StevenDimDoors.mod_pocketDim.world;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.network.packet.Packet34EntityTeleport;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MobObelisk;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.MonolithSpawner;
|
||||
|
||||
public class PocketGenerator extends ChunkProviderGenerate implements IChunkProvider
|
||||
{
|
||||
private World worldObj;
|
||||
|
||||
private DDProperties properties = null;
|
||||
|
||||
|
||||
private MonolithSpawner spawner;
|
||||
|
||||
public PocketGenerator(World par1World, long par2, boolean par4)
|
||||
public PocketGenerator(World par1World, long par2, boolean par4, MonolithSpawner spawner)
|
||||
{
|
||||
super(par1World, par2, par4);
|
||||
this.worldObj = par1World;
|
||||
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
this.spawner = spawner;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,8 +46,8 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
||||
|
||||
if(!chunk.isTerrainPopulated)
|
||||
{
|
||||
chunk.isTerrainPopulated=true;
|
||||
CommonTickHandler.chunksToPopulate.add(new int[] {chunk.worldObj.provider.dimensionId,chunkX,chunkZ});
|
||||
chunk.isTerrainPopulated = true;
|
||||
spawner.registerChunkForPopulation(worldObj.provider.dimensionId, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
return chunk;
|
||||
@@ -77,6 +65,7 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user