Search in sources :

Example 1 with VoidFluidHandlerItemStack

use of gregtech.api.capability.impl.VoidFluidHandlerItemStack in project GregTech by GregTechCE.

the class PlungerBehaviour method createProvider.

@Override
public ICapabilityProvider createProvider(ItemStack itemStack) {
    return new VoidFluidHandlerItemStack(itemStack) {

        @Override
        public int fill(FluidStack resource, boolean doFill) {
            int result = super.fill(resource, doFill);
            if (result > 0) {
                // Adjust the fluid amount based on remaining durability/charge of the item
                final ItemStack container = getContainer();
                final IToolItem plunger = (IToolItem) container.getItem();
                double operations = result;
                operations /= 1000;
                final int damage = (int) Math.ceil(operations);
                result = 1000 * plunger.damageItem(container, damage, true, !doFill);
            }
            // TODO play sound (how to get the player?)
            return result;
        }
    };
}
Also used : VoidFluidHandlerItemStack(gregtech.api.capability.impl.VoidFluidHandlerItemStack) FluidStack(net.minecraftforge.fluids.FluidStack) VoidFluidHandlerItemStack(gregtech.api.capability.impl.VoidFluidHandlerItemStack) ItemStack(net.minecraft.item.ItemStack) IToolItem(gregtech.api.items.IToolItem)

Aggregations

VoidFluidHandlerItemStack (gregtech.api.capability.impl.VoidFluidHandlerItemStack)1 IToolItem (gregtech.api.items.IToolItem)1 ItemStack (net.minecraft.item.ItemStack)1 FluidStack (net.minecraftforge.fluids.FluidStack)1