Search in sources :

Example 46 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class FluidTankList method deserializeNBT.

@Override
public void deserializeNBT(NBTTagCompound nbt) {
    NBTTagList tanks = nbt.getTagList("Tanks", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < Math.min(fluidTanks.size(), nbt.getInteger("TankAmount")); i++) {
        NBTBase nbtTag = tanks.get(i);
        IFluidTank fluidTank = fluidTanks.get(i);
        if (fluidTank instanceof FluidTank) {
            ((FluidTank) fluidTank).readFromNBT((NBTTagCompound) nbtTag);
        } else if (fluidTank instanceof INBTSerializable) {
            ((INBTSerializable) fluidTank).deserializeNBT(nbtTag);
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) NBTBase(net.minecraft.nbt.NBTBase) INBTSerializable(net.minecraftforge.common.util.INBTSerializable) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 47 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class FluidTankList method getTankProperties.

@Override
public IFluidTankProperties[] getTankProperties() {
    if (fluidTankProperties == null) {
        ArrayList<IFluidTankProperties> propertiesList = new ArrayList<>();
        for (IFluidTank fluidTank : fluidTanks) {
            if (fluidTank instanceof IFluidHandler) {
                IFluidHandler fluidHandler = (IFluidHandler) fluidTank;
                propertiesList.addAll(Arrays.asList(fluidHandler.getTankProperties()));
            }
        }
        this.fluidTankProperties = propertiesList.toArray(new IFluidTankProperties[0]);
    }
    return fluidTankProperties;
}
Also used : IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) IFluidTank(net.minecraftforge.fluids.IFluidTank) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 48 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class FluidTankList method serializeNBT.

@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound fluidInventory = new NBTTagCompound();
    fluidInventory.setInteger("TankAmount", this.getTanks());
    NBTTagList tanks = new NBTTagList();
    for (int i = 0; i < this.getTanks(); i++) {
        NBTBase writeTag;
        IFluidTank fluidTank = fluidTanks.get(i);
        if (fluidTank instanceof FluidTank) {
            writeTag = ((FluidTank) fluidTank).writeToNBT(new NBTTagCompound());
        } else if (fluidTank instanceof INBTSerializable) {
            writeTag = ((INBTSerializable) fluidTank).serializeNBT();
        } else
            writeTag = new NBTTagCompound();
        tanks.appendTag(writeTag);
    }
    fluidInventory.setTag("Tanks", tanks);
    return fluidInventory;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) INBTSerializable(net.minecraftforge.common.util.INBTSerializable) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 49 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class MultiblockWithDisplayBase method setVoidingMode.

private void setVoidingMode(int mode) {
    this.voidingMode = VoidingMode.VALUES[mode];
    this.voidingFluids = mode >= 2;
    this.voidingItems = mode == 1 || mode == 3;
    // After changing the voiding mode, reset the notified buses in case a recipe can run now that voiding mode has been changed
    for (IFluidTank tank : this.getAbilities(MultiblockAbility.IMPORT_FLUIDS)) {
        this.getNotifiedFluidInputList().add((IFluidHandler) tank);
    }
    this.getNotifiedItemInputList().addAll(this.getAbilities(MultiblockAbility.IMPORT_ITEMS));
    this.getHolder().markDirty();
}
Also used : IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 50 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class RecipeMapSteamMultiblockController method addDisplayText.

@Override
protected void addDisplayText(List<ITextComponent> textList) {
    super.addDisplayText(textList);
    if (isStructureFormed()) {
        IFluidTank steamFluidTank = recipeMapWorkable.getSteamFluidTankCombined();
        if (steamFluidTank != null && steamFluidTank.getCapacity() > 0) {
            int steamStored = steamFluidTank.getFluidAmount();
            textList.add(new TextComponentTranslation("gregtech.multiblock.steam.steam_stored", steamStored, steamFluidTank.getCapacity()));
        }
        if (!recipeMapWorkable.isWorkingEnabled()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.work_paused"));
        } else if (recipeMapWorkable.isActive()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.running"));
            int currentProgress = (int) (recipeMapWorkable.getProgressPercent() * 100);
            if (this.recipeMapWorkable.getParallelLimit() != 1) {
                textList.add(new TextComponentTranslation("gregtech.multiblock.parallel", this.recipeMapWorkable.getParallelLimit()));
            }
            textList.add(new TextComponentTranslation("gregtech.multiblock.progress", currentProgress));
        } else {
            textList.add(new TextComponentTranslation("gregtech.multiblock.idling"));
        }
        if (recipeMapWorkable.isHasNotEnoughEnergy()) {
            textList.add(new TextComponentTranslation("gregtech.multiblock.steam.low_steam").setStyle(new Style().setColor(TextFormatting.RED)));
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) Style(net.minecraft.util.text.Style) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Aggregations

IFluidTank (net.minecraftforge.fluids.IFluidTank)58 FluidStack (net.minecraftforge.fluids.FluidStack)30 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)10 FluidTank (net.minecraftforge.fluids.FluidTank)9 Nullable (javax.annotation.Nullable)6 Block (net.minecraft.block.Block)6 ItemStack (net.minecraft.item.ItemStack)6 TileEntity (net.minecraft.tileentity.TileEntity)5 NBTBase (net.minecraft.nbt.NBTBase)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 INBTSerializable (net.minecraftforge.common.util.INBTSerializable)4 Recipe (gregtech.api.recipes.Recipe)3 ArrayList (java.util.ArrayList)3 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)3 FluidTankTileEntity (com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity)2 FluidTankGT (gregapi.fluid.FluidTankGT)2 OreDictItemData (gregapi.oredict.OreDictItemData)2 FuelRecipe (gregtech.api.recipes.recipes.FuelRecipe)2 BlockLiquid (net.minecraft.block.BlockLiquid)2