Java Code Examples for net.minecraftforge.fluids.FluidContainerRegistry#isEmptyContainer()
The following examples show how to use
net.minecraftforge.fluids.FluidContainerRegistry#isEmptyContainer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FluidUtils.java From CodeChickenCore with MIT License | 6 votes |
public static boolean emptyTankIntoContainer(IFluidHandler tank, EntityPlayer player, FluidStack tankLiquid) { ItemStack stack = player.getCurrentEquippedItem(); if (!FluidContainerRegistry.isEmptyContainer(stack)) return false; ItemStack filled = FluidContainerRegistry.fillFluidContainer(tankLiquid, stack); FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(filled); if (liquid == null || filled == null) return false; tank.drain(null, liquid.amount, true); if (!player.capabilities.isCreativeMode) { if (stack.stackSize == 1) player.inventory.setInventorySlotContents(player.inventory.currentItem, filled); else if (player.inventory.addItemStackToInventory(filled)) stack.stackSize--; else return false; } player.inventoryContainer.detectAndSendChanges(); return true; }
Example 2
Source File: ECPrivatePatternInventory.java From ExtraCells1 with MIT License | 6 votes |
@Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { if (gridTE != null) { ICraftingPattern currentPattern = Util.getAssemblerPattern(itemstack); if (currentPattern == null || currentPattern.getRequirements() == null) return false; if (FluidContainerRegistry.isEmptyContainer(currentPattern.getOutput())) return false; for (ItemStack entry : currentPattern.getRequirements()) { if (entry != null && entry.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isFilledContainer(entry)) { return doesRecipeExist((ICraftingPatternMAC) currentPattern); } } } return false; }
Example 3
Source File: StaticUtils.java From BigReactors with MIT License | 5 votes |
public static boolean fillContainerFromTank(World world, IFluidHandler handler, EntityPlayer player, FluidStack tankFluid) { ItemStack container = player.getCurrentEquippedItem(); if (FluidContainerRegistry.isEmptyContainer(container)) { ItemStack returnStack = FluidContainerRegistry.fillFluidContainer(tankFluid, container); FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(returnStack); if (fluid == null || returnStack == null) { return false; } if (!player.capabilities.isCreativeMode) { if (container.stackSize == 1) { container = container.copy(); player.inventory.setInventorySlotContents(player.inventory.currentItem, returnStack); } else if (!player.inventory.addItemStackToInventory(returnStack)) { return false; } handler.drain(ForgeDirection.UNKNOWN, fluid.amount, true); container.stackSize--; if (container.stackSize <= 0) { container = null; } } else { handler.drain(ForgeDirection.UNKNOWN, fluid.amount, true); } return true; } return false; }
Example 4
Source File: BlockBRDevice.java From BigReactors with MIT License | 4 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { TileEntity te = world.getTileEntity(x, y, z); if(te == null) { return false; } if(entityPlayer.isSneaking()) { // Wrench + Sneak = Dismantle if(StaticUtils.Inventory.isPlayerHoldingWrench(entityPlayer)) { // Pass simulate == true on the client to prevent creation of "ghost" item stacks dismantleBlock(entityPlayer, null, world, x, y, z, false, world.isRemote); return true; } return false; } if(te instanceof IWrenchable && StaticUtils.Inventory.isPlayerHoldingWrench(entityPlayer)) { return ((IWrenchable)te).onWrench(entityPlayer, side); } // Handle buckets if(te instanceof IFluidHandler) { if(FluidContainerRegistry.isEmptyContainer(entityPlayer.inventory.getCurrentItem())) { IFluidHandler fluidHandler = (IFluidHandler)te; FluidTankInfo[] infoz = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN); for(FluidTankInfo info : infoz) { if(StaticUtils.Fluids.fillContainerFromTank(world, fluidHandler, entityPlayer, info.fluid)) { return true; } } } else if(FluidContainerRegistry.isFilledContainer(entityPlayer.inventory.getCurrentItem())) { if(StaticUtils.Fluids.fillTankWithContainer(world, (IFluidHandler)te, entityPlayer)) { return true; } } } // Show GUI if(te instanceof TileEntityBeefBase) { if(!world.isRemote) { entityPlayer.openGui(BRLoader.instance, 0, world, x, y, z); } return true; } return false; }