Search in sources :

Example 1 with FluidBucketWrapper

use of net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper in project MinecraftForge by MinecraftForge.

the class UniversalBucket method getSubItems.

@SideOnly(Side.CLIENT)
@Override
public void getSubItems(@Nonnull Item itemIn, @Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
    for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
        if (fluid != FluidRegistry.WATER && fluid != FluidRegistry.LAVA && !fluid.getName().equals("milk")) {
            // add all fluids that the bucket can be filled  with
            FluidStack fs = new FluidStack(fluid, getCapacity());
            ItemStack stack = new ItemStack(this);
            IFluidHandlerItem fluidHandler = new FluidBucketWrapper(stack);
            if (fluidHandler.fill(fs, true) == fs.amount) {
                ItemStack filled = fluidHandler.getContainer();
                subItems.add(filled);
            }
        }
    }
}
Also used : FluidBucketWrapper(net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper) IFluidHandlerItem(net.minecraftforge.fluids.capability.IFluidHandlerItem) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with FluidBucketWrapper

use of net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper in project RFTools by McJty.

the class SensorTileEntity method checkFluid.

private boolean checkFluid(BlockPos newpos) {
    IBlockState state = getWorld().getBlockState(newpos);
    ItemStack matcher = inventoryHelper.getStackInSlot(0);
    Block block = state.getBlock();
    if (matcher.isEmpty()) {
        if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
            return !block.isAir(state, getWorld(), newpos);
        }
        return false;
    }
    ItemStack stack = block.getItem(getWorld(), newpos, state);
    Item matcherItem = matcher.getItem();
    FluidStack matcherFluidStack = null;
    // }
    if (matcherItem instanceof ItemBucket || matcherItem instanceof UniversalBucket) {
        matcherFluidStack = new FluidBucketWrapper(matcher).getFluid();
        return checkFluid(block, matcherFluidStack, state, newpos);
    }
    return false;
}
Also used : UniversalBucket(net.minecraftforge.fluids.UniversalBucket) FluidBucketWrapper(net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) ItemStack(net.minecraft.item.ItemStack) ItemBucket(net.minecraft.item.ItemBucket)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2 FluidBucketWrapper (net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper)2 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 IBlockState (net.minecraft.block.state.IBlockState)1 Item (net.minecraft.item.Item)1 ItemBucket (net.minecraft.item.ItemBucket)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)1 UniversalBucket (net.minecraftforge.fluids.UniversalBucket)1 IFluidHandlerItem (net.minecraftforge.fluids.capability.IFluidHandlerItem)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1