diff --git a/common/buildcraft/core/utils/FluidUtils.java b/common/buildcraft/core/utils/FluidUtils.java index 8ac31e44..658cb6ac 100644 --- a/common/buildcraft/core/utils/FluidUtils.java +++ b/common/buildcraft/core/utils/FluidUtils.java @@ -1,8 +1,12 @@ package buildcraft.core.utils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidContainerItem; public final class FluidUtils { @@ -10,21 +14,30 @@ public final class FluidUtils { } - public static Fluid getFluidFromItemStack(ItemStack stack) { + public static FluidStack getFluidStackFromItemStack(ItemStack stack) { if (stack != null) { if (stack.getItem() instanceof IFluidContainerItem) { IFluidContainerItem ctr = (IFluidContainerItem) stack.getItem(); if (ctr.getFluid(stack) != null) { - return ctr.getFluid(stack).getFluid(); + return ctr.getFluid(stack); } } else if (FluidContainerRegistry.isFilledContainer(stack) && FluidContainerRegistry.getFluidForFilledItem(stack) != null) { - return FluidContainerRegistry.getFluidForFilledItem(stack).getFluid(); + return FluidContainerRegistry.getFluidForFilledItem(stack); + } else if (stack.getItem() instanceof ItemBlock) { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b instanceof IFluidBlock) { + return new FluidStack(((IFluidBlock) b).getFluid(), 1000); + } } } return null; } + public static Fluid getFluidFromItemStack(ItemStack stack) { + return getFluidStackFromItemStack(stack).getFluid(); + } + public static boolean isFluidContainer(ItemStack stack) { return stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isFilledContainer(stack); }