Skip to content

Commit

Permalink
Merge branch 'master' into DistillationTower_Recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master authored Jan 8, 2025
2 parents a07dd32 + ff0c88c commit 1388e8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static gregtech.api.util.GTStructureUtility.ofCoil;

import java.util.ArrayList;
import java.util.Arrays;

import javax.annotation.Nonnull;
Expand All @@ -35,7 +34,6 @@
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
Expand All @@ -50,15 +48,13 @@
import gregtech.api.GregTechAPI;
import gregtech.api.enums.GTValues;
import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.Materials;
import gregtech.api.enums.SoundResource;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.metatileentity.implementations.MTEHatchEnergy;
import gregtech.api.metatileentity.implementations.MTEHatchOutput;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
Expand All @@ -79,10 +75,7 @@ public class MTEMegaBlastFurnace extends MegaMultiBlockBase<MTEMegaBlastFurnace>
.addElement('=', StructureElementAirNoHint.getInstance())
.addElement(
't',
buildHatchAdder(MTEMegaBlastFurnace.class)
.atLeast(
OutputHatch.withAdder(MTEMegaBlastFurnace::addOutputHatchToTopList)
.withCount(t -> t.mPollutionOutputHatches.size()))
buildHatchAdder(MTEMegaBlastFurnace.class).atLeast(OutputHatch)
.casingIndex(CASING_INDEX)
.dot(1)
.buildAndChain(GregTechAPI.sBlockCasings1, CASING_INDEX))
Expand Down Expand Up @@ -144,9 +137,6 @@ private static String[][] createShape() {
}

private HeatingCoilLevel mCoilLevel;
protected final ArrayList<MTEHatchOutput> mPollutionOutputHatches = new ArrayList<>();
protected final FluidStack[] pollutionFluidStacks = { Materials.CarbonDioxide.getGas(1000),
Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000) };
private int mHeatingCapacity;
private byte glassTier;
private final static int polPtick = PollutionConfig.basePollutionMBFSecond / 20
Expand Down Expand Up @@ -189,7 +179,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addPollutionAmount(getPollutionPerSecond(null))
.beginStructureBlock(15, 20, 15, true)
.addController("3rd layer center")
.addCasingInfoRange("Heat Proof Machine Casing", 0, 279, false)
.addCasingInfoRange("Heat Proof Machine Casing", 0, 447, false)
.addOtherStructurePart("864x Heating Coils", "Inner 13x18x13 (Hollow)")
.addOtherStructurePart("1007x Borosilicate Glass", "Outer 15x18x15")
.addStructureInfo("The glass tier limits the Energy Input tier")
Expand All @@ -199,9 +189,7 @@ protected MultiblockTooltipBuilder createTooltip() {
.addInputBus("Any bottom layer casing")
.addInputHatch("Any bottom layer casing")
.addOutputBus("Any bottom layer casing")
.addOutputHatch("Gasses, Any top layer casing")
.addStructureInfo("Recovery amount scales with Muffler Hatch tier")
.addOutputHatch("Platline fluids, Any bottom layer casing")
.addOutputHatch("Any Heat Proof Machine Casing")
.addStructureHint("This Mega Multiblock is too big to have its structure hologram displayed fully.")
.toolTipFinisher();
return tt;
Expand Down Expand Up @@ -275,17 +263,6 @@ public int getPollutionPerSecond(ItemStack aStack) {
return polPtick * 20;
}

public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof MTEHatchOutput) {
((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
return this.mPollutionOutputHatches.add((MTEHatchOutput) aMetaTileEntity);
}
return false;
}

@Override
protected String[] getExtendedInfoData() {
return new String[] { StatCollector.translateToLocal("GT5U.EBF.heat") + ": "
Expand Down Expand Up @@ -344,36 +321,13 @@ public HeatingCoilLevel getCoilLevel() {
return this.mCoilLevel;
}

@Override
public boolean addOutput(FluidStack aLiquid) {
if (aLiquid == null) return false;
FluidStack tLiquid = aLiquid.copy();
boolean isOutputPollution = false;
for (FluidStack pollutionFluidStack : this.pollutionFluidStacks) {
if (!tLiquid.isFluidEqual(pollutionFluidStack)) continue;

isOutputPollution = true;
break;
}
ArrayList<MTEHatchOutput> tOutputHatches;
if (isOutputPollution) {
tOutputHatches = this.mPollutionOutputHatches;
tLiquid.amount = tLiquid.amount * Math.min(100 - getAveragePollutionPercentage(), 100) / 100;
} else {
tOutputHatches = this.mOutputHatches;
}
return dumpFluid(tOutputHatches, tLiquid, true) || dumpFluid(tOutputHatches, tLiquid, false);
}

@Override
public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) {
this.mHeatingCapacity = 0;
this.glassTier = 0;

this.setCoilLevel(HeatingCoilLevel.None);

this.mPollutionOutputHatches.clear();

if (!this.checkPiece("main", 7, 17, 0) || this.getCoilLevel() == HeatingCoilLevel.None
|| this.mMaintenanceHatches.size() != 1) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class MTEHatchMuffler extends MTEHatch {
private static final String localizedDescFormat = GTLanguageManager.addStringLocalization(
"gt.blockmachines.hatch.muffler.desc.format",
"Outputs the Pollution (Might cause ... things)%n" + "DO NOT OBSTRUCT THE OUTPUT!%n"
+ "Reduces Pollution to %d%%%n"
+ "Recovers %d%% of CO2/CO/SO2");
+ "Reduces Pollution to %d%%%n");
private final int pollutionReduction = calculatePollutionReduction(100);
private final int pollutionRecover = 100 - pollutionReduction;
private final String[] description = String.format(localizedDescFormat, pollutionReduction, pollutionRecover)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,16 @@
import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static gregtech.api.util.GTStructureUtility.ofCoil;
import static gregtech.api.util.GTUtility.filterValidMTEs;
import static gregtech.api.util.GTUtility.validMTEList;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;

import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
Expand All @@ -44,16 +37,12 @@
import gregtech.GTMod;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.HeatingCoilLevel;
import gregtech.api.enums.Materials;
import gregtech.api.enums.SoundResource;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.fluid.IFluidStore;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.metatileentity.implementations.MTEHatchEnergy;
import gregtech.api.metatileentity.implementations.MTEHatchOutput;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
Expand All @@ -68,9 +57,6 @@ public class MTEElectricBlastFurnace extends MTEAbstractMultiFurnace<MTEElectric
implements ISurvivalConstructable {

private int mHeatingCapacity = 0;
protected final ArrayList<MTEHatchOutput> mPollutionOutputHatches = new ArrayList<>();
protected final FluidStack[] pollutionFluidStacks = { Materials.CarbonDioxide.getGas(1000),
Materials.CarbonMonoxide.getGas(1000), Materials.SulfurDioxide.getGas(1000) };

protected static final int CASING_INDEX = 11;
protected static final String STRUCTURE_PIECE_MAIN = "main";
Expand All @@ -79,16 +65,13 @@ public class MTEElectricBlastFurnace extends MTEAbstractMultiFurnace<MTEElectric
.addShape(
STRUCTURE_PIECE_MAIN,
transpose(
new String[][] { { "ttt", "tmt", "ttt" }, { "CCC", "C-C", "CCC" }, { "CCC", "C-C", "CCC" },
new String[][] { { "fff", "fmf", "fff" }, { "CCC", "C-C", "CCC" }, { "CCC", "C-C", "CCC" },
{ "b~b", "bbb", "bbb" } }))
.addElement(
't',
buildHatchAdder(MTEElectricBlastFurnace.class)
.atLeast(
OutputHatch.withAdder(MTEElectricBlastFurnace::addOutputHatchToTopList)
.withCount(t -> t.mPollutionOutputHatches.size()))
'f',
buildHatchAdder(MTEElectricBlastFurnace.class).atLeast(OutputHatch)
.casingIndex(CASING_INDEX)
.dot(1)
.dot(3)
.buildAndChain(GregTechAPI.sBlockCasings1, CASING_INDEX))
.addElement('m', Muffler.newAny(CASING_INDEX, 2))
.addElement('C', ofCoil(MTEElectricBlastFurnace::setCoilLevel, MTEElectricBlastFurnace::getCoilLevel))
Expand Down Expand Up @@ -128,15 +111,13 @@ protected MultiblockTooltipBuilder createTooltip() {
.addController("Front bottom")
.addCasingInfoRange("Heat Proof Machine Casing", 0, 15, false)
.addOtherStructurePart("Heating Coils", "Two middle Layers")
.addEnergyHatch("Any bottom layer casing", 3)
.addMaintenanceHatch("Any bottom layer casing", 3)
.addEnergyHatch("Any bottom layer casing", 1)
.addMaintenanceHatch("Any bottom layer casing", 1)
.addMufflerHatch("Top middle", 2)
.addInputBus("Any bottom layer casing", 3)
.addInputHatch("Any bottom layer casing", 3)
.addOutputBus("Any bottom layer casing", 3)
.addOutputHatch("Fluid outputs, Any bottom layer casing")
.addOutputHatch("Pollution gases (CO2/CO/SO2), Any top layer casing", 1)
.addStructureInfo("Pollution gas output amount scales with Muffler Hatch tier")
.addInputBus("Any bottom layer casing", 1)
.addInputHatch("Any bottom layer casing", 1)
.addOutputBus("Any bottom layer casing", 1)
.addOutputHatch("Any Heat Proof Machine Casing", 3)
.toolTipFinisher();
return tt;
}
Expand Down Expand Up @@ -177,11 +158,6 @@ public RecipeMap<?> getRecipeMap() {
return RecipeMaps.blastFurnaceRecipes;
}

@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}

@Override
public IStructureDefinition<MTEElectricBlastFurnace> getStructureDefinition() {
return STRUCTURE_DEFINITION;
Expand All @@ -208,25 +184,12 @@ protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe
};
}

public boolean addOutputHatchToTopList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) return false;
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) return false;
if (aMetaTileEntity instanceof MTEHatchOutput) {
((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
return mPollutionOutputHatches.add((MTEHatchOutput) aMetaTileEntity);
}
return false;
}

@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
this.mHeatingCapacity = 0;

setCoilLevel(HeatingCoilLevel.None);

mPollutionOutputHatches.clear();

if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) return false;

if (getCoilLevel() == HeatingCoilLevel.None) return false;
Expand All @@ -237,42 +200,6 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
return true;
}

@Override
public boolean addOutput(FluidStack aLiquid) {
if (aLiquid == null) return false;
FluidStack tLiquid = aLiquid.copy();
ArrayList<MTEHatchOutput> tOutputHatches;
if (isPollutionFluid(tLiquid)) {
tOutputHatches = this.mPollutionOutputHatches;
multiplyPollutionFluidAmount(tLiquid);
} else {
tOutputHatches = this.mOutputHatches;
}
return dumpFluid(tOutputHatches, tLiquid, true) || dumpFluid(tOutputHatches, tLiquid, false);
}

protected boolean isPollutionFluid(@Nullable FluidStack fluidStack) {
if (fluidStack == null) return false;
for (FluidStack pollutionFluidStack : pollutionFluidStacks) {
if (!fluidStack.isFluidEqual(pollutionFluidStack)) continue;
return true;
}
return false;
}

@Override
public List<? extends IFluidStore> getFluidOutputSlots(FluidStack[] toOutput) {
if (Arrays.stream(toOutput)
.anyMatch(this::isPollutionFluid)) {
return filterValidMTEs(mPollutionOutputHatches);
}
return filterValidMTEs(mOutputHatches);
}

protected void multiplyPollutionFluidAmount(@Nonnull FluidStack fluid) {
fluid.amount = fluid.amount * Math.min(100 - getAveragePollutionPercentage(), 100) / 100;
}

@Override
public String[] getInfoData() {
long storedEnergy = 0;
Expand Down

0 comments on commit 1388e8b

Please sign in to comment.