Java Code Examples for net.minecraftforge.fluids.FluidContainerRegistry#getFluidForFilledItem()
The following examples show how to use
net.minecraftforge.fluids.FluidContainerRegistry#getFluidForFilledItem() .
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 fillTankWithContainer(IFluidHandler tank, EntityPlayer player) { ItemStack stack = player.getCurrentEquippedItem(); FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack); if (liquid == null) return false; if (tank.fill(null, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode) return false; tank.fill(null, liquid, true); if (!player.capabilities.isCreativeMode) InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem); player.inventoryContainer.detectAndSendChanges(); return true; }
Example 2
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 3
Source File: StaticUtils.java From BigReactors with MIT License | 6 votes |
public static boolean fillTankWithContainer(World world, IFluidHandler handler, EntityPlayer player) { ItemStack container = player.getCurrentEquippedItem(); FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container); if (fluid != null) { if (handler.fill(ForgeDirection.UNKNOWN, fluid, false) == fluid.amount || player.capabilities.isCreativeMode) { if (world.isRemote) { return true; } handler.fill(ForgeDirection.UNKNOWN, fluid, true); if (!player.capabilities.isCreativeMode) { player.inventory.setInventorySlotContents(player.inventory.currentItem, Inventory.consumeItem(container)); } return true; } } return false; }
Example 4
Source File: FluidKineticGeneratorRecipes.java From Production-Line with MIT License | 5 votes |
/** * @return Whether this item can process */ @Override public boolean canProcess(ItemStack itemStack) { FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(itemStack); if (fluidStack != null) { for (RecipePart recipePart : this.processList) { if (((RecipePartFluidKineticGenerator) recipePart).fluidStack.isFluidEqual(fluidStack)) { return true; } } } return false; }
Example 5
Source File: RecipeInputFluidContainer.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@Override public boolean matches(ItemStack subject) { FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject); if (fs == null) return false; return fs.getFluid() == fluid; }
Example 6
Source File: CraftingRegistrator.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private static void scanForFluids(ShapedOreRecipe recipe){ for(int i = 0; i < recipe.getRecipeSize(); i++) { Object o = recipe.getInput()[i]; if(o instanceof ItemStack) { ItemStack stack = (ItemStack)o; FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack); if(fluid != null) { GameRegistry.addRecipe(new RecipeFluid(recipe, i)); } } } }
Example 7
Source File: RecipeFluid.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public RecipeFluid(ShapedOreRecipe recipe, int fluidIndex){ this.recipe = recipe; originalStack = (ItemStack)recipe.getInput()[fluidIndex]; fluidStack = FluidContainerRegistry.getFluidForFilledItem(originalStack); if(fluidStack == null) throw new IllegalArgumentException("Recipe doesn't have fluid item at index " + fluidIndex + ". Item: " + originalStack); this.fluidIndex = fluidIndex; }
Example 8
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 9
Source File: SlotFullFluidContainer.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isItemValid(ItemStack stack){ return stack != null && (FluidContainerRegistry.getFluidForFilledItem(stack) != null || stack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)stack.getItem()).getFluid(stack) != null); }
Example 10
Source File: TileEntityLiquidCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isItemValidForSlot(int slot, ItemStack stack){ return slot == 5 ? false : stack != null && (FluidContainerRegistry.getFluidForFilledItem(stack) != null || stack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)stack.getItem()).getFluid(stack) != null); }
Example 11
Source File: TileEntityKeroseneLamp.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isItemValidForSlot(int slot, ItemStack stack){ return slot == 1 ? false : stack != null && (FluidContainerRegistry.getFluidForFilledItem(stack) != null || stack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)stack.getItem()).getFluid(stack) != null); }
Example 12
Source File: BlockCertusTank.java From ExtraCells1 with MIT License | 4 votes |
@Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID, float offsetX, float offsetY, float offsetZ) { ItemStack current = entityplayer.inventory.getCurrentItem(); if (entityplayer.isSneaking() && current == null) { dropBlockAsItem_do(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z)); worldObj.destroyBlock(x, y, z, false); return true; } if (current != null) { FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); TileEntityCertusTank tank = (TileEntityCertusTank) worldObj.getBlockTileEntity(x, y, z); if (liquid != null) { int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true); if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode) { if (current.stackSize > 1) { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1; entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItemStack(current)); } else { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem().getContainerItemStack(current); } } return true; // Handle empty containers } else { FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; if (available != null) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); liquid = FluidContainerRegistry.getFluidForFilledItem(filled); if (liquid != null) { if (!entityplayer.capabilities.isCreativeMode) { if (current.stackSize > 1) { if (!entityplayer.inventory.addItemStackToInventory(filled)) { tank.fill(ForgeDirection.UNKNOWN, new FluidStack(liquid, liquid.amount), true); return false; } else { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1; } } else { entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = filled; } } tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true); return true; } } } } return false; }