use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class LogisticsManager method getRequestedAmount.
public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack) {
int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.amount;
if (requestedAmount == 0)
return 0;
providingStack = providingStack.copy();
providingStack.amount = requestedAmount;
FluidStack remainder = providingStack.copy();
remainder.amount += requester.getIncomingFluid(remainder.getFluid());
TileEntity te = requester.getTileEntity();
if (te instanceof IFluidHandler) {
IFluidHandler fluidHandler = (IFluidHandler) te;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
int fluidFilled = fluidHandler.fill(d, remainder, false);
if (fluidFilled > 0) {
remainder.amount -= fluidFilled;
break;
}
}
}
providingStack.amount -= remainder.amount;
if (providingStack.amount <= 0)
return 0;
return providingStack.amount;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class BlockAphorismTile method setBlockBoundsBasedOnState.
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int par2, int par3, int par4) {
ForgeDirection dir = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(par2, par3, par4));
setBlockBounds(dir.offsetX <= 0 ? 0 : 1F - BBConstants.APHORISM_TILE_THICKNESS, dir.offsetY <= 0 ? 0 : 1F - BBConstants.APHORISM_TILE_THICKNESS, dir.offsetZ <= 0 ? 0 : 1F - BBConstants.APHORISM_TILE_THICKNESS, dir.offsetX >= 0 ? 1 : BBConstants.APHORISM_TILE_THICKNESS, dir.offsetY >= 0 ? 1 : BBConstants.APHORISM_TILE_THICKNESS, dir.offsetZ >= 0 ? 1 : BBConstants.APHORISM_TILE_THICKNESS);
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class BlockHeatSink method setBlockBoundsBasedOnState.
@Override
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int par2, int par3, int par4) {
ForgeDirection dir = ForgeDirection.getOrientation(blockAccess.getBlockMetadata(par2, par3, par4));
setBlockBounds(dir.offsetX <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetY <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetZ <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS, dir.offsetX >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS, dir.offsetY >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS, dir.offsetZ >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS);
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class BlockOmnidirectionalHopper method collisionRayTrace.
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityOmnidirectionalHopper) {
ForgeDirection o = ((TileEntityOmnidirectionalHopper) te).getDirection();
boolean isColliding = false;
setBlockBounds(o.offsetX == 1 ? 10 / 16F : 0, o.offsetY == 1 ? 10 / 16F : 0, o.offsetZ == 1 ? 10 / 16F : 0, o.offsetX == -1 ? 6 / 16F : 1, o.offsetY == -1 ? 6 / 16F : 1, o.offsetZ == -1 ? 6 / 16F : 1);
if (super.collisionRayTrace(world, x, y, z, origin, direction) != null)
isColliding = true;
setBlockBounds(4 / 16F, 4 / 16F, 4 / 16F, 12 / 16F, 12 / 16F, 12 / 16F);
if (super.collisionRayTrace(world, x, y, z, origin, direction) != null)
isColliding = true;
setBlockBounds(0, 0, 0, 1, 1, 1);
return isColliding ? super.collisionRayTrace(world, x, y, z, origin, direction) : null;
}
return null;
}
use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.
the class BlockElevatorCaller method collisionRayTrace.
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
setBlockBounds(0, 0, 0, 1, 1, 1);
MovingObjectPosition rayTrace = super.collisionRayTrace(world, x, y, z, origin, direction);
ForgeDirection orientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z) & 7).getOpposite();
if (rayTrace != null && rayTrace.sideHit == orientation.ordinal()) {
TileEntity te = world.getTileEntity(x, y, z);
if (te instanceof TileEntityElevatorCaller) {
TileEntityElevatorCaller caller = (TileEntityElevatorCaller) te;
for (TileEntityElevatorCaller.ElevatorButton button : caller.getFloors()) {
float startX = 0, startZ = 0, endX = 0, endZ = 0;
switch(orientation) {
case NORTH:
startZ = 0F;
endZ = 0.01F;
endX = 1 - (float) button.posX;
startX = 1 - ((float) button.posX + (float) button.width);
break;
case SOUTH:
startZ = 0.99F;
endZ = 1F;
startX = (float) button.posX;
endX = (float) button.posX + (float) button.width;
break;
case WEST:
startX = 0F;
endX = 0.01F;
startZ = (float) button.posX;
endZ = (float) button.posX + (float) button.width;
break;
case EAST:
startX = 0.99F;
endX = 1F;
endZ = 1 - (float) button.posX;
startZ = 1 - ((float) button.posX + (float) button.width);
break;
}
setBlockBounds(startX, 1 - (float) (button.posY + button.height), startZ, endX, 1 - (float) button.posY, endZ);
MovingObjectPosition buttonTrace = super.collisionRayTrace(world, x, y, z, origin, direction);
if (buttonTrace != null) {
if (startX > 0.01F && startX < 0.98F)
startX += 0.01F;
if (startZ > 0.01F && startZ < 0.98F)
startZ += 0.01F;
if (endX > 0.02F && endX < 0.99F)
endX -= 0.01F;
if (endZ > 0.02F && endZ < 0.99F)
endZ -= 0.01F;
setBlockBounds(startX, 1.01F - (float) (button.posY + button.height), startZ, endX, 0.99F - (float) button.posY, endZ);
buttonTrace.subHit = button.floorNumber;
return buttonTrace;
}
}
}
}
setBlockBounds(0, 0, 0, 1, 1, 1);
return rayTrace;
}
Aggregations