List of usage examples for net.minecraftforge.fluids.capability CapabilityFluidHandler FLUID_HANDLER_ITEM_CAPABILITY
Capability FLUID_HANDLER_ITEM_CAPABILITY
To view the source code for net.minecraftforge.fluids.capability CapabilityFluidHandler FLUID_HANDLER_ITEM_CAPABILITY.
Click Source Link
From source file:blusunrize.immersiveengineering.common.gui.ContainerRefinery.java
public ContainerRefinery(InventoryPlayer inventoryPlayer, TileEntityRefinery tile) { super(inventoryPlayer, tile); final TileEntityRefinery tileF = tile; this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 0, 37, 15, 2) { @Override//from ww w. ja v a2s .c om public boolean isItemValid(ItemStack itemStack) { IFluidHandler h = itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); if (h == null || h.getTankProperties().length == 0) return false; FluidStack fs = h.getTankProperties()[0].getContents(); if (fs == null) return false; if (RefineryRecipe.findIncompleteRefineryRecipe(fs, null) == null) return false; if (tileF.tanks[0].getFluidAmount() > 0 && !fs.isFluidEqual(tileF.tanks[0].getFluid())) return false; if (tileF.tanks[1].getFluidAmount() <= 0) return true; List<RefineryRecipe> incomplete = RefineryRecipe.findIncompleteRefineryRecipe(fs, tileF.tanks[1].getFluid()); return incomplete != null && !incomplete.isEmpty(); } }); this.addSlotToContainer(new IESlot.Output(this, this.inv, 1, 37, 54)); this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 2, 85, 15, 2) { @Override public boolean isItemValid(ItemStack itemStack) { IFluidHandler h = itemStack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); if (h == null || h.getTankProperties().length == 0) return false; FluidStack fs = h.getTankProperties()[0].getContents(); if (fs == null) return false; if (RefineryRecipe.findIncompleteRefineryRecipe(fs, null) == null) return false; if (tileF.tanks[1].getFluidAmount() > 0 && !fs.isFluidEqual(tileF.tanks[1].getFluid())) return false; if (tileF.tanks[0].getFluidAmount() <= 0) return true; List<RefineryRecipe> incomplete = RefineryRecipe.findIncompleteRefineryRecipe(fs, tileF.tanks[0].getFluid()); return incomplete != null && !incomplete.isEmpty(); } }); this.addSlotToContainer(new IESlot.Output(this, this.inv, 3, 85, 54)); this.addSlotToContainer(new IESlot.FluidContainer(this, this.inv, 4, 133, 15, 0)); this.addSlotToContainer(new IESlot.Output(this, this.inv, 5, 133, 54)); slotCount = 6; for (int i = 0; i < 3; i++) for (int j = 0; j < 9; j++) addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 85 + i * 18)); for (int i = 0; i < 9; i++) addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 143)); }
From source file:blusunrize.immersiveengineering.common.items.ItemChemthrower.java
@Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { if (!stack.isEmpty()) return new IEItemStackHandler(stack) { IEItemFluidHandler fluids = new IEItemFluidHandler(stack, 2000); ShaderWrapper_Item shaders = new ShaderWrapper_Item("immersiveengineering:chemthrower", stack); @Override/*www . j a va2 s . com*/ public boolean hasCapability(@Nonnull Capability<?> capability, EnumFacing facing) { return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY || capability == CapabilityShader.SHADER_CAPABILITY || super.hasCapability(capability, facing); } @Override public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) return (T) fluids; if (capability == CapabilityShader.SHADER_CAPABILITY) return (T) shaders; return super.getCapability(capability, facing); } }; return null; }
From source file:blusunrize.immersiveengineering.common.items.ItemDrill.java
@Override public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) { if (!stack.isEmpty()) return new IEItemStackHandler(stack) { IEItemFluidHandler fluids = new IEItemFluidHandler(stack, 2000); ShaderWrapper_Item shaders = new ShaderWrapper_Item("immersiveengineering:drill", stack); @Override/*w w w .j a v a 2 s . c o m*/ public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY || capability == CapabilityShader.SHADER_CAPABILITY || super.hasCapability(capability, facing); } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) return (T) fluids; if (capability == CapabilityShader.SHADER_CAPABILITY) return (T) shaders; return super.getCapability(capability, facing); } }; return null; }
From source file:claybucket.FluidHandler.java
License:Open Source License
@Override public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY; }
From source file:claybucket.FluidHandler.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// w w w .j a v a2s.c o m @Nullable public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY ? (T) this : null; }
From source file:com.buuz135.industrial.item.MeatFeederItem.java
License:Open Source License
@Override public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {/*w w w . j av a2 s . c om*/ super.addInformation(stack, worldIn, tooltip, flagIn); FluidHandlerItemStack handlerItemStack = (FluidHandlerItemStack) stack .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.DOWN); tooltip.add(getFilledAmount(stack) + "/" + handlerItemStack.getTankProperties()[0].getCapacity() + "mb of Meat"); }
From source file:com.buuz135.industrial.item.MeatFeederItem.java
License:Open Source License
public int getFilledAmount(ItemStack stack) { FluidHandlerItemStack handlerItemStack = (FluidHandlerItemStack) stack .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.DOWN); return (handlerItemStack.getFluid() == null ? 0 : handlerItemStack.getFluid().amount); }
From source file:com.buuz135.industrial.item.MeatFeederItem.java
License:Open Source License
public void drain(ItemStack stack, int amount) { FluidHandlerItemStack handlerItemStack = (FluidHandlerItemStack) stack .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.DOWN); handlerItemStack.drain(new FluidStack(FluidsRegistry.MEAT, amount), true); }
From source file:com.buuz135.industrial.proxy.block.BlockLabel.java
License:Open Source License
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { TileEntity entity = worldIn.getTileEntity(pos.offset(state.getValue(FACING))); TileEntity self = worldIn.getTileEntity(pos); if (!worldIn.isRemote && self instanceof TileEntityLabel && entity instanceof IHasDisplayStack && !((IHasDisplayStack) entity).getItemStack() .hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) { if (playerIn.isSneaking()) { playerIn.playSound(SoundEvents.BLOCK_LEVER_CLICK, 1, 1); if (((TileEntityLabel) self).getFormatType() == TileEntityLabel.FormatType.STACKS) ((TileEntityLabel) self).setFormatType(TileEntityLabel.FormatType.MILL); else//w w w. j a va 2 s . c om ((TileEntityLabel) self).setFormatType(TileEntityLabel.FormatType.STACKS); } else if (entity instanceof BlackHoleUnitTile && entity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH)) { ItemStack stack = playerIn.getHeldItem(hand); if (!stack.isEmpty() && ((BlackHoleUnitTile) entity).canInsertItem(stack)) { playerIn.setHeldItem(hand, entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH) .insertItem(0, stack, false)); } else if (System.currentTimeMillis() - INTERACTION_LOGGER.getOrDefault(playerIn.getUniqueID(), System.currentTimeMillis()) < 300) { IItemHandler handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); for (ItemStack itemStack : playerIn.inventory.mainInventory) { if (!itemStack.isEmpty() && handler.insertItem(0, itemStack, true).isEmpty()) { handler.insertItem(0, itemStack.copy(), false); itemStack.setCount(0); } } } INTERACTION_LOGGER.put(playerIn.getUniqueID(), System.currentTimeMillis()); } } return true; }
From source file:com.buuz135.industrial.proxy.block.BlockLabel.java
License:Open Source License
@Override public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { if (!worldIn.isRemote) { TileEntity entity = worldIn.getTileEntity(pos.offset(worldIn.getBlockState(pos).getValue(FACING))); TileEntity self = worldIn.getTileEntity(pos); if (self instanceof TileEntityLabel && entity instanceof BlackHoleUnitTile && ((BlackHoleUnitTile) entity).getDisplayAmount() > 0 && !((IHasDisplayStack) entity).getItemStack() .hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) { ItemHandlerHelper.giveItemToPlayer(playerIn, entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH) .extractItem(0, playerIn.isSneaking() ? 64 : 1, false)); }//from www .j av a 2 s . c om } super.onBlockClicked(worldIn, pos, playerIn); }