687a75f4d5
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.
64 lines
1.8 KiB
Java
64 lines
1.8 KiB
Java
package StevenDimDoors.mod_pocketDim.blocks;
|
|
|
|
import java.util.Random;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
import net.minecraft.util.Icon;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
import StevenDimDoors.mod_pocketDim.LimboDecay;
|
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
public class BlockLimbo extends Block
|
|
{
|
|
private final int limboDimensionID;
|
|
private final LimboDecay decay;
|
|
|
|
public BlockLimbo(int i, int j, Material par2Material, int limboDimensionID, LimboDecay decay)
|
|
{
|
|
super(i, Material.ground);
|
|
this.limboDimensionID = limboDimensionID;
|
|
this.decay = decay;
|
|
this.setTickRandomly(true);
|
|
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
|
}
|
|
|
|
/**
|
|
* Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
|
|
*/
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side)
|
|
{
|
|
return this.getIcon(side, blockAccess.getBlockMetadata(x, y, z));
|
|
}
|
|
|
|
@Override
|
|
public void registerIcons(IconRegister iconRegister)
|
|
{
|
|
this.blockIcon = iconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName2());
|
|
}
|
|
|
|
@Override
|
|
public Icon getIcon(int par1, int par2)
|
|
{
|
|
return this.blockIcon;
|
|
}
|
|
|
|
/**
|
|
* If the block is in Limbo, attempt to decay surrounding blocks upon receiving a random update tick.
|
|
*/
|
|
@Override
|
|
public void updateTick(World world, int x, int y, int z, Random random)
|
|
{
|
|
//Make sure this block is in Limbo
|
|
if (world.provider.dimensionId == limboDimensionID)
|
|
{
|
|
decay.applySpreadDecay(world, x, y, z);
|
|
}
|
|
}
|
|
}
|