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);
}
}
}
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;
}
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;
}
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();
}
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)));
}
}
}
Aggregations