diff --git a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt index d4d19e94e..d9018e278 100644 --- a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt +++ b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt @@ -73,7 +73,6 @@ -Ring of Growth: Lets Plants grow, more Reach with Tier 2 -Ring of Thorns: Hurts Attackers when they hit you with a Projectile -Ring of Water Walking - -Ring of Flight -Ring of Aquadive: Fast underwater movement -Ring of Suction: Sucks up Items in the area -Ring of Water Absorption: Removes Water around diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java index 7ebae8bde..defe974f1 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java @@ -5,7 +5,7 @@ import cofh.api.energy.IEnergyReceiver; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import net.minecraft.block.Block; +import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; @@ -19,6 +19,9 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I private final int maxWorkTime = ConfigIntValues.LAVA_FACTORY_TIME.getValue(); private int currentWorkTime; + //The Positions the Case Blocks should be in for the Factory to work + private static final int[][] CASE_POSITIONS = {{-1, 1, 0}, {1, 1, 0}, {0, 1, -1}, {0, 1, 1}}; + @Override @SuppressWarnings("unchecked") public void updateEntity(){ @@ -36,24 +39,12 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I } public int isMultiblock(){ - Block blockNorth = worldObj.getBlock(xCoord+ForgeDirection.NORTH.offsetX, yCoord+1, zCoord+ForgeDirection.NORTH.offsetZ); - Block blockEast = worldObj.getBlock(xCoord+ForgeDirection.EAST.offsetX, yCoord+1, zCoord+ForgeDirection.EAST.offsetZ); - Block blockSouth = worldObj.getBlock(xCoord+ForgeDirection.SOUTH.offsetX, yCoord+1, zCoord+ForgeDirection.SOUTH.offsetZ); - Block blockWest = worldObj.getBlock(xCoord+ForgeDirection.WEST.offsetX, yCoord+1, zCoord+ForgeDirection.WEST.offsetZ); - int metaNorth = worldObj.getBlockMetadata(xCoord+ForgeDirection.NORTH.offsetX, yCoord+1, zCoord+ForgeDirection.NORTH.offsetZ); - int metaEast = worldObj.getBlockMetadata(xCoord+ForgeDirection.EAST.offsetX, yCoord+1, zCoord+ForgeDirection.EAST.offsetZ); - int metaSouth = worldObj.getBlockMetadata(xCoord+ForgeDirection.SOUTH.offsetX, yCoord+1, zCoord+ForgeDirection.SOUTH.offsetZ); - int metaWest = worldObj.getBlockMetadata(xCoord+ForgeDirection.WEST.offsetX, yCoord+1, zCoord+ForgeDirection.WEST.offsetZ); - int metaNeeded = TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(); - - if(blockNorth == InitBlocks.blockMisc && blockEast == InitBlocks.blockMisc && blockSouth == InitBlocks.blockMisc && blockWest == InitBlocks.blockMisc){ - if(metaNorth == metaNeeded && metaEast == metaNeeded && metaSouth == metaNeeded && metaWest == metaNeeded){ - if(worldObj.getBlock(xCoord, yCoord+1, zCoord) == Blocks.lava || worldObj.getBlock(xCoord, yCoord+1, zCoord) == Blocks.flowing_lava){ - return HAS_LAVA; - } - if(worldObj.getBlock(xCoord, yCoord+1, zCoord) == null || worldObj.isAirBlock(xCoord, yCoord+1, zCoord)){ - return HAS_AIR; - } + if(WorldUtil.hasBlocksInPlacesGiven(CASE_POSITIONS, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), worldObj, xCoord, yCoord, zCoord)){ + if(worldObj.getBlock(xCoord, yCoord+1, zCoord) == Blocks.lava || worldObj.getBlock(xCoord, yCoord+1, zCoord) == Blocks.flowing_lava){ + return HAS_LAVA; + } + if(worldObj.getBlock(xCoord, yCoord+1, zCoord) == null || worldObj.isAirBlock(xCoord, yCoord+1, zCoord)){ + return HAS_AIR; } } return NOT_MULTI; diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index 5ab637800..9746cb12c 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -50,6 +50,26 @@ public class WorldUtil{ } } + /** + * Checks if a given Block with a given Meta is present in given Positions + * @param positions The Positions, an array of {xCoord, yCoord, zCoord} arrays containing RELATIVE Positions + * @param block The Block + * @param meta The Meta + * @param world The World + * @param x The Start X Coord + * @param y The Start Y Coord + * @param z The Start Z Coord + * @return Is every block present? + */ + public static boolean hasBlocksInPlacesGiven(int[][] positions, Block block, int meta, World world, int x, int y, int z){ + for(int[] xYZ : positions){ + if(!(world.getBlock(x+xYZ[0], y+xYZ[1], z+xYZ[2]) == block && world.getBlockMetadata(x+xYZ[0], y+xYZ[1], z+xYZ[2]) == meta)){ + return false; + } + } + return true; + } + public static void updateTileAndTilesAround(TileEntity tile){ tile.getWorldObj().markBlockForUpdate(tile.xCoord+1, tile.yCoord, tile.zCoord); tile.getWorldObj().markBlockForUpdate(tile.xCoord-1, tile.yCoord, tile.zCoord);