use of net.minecraftforge.fluids.IFluidBlock in project BuildCraft by BuildCraft.
the class TileQuarry method isQuarriableBlock.
private boolean isQuarriableBlock(BlockPos pos) {
IBlockState state = worldObj.getBlockState(pos);
Block block = state.getBlock();
return BlockUtil.canChangeBlock(state, worldObj, pos) && !BuildCraftAPI.isSoftBlock(worldObj, pos) && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock);
}
use of net.minecraftforge.fluids.IFluidBlock in project BuildCraft by BuildCraft.
the class PipeItemsStripes method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (container.getWorld().isRemote) {
return;
}
if (battery.getEnergyStored() >= 10) {
EnumPipePart o = actionDir;
if (o == EnumPipePart.CENTER) {
o = EnumPipePart.fromFacing(getOpenOrientation());
}
if (o != EnumPipePart.CENTER) {
Vec3d vec = Utils.convert(container.getPos()).add(Utils.convert(o.face));
BlockPos veci = Utils.convertFloor(vec);
if (!BlockUtil.isUnbreakableBlock(getWorld(), Utils.convertFloor(vec))) {
IBlockState state = getWorld().getBlockState(Utils.convertFloor(vec));
Block block = state.getBlock();
if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
return;
}
ItemStack stack = new ItemStack(block, 1, block.getMetaFromState(state));
EntityPlayer player = CoreProxy.proxy.getBuildCraftPlayer((WorldServer) getWorld(), veci).get();
if (battery.useEnergy(10, 10, false) != 10) {
return;
}
for (IStripesHandler handler : PipeManager.stripesHandlers) {
if (handler.getType() == StripesHandlerType.BLOCK_BREAK && handler.shouldHandle(stack)) {
if (handler.handle(getWorld(), veci, o.face, stack, player, this)) {
return;
}
}
}
List<ItemStack> stacks = block.getDrops(getWorld(), veci, state, 0);
if (stacks != null) {
for (ItemStack s : stacks) {
if (s != null) {
sendItem(s, o.opposite().face);
}
}
}
getWorld().setBlockToAir(veci);
}
}
return;
}
}
use of net.minecraftforge.fluids.IFluidBlock in project BuildCraft by BuildCraft.
the class ItemFacade method isValidFacade.
public static boolean isValidFacade(IBlockState state) {
if (blacklistedFacades.contains(state)) {
return false;
}
if (whitelistedFacades.contains(state)) {
return true;
}
Block block = state.getBlock();
if (block instanceof IFluidBlock || block.hasTileEntity(state)) {
return false;
}
block.setBlockBoundsBasedOnState(new FakeBlockAccessSingleBlock(state), BlockPos.ORIGIN);
if (block.getBlockBoundsMinX() != 0.0D || block.getBlockBoundsMinY() != 0.0D || block.getBlockBoundsMinZ() != 0.0D) {
return false;
}
if (block.getBlockBoundsMaxX() != 1.0D || block.getBlockBoundsMaxY() != 1.0D || block.getBlockBoundsMaxZ() != 1.0D) {
return false;
}
return true;
}
use of net.minecraftforge.fluids.IFluidBlock in project BloodMagic by WayofTime.
the class RitualPump method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
if (tileEntity != null && tileEntity.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
IFluidHandler fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN);
IBlockState tankState = world.getBlockState(masterRitualStone.getBlockPos().up());
int maxDrain = fluidHandler.getTankProperties()[0].getCapacity();
if (fluidHandler.getTankProperties()[0].getContents() != null && fluidHandler.getTankProperties()[0].getContents().amount >= maxDrain)
return;
for (BlockPos pos : getBlockRange(PUMP_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) {
IBlockState state = world.getBlockState(pos);
IFluidHandler blockHandler = null;
if (state.getBlock() instanceof BlockLiquid)
blockHandler = new BlockLiquidWrapper((BlockLiquid) state.getBlock(), world, pos);
else if (state.getBlock() instanceof IFluidHandler)
blockHandler = new FluidBlockWrapper((IFluidBlock) state.getBlock(), world, pos);
if (blockHandler != null) {
FluidStack blockDrain = blockHandler.drain(maxDrain, false);
if (blockDrain != null && fluidHandler.fill(blockDrain, false) == blockDrain.amount) {
Pair<BlockPos, FluidStack> posInfo = Pair.of(pos, blockHandler.drain(maxDrain, false));
if (!liquidsCache.contains(posInfo))
liquidsCache.add(posInfo);
}
}
}
blockPosIterator = liquidsCache.iterator();
if (blockPosIterator.hasNext()) {
Pair<BlockPos, FluidStack> posInfo = blockPosIterator.next();
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost());
fluidHandler.fill(posInfo.getRight(), true);
world.setBlockState(posInfo.getLeft(), Blocks.STONE.getDefaultState());
world.notifyBlockUpdate(posInfo.getLeft(), tankState, tankState, 3);
blockPosIterator.remove();
}
}
}
use of net.minecraftforge.fluids.IFluidBlock in project GregTech by GregTechCE.
the class MetaTileEntityPump method checkFluidBlockAt.
private void checkFluidBlockAt(BlockPos pumpHeadPos, BlockPos checkPos) {
IBlockState blockHere = getWorld().getBlockState(checkPos);
boolean shouldCheckNeighbours = isStraightInPumpRange(checkPos);
if (blockHere.getBlock() instanceof BlockLiquid || blockHere.getBlock() instanceof IFluidBlock) {
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(getWorld(), checkPos, null);
FluidStack drainStack = fluidHandler.drain(Integer.MAX_VALUE, false);
if (drainStack != null && drainStack.amount > 0) {
this.fluidSourceBlocks.add(checkPos);
}
shouldCheckNeighbours = true;
}
if (shouldCheckNeighbours) {
int maxPumpRange = getMaxPumpRange();
for (EnumFacing facing : EnumFacing.VALUES) {
BlockPos offsetPos = checkPos.offset(facing);
if (offsetPos.distanceSq(pumpHeadPos) > maxPumpRange * maxPumpRange)
// do not add blocks outside bounds
continue;
if (!fluidSourceBlocks.contains(offsetPos) && !blocksToCheck.contains(offsetPos)) {
this.blocksToCheck.add(offsetPos);
}
}
}
}
Aggregations