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>();
if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){
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){
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){
@ -43,7 +43,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr
Random rand = new Random();
if(rand.nextInt(randomChance) == 0){
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){

View file

@ -309,8 +309,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
public void initVars(){
//Gets the Place to put and Pull
this.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionByRotatingSide(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.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionBySidesInOrder(this.sideToPull), 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
if(this.placeToPull instanceof IInventory){

View file

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