use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class HeatBehaviourLiquidTransition method transformSourceBlock.
protected void transformSourceBlock(Block turningBlockSource, Block turningBlockFlowing) {
if (FluidUtils.isSourceBlock(getWorld(), getX(), getY(), getZ())) {
getWorld().setBlock(getX(), getY(), getZ(), turningBlockSource);
onLiquidTransition(getX(), getY(), getZ());
} else {
Set<ChunkPosition> traversed = new HashSet<ChunkPosition>();
Stack<ChunkPosition> pending = new Stack<ChunkPosition>();
pending.push(new ChunkPosition(getX(), getY(), getZ()));
while (!pending.isEmpty()) {
ChunkPosition pos = pending.pop();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
ChunkPosition newPos = new ChunkPosition(pos.chunkPosX + d.offsetX, pos.chunkPosY + d.offsetY, pos.chunkPosZ + d.offsetZ);
Block checkingBlock = getWorld().getBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
if ((checkingBlock == getBlock() || getBlock() == Blocks.flowing_water && checkingBlock == Blocks.water || getBlock() == Blocks.flowing_lava && checkingBlock == Blocks.lava) && traversed.add(newPos)) {
if (FluidUtils.isSourceBlock(getWorld(), newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ)) {
getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockSource);
onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
return;
} else {
getWorld().setBlock(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ, turningBlockFlowing);
onLiquidTransition(newPos.chunkPosX, newPos.chunkPosY, newPos.chunkPosZ);
pending.push(newPos);
}
}
}
}
}
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class ModuleRegulatorTube method getMaxDispersion.
@Override
public int getMaxDispersion() {
IAirHandler connectedHandler = null;
for (Pair<ForgeDirection, IAirHandler> entry : pressureTube.getAirHandler().getConnectedPneumatics()) {
if (entry.getKey().equals(dir)) {
connectedHandler = entry.getValue();
break;
}
}
if (connectedHandler == null)
return 0;
int maxDispersion = (int) ((getThreshold() - connectedHandler.getPressure(ForgeDirection.UNKNOWN)) * connectedHandler.getVolume());
if (maxDispersion < 0)
return 0;
return maxDispersion;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class BlockPneumaticDoorBase method shouldSideBeRendered.
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
ForgeDirection d = ForgeDirection.getOrientation(side);
TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase) world.getTileEntity(x - d.offsetX, y - d.offsetY, z - d.offsetZ);
ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
Block block = ((ItemBlock) camoStack.getItem()).field_150939_a;
if (PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
return true;
}
}
return false;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class BlockPressureTube method canConnectRedstone.
/**
* Determine if this block can make a redstone connection on the side provided,
* Useful to control which sides are inputs and outputs for redstone wires.
*
* Side:
* -1: UP
* 0: NORTH
* 1: EAST
* 2: SOUTH
* 3: WEST
*
* @param world The current world
* @param x X Position
* @param y Y Position
* @param z Z Position
* @param side The side that is trying to make the connection
* @return True to make the connection
*/
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
if (side < 0 || side > 3)
return false;
TileEntityPressureTube tube = (TileEntityPressureTube) world.getTileEntity(x, y, z);
ForgeDirection d = ForgeDirection.NORTH;
for (int i = 0; i < side; i++) {
d = d.getRotation(ForgeDirection.UP);
}
side = d.ordinal();
for (int i = 0; i < 6; i++) {
if (tube.modules[i] != null) {
if ((side ^ 1) == i || i != side && tube.modules[i].isInline()) {
//if we are on the same side, or when we have an 'in line' module that is not on the opposite side.
if (tube.modules[i] instanceof TubeModuleRedstoneEmitting)
return true;
}
}
}
return false;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class SemiBlockRequester method amountRequested.
@Override
public int amountRequested(FluidStack stack) {
int totalRequestingAmount = getTotalRequestedAmount(stack);
if (totalRequestingAmount > 0) {
TileEntity te = getTileEntity();
if (te instanceof IFluidHandler) {
int count = 0;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
FluidTankInfo[] infos = ((IFluidHandler) te).getTankInfo(d);
if (infos != null) {
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.getFluid() == stack.getFluid()) {
count += info.fluid.amount;
}
}
if (count > 0)
break;
}
}
count += getIncomingFluid(stack.getFluid());
int requested = Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
return requested;
}
}
return 0;
}
Aggregations