Changed a method in WorldUtil just for comfort in the future

This commit is contained in:
Ellpeck 2015-07-27 08:40:24 +02:00
parent 0db7276493
commit eb82add938
3 changed files with 22 additions and 20 deletions

View file

@ -27,7 +27,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
ArrayList<Integer> blocksAround = new ArrayList<Integer>(); ArrayList<Integer> blocksAround = new ArrayList<Integer>();
if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
for(int i = 1; i <= 5; i++){ for(int i = 1; i <= 5; i++){
WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByRotatingSide(i), worldObj, xCoord, yCoord, zCoord); WorldPos coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionBySidesInOrder(i), worldObj, xCoord, yCoord, zCoord);
if(coords != null){ if(coords != null){
Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ()); Block block = worldObj.getBlock(coords.getX(), coords.getY(), coords.getZ());
if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){ if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.getX(), coords.getY(), coords.getZ()) == 0){
@ -43,7 +43,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
Random rand = new Random(); Random rand = new Random();
if(rand.nextInt(randomChance) == 0){ if(rand.nextInt(randomChance) == 0){
int randomSide = blocksAround.get(rand.nextInt(blocksAround.size())); int randomSide = blocksAround.get(rand.nextInt(blocksAround.size()));
WorldUtil.breakBlockAtSide(WorldUtil.getDirectionByRotatingSide(randomSide), worldObj, xCoord, yCoord, zCoord); WorldUtil.breakBlockAtSide(WorldUtil.getDirectionBySidesInOrder(randomSide), worldObj, xCoord, yCoord, zCoord);
} }
} }
if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){

View file

@ -309,8 +309,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
public void initVars(){ public void initVars(){
//Gets the Place to put and Pull //Gets the Place to put and Pull
this.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionByRotatingSide(this.sideToPull), this.worldObj, this.xCoord, this.yCoord, this.zCoord); this.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPull), this.worldObj, this.xCoord, this.yCoord, this.zCoord);
this.placeToPut = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionByRotatingSide(this.sideToPut), this.worldObj, this.xCoord, this.yCoord, this.zCoord); this.placeToPut = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPut), this.worldObj, this.xCoord, this.yCoord, this.zCoord);
//Resets the Variables //Resets the Variables
if(this.placeToPull instanceof IInventory){ if(this.placeToPull instanceof IInventory){

View file

@ -193,23 +193,25 @@ public class WorldUtil{
} }
} }
public static ForgeDirection getDirectionByRotatingSide(int side){ /**
switch(side){ * Horizontal Directions in Order:
case 0: * Up, Down
return ForgeDirection.UP; */
case 1: public static final ForgeDirection[] HORIZONTAL_DIRECTIONS_ORDER = new ForgeDirection[]{ForgeDirection.UP, ForgeDirection.DOWN};
return ForgeDirection.DOWN; /**
case 2: * Cardinal Directions in Order:
return ForgeDirection.NORTH; * North, East, South, West
case 3: */
return ForgeDirection.EAST; public static final ForgeDirection[] CARDINAL_DIRECTIONS_ORDER = new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.WEST};
case 4:
return ForgeDirection.SOUTH; public static ForgeDirection getDirectionBySidesInOrder(int side){
case 5: if(side >= 0 && side < HORIZONTAL_DIRECTIONS_ORDER.length+CARDINAL_DIRECTIONS_ORDER.length){
return ForgeDirection.WEST; if(side < HORIZONTAL_DIRECTIONS_ORDER.length){
default: return HORIZONTAL_DIRECTIONS_ORDER[side];
return ForgeDirection.UNKNOWN;
} }
else return CARDINAL_DIRECTIONS_ORDER[side-HORIZONTAL_DIRECTIONS_ORDER.length];
}
return ForgeDirection.UNKNOWN;
} }
public static ArrayList<Material> getMaterialsAround(World world, int x, int y, int z){ public static ArrayList<Material> getMaterialsAround(World world, int x, int y, int z){