From 89d30a5cfcc2d3d5773647350edf913f156062b3 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 27 Sep 2019 02:48:32 +0100 Subject: + Added ability for Pollution Scrubbers to remove pollution if it's disabled. Useful if you disable it after starting, as GT will then ignore it forever in the chunks it's left in. % Adjusted Melting point of CO2. % Adjusted the fuel usage on the LRE, I think? (I don't remember) $ Removed logging from decayable NEI handler. $ Fixed potential bad handling of fluid assignment to GT++ materials. $ Fixed incorrect handling of Sulphur Dioxide. $ Hopefully something here fixes the corruption of all canning recipes. :< --- .../gtPlusPlus/core/material/MISC_MATERIALS.java | 2 +- src/Java/gtPlusPlus/core/material/Material.java | 22 ++-- .../gtPlusPlus/core/util/minecraft/FluidUtils.java | 23 ++++ .../util/minecraft/gregtech/PollutionUtils.java | 121 +++++++++++++++++---- 4 files changed, 132 insertions(+), 36 deletions(-) (limited to 'src/Java/gtPlusPlus/core') diff --git a/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java b/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java index aa80f784a9..0e661fd429 100644 --- a/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java +++ b/src/Java/gtPlusPlus/core/material/MISC_MATERIALS.java @@ -107,7 +107,7 @@ public final class MISC_MATERIALS { "Carbon Dioxide", MaterialState.PURE_LIQUID, //State null, //Material Colour - -56, //Melting Point in C + -1, //Melting Point in C -1, //Boiling Point in C -1, //Protons -1, diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 904d1fb4df..dbcbeac32a 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -477,28 +477,26 @@ public class Material { if (aTest != null){ this.vMoltenFluid = aTest.getFluid(); } - else if (isValid == null || isValid == Materials._NULL){ - queueFluidGeneration(); - } else { - if (isValid.mFluid != null){ - this.vMoltenFluid = isValid.mFluid; - } - else if (isValid.mGas != null){ - this.vMoltenFluid = isValid.mGas; - } - else { + if (isValid == null || isValid == Materials._NULL){ queueFluidGeneration(); } + else { + FluidStack aTest2 = FluidUtils.getWildcardFluidStack(localizedName, 1); + if (aTest2 != null){ + this.vMoltenFluid = aTest2.getFluid(); + } + else { + queueFluidGeneration(); + } + } } - this.vPlasma = this.generatePlasma(); } else { this.vMoltenFluid = null; this.vPlasma = null; } - String ratio = ""; if (this.vSmallestRatio != null) { for (int hu=0;hu mPollutionFluidStacks = new AutoMap(); static { - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || CORE.GTNH) { mIsPollutionEnabled = mPollution(); } else { mIsPollutionEnabled = false; @@ -129,8 +134,57 @@ public class PollutionUtils { return addPollution(aChunk, -pollutionValue); } + public static boolean nullifyPollution(IGregTechTileEntity te) { + if (te == null) { + return false; + } + return nullifyPollution(te); + } + + public static boolean nullifyPollution(IHasWorldObjectAndCoords aTileOfSomeSort) { + if (aTileOfSomeSort == null) { + return false; + } + IHasWorldObjectAndCoords j = (IHasWorldObjectAndCoords) aTileOfSomeSort; + Chunk c = j.getWorld().getChunkFromBlockCoords(j.getXCoord(), j.getZCoord()); + return nullifyPollution(c); + } + + public static boolean nullifyPollution(Chunk aChunk) { + try { + if (aChunk == null) { + return false; + } + long getCurrentPollution = getPollution(aChunk); + if (getCurrentPollution <= 0) { + return false; + } + else { + if (mAddPollution2 != null) { + mAddPollution2.invoke(null, aChunk, -getCurrentPollution); + return true; + } + else { + Class GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); + if (GT_Pollution != null) { + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", Chunk.class, int.class); + if (addPollution != null) { + mAddPollution2 = addPollution; + mAddPollution2.invoke(null, aChunk, 0); + return true; + } + } + } + } + + } catch (SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + } + return false; + } + public static int getPollution(IGregTechTileEntity te) { - if (mIsPollutionEnabled) + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) try { if (te == null) { return 0; @@ -153,7 +207,7 @@ public class PollutionUtils { } public static int getPollution(Chunk te) { - if (mIsPollutionEnabled) + if (MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) try { if (te == null) { return 0; @@ -175,31 +229,52 @@ public class PollutionUtils { return 0; } - public static boolean setPollutionFluids() { - FluidStack CD, CM, SD; - CD = FluidUtils.getFluidStack("carbondioxide", 1000); - CM = FluidUtils.getFluidStack("carbonmonoxide", 1000); - SD = FluidUtils.getFluidStack("sulfuredioxide", 1000); - if (PollutionUtils.mPollutionFluidStacks.size() == 0) { - if (CD != null) { - PollutionUtils.mPollutionFluidStacks.put(CD); - ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonDioxide", 1); - if (ItemUtils.checkForInvalidItems(cellCD)) { - MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); + public static boolean setPollutionFluids() { + if (mPollutionFluidStacks.isEmpty()) { + FluidStack CD, CM, SD; + CD = FluidUtils.getFluidStack("carbondioxide", 1000); + CM = FluidUtils.getFluidStack("carbonmonoxide", 1000); + SD = FluidUtils.getFluidStack("sulfurdioxide", 1000); + if (PollutionUtils.mPollutionFluidStacks.size() == 0) { + if (CD != null) { + Logger.INFO("[PollutionCompat] Found carbon dioxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(CD); + ItemStack cellCD = ItemUtils.getItemStackOfAmountFromOreDict("cellCarbonDioxide", 1); + if (ItemUtils.checkForInvalidItems(cellCD)) { + Logger.INFO("[PollutionCompat] Found carbon dioxide cell, registering component."); + MISC_MATERIALS.CARBON_DIOXIDE.registerComponentForMaterial(OrePrefixes.cell, cellCD); + } + } + else { + MaterialGenerator.generate(MISC_MATERIALS.CARBON_DIOXIDE, false, false); + } + if (CM != null) { + Logger.INFO("[PollutionCompat] Found carbon monoxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(CM); + } + if (SD != null) { + Logger.INFO("[PollutionCompat] Found sulfur dioxide fluid, registering it."); + PollutionUtils.mPollutionFluidStacks.put(SD); } } - else { - MaterialGenerator.generate(MISC_MATERIALS.CARBON_DIOXIDE, false, false); + if (PollutionUtils.mPollutionFluidStacks.size() > 0) { + return true; } - if (CM != null) - PollutionUtils.mPollutionFluidStacks.put(CM); - if (SD != null) - PollutionUtils.mPollutionFluidStacks.put(SD); + return false; } - if (PollutionUtils.mPollutionFluidStacks.size() > 0) { - return true; + else { + if (mPollutionFluidStacks.size() != 3) { + Logger.INFO("Unable to detect all 3 pollution fluids. Found: "); + Logger.INFO(ArrayUtils.toString(mPollutionFluidStacks)); + return false; + } + else { + return true; + } } - return false; + + + } } -- cgit