blob: f72329387e3bbc4444eee5a3ac97dc94362daad9 [file] [log] [blame] [raw]
package universalelectricity.prefab.block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.core.block.IConductor;
public abstract class BlockConductor extends BlockContainer
{
public BlockConductor(int id, Material material)
{
super(id, material);
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IConductor)
{
((IConductor) tileEntity).updateAdjacentConnections();
}
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
* (coordinates passed are their own) Args: x, y, z, neighbor blockID
*/
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IConductor)
{
((IConductor) tileEntity).updateAdjacentConnections();
}
}
}