Prevent enchanters from crashing the world if somehow spawned in with an invalid metadata.

This commit is contained in:
Lizbeth Rika committed 2014-09-23 19:35:15 +01:00
1 parent ea4e365cbe
commit 200ef1e5d1
1 file changed
+7 -5
@@ -101,11 +101,13 @@ public class TileEnchanter extends TileMod implements ISparkAttachable {
@Override
public void updateEntity() {
if(!canEnchanterExist(worldObj, xCoord, yCoord, zCoord, getBlockMetadata())) {
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
if(tile != null && tile instanceof TilePylon)
((TilePylon) tile).activated = false;
}
if(getBlockMetadata() < PYLON_LOCATIONS.length)
for(int[] pylon : PYLON_LOCATIONS[getBlockMetadata()]) {
TileEntity tile = worldObj.getTileEntity(xCoord + pylon[0], yCoord + pylon[1], zCoord + pylon[2]);
if(tile != null && tile instanceof TilePylon)
((TilePylon) tile).activated = false;
}
worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.lapis_block, 0, 1 | 2);
for(int i = 0; i < 50; i++) {
float red = (float) Math.random();