Search in sources :

Example 1 with FluidHandlerProxy

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

the class MetaTileEntity method initializeInventory.

protected void initializeInventory() {
    this.importItems = createImportItemHandler();
    this.exportItems = createExportItemHandler();
    this.itemInventory = new ItemHandlerProxy(importItems, exportItems);
    this.importFluids = createImportFluidHandler();
    this.exportFluids = createExportFluidHandler();
    this.fluidInventory = new FluidHandlerProxy(importFluids, exportFluids);
}
Also used : FluidHandlerProxy(gregtech.api.capability.impl.FluidHandlerProxy) ItemHandlerProxy(gregtech.api.capability.impl.ItemHandlerProxy)

Example 2 with FluidHandlerProxy

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

the class PlungerBehaviour method onItemUseFirst.

@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity == null) {
        return EnumActionResult.PASS;
    }
    IFluidHandler fluidHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
    if (fluidHandler == null) {
        return EnumActionResult.PASS;
    }
    ItemStack toolStack = player.getHeldItem(hand);
    boolean isShiftClick = player.isSneaking();
    IFluidHandler handlerToRemoveFrom = isShiftClick ? (fluidHandler instanceof FluidHandlerProxy ? ((FluidHandlerProxy) fluidHandler).input : null) : (fluidHandler instanceof FluidHandlerProxy ? ((FluidHandlerProxy) fluidHandler).output : fluidHandler);
    if (handlerToRemoveFrom != null && GTUtility.doDamageItem(toolStack, cost, false)) {
        if (!world.isRemote) {
            FluidStack drainStack = handlerToRemoveFrom.drain(1000, true);
            int amountOfFluid = drainStack == null ? 0 : drainStack.amount;
            if (amountOfFluid > 0) {
                player.playSound(SoundEvents.ENTITY_SLIME_SQUISH, 1.0f, amountOfFluid / 1000.0f);
            }
        }
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.PASS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidHandlerProxy(gregtech.api.capability.impl.FluidHandlerProxy) FluidStack(net.minecraftforge.fluids.FluidStack) VoidFluidHandlerItemStack(gregtech.api.capability.impl.VoidFluidHandlerItemStack) ItemStack(net.minecraft.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 3 with FluidHandlerProxy

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

the class MetaTileEntityCokeOvenHatch method addToMultiBlock.

@Override
public void addToMultiBlock(MultiblockControllerBase controllerBase) {
    super.addToMultiBlock(controllerBase);
    this.fluidInventory = new FluidHandlerProxy(new FluidTankList(false), controllerBase.getExportFluids());
    this.itemInventory = new ItemHandlerProxy(controllerBase.getImportItems(), controllerBase.getExportItems());
}
Also used : FluidTankList(gregtech.api.capability.impl.FluidTankList) FluidHandlerProxy(gregtech.api.capability.impl.FluidHandlerProxy) ItemHandlerProxy(gregtech.api.capability.impl.ItemHandlerProxy)

Example 4 with FluidHandlerProxy

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

the class SimpleMachineMetaTileEntity method initializeInventory.

@Override
protected void initializeInventory() {
    super.initializeInventory();
    this.outputItemInventory = new ItemHandlerProxy(new ItemStackHandler(0), exportItems);
    this.outputFluidInventory = new FluidHandlerProxy(new FluidTankList(false), exportFluids);
}
Also used : FluidTankList(gregtech.api.capability.impl.FluidTankList) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) FluidHandlerProxy(gregtech.api.capability.impl.FluidHandlerProxy) ItemHandlerProxy(gregtech.api.capability.impl.ItemHandlerProxy)

Aggregations

FluidHandlerProxy (gregtech.api.capability.impl.FluidHandlerProxy)4 ItemHandlerProxy (gregtech.api.capability.impl.ItemHandlerProxy)3 FluidTankList (gregtech.api.capability.impl.FluidTankList)2 VoidFluidHandlerItemStack (gregtech.api.capability.impl.VoidFluidHandlerItemStack)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)1 ItemStackHandler (net.minecraftforge.items.ItemStackHandler)1