net.minecraftforge.fluids.IFluidContainerItem Java Examples

The following examples show how to use net.minecraftforge.fluids.IFluidContainerItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BW_TileEntityContainer.java    From bartworks with MIT License 6 votes vote down vote up
@Override
public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
    if (worldObj.isRemote) {
        return false;
    }
    TileEntity tile = worldObj.getTileEntity(x, y, z);
    if (tile instanceof BW_TileEntity_HeatedWaterPump) {
        if (player.getHeldItem() != null && (player.getHeldItem().getItem().equals(Items.bucket) || player.getHeldItem().getItem() instanceof IFluidContainerItem) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false) != null)
            if (player.getHeldItem().getItem().equals(Items.bucket) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false).amount == 1000) {
                ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, true);
                player.getHeldItem().stackSize--;
                if (player.getHeldItem().stackSize <= 0)
                    player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
                player.inventory.addItemStackToInventory(new ItemStack(Items.water_bucket));
                return true;
            }
    }
    if (!player.isSneaking()) {
        if (tile instanceof IHasGui) {
            return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile);
        } else if (tile instanceof ITileWithGUI) {
            return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player);
        }
    }
    return false;
}
 
Example #2
Source File: ItemInHandInfoCommand.java    From NewHorizonsCoreMod with GNU General Public License v3.0 6 votes vote down vote up
private String getFluidContainerContents(ItemStack pItemInQuestion)
{
    String tResult = "No fluid container";
    
    if (pItemInQuestion.getItem() instanceof IFluidContainerItem)
    {
        IFluidContainerItem tFluidContainer = IFluidContainerItem.class.cast(pItemInQuestion.getItem());
        FluidStack tContents = tFluidContainer.getFluid(pItemInQuestion);
        if (tContents != null)
        {
            tResult = String.format("FluidID: [%d], UnlocName: [%s], Name: [%s]", tContents.getFluid().getID(), tContents.getFluid().getUnlocalizedName(), tContents.getFluid().getName()); 
        }
    }
    
    return tResult;
}
 
Example #3
Source File: ECPrivatePatternInventory.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
	if (gridTE != null)
	{
		ICraftingPattern currentPattern = Util.getAssemblerPattern(itemstack);
		if (currentPattern == null || currentPattern.getRequirements() == null)
			return false;
		if (FluidContainerRegistry.isEmptyContainer(currentPattern.getOutput()))
			return false;

		for (ItemStack entry : currentPattern.getRequirements())
		{
			if (entry != null && entry.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isFilledContainer(entry))
			{
				return doesRecipeExist((ICraftingPatternMAC) currentPattern);
			}
		}
	}
	return false;
}
 
Example #4
Source File: BoilerFuelMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(IFluidContainerItem target, ItemStack stack) {
	FluidStack fluidStack = target.getFluid(stack);
	if (fluidStack != null && fluidStack.amount > 0) {
		int heatPerBucket = FuelManager.getBoilerFuelValue(fluidStack.getFluid());
		if (heatPerBucket > 0) {
			Map<String, Number> result = Maps.newHashMap();
			result.put("total", heatPerBucket / 1000.0f * fluidStack.amount);
			result.put("per_bucket", heatPerBucket);
			return result;
		}
	}

	return null;
}
 
Example #5
Source File: FluidContainerMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(IFluidContainerItem target, ItemStack stack) {
	Map<String, Object> map = Maps.newHashMap();
	map.put("contents", target.getFluid(stack));
	map.put("capacity", target.getCapacity(stack));
	return map;
}
 
Example #6
Source File: OvenGlove.java    From NewHorizonsCoreMod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check if given ItemStack is a valid lava-containing container.
 * Either the "unlocalized name" contains the word "lava"
 * - OR -
 * The item is a Tinkers-LavaTank block which contains lava
 * - OR -
 * The item is an item which implements the IFluidContainer Interface, and it actually
 * does contain lava
 * 
 * @param pHeldItem
 * @return
 */
private boolean isValidLavaContainerItem( ItemStack pHeldItem )
{
  boolean tResult = false;

  if( pHeldItem.getUnlocalizedName().toLowerCase().contains( "lava" ) ) {
    tResult = true;
  }

  if( pHeldItem.getItem() instanceof IFluidContainerItem )
  {
    FluidStack tStackFluid = FluidHelper.getFluidStackFromContainer( pHeldItem );
    if( tStackFluid != null )
    {
      if( tStackFluid.amount > 0 && "lava".equalsIgnoreCase(tStackFluid.getFluid().getName())) {
        tResult = true;
      }
    }
  }
  else if("tconstruct.smeltery.itemblocks.LavaTankItemBlock".equals(pHeldItem.getItem().getClass().getName()))
  {
    NBTTagCompound tNBT = pHeldItem.getTagCompound();
    if( tNBT != null && tNBT.hasKey( "Fluid" ) )
    {
      // _mLogger.info("...Has NBT 'Fluid'...");
      NBTTagCompound tFluidCompound = tNBT.getCompoundTag( "Fluid" );
      if( tFluidCompound != null && tFluidCompound.hasKey( "FluidName" ) )
      {
        String tFluidName = tFluidCompound.getString( "FluidName" );
        if( tFluidName != null && !tFluidName.isEmpty())
        {
          if("lava".equalsIgnoreCase(tFluidName)) {
            tResult = true;
          }
        }
      }
    }
  }

  return tResult;
}
 
Example #7
Source File: SlotFullFluidContainer.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack){
    return stack != null && (FluidContainerRegistry.getFluidForFilledItem(stack) != null || stack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)stack.getItem()).getFluid(stack) != null);
}
 
Example #8
Source File: TileEntityLiquidCompressor.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack){
    return slot == 5 ? false : stack != null && (FluidContainerRegistry.getFluidForFilledItem(stack) != null || stack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)stack.getItem()).getFluid(stack) != null);
}
 
Example #9
Source File: TileEntityKeroseneLamp.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack){
    return slot == 1 ? false : stack != null && (FluidContainerRegistry.getFluidForFilledItem(stack) != null || stack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem)stack.getItem()).getFluid(stack) != null);
}
 
Example #10
Source File: ECPrivateInventory.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
	return FluidContainerRegistry.isContainer(itemstack) || (itemstack != null && itemstack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) itemstack.getItem()).getFluid(itemstack) != null);
}