net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack Java Examples
The following examples show how to use
net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack.
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: ItemFluidContainer.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
@SideOnly(Side.CLIENT) @Override public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) { if (isInCreativeTab(tab)) { subItems.add(new ItemStack(this)); for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { if (!fluid.getName().equals("milk")) { // add all fluids that the bucket can be filled with FluidStack fs = new FluidStack(fluid, content.capacity); ItemStack stack = new ItemStack(this); IFluidHandlerItem fluidHandler = new FluidHandlerItemStack(stack, content.capacity); if (fluidHandler.fill(fs, true) == fs.amount) { ItemStack filled = fluidHandler.getContainer(); subItems.add(filled); } } } } }
Example #2
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initFromItemStackData(NBTTagCompound itemStack) { super.initFromItemStackData(itemStack); if (itemStack.hasKey(FluidHandlerItemStack.FLUID_NBT_KEY, NBT.TAG_COMPOUND)) { FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(itemStack.getCompoundTag(FluidHandlerItemStack.FLUID_NBT_KEY)); this.multiblockFluidTank.fill(fluidStack, true); } }
Example #3
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void writeItemStackData(NBTTagCompound itemStack) { super.writeItemStackData(itemStack); FluidStack fluidStack = multiblockFluidTank.drain(Integer.MAX_VALUE, false); if (fluidStack != null && fluidStack.amount > 0) { NBTTagCompound tagCompound = new NBTTagCompound(); fluidStack.writeToNBT(tagCompound); itemStack.setTag(FluidHandlerItemStack.FLUID_NBT_KEY, tagCompound); } }
Example #4
Source File: MetaTileEntityTank.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ICapabilityProvider initItemStackCapabilities(ItemStack itemStack) { return new FluidHandlerItemStack(itemStack, tankSize) { @Override public boolean canFillFluidType(FluidStack fluid) { return MetaTileEntityTank.this.canFillFluidType(fluid); } }; }
Example #5
Source File: FoamSprayerBehavior.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ICapabilityProvider createProvider(ItemStack itemStack) { return new FluidHandlerItemStack(itemStack, 10000) { @Override public boolean canFillFluidType(FluidStack fluid) { return fluid != null && fluid.isFluidEqual(Materials.ConstructionFoam.getFluid(1)); } }; }
Example #6
Source File: TankCapabilityItemStack.java From AdvancedRocketry with MIT License | 4 votes |
public TankCapabilityItemStack(ItemStack stack, int capacity) { fluidHandler = new FluidHandlerItemStack(stack, capacity); }