Search in sources :

Example 61 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class TileEntitySheetmetalTank method update.

@Override
public void update() {
    if (pos == 4 && !worldObj.isRemote && worldObj.isBlockIndirectlyGettingPowered(getPos()) > 0)
        for (int i = 0; i < 6; i++) if (i != 1 && tank.getFluidAmount() > 0) {
            EnumFacing f = EnumFacing.getFront(i);
            int outSize = Math.min(144, tank.getFluidAmount());
            FluidStack out = new FluidStack(tank.getFluid().getFluid(), outSize);
            BlockPos outputPos = getPos().offset(f);
            IFluidHandler output = FluidUtil.getFluidHandler(worldObj, outputPos, f.getOpposite());
            if (output != null) {
                int accepted = output.fill(out, false);
                if (accepted > 0) {
                    int drained = output.fill(Utils.copyFluidStackWithAmount(out, Math.min(out.amount, accepted), false), true);
                    this.tank.drain(drained, true);
                    this.markContainingBlockForUpdate(null);
                    updateComparatorValuesPart2();
                }
            }
        }
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) IComparatorOverride(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IComparatorOverride)

Example 62 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class TileEntitySheetmetalTank method getOverlayText.

//	@Override
//	public TileEntitySheetmetalTank master()
//	{
//		if(offset[0]==0&&offset[1]==0&&offset[2]==0)
//			return null;
//		TileEntity te = worldObj.getTileEntity(xCoord-offset[0], yCoord-offset[1], zCoord-offset[2]);
//		return te instanceof TileEntitySheetmetalTank?(TileEntitySheetmetalTank)te : null;
//	}
@Override
public String[] getOverlayText(EntityPlayer player, RayTraceResult mop, boolean hammer) {
    if (Utils.isFluidRelatedItemStack(player.getHeldItem(EnumHand.MAIN_HAND))) {
        TileEntitySheetmetalTank master = master();
        FluidStack fs = master != null ? master.tank.getFluid() : this.tank.getFluid();
        String s = null;
        if (fs != null)
            s = fs.getLocalizedName() + ": " + fs.amount + "mB";
        else
            s = I18n.format(Lib.GUI + "empty");
        return new String[] { s };
    }
    return null;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IComparatorOverride(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IComparatorOverride)

Example 63 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class ItemJerrycan method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) {
    FluidStack fs = FluidUtil.getFluidContained(stack);
    if (fs != null) {
        TextFormatting rarity = fs.getFluid().getRarity() == EnumRarity.COMMON ? TextFormatting.GRAY : fs.getFluid().getRarity().rarityColor;
        list.add(rarity + fs.getLocalizedName() + TextFormatting.GRAY + ": " + fs.amount + "/" + 10000 + "mB");
    } else
        list.add(I18n.format(Lib.DESC_FLAVOUR + "drill.empty"));
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) TextFormatting(net.minecraft.util.text.TextFormatting) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 64 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class MultiblockRecipe method setupJEI.

public void setupJEI() {
    if (inputList != null) {
        this.jeiItemInputList = new ArrayList[inputList.size()];
        this.jeiTotalItemInputList = new ArrayList();
        for (int i = 0; i < inputList.size(); i++) {
            IngredientStack ingr = inputList.get(i);
            ArrayList list = new ArrayList();
            if (ingr.oreName != null)
                for (ItemStack stack : OreDictionary.getOres(ingr.oreName)) list.add(ApiUtils.copyStackWithAmount(stack, ingr.inputSize));
            else if (ingr.stackList != null)
                for (ItemStack stack : ingr.stackList) list.add(ApiUtils.copyStackWithAmount(stack, ingr.inputSize));
            else
                list.add(ApiUtils.copyStackWithAmount(ingr.stack, ingr.inputSize));
            this.jeiItemInputList[i] = list;
            this.jeiTotalItemInputList.addAll(list);
        }
    } else
        this.jeiTotalItemInputList = Collections.emptyList();
    if (outputList != null) {
        this.jeiItemOutputList = new ArrayList[outputList.size()];
        this.jeiTotalItemOutputList = new ArrayList();
        for (int i = 0; i < outputList.size(); i++) {
            ItemStack s = outputList.get(i);
            ArrayList<ItemStack> list = Lists.newArrayList(s != null ? s.copy() : null);
            this.jeiItemOutputList[i] = list;
            this.jeiTotalItemOutputList.addAll(list);
        }
    } else
        this.jeiTotalItemOutputList = Collections.emptyList();
    if (fluidInputList != null) {
        this.jeiFluidInputList = new ArrayList();
        for (int i = 0; i < fluidInputList.size(); i++) {
            FluidStack fs = fluidInputList.get(i);
            if (fs != null)
                this.jeiFluidInputList.add(fs.copy());
        }
    } else
        this.jeiFluidInputList = Collections.emptyList();
    if (fluidOutputList != null) {
        this.jeiFluidOutputList = new ArrayList();
        for (int i = 0; i < fluidOutputList.size(); i++) {
            FluidStack fs = fluidOutputList.get(i);
            if (fs != null)
                this.jeiFluidOutputList.add(fs.copy());
        }
    } else
        this.jeiFluidOutputList = Collections.emptyList();
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 65 with FluidStack

use of net.minecraftforge.fluids.FluidStack in project ImmersiveEngineering by BluSunrize.

the class RefineryRecipe method loadFromNBT.

public static RefineryRecipe loadFromNBT(NBTTagCompound nbt) {
    FluidStack input0 = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("input0"));
    FluidStack input1 = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("input1"));
    return findRecipe(input0, input1);
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

FluidStack (net.minecraftforge.fluids.FluidStack)188 ItemStack (net.minecraft.item.ItemStack)63 TileEntity (net.minecraft.tileentity.TileEntity)30 Fluid (net.minecraftforge.fluids.Fluid)28 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)25 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)19 ArrayList (java.util.ArrayList)18 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)16 Block (net.minecraft.block.Block)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)10 Item (net.minecraft.item.Item)9 BlockPos (net.minecraft.util.math.BlockPos)9 HashMap (java.util.HashMap)6 FluidIdentifier (logisticspipes.utils.FluidIdentifier)6 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 PipeFluidTransportLogistics (logisticspipes.transport.PipeFluidTransportLogistics)5 IBlockState (net.minecraft.block.state.IBlockState)5 EnumFacing (net.minecraft.util.EnumFacing)5