diff options
author | Alexdoru <57050655+Alexdoru@users.noreply.github.com> | 2024-10-21 21:21:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-21 19:21:33 +0000 |
commit | 901cb0d294b0c4f114bb247fbd7d6f97e7484f3c (patch) | |
tree | fd4900d59f98ec34c9119c2003f79f7467abddf0 /src/main/java/gregtech | |
parent | e741976ea6a6fa5dbcb45813fd1e2ca368331ba5 (diff) | |
download | GT5-Unofficial-901cb0d294b0c4f114bb247fbd7d6f97e7484f3c.tar.gz GT5-Unofficial-901cb0d294b0c4f114bb247fbd7d6f97e7484f3c.tar.bz2 GT5-Unofficial-901cb0d294b0c4f114bb247fbd7d6f97e7484f3c.zip |
Import pollution mixins from hodgepodge (#3395)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Diffstat (limited to 'src/main/java/gregtech')
28 files changed, 779 insertions, 178 deletions
diff --git a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java index e9364f922b..3d6a33fe7f 100644 --- a/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java +++ b/src/main/java/gregtech/api/graphs/consumers/NodeEnergyReceiver.java @@ -14,7 +14,7 @@ import gregtech.api.enums.GTValues; import gregtech.api.enums.SoundResource; import gregtech.api.util.GTUtility; import gregtech.api.util.WorldSpawnedEventBuilder; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; // consumer for RF machines public class NodeEnergyReceiver extends ConsumerNode { diff --git a/src/main/java/gregtech/api/interfaces/ICleanroomReceiver.java b/src/main/java/gregtech/api/interfaces/ICleanroomReceiver.java index b26c7035c7..c7c488ccbd 100644 --- a/src/main/java/gregtech/api/interfaces/ICleanroomReceiver.java +++ b/src/main/java/gregtech/api/interfaces/ICleanroomReceiver.java @@ -4,7 +4,7 @@ import javax.annotation.Nullable; import net.minecraft.tileentity.TileEntity; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; /** * Implement this interface for TileEntities that can have association to cleanroom. diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index e39f78cee0..da81e7d9cb 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -83,8 +83,8 @@ import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTUtility; import gregtech.api.util.shutdown.ShutDownReason; import gregtech.api.util.shutdown.ShutDownReasonRegistry; -import gregtech.common.Pollution; import gregtech.common.covers.CoverInfo; +import gregtech.common.pollution.Pollution; import ic2.api.Direction; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicGenerator.java index 963acf191f..8ab0da4349 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicGenerator.java @@ -22,7 +22,7 @@ import gregtech.api.recipe.maps.FuelBackend; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; public abstract class MTEBasicGenerator extends MTEBasicTank implements RecipeMapWorkable { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchMuffler.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchMuffler.java index 179ba56254..576389de80 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchMuffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEHatchMuffler.java @@ -18,7 +18,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTLanguageManager; import gregtech.api.util.WorldSpawnedEventBuilder; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; @SuppressWarnings("unused") // Unused API is expected within scope public class MTEHatchMuffler extends MTEHatch { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java index 363c45bfc9..ce508433ec 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEMultiBlockBase.java @@ -95,11 +95,11 @@ import gregtech.api.util.VoidProtectionHelper; import gregtech.api.util.shutdown.ShutDownReason; import gregtech.api.util.shutdown.ShutDownReasonRegistry; import gregtech.client.GTSoundLoop; -import gregtech.common.Pollution; import gregtech.common.config.MachineStats; import gregtech.common.gui.modularui.widget.CheckRecipeResultSyncer; import gregtech.common.gui.modularui.widget.ShutDownReasonSyncer; import gregtech.common.items.MetaGeneratedTool01; +import gregtech.common.pollution.Pollution; import gregtech.common.tileentities.machines.IDualInputHatch; import gregtech.common.tileentities.machines.IDualInputInventory; import gregtech.common.tileentities.machines.IRecipeProcessingAwareHatch; diff --git a/src/main/java/gregtech/api/task/tasks/PollutionTask.java b/src/main/java/gregtech/api/task/tasks/PollutionTask.java index 3770409fb1..c8c9705e6c 100644 --- a/src/main/java/gregtech/api/task/tasks/PollutionTask.java +++ b/src/main/java/gregtech/api/task/tasks/PollutionTask.java @@ -8,7 +8,7 @@ import gregtech.api.enums.TickTime; import gregtech.api.interfaces.tileentity.IMachineProgress; import gregtech.api.task.TaskHost; import gregtech.api.task.TickableTask; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; public class PollutionTask<T extends TaskHost & IMachineProgress> extends TickableTask<T> { diff --git a/src/main/java/gregtech/api/util/GTUtility.java b/src/main/java/gregtech/api/util/GTUtility.java index 83cd5ced7a..da805f995d 100644 --- a/src/main/java/gregtech/api/util/GTUtility.java +++ b/src/main/java/gregtech/api/util/GTUtility.java @@ -167,8 +167,8 @@ import gregtech.api.objects.ItemData; import gregtech.api.recipe.RecipeMaps; import gregtech.api.threads.RunnableSound; import gregtech.api.util.extensions.ArrayExt; -import gregtech.common.Pollution; import gregtech.common.blocks.BlockOresAbstract; +import gregtech.common.pollution.Pollution; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; diff --git a/src/main/java/gregtech/asm/GTCorePlugin.java b/src/main/java/gregtech/asm/GTCorePlugin.java index 3b8aa08d16..f8dde28c58 100644 --- a/src/main/java/gregtech/asm/GTCorePlugin.java +++ b/src/main/java/gregtech/asm/GTCorePlugin.java @@ -10,6 +10,7 @@ import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader; import bartworks.common.configs.Configuration; import cpw.mods.fml.relauncher.IFMLLoadingPlugin; +import gregtech.common.pollution.PollutionConfig; import gregtech.mixin.Mixin; import gtPlusPlus.core.config.ASMConfiguration; @@ -20,8 +21,9 @@ public class GTCorePlugin implements IFMLLoadingPlugin, IEarlyMixinLoader { static { try { - ConfigurationManager.registerConfig(Configuration.class); ConfigurationManager.registerConfig(ASMConfiguration.class); + ConfigurationManager.registerConfig(Configuration.class); + ConfigurationManager.registerConfig(PollutionConfig.class); } catch (ConfigException e) { throw new RuntimeException(e); } diff --git a/src/main/java/gregtech/client/GTGUIClientConfig.java b/src/main/java/gregtech/client/GTGUIClientConfig.java index cf063acf55..875e62f7f8 100644 --- a/src/main/java/gregtech/client/GTGUIClientConfig.java +++ b/src/main/java/gregtech/client/GTGUIClientConfig.java @@ -11,6 +11,7 @@ import gregtech.common.config.Client; import gregtech.common.config.Gregtech; import gregtech.common.config.MachineStats; import gregtech.common.config.Worldgen; +import gregtech.common.pollution.PollutionConfig; public class GTGUIClientConfig extends SimpleGuiConfig { @@ -23,6 +24,7 @@ public class GTGUIClientConfig extends SimpleGuiConfig { Client.class, Gregtech.class, MachineStats.class, + PollutionConfig.class, Worldgen.class); } } diff --git a/src/main/java/gregtech/common/GTClient.java b/src/main/java/gregtech/common/GTClient.java index 844731e82f..7cd673c001 100644 --- a/src/main/java/gregtech/common/GTClient.java +++ b/src/main/java/gregtech/common/GTClient.java @@ -92,6 +92,8 @@ import gregtech.client.GTMouseEventHandler; import gregtech.client.SeekingOggCodec; import gregtech.common.blocks.BlockFrameBox; import gregtech.common.blocks.ItemMachines; +import gregtech.common.pollution.Pollution; +import gregtech.common.pollution.PollutionRenderer; import gregtech.common.render.BlackholeRenderer; import gregtech.common.render.DroneRender; import gregtech.common.render.FlaskRenderer; @@ -101,7 +103,6 @@ import gregtech.common.render.GTRendererBlock; import gregtech.common.render.LaserRenderer; import gregtech.common.render.MetaGeneratedToolRenderer; import gregtech.common.render.MultiTileRenderer; -import gregtech.common.render.PollutionRenderer; import gregtech.common.render.WormholeRenderer; import gregtech.common.render.items.DataStickRenderer; import gregtech.common.render.items.InfiniteSprayCanRenderer; @@ -670,6 +671,7 @@ public class GTClient extends GTProxy implements Runnable { .forEach(CoverBehaviorBase::reloadColorOverride); } }); + Pollution.onPostInitClient(); } @Override diff --git a/src/main/java/gregtech/common/GTProxy.java b/src/main/java/gregtech/common/GTProxy.java index 643811234d..e7cb627c91 100644 --- a/src/main/java/gregtech/common/GTProxy.java +++ b/src/main/java/gregtech/common/GTProxy.java @@ -167,6 +167,7 @@ import gregtech.common.items.MetaGeneratedTool01; import gregtech.common.misc.GlobalEnergyWorldSavedData; import gregtech.common.misc.GlobalMetricsCoverDatabase; import gregtech.common.misc.spaceprojects.SpaceProjectWorldSavedData; +import gregtech.common.pollution.Pollution; import gregtech.common.tileentities.machines.multi.drone.MTEDroneCentre; import gregtech.nei.GTNEIDefaultHandler; diff --git a/src/main/java/gregtech/common/config/Gregtech.java b/src/main/java/gregtech/common/config/Gregtech.java index a293b6cba7..e852a6b022 100644 --- a/src/main/java/gregtech/common/config/Gregtech.java +++ b/src/main/java/gregtech/common/config/Gregtech.java @@ -27,9 +27,6 @@ public class Gregtech { @Config.Comment("Ore drop behavior section") public static final OreDropBehavior oreDropBehavior = new OreDropBehavior(); - @Config.Comment("Pollution section") - public static final Pollution pollution = new Pollution(); - @Config.LangKey("GT5U.gui.config.gregtech.debug") public static class Debug { @@ -558,128 +555,4 @@ public class Gregtech { @Config.RequiresMcRestart public GTProxy.OreDropSystem setting = GTProxy.OreDropSystem.FortuneItem; } - - @Config.LangKey("GT5U.gui.config.gregtech.pollution") - public static class Pollution { - - @Config.Comment("if true, enables pollution in the game.") - @Config.DefaultBoolean(true) - @Config.RequiresMcRestart - public boolean pollution; - - @Config.Comment("Controls the threshold starting from which you can see fog.") - @Config.DefaultInt(550_000) - @Config.RequiresMcRestart - public int pollutionSmogLimit; - @Config.Comment("Controls the threshold starting from which players get poison effect.") - @Config.DefaultInt(750_000) - @Config.RequiresMcRestart - public int pollutionPoisonLimit; - @Config.Comment("Controls the threshold starting from which vegetation starts to be killed.") - @Config.DefaultInt(1_000_000) - @Config.RequiresMcRestart - public int pollutionVegetationLimit; - @Config.Comment("Controls the threshold starting from which if it rains, will turn cobblestone into gravel and gravel into sand.") - @Config.DefaultInt(2_000_000) - @Config.RequiresMcRestart - public int pollutionSourRainLimit; - @Config.Comment("Controls the pollution released by an explosion.") - @Config.DefaultInt(100_000) - @Config.RequiresMcRestart - public int pollutionOnExplosion; - @Config.Comment("Controls the pollution released per second by the bricked blast furnace.") - @Config.DefaultInt(200) - @Config.RequiresMcRestart - public int pollutionPrimitveBlastFurnacePerSecond; - @Config.Comment("Controls the pollution released per second by the charcoal pile igniter.") - @Config.DefaultInt(100) - @Config.RequiresMcRestart - public int pollutionCharcoalPitPerSecond; - @Config.Comment("Controls the pollution released per second by the EBF.") - @Config.DefaultInt(400) - @Config.RequiresMcRestart - public int pollutionEBFPerSecond; - @Config.Comment("Controls the pollution released per second by the large combustion engine.") - @Config.DefaultInt(480) - @Config.RequiresMcRestart - public int pollutionLargeCombustionEnginePerSecond; - @Config.Comment("Controls the pollution released per second by the extreme combustion engine.") - @Config.DefaultInt(3_840) - @Config.RequiresMcRestart - public int pollutionExtremeCombustionEnginePerSecond; - @Config.Comment("Controls the pollution released per second by the implosion compressor.") - @Config.DefaultInt(10_000) - @Config.RequiresMcRestart - public int pollutionImplosionCompressorPerSecond; - @Config.Comment("Controls the pollution released per second by the large bronze boiler.") - @Config.DefaultInt(1_000) - @Config.RequiresMcRestart - public int pollutionLargeBronzeBoilerPerSecond; - @Config.Comment("Controls the pollution released per second by the large steel boiler.") - @Config.DefaultInt(2_000) - @Config.RequiresMcRestart - public int pollutionLargeSteelBoilerPerSecond; - @Config.Comment("Controls the pollution released per second by the large titanium boiler.") - @Config.DefaultInt(3_000) - @Config.RequiresMcRestart - public int pollutionLargeTitaniumBoilerPerSecond; - @Config.Comment("Controls the pollution released per second by the large tungstensteel boiler.") - @Config.DefaultInt(4_000) - @Config.RequiresMcRestart - public int pollutionLargeTungstenSteelBoilerPerSecond; - @Config.Comment("Controls the pollution reduction obtained with each increment of the circuit when throttling large boilers.") - @Config.DefaultFloat(1.0f / 24.0f) // divided by 24 because there are 24 circuit configs. - @Config.RequiresMcRestart - public float pollutionReleasedByThrottle; - @Config.Comment("Controls the pollution released per second by the large gas turbine.") - @Config.DefaultInt(300) - @Config.RequiresMcRestart - public int pollutionLargeGasTurbinePerSecond; - @Config.Comment("Controls the pollution released per second by the multi smelter.") - @Config.DefaultInt(400) - @Config.RequiresMcRestart - public int pollutionMultiSmelterPerSecond; - @Config.Comment("Controls the pollution released per second by the pyrolyse oven.") - @Config.DefaultInt(300) - @Config.RequiresMcRestart - public int pollutionPyrolyseOvenPerSecond; - @Config.Comment("Controls the pollution released per second by the small coil boiler.") - @Config.DefaultInt(20) - @Config.RequiresMcRestart - public int pollutionSmallCoalBoilerPerSecond; - @Config.Comment("Controls the pollution released per second by the high pressure lava boiler.") - @Config.DefaultInt(20) - @Config.RequiresMcRestart - public int pollutionHighPressureLavaBoilerPerSecond; - @Config.Comment("Controls the pollution released per second by the high pressure coil boiler.") - @Config.DefaultInt(30) - @Config.RequiresMcRestart - public int pollutionHighPressureCoalBoilerPerSecond; - - @Config.Comment("Controls the pollution released per second by the base diesel generator.") - @Config.DefaultInt(40) - @Config.RequiresMcRestart - public int pollutionBaseDieselGeneratorPerSecond; - - // reading double as strings, not perfect, but better than nothing - @Config.Comment({ - "Pollution released by tier, with the following formula: PollutionBaseDieselGeneratorPerSecond * PollutionDieselGeneratorReleasedByTier[Tier]", - "The first entry has meaning as it is here to since machine tier with array index: LV is 1, etc." }) - @Config.DefaultDoubleList({ 0.1, 1.0, 0.9, 0.8 }) - @Config.RequiresMcRestart - public double[] pollutionDieselGeneratorReleasedByTier; - - @Config.Comment("Controls the pollution released per second by the base gas turbine.") - @Config.DefaultInt(40) - @Config.RequiresMcRestart - public int pollutionBaseGasTurbinePerSecond; - - // reading double as strings, not perfect, but better than nothing - @Config.Comment({ - "Pollution released by tier, with the following formula: PollutionBaseGasTurbinePerSecond * PollutionGasTurbineReleasedByTier[Tier]", - "The first entry has meaning as it is here to since machine tier with array index: LV is 1, etc." }) - @Config.DefaultDoubleList({ 0.1, 1.0, 0.9, 0.8, 0.7, 0.6 }) - @Config.RequiresMcRestart - public double[] pollutionGasTurbineReleasedByTier; - } } diff --git a/src/main/java/gregtech/common/misc/GTCommand.java b/src/main/java/gregtech/common/misc/GTCommand.java index f1590ec792..e6fbe12144 100644 --- a/src/main/java/gregtech/common/misc/GTCommand.java +++ b/src/main/java/gregtech/common/misc/GTCommand.java @@ -25,8 +25,8 @@ import gregtech.api.enums.GTValues; import gregtech.api.objects.GTChunkManager; import gregtech.api.util.GTMusicSystem; import gregtech.api.util.GTUtility; -import gregtech.common.Pollution; import gregtech.common.misc.spaceprojects.SpaceProjectManager; +import gregtech.common.pollution.Pollution; public final class GTCommand extends CommandBase { diff --git a/src/main/java/gregtech/common/pollution/BlockMatcher.java b/src/main/java/gregtech/common/pollution/BlockMatcher.java new file mode 100644 index 0000000000..a701d323bd --- /dev/null +++ b/src/main/java/gregtech/common/pollution/BlockMatcher.java @@ -0,0 +1,96 @@ +package gregtech.common.pollution; + +import java.util.Map; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraftforge.event.world.WorldEvent; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.FMLControlledNamespacedRegistry; +import cpw.mods.fml.common.registry.GameData; +import gregtech.GTMod; + +// Shamelessly Taken from BetterFoliage by octarine-noise +public class BlockMatcher { + + public Map<Class<?>, ColorOverrideType> whiteList = Maps.newHashMap(); + public Set<Class<?>> blackList = Sets.newHashSet(); + public Map<Integer, ColorOverrideType> blockIDs = Maps.newHashMap(); + + public ColorOverrideType matchesID(int blockId) { + return blockIDs.get(blockId); + } + + public ColorOverrideType matchesID(Block block) { + return blockIDs.get(Block.blockRegistry.getIDForObject(block)); + } + + public void updateClassList(String[] cfg) { + whiteList.clear(); + blackList.clear(); + for (String line : cfg) { + GTMod.GT_FML_LOGGER.info("Checking for block:" + line); + String[] lines = line.split(":"); + ColorOverrideType type = null; + if (lines.length > 1) { + try { + type = ColorOverrideType.fromName(lines[1].trim()); + } catch (NumberFormatException e) { + GTMod.GT_FML_LOGGER.error(String.format("Invalid type [%s]", line)); + continue; + } + } + + if (lines[0].startsWith("-")) { + try { + blackList.add(Class.forName(lines[0].substring(1))); + GTMod.GT_FML_LOGGER.info("\t added blacklist:" + lines[0].substring(1)); + } catch (ClassNotFoundException ignored) {} + } else { + if (type == null) { + GTMod.GT_FML_LOGGER.error(String.format("Invalid type [%s]", line)); + continue; + } + + try { + whiteList.put(Class.forName(lines[0]), type); + GTMod.GT_FML_LOGGER.info("\t added whitelist:" + lines[0]); + } catch (ClassNotFoundException ignored) {} + } + } + // updateBlockIDs(); + } + + private void updateBlockIDs() { + blockIDs.clear(); + FMLControlledNamespacedRegistry<Block> blockRegistry = GameData.getBlockRegistry(); + for (Block block : blockRegistry.typeSafeIterable()) { + ColorOverrideType t = matchesClass(block); + if (t != null) blockIDs.put(Block.blockRegistry.getIDForObject(block), t); + } + } + + private ColorOverrideType matchesClass(Block block) { + for (Class<?> clazz : blackList) if (clazz.isAssignableFrom(block.getClass())) return null; + for (Class<?> clazz : whiteList.keySet()) + if (clazz.isAssignableFrom(block.getClass())) return whiteList.get(clazz); + return null; + } + + /** + * Caches block IDs on world load for fast lookup + * + * @param event + */ + @SubscribeEvent + public void handleWorldLoad(WorldEvent.Load event) { + if (event.world instanceof WorldClient) { + updateBlockIDs(); + } + } +} diff --git a/src/main/java/gregtech/common/pollution/ColorOverrideType.java b/src/main/java/gregtech/common/pollution/ColorOverrideType.java new file mode 100644 index 0000000000..de0a44a835 --- /dev/null +++ b/src/main/java/gregtech/common/pollution/ColorOverrideType.java @@ -0,0 +1,28 @@ +package gregtech.common.pollution; + +public enum ColorOverrideType { + + FLOWER, + GRASS, + LEAVES, + LIQUID; + + public static ColorOverrideType fromName(String name) { + return switch (name) { + case "FLOWER" -> FLOWER; + case "GRASS" -> GRASS; + case "LEAVES" -> LEAVES; + case "LIQUID" -> LIQUID; + default -> throw new RuntimeException(); + }; + } + + public int getColor(int oColor, int x, int z) { + return switch (this) { + case FLOWER -> PollutionRenderer.colorFoliage(oColor, x, z); + case GRASS -> PollutionRenderer.colorGrass(oColor, x, z); + case LEAVES -> PollutionRenderer.colorLeaves(oColor, x, z); + case LIQUID -> PollutionRenderer.colorLiquid(oColor, x, z); + }; + } +} diff --git a/src/main/java/gregtech/common/entities/EntityFXPollution.java b/src/main/java/gregtech/common/pollution/EntityFXPollution.java index facd3d3364..f1a1f18447 100644 --- a/src/main/java/gregtech/common/entities/EntityFXPollution.java +++ b/src/main/java/gregtech/common/pollution/EntityFXPollution.java @@ -1,4 +1,4 @@ -package gregtech.common.entities; +package gregtech.common.pollution; import java.util.Random; diff --git a/src/main/java/gregtech/common/misc/GTClientPollutionMap.java b/src/main/java/gregtech/common/pollution/GTClientPollutionMap.java index 546f8e8d12..0fd1da309b 100644 --- a/src/main/java/gregtech/common/misc/GTClientPollutionMap.java +++ b/src/main/java/gregtech/common/pollution/GTClientPollutionMap.java @@ -1,4 +1,4 @@ -package gregtech.common.misc; +package gregtech.common.pollution; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; diff --git a/src/main/java/gregtech/common/Pollution.java b/src/main/java/gregtech/common/pollution/Pollution.java index 4245a0ef12..10b8ffcfa7 100644 --- a/src/main/java/gregtech/common/Pollution.java +++ b/src/main/java/gregtech/common/pollution/Pollution.java @@ -1,4 +1,4 @@ -package gregtech.common; +package gregtech.common.pollution; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import static gregtech.common.GTProxy.dimensionWisePollution; @@ -45,7 +45,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.net.GTPacketPollution; import gregtech.api.util.GTChunkAssociatedData; import gregtech.api.util.GTUtility; -import gregtech.common.render.PollutionRenderer; public class Pollution { @@ -101,6 +100,33 @@ public class Pollution { pollutionInstance.tickPollutionInWorld((int) (aEvent.world.getTotalWorldTime() % cycleLen)); } + public static BlockMatcher standardBlocks; + public static BlockMatcher liquidBlocks; + public static BlockMatcher doublePlants; + public static BlockMatcher crossedSquares; + public static BlockMatcher blockVine; + + public static void onPostInitClient() { + if (PollutionConfig.pollution) { + standardBlocks = new BlockMatcher(); + liquidBlocks = new BlockMatcher(); + doublePlants = new BlockMatcher(); + crossedSquares = new BlockMatcher(); + blockVine = new BlockMatcher(); + standardBlocks.updateClassList(PollutionConfig.renderStandardBlock); + liquidBlocks.updateClassList(PollutionConfig.renderBlockLiquid); + doublePlants.updateClassList(PollutionConfig.renderBlockDoublePlant); + crossedSquares.updateClassList(PollutionConfig.renderCrossedSquares); + blockVine.updateClassList(PollutionConfig.renderblockVine); + MinecraftForge.EVENT_BUS.register(standardBlocks); + MinecraftForge.EVENT_BUS.register(liquidBlocks); + MinecraftForge.EVENT_BUS.register(doublePlants); + MinecraftForge.EVENT_BUS.register(crossedSquares); + MinecraftForge.EVENT_BUS.register(blockVine); + MinecraftForge.EVENT_BUS.register(new PollutionTooltip()); + } + } + private void tickPollutionInWorld(int aTickID) { // called from method above // gen data set if (aTickID == 0 || blank) { @@ -406,7 +432,7 @@ public class Pollution { addPollution(aWorld.getChunkFromBlockCoords(aPos.chunkPosX, aPos.chunkPosZ), aPollution); } - static void migrate(ChunkDataEvent.Load e) { + public static void migrate(ChunkDataEvent.Load e) { addPollution( e.getChunk(), e.getData() diff --git a/src/main/java/gregtech/common/pollution/PollutionConfig.java b/src/main/java/gregtech/common/pollution/PollutionConfig.java new file mode 100644 index 0000000000..90098791c4 --- /dev/null +++ b/src/main/java/gregtech/common/pollution/PollutionConfig.java @@ -0,0 +1,397 @@ +package gregtech.common.pollution; + +import com.gtnewhorizon.gtnhlib.config.Config; + +import gregtech.api.enums.Mods; + +// needs to be loaded early from the coremod because +// it decides to load some mixins or not +@Config(modid = Mods.Names.GREG_TECH, category = "Pollution", configSubDirectory = "GregTech", filename = "Pollution") +public class PollutionConfig { + + // override name to be at the top of the cfg file + @Config.Name("Activate Pollution") + @Config.Comment("if true, enables pollution in the game.") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean pollution; + + @Config.Comment("Controls the threshold starting from which you can see fog.") + @Config.DefaultInt(550_000) + @Config.RequiresMcRestart + public static int pollutionSmogLimit; + @Config.Comment("Controls the threshold starting from which players get poison effect.") + @Config.DefaultInt(750_000) + @Config.RequiresMcRestart + public static int pollutionPoisonLimit; + @Config.Comment("Controls the threshold starting from which vegetation starts to be killed.") + @Config.DefaultInt(1_000_000) + @Config.RequiresMcRestart + public static int pollutionVegetationLimit; + @Config.Comment("Controls the threshold starting from which if it rains, will turn cobblestone into gravel and gravel into sand.") + @Config.DefaultInt(2_000_000) + @Config.RequiresMcRestart + public static int pollutionSourRainLimit; + @Config.Comment("Controls the pollution released by an explosion.") + @Config.DefaultInt(100_000) + @Config.RequiresMcRestart + public static int pollutionOnExplosion; + @Config.Comment("Controls the pollution released per second by the bricked blast furnace.") + @Config.DefaultInt(200) + @Config.RequiresMcRestart + public static int pollutionPrimitveBlastFurnacePerSecond; + @Config.Comment("Controls the pollution released per second by the charcoal pile igniter.") + @Config.DefaultInt(100) + @Config.RequiresMcRestart + public static int pollutionCharcoalPitPerSecond; + @Config.Comment("Controls the pollution released per second by the EBF.") + @Config.DefaultInt(400) + @Config.RequiresMcRestart + public static int pollutionEBFPerSecond; + @Config.Comment("Controls the pollution released per second by the large combustion engine.") + @Config.DefaultInt(480) + @Config.RequiresMcRestart + public static int pollutionLargeCombustionEnginePerSecond; + @Config.Comment("Controls the pollution released per second by the extreme combustion engine.") + @Config.DefaultInt(3_840) + @Config.RequiresMcRestart + public static int pollutionExtremeCombustionEnginePerSecond; + @Config.Comment("Controls the pollution released per second by the implosion compressor.") + @Config.DefaultInt(10_000) + @Config.RequiresMcRestart + public static int pollutionImplosionCompressorPerSecond; + @Config.Comment("Controls the pollution released per second by the large bronze boiler.") + @Config.DefaultInt(1_000) + @Config.RequiresMcRestart + public static int pollutionLargeBronzeBoilerPerSecond; + @Config.Comment("Controls the pollution released per second by the large steel boiler.") + @Config.DefaultInt(2_000) + @Config.RequiresMcRestart + public static int pollutionLargeSteelBoilerPerSecond; + @Config.Comment("Controls the pollution released per second by the large titanium boiler.") + @Config.DefaultInt(3_000) + @Config.RequiresMcRestart + public static int pollutionLargeTitaniumBoilerPerSecond; + @Config.Comment("Controls the pollution released per second by the large tungstensteel boiler.") + @Config.DefaultInt(4_000) + @Config.RequiresMcRestart + public static int pollutionLargeTungstenSteelBoilerPerSecond; + @Config.Comment("Controls the pollution reduction obtained with each increment of the circuit when throttling large boilers.") + @Config.DefaultFloat(1.0f / 24.0f) // divided by 24 because there are 24 circuit configs. + @Config.RequiresMcRestart + public static float pollutionReleasedByThrottle; + @Config.Comment("Controls the pollution released per second by the large gas turbine.") + @Config.DefaultInt(300) + @Config.RequiresMcRestart + public static int pollutionLargeGasTurbinePerSecond; + @Config.Comment("Controls the pollution released per second by the multi smelter.") + @Config.DefaultInt(400) + @Config.RequiresMcRestart + public static int pollutionMultiSmelterPerSecond; + @Config.Comment("Controls the pollution released per second by the pyrolyse oven.") + @Config.DefaultInt(300) + @Config.RequiresMcRestart + public static int pollutionPyrolyseOvenPerSecond; + @Config.Comment("Controls the pollution released per second by the small coil boiler.") + @Config.DefaultInt(20) + @Config.RequiresMcRestart + public static int pollutionSmallCoalBoilerPerSecond; + @Config.Comment("Controls the pollution released per second by the high pressure lava boiler.") + @Config.DefaultInt(20) + @Config.RequiresMcRestart + public static int pollutionHighPressureLavaBoilerPerSecond; + @Config.Comment("Controls the pollution released per second by the high pressure coil boiler.") + @Config.DefaultInt(30) + @Config.RequiresMcRestart + public static int pollutionHighPressureCoalBoilerPerSecond; + + @Config.Comment("Controls the pollution released per second by the base diesel generator.") + @Config.DefaultInt(40) + @Config.RequiresMcRestart + public static int pollutionBaseDieselGeneratorPerSecond; + + // reading double as strings, not perfect, but better than nothing + @Config.Comment({ + "Pollution released by tier, with the following formula: PollutionBaseDieselGeneratorPerSecond * PollutionDieselGeneratorReleasedByTier[Tier]", + "The first entry has meaning as it is here to since machine tier with array index: LV is 1, etc." }) + @Config.DefaultDoubleList({ 0.1, 1.0, 0.9, 0.8 }) + @Config.RequiresMcRestart + public static double[] pollutionDieselGeneratorReleasedByTier; + + @Config.Comment("Controls the pollution released per second by the base gas turbine.") + @Config.DefaultInt(40) + @Config.RequiresMcRestart + public static int pollutionBaseGasTurbinePerSecond; + + // reading double as strings, not perfect, but better than nothing + @Config.Comment({ + "Pollution released by tier, with the following formula: PollutionBaseGasTurbinePerSecond * PollutionGasTurbineReleasedByTier[Tier]", + "The first entry has meaning as it is here to since machine tier with array index: LV is 1, etc." }) + @Config.DefaultDoubleList({ 0.1, 1.0, 0.9, 0.8, 0.7, 0.6 }) + @Config.RequiresMcRestart + public static double[] pollutionGasTurbineReleasedByTier; + + // Minecraft + @Config.Comment("Explosion pollution") + @Config.DefaultFloat(333.34f) + public static float explosionPollutionAmount; + + @Config.Comment("Make furnaces Pollute") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean furnacesPollute; + + @Config.Comment("Furnace pollution per second, min 1!") + @Config.DefaultInt(20) + public static int furnacePollutionAmount; + + // Galacticraft + + @Config.Comment("Pollution Amount for Rockets") + @Config.DefaultInt(10000) + public static int rocketPollutionAmount; + + @Config.Comment("Make rockets Pollute") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean rocketsPollute; + + // Railcraft + + @Config.Comment("Pollution Amount for Advanced Coke Ovens") + @Config.DefaultInt(80) + public static int advancedCokeOvenPollutionAmount; + + @Config.Comment("Pollution Amount for Coke Ovens") + @Config.DefaultInt(10) + public static int cokeOvenPollutionAmount; + + @Config.Comment("Pollution Amount for RC Firebox") + @Config.DefaultInt(20) + public static int fireboxPollutionAmount; + + @Config.Comment("Pollution Amount for hobbyist steam engine") + @Config.DefaultInt(20) + public static int hobbyistEnginePollutionAmount; + + @Config.Comment("Make Railcraft Pollute") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean railcraftPollutes; + + @Config.Comment("Pollution Amount for tunnel bore") + @Config.DefaultInt(2) + public static int tunnelBorePollutionAmount; + + // bartworks + @Config.Comment("How much should the Simple Stirling Water Pump produce pollution per second") + @Config.DefaultInt(5) + public static int pollutionHeatedWaterPumpSecond; + + @Config.Comment("How much should the MBF produce pollution per tick per ingot. Then it'll be multiplied by the amount of ingots done in parallel") + @Config.DefaultInt(400) + public static int basePollutionMBFSecond; + + @Config.Comment("Changes colors of certain blocks based on pollution levels") + @Config.DefaultBoolean(true) + @Config.RequiresMcRestart + public static boolean pollutionBlockRecolor; + + @Config.Comment("Double Plant Blocks - Recolor Block List") + @Config.DefaultStringList({ "net.minecraft.block.BlockDoublePlant:FLOWER", }) + @Config.RequiresMcRestart + public static String[] renderBlockDoublePlant; + + @Config.Comment("Liquid Blocks - Recolor Block List") + @Config.DefaultStringList({ "net.minecraft.block.BlockLiquid:LIQUID" }) + @Config.RequiresMcRestart + public static String[] renderBlockLiquid; + + @Config.Comment("Block Vine - Recolor Block List") + @Config.DefaultStringList({ "net.minecraft.block.BlockVine:FLOWER", }) + @Config.RequiresMcRestart + public static String[] renderblockVine; + + @Config.Comment("Crossed Squares - Recolor Block List") + @Config.DefaultStringList({ "net.minecraft.block.BlockTallGrass:FLOWER", "net.minecraft.block.BlockFlower:FLOWER", + "biomesoplenty.common.blocks.BlockBOPFlower:FLOWER", "biomesoplenty.common.blocks.BlockBOPFlower2:FLOWER", + "biomesoplenty.common.blocks.BlockBOPFoliage:FLOWER", }) + @Config.RequiresMcRestart + public static String[] renderCrossedSquares; + + @Config.Comment("Standard Blocks - Recolor Block List") + @Config.DefaultStringList({ "net.minecraft.block.BlockGrass:GRASS", "net.minecraft.block.BlockLeavesBase:LEAVES", + "biomesoplenty.common.blocks.BlockOriginGrass:GRASS", "biomesoplenty.common.blocks.BlockLongGrass:GRASS", + "biomesoplenty.common.blocks.BlockNewGrass:GRASS", "tconstruct.blocks.slime.SlimeGrass:GRASS", + "thaumcraft.common.blocks.BlockMagicalLeaves:LEAVES", }) + @Config.RequiresMcRestart + public static String[] renderStandardBlock; + + // gt++ + @Config.Comment("pollution rate in gibbl/s for the Amazon warehousing depot") + @Config.DefaultInt(40) + public static int pollutionPerSecondMultiPackager; + @Config.Comment("pollution rate in gibbl/s for the Alloy blast smelter") + @Config.DefaultInt(300) + public static int pollutionPerSecondMultiIndustrialAlloySmelter; + @Config.Comment("pollution rate in gibbl/s for the High current arc furnace") + @Config.DefaultInt(2_400) + public static int pollutionPerSecondMultiIndustrialArcFurnace; + @Config.Comment("pollution rate in gibbl/s for the Industrial centrifuge") + @Config.DefaultInt(300) + public static int pollutionPerSecondMultiIndustrialCentrifuge; + @Config.Comment("pollution rate in gibbl/s for the Industrial coke oven") + @Config.DefaultInt(80) + public static int pollutionPerSecondMultiIndustrialCokeOven; + @Config.Comment("pollution rate in gibbl/s for the Cutting factory") + @Config.DefaultInt(160) + public static int pollutionPerSecondMultiIndustrialCuttingMachine; + @Config.Comment("pollution rate in gibbl/s for the Utupu-Tanuri") + @Config.DefaultInt(500) + public static int pollutionPerSecondMultiIndustrialDehydrator; + @Config.Comment("pollution rate in gibbl/s for the Industrial electrolyzer") + @Config.DefaultInt(300) + public static int pollutionPerSecondMultiIndustrialElectrolyzer; + @Config.Comment("pollution rate in gibbl/s for the Industrial extrusion machine") + @Config.DefaultInt(1_000) + public static int pollutionPerSecondMultiIndustrialExtruder; + @Config.Comment("pollution rate in gibbl/s for the Maceration stack") + @Config.DefaultInt(400) + public static int pollutionPerSecondMultiIndustrialMacerator; + @Config.Comment("pollution rate in gibbl/s for the Industrial mixing machine") + @Config.DefaultInt(800) + public static int pollutionPerSecondMultiIndustrialMixer; + @Config.Comment("pollution rate in gibbl/s for the Large processing factory in metal mode") + @Config.DefaultInt(400) + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMetal; + @Config.Comment("pollution rate in gibbl/s for the Large processing factory in fluid mode") + @Config.DefaultInt(400) + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeFluid; + @Config.Comment("pollution rate in gibbl/s for the Large processing factory in misc mode") + @Config.DefaultInt(600) + public static int pollutionPerSecondMultiIndustrialMultiMachine_ModeMisc; + @Config.Comment("pollution rate in gibbl/s for the Industrial material press in forming mode") + @Config.DefaultInt(240) + public static int pollutionPerSecondMultiIndustrialPlatePress_ModeForming; + @Config.Comment("pollution rate in gibbl/s for the Industrial material press in bending mode") + @Config.DefaultInt(480) + public static int pollutionPerSecondMultiIndustrialPlatePress_ModeBending; + @Config.Comment("pollution rate in gibbl/s for the Industrial Forge Hammer") + @Config.DefaultInt(250) + public static int pollutionPerSecondMultiIndustrialForgeHammer; + @Config.Comment("pollution rate in gibbl/s for the Large Sifter") + @Config.DefaultInt(40) + public static int pollutionPerSecondMultiIndustrialSifter; + @Config.Comment("pollution rate in gibbl/s for the Large thermal refinery") + @Config.DefaultInt(1_000) + public static int pollutionPerSecondMultiIndustrialThermalCentrifuge; + @Config.Comment("pollution rate in gibbl/s for the Industrial fluid heater") + @Config.DefaultInt(1_000) + public static int pollutionPerSecondMultiIndustrialFluidHeater; + @Config.Comment("pollution rate in gibbl/s for the Cryogenic freezer") + @Config.DefaultInt(500) + public static int pollutionPerSecondMultiIndustrialVacuumFreezer; + @Config.Comment("pollution rate in gibbl/s for the Ore washing plant in chemical bath mode") + @Config.DefaultInt(400) + public static int pollutionPerSecondMultiIndustrialWashPlant_ModeChemBath; + @Config.Comment("pollution rate in gibbl/s for the Ore washing plant in ore washer mode") + @Config.DefaultInt(100) + public static int pollutionPerSecondMultiIndustrialWashPlant_ModeWasher; + @Config.Comment("pollution rate in gibbl/s for the Wire factory") + @Config.DefaultInt(100) + public static int pollutionPerSecondMultiIndustrialWireMill; + @Config.Comment("pollution rate in gibbl/s for the IsaMill grinding machine") + @Config.DefaultInt(1_280) + public static int pollutionPerSecondMultiIsaMill; + @Config.Comment("pollution rate in gibbl/s for the Dangote distillus in distillery mode") + @Config.DefaultInt(240) + public static int pollutionPerSecondMultiAdvDistillationTower_ModeDistillery; + @Config.Comment("pollution rate in gibbl/s for the Dangote distillus in distillation tower mode") + @Config.DefaultInt(480) + public static int pollutionPerSecondMultiAdvDistillationTower_ModeDT; + @Config.Comment("pollution rate in gibbl/s for the Volcanus") + @Config.DefaultInt(500) + public static int pollutionPerSecondMultiAdvEBF; + @Config.Comment("pollution rate in gibbl/s for the Density^2") + @Config.DefaultInt(5_000) + public static int pollutionPerSecondMultiAdvImplosion; + @Config.Comment("pollution rate in gibbl/s for the Alloy blast furnace") + @Config.DefaultInt(200) + public static int pollutionPerSecondMultiABS; + @Config.Comment("pollution rate in gibbl/s for the Cyclotron") + @Config.DefaultInt(200) + public static int pollutionPerSecondMultiCyclotron; + @Config.Comment("pollution rate in gibbl/s for the Zuhai - fishing port") + @Config.DefaultInt(20) + public static int pollutionPerSecondMultiIndustrialFishingPond; + // pollutionPerSecondMultiLargeRocketEngine; + @Config.Comment("pollution rate in gibbl/s for the Large semifluid burner") + @Config.DefaultInt(1_280) + public static int pollutionPerSecondMultiLargeSemiFluidGenerator; + @Config.Comment("pollution rate in gibbl/s for the Matter fabrication CPU") + @Config.DefaultInt(40) + public static int pollutionPerSecondMultiMassFabricator; + @Config.Comment("pollution rate in gibbl/s for the Reactor fuel processing plant") + @Config.DefaultInt(4_000) + public static int pollutionPerSecondMultiRefinery; + @Config.Comment("pollution rate in gibbl/s for the Industrial Rock Breaker") + @Config.DefaultInt(100) + public static int pollutionPerSecondMultiIndustrialRockBreaker; + @Config.Comment("pollution rate in gibbl/s for the Industrial Chisel") + @Config.DefaultInt(50) + public static int pollutionPerSecondMultiIndustrialChisel; + @Config.Comment("pollution rate in gibbl/s for the Tree growth simulator") + @Config.DefaultInt(100) + public static int pollutionPerSecondMultiTreeFarm; + @Config.Comment("pollution rate in gibbl/s for the Flotation cell regulator") + @Config.DefaultInt(0) + public static int pollutionPerSecondMultiFrothFlotationCell; + @Config.Comment("pollution rate in gibbl/s for the Large-Scale auto assembler v1.01") + @Config.DefaultInt(500) + public static int pollutionPerSecondMultiAutoCrafter; + @Config.Comment("pollution rate in gibbl/s for the Nuclear salt processing plant") + @Config.DefaultInt(500) + public static int pollutionPerSecondNuclearSaltProcessingPlant; + @Config.Comment("pollution rate in gibbl/s for the Multiblock Molecular Transformer") + @Config.DefaultInt(1_000) + public static int pollutionPerSecondMultiMolecularTransformer; + + @Config.Comment("pollution rate in gibbl/s for the Elemental Duplicator") + @Config.DefaultInt(1_000) + public static int pollutionPerSecondElementalDuplicator; + + @Config.Comment("pollution rate in gibbl/s for the Thermal boiler") + @Config.DefaultInt(700) + public static int pollutionPerSecondMultiThermalBoiler; + @Config.Comment("pollution rate in gibbl/s for the Algae farm") + @Config.DefaultInt(0) + public static int pollutionPerSecondMultiAlgaePond; + @Config.Comment("base pollution rate in gibbl/s for the single block semi fluid generators") + @Config.DefaultInt(40) + public static int basePollutionPerSecondSemiFluidGenerator; + @Config.Comment("coefficient applied to the base rate of the single block semi fluid generators based on its tier (first is tier 0 aka ULV)") + @Config.DefaultDoubleList({ 0.0, 2.0, 4.0, 8.0, 12.0, 16.0 }) + public static double[] pollutionReleasedByTierSemiFluidGenerator; + @Config.Comment("base pollution rate in gibbl/s for the single block boilers") + @Config.DefaultInt(35) + public static int basePollutionPerSecondBoiler; + @Config.Comment("coefficient applied to the base rate of the single block boilers based on its tier (first is tier 0 aka ULV)") + @Config.DefaultDoubleList({ 0.0, 1.0, 1.43, 1.86 }) + public static double[] pollutionReleasedByTierBoiler; + @Config.Comment("minimum base pollution rate in gibbl/s for the single block rocket engines") + @Config.DefaultInt(250) + public static int baseMinPollutionPerSecondRocketFuelGenerator; + @Config.Comment("maximum base pollution rate in gibbl/s for the single block rocket engines") + @Config.DefaultInt(2_000) + public static int baseMaxPollutionPerSecondRocketFuelGenerator; + @Config.Comment("coefficient applied to the base rate of the single block rocket engines based on its tier (first is tier 0 aka ULV)") + @Config.DefaultDoubleList({ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0 }) + public static double[] pollutionReleasedByTierRocketFuelGenerator; + @Config.Comment("base pollution rate in gibbl/s for the geothermal engines") + @Config.DefaultInt(100) + public static int basePollutionPerSecondGeothermalGenerator; + @Config.Comment("coefficient applied to the base rate of the single block geothermal engines based on its tier (first is tier 0 aka ULV)") + @Config.DefaultDoubleList({ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 }) + public static double[] pollutionReleasedByTierGeothermalGenerator; + +} diff --git a/src/main/java/gregtech/common/render/PollutionRenderer.java b/src/main/java/gregtech/common/pollution/PollutionRenderer.java index 3b97fc820f..d0b76a58b1 100644 --- a/src/main/java/gregtech/common/render/PollutionRenderer.java +++ b/src/main/java/gregtech/common/pollution/PollutionRenderer.java @@ -1,4 +1,4 @@ -package gregtech.common.render; +package gregtech.common.pollution; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -22,8 +22,6 @@ import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GTMod; -import gregtech.common.entities.EntityFXPollution; -import gregtech.common.misc.GTClientPollutionMap; @SideOnly(Side.CLIENT) public class PollutionRenderer { diff --git a/src/main/java/gregtech/common/pollution/PollutionTooltip.java b/src/main/java/gregtech/common/pollution/PollutionTooltip.java new file mode 100644 index 0000000000..0fa338a624 --- /dev/null +++ b/src/main/java/gregtech/common/pollution/PollutionTooltip.java @@ -0,0 +1,108 @@ +package gregtech.common.pollution; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.Mods; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; + +public class PollutionTooltip { + + private static final String PRODUCES_POLLUTION_FORMAT = "Produces %d Pollution/Second"; + private static final String MULTI_POLLUTION_FORMAT = "A complete Multiblock produces %d Pollution/Second"; + + @SubscribeEvent(priority = EventPriority.LOWEST) + public void getTooltip(ItemTooltipEvent event) { + if (event.itemStack == null) return; + + if (PollutionConfig.furnacesPollute) { + String furnacePollution = String.format(PRODUCES_POLLUTION_FORMAT, PollutionConfig.furnacePollutionAmount); + + // Furnace and Iron Furnace + if (GTUtility.areStacksEqual(event.itemStack, new ItemStack(Blocks.furnace)) + || GTUtility.areStacksEqual(event.itemStack, GTModHandler.getModItem("IC2", "blockMachine", 1, 1))) { + event.toolTip.add(furnacePollution); + } + + // Alchemical Furnace + if (Mods.Thaumcraft.isModLoaded()) { + if (GTUtility + .areStacksEqual(event.itemStack, GTModHandler.getModItem("Thaumcraft", "blockStoneDevice", 1, 0))) { + event.toolTip.add(furnacePollution); + } + } + + // Advanced Alchemical Furnace + if (Mods.ThaumicBases.isModLoaded()) { + if (GTUtility + .areStacksEqual(event.itemStack, GTModHandler.getModItem("thaumicbases", "advAlchFurnace", 1, 0))) { + event.toolTip.add(furnacePollution); + } + } + } + + if (Mods.Railcraft.isModLoaded() && PollutionConfig.railcraftPollutes) { + + // Solid and Liquid Boiler Firebox + if (GTUtility.areStacksEqual(event.itemStack, GTModHandler.getModItem("Railcraft", "machine.beta", 1, 5)) + || GTUtility + .areStacksEqual(event.itemStack, GTModHandler.getModItem("Railcraft", "machine.beta", 1, 6))) { + event.toolTip.add( + String.format("Produces %d Pollution/Second per firebox", PollutionConfig.fireboxPollutionAmount)); + } + + // Tunnel Bore + if (GTUtility.areStacksEqual(event.itemStack, GTModHandler.getModItem("Railcraft", "cart.bore", 1, 0))) { + event.toolTip.add(String.format(PRODUCES_POLLUTION_FORMAT, PollutionConfig.tunnelBorePollutionAmount)); + } + + // Coke Oven Brick + if (GTUtility + .areStacksEqual(event.itemStack, GTModHandler.getModItem("Railcraft", "machine.alpha", 1, 7))) { + event.toolTip.add(String.format(MULTI_POLLUTION_FORMAT, PollutionConfig.cokeOvenPollutionAmount)); + } + + // Advanced Coke Oven Brick + if (GTUtility + .areStacksEqual(event.itemStack, GTModHandler.getModItem("Railcraft", "machine.alpha", 1, 12))) { + event.toolTip + .add(String.format(MULTI_POLLUTION_FORMAT, PollutionConfig.advancedCokeOvenPollutionAmount)); + } + + // Hobbyist's Steam Engine + if (GTUtility.areStacksEqual(event.itemStack, GTModHandler.getModItem("Railcraft", "machine.beta", 1, 7))) { + event.toolTip + .add(String.format(PRODUCES_POLLUTION_FORMAT, PollutionConfig.hobbyistEnginePollutionAmount)); + } + } + + // Galacticraft (and Galaxy Space) rockets + if (Mods.GalacticraftCore.isModLoaded() && PollutionConfig.rocketsPollute + && event.itemStack.getItem() != null) { + String simpleName = event.itemStack.getItem() + .getClass() + .getSimpleName(); + // TODO I'm sure there is a better way to check the tier of a rocket.... + if (simpleName.contains("Rocket")) { + for (char d : simpleName.toCharArray()) { + if (Character.isDigit(d)) { + int tier = Character.getNumericValue(d); + event.toolTip.add( + String.format( + "Produces %d Pollution/Second when ignited", + (PollutionConfig.rocketPollutionAmount * tier / 100))); + event.toolTip.add( + String.format( + "Produces %d Pollution/Second when flying", + PollutionConfig.rocketPollutionAmount * tier)); + break; + } + } + } + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/boilers/MTEBoiler.java b/src/main/java/gregtech/common/tileentities/boilers/MTEBoiler.java index b49da44e97..a84cb8ac91 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/MTEBoiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/MTEBoiler.java @@ -41,7 +41,7 @@ import gregtech.api.util.GTLog; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTUtility; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; public abstract class MTEBoiler extends MTEBasicTank implements IGetTitleColor, IAddUIWidgets { diff --git a/src/main/java/gregtech/common/tileentities/boilers/MTEBoilerBronze.java b/src/main/java/gregtech/common/tileentities/boilers/MTEBoilerBronze.java index e951656d23..632ff0ac1f 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/MTEBoilerBronze.java +++ b/src/main/java/gregtech/common/tileentities/boilers/MTEBoilerBronze.java @@ -36,7 +36,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTUtility; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; public class MTEBoilerBronze extends MTEBoiler { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTECharcoalPit.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTECharcoalPit.java index bfa672577d..f39ea70422 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTECharcoalPit.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTECharcoalPit.java @@ -35,7 +35,7 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.WorldSpawnedEventBuilder; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; public class MTECharcoalPit extends MTETooltipMultiBlockBase implements ISecondaryDescribable { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPrimitiveBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPrimitiveBlastFurnace.java index 0011a0efad..9c92733322 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEPrimitiveBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEPrimitiveBlastFurnace.java @@ -49,7 +49,7 @@ import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; -import gregtech.common.Pollution; +import gregtech.common.pollution.Pollution; public abstract class MTEPrimitiveBlastFurnace extends MetaTileEntity implements IAlignment, ISurvivalConstructable, RecipeMapWorkable, IAddUIWidgets, IGetTitleColor { diff --git a/src/main/java/gregtech/loaders/preload/GTPreLoad.java b/src/main/java/gregtech/loaders/preload/GTPreLoad.java index bef36a2bdb..a3d6572dd9 100644 --- a/src/main/java/gregtech/loaders/preload/GTPreLoad.java +++ b/src/main/java/gregtech/loaders/preload/GTPreLoad.java @@ -45,6 +45,7 @@ import gregtech.common.config.Gregtech; import gregtech.common.config.MachineStats; import gregtech.common.config.OPStuff; import gregtech.common.config.Worldgen; +import gregtech.common.pollution.PollutionConfig; import gregtech.common.tileentities.machines.long_distance.MTELongDistancePipelineBase; public class GTPreLoad { @@ -445,31 +446,31 @@ public class GTPreLoad { loadClientConfig(); // Pollution - GTMod.gregtechproxy.mPollution = Gregtech.pollution.pollution; - GTMod.gregtechproxy.mPollutionSmogLimit = Gregtech.pollution.pollutionSmogLimit; - GTMod.gregtechproxy.mPollutionPoisonLimit = Gregtech.pollution.pollutionPoisonLimit; - GTMod.gregtechproxy.mPollutionVegetationLimit = Gregtech.pollution.pollutionVegetationLimit; - GTMod.gregtechproxy.mPollutionSourRainLimit = Gregtech.pollution.pollutionSourRainLimit; - GTMod.gregtechproxy.mPollutionOnExplosion = Gregtech.pollution.pollutionOnExplosion; - GTMod.gregtechproxy.mPollutionPrimitveBlastFurnacePerSecond = Gregtech.pollution.pollutionPrimitveBlastFurnacePerSecond; - GTMod.gregtechproxy.mPollutionCharcoalPitPerSecond = Gregtech.pollution.pollutionCharcoalPitPerSecond; - GTMod.gregtechproxy.mPollutionEBFPerSecond = Gregtech.pollution.pollutionEBFPerSecond; - GTMod.gregtechproxy.mPollutionLargeCombustionEnginePerSecond = Gregtech.pollution.pollutionLargeCombustionEnginePerSecond; - GTMod.gregtechproxy.mPollutionExtremeCombustionEnginePerSecond = Gregtech.pollution.pollutionExtremeCombustionEnginePerSecond; - GTMod.gregtechproxy.mPollutionImplosionCompressorPerSecond = Gregtech.pollution.pollutionImplosionCompressorPerSecond; - GTMod.gregtechproxy.mPollutionLargeBronzeBoilerPerSecond = Gregtech.pollution.pollutionLargeBronzeBoilerPerSecond; - GTMod.gregtechproxy.mPollutionLargeSteelBoilerPerSecond = Gregtech.pollution.pollutionLargeSteelBoilerPerSecond; - GTMod.gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond = Gregtech.pollution.pollutionLargeTitaniumBoilerPerSecond; - GTMod.gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond = Gregtech.pollution.pollutionLargeTungstenSteelBoilerPerSecond; - GTMod.gregtechproxy.mPollutionReleasedByThrottle = Gregtech.pollution.pollutionReleasedByThrottle; - GTMod.gregtechproxy.mPollutionLargeGasTurbinePerSecond = Gregtech.pollution.pollutionLargeGasTurbinePerSecond; - GTMod.gregtechproxy.mPollutionMultiSmelterPerSecond = Gregtech.pollution.pollutionMultiSmelterPerSecond; - GTMod.gregtechproxy.mPollutionPyrolyseOvenPerSecond = Gregtech.pollution.pollutionPyrolyseOvenPerSecond; - GTMod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond = Gregtech.pollution.pollutionSmallCoalBoilerPerSecond; - GTMod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond = Gregtech.pollution.pollutionHighPressureLavaBoilerPerSecond; - GTMod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond = Gregtech.pollution.pollutionHighPressureCoalBoilerPerSecond; - GTMod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond = Gregtech.pollution.pollutionBaseDieselGeneratorPerSecond; - double[] mPollutionDieselGeneratorReleasedByTier = Gregtech.pollution.pollutionDieselGeneratorReleasedByTier; + GTMod.gregtechproxy.mPollution = PollutionConfig.pollution; + GTMod.gregtechproxy.mPollutionSmogLimit = PollutionConfig.pollutionSmogLimit; + GTMod.gregtechproxy.mPollutionPoisonLimit = PollutionConfig.pollutionPoisonLimit; + GTMod.gregtechproxy.mPollutionVegetationLimit = PollutionConfig.pollutionVegetationLimit; + GTMod.gregtechproxy.mPollutionSourRainLimit = PollutionConfig.pollutionSourRainLimit; + GTMod.gregtechproxy.mPollutionOnExplosion = PollutionConfig.pollutionOnExplosion; + GTMod.gregtechproxy.mPollutionPrimitveBlastFurnacePerSecond = PollutionConfig.pollutionPrimitveBlastFurnacePerSecond; + GTMod.gregtechproxy.mPollutionCharcoalPitPerSecond = PollutionConfig.pollutionCharcoalPitPerSecond; + GTMod.gregtechproxy.mPollutionEBFPerSecond = PollutionConfig.pollutionEBFPerSecond; + GTMod.gregtechproxy.mPollutionLargeCombustionEnginePerSecond = PollutionConfig.pollutionLargeCombustionEnginePerSecond; + GTMod.gregtechproxy.mPollutionExtremeCombustionEnginePerSecond = PollutionConfig.pollutionExtremeCombustionEnginePerSecond; + GTMod.gregtechproxy.mPollutionImplosionCompressorPerSecond = PollutionConfig.pollutionImplosionCompressorPerSecond; + GTMod.gregtechproxy.mPollutionLargeBronzeBoilerPerSecond = PollutionConfig.pollutionLargeBronzeBoilerPerSecond; + GTMod.gregtechproxy.mPollutionLargeSteelBoilerPerSecond = PollutionConfig.pollutionLargeSteelBoilerPerSecond; + GTMod.gregtechproxy.mPollutionLargeTitaniumBoilerPerSecond = PollutionConfig.pollutionLargeTitaniumBoilerPerSecond; + GTMod.gregtechproxy.mPollutionLargeTungstenSteelBoilerPerSecond = PollutionConfig.pollutionLargeTungstenSteelBoilerPerSecond; + GTMod.gregtechproxy.mPollutionReleasedByThrottle = PollutionConfig.pollutionReleasedByThrottle; + GTMod.gregtechproxy.mPollutionLargeGasTurbinePerSecond = PollutionConfig.pollutionLargeGasTurbinePerSecond; + GTMod.gregtechproxy.mPollutionMultiSmelterPerSecond = PollutionConfig.pollutionMultiSmelterPerSecond; + GTMod.gregtechproxy.mPollutionPyrolyseOvenPerSecond = PollutionConfig.pollutionPyrolyseOvenPerSecond; + GTMod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond = PollutionConfig.pollutionSmallCoalBoilerPerSecond; + GTMod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond = PollutionConfig.pollutionHighPressureLavaBoilerPerSecond; + GTMod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond = PollutionConfig.pollutionHighPressureCoalBoilerPerSecond; + GTMod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond = PollutionConfig.pollutionBaseDieselGeneratorPerSecond; + double[] mPollutionDieselGeneratorReleasedByTier = PollutionConfig.pollutionDieselGeneratorReleasedByTier; if (mPollutionDieselGeneratorReleasedByTier.length == GTMod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier.length) { GTMod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier = mPollutionDieselGeneratorReleasedByTier; @@ -477,8 +478,8 @@ public class GTPreLoad { GT_FML_LOGGER .error("The Length of the Diesel Turbine Pollution Array Config must be the same as the Default"); } - GTMod.gregtechproxy.mPollutionBaseGasTurbinePerSecond = Gregtech.pollution.pollutionBaseGasTurbinePerSecond; - double[] mPollutionGasTurbineReleasedByTier = Gregtech.pollution.pollutionGasTurbineReleasedByTier; + GTMod.gregtechproxy.mPollutionBaseGasTurbinePerSecond = PollutionConfig.pollutionBaseGasTurbinePerSecond; + double[] mPollutionGasTurbineReleasedByTier = PollutionConfig.pollutionGasTurbineReleasedByTier; if (mPollutionGasTurbineReleasedByTier.length == GTMod.gregtechproxy.mPollutionGasTurbineReleasedByTier.length) { GTMod.gregtechproxy.mPollutionGasTurbineReleasedByTier = mPollutionGasTurbineReleasedByTier; diff --git a/src/main/java/gregtech/mixin/Mixin.java b/src/main/java/gregtech/mixin/Mixin.java index b9ba1db098..001477b5d1 100644 --- a/src/main/java/gregtech/mixin/Mixin.java +++ b/src/main/java/gregtech/mixin/Mixin.java @@ -14,6 +14,7 @@ import org.apache.logging.log4j.Logger; import bartworks.common.configs.Configuration; import cpw.mods.fml.relauncher.FMLLaunchHandler; +import gregtech.common.pollution.PollutionConfig; public enum Mixin { @@ -64,7 +65,73 @@ public enum Mixin { .addTargetedMod(TargetedMod.IC2) .setApplyIf(() -> true) .setPhase(Phase.LATE) - .setSide(Side.BOTH)); + .setSide(Side.BOTH)), + IC2_HAZMAT(new Builder("Hazmat").setPhase(Phase.LATE) + .setSide(Side.BOTH) + .addMixinClasses("ic2.MixinIc2Hazmat") + .setApplyIf(() -> true) + .addTargetedMod(TargetedMod.IC2) + .addExcludedMod(TargetedMod.GT6)), + + // Pollution + POLLUTION_RENDER_BLOCKS(new Builder("Changes colors of certain blocks based on pollution levels") + .addMixinClasses("minecraft.pollution.MixinRenderBlocks_PollutionWithoutOptifine") + .addTargetedMod(TargetedMod.VANILLA) + .addExcludedMod(TargetedMod.OPTIFINE) + .setSide(Side.CLIENT) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.pollutionBlockRecolor) + .setPhase(Phase.EARLY)), + POLLUTION_RENDER_BLOCKS_OPTIFINE(new Builder("Changes colors of certain blocks based on pollution levels") + .addMixinClasses("minecraft.pollution.MixinRenderBlocks_PollutionWithOptifine") + .addTargetedMod(TargetedMod.VANILLA) + .addTargetedMod(TargetedMod.OPTIFINE) + .addExcludedMod(TargetedMod.ANGELICA) + .setSide(Side.CLIENT) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.pollutionBlockRecolor) + .setPhase(Phase.EARLY)), + POLLUTION_RENDER_BLOCKS_BOP(new Builder("Changes colors of certain blocks based on pollution levels") + .addMixinClasses("biomesoplenty.MixinFoliageRendererPollution") + .addTargetedMod(TargetedMod.BOP) + .setSide(Side.CLIENT) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.pollutionBlockRecolor) + .setPhase(Phase.LATE)), + POLLUTION_MINECRAFT_FURNACE(new Builder("Minecraft Furnace Pollutes").setPhase(Phase.EARLY) + .addMixinClasses("minecraft.pollution.MixinTileEntityFurnacePollution") + .setSide(Side.BOTH) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.furnacesPollute) + .addTargetedMod(TargetedMod.VANILLA)), + POLLUTION_MINECRAFT_EXPLOSION(new Builder("Minecraft explosions pollute").setPhase(Phase.EARLY) + .addMixinClasses("minecraft.pollution.MixinExplosionPollution") + .setSide(Side.BOTH) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.explosionPollutionAmount != 0F) + .addTargetedMod(TargetedMod.VANILLA)), + POLLUTION_IC2_IRON_FURNACE( + new Builder("Ic2 Iron Furnace Pollutes").addMixinClasses("ic2.MixinIC2IronFurnacePollution") + .setPhase(Phase.LATE) + .setSide(Side.BOTH) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.furnacesPollute) + .addTargetedMod(TargetedMod.IC2)), + POLLUTION_THAUMCRAFT_ALCHEMICAL_FURNACE(new Builder("Thaumcraft Alchemical Construct Pollutes") + .addMixinClasses("thaumcraft.MixinThaumcraftAlchemyFurnacePollution") + .setPhase(Phase.LATE) + .setSide(Side.BOTH) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.furnacesPollute) + .addTargetedMod(TargetedMod.THAUMCRAFT)), + POLLUTION_RAILCRAFT(new Builder("Make Railcraft Pollute") + .addMixinClasses( + "railcraft.MixinRailcraftBoilerPollution", + "railcraft.MixinRailcraftCokeOvenPollution", + "railcraft.MixinRailcraftTunnelBorePollution") + .setPhase(Phase.LATE) + .setSide(Side.BOTH) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.railcraftPollutes) + .addTargetedMod(TargetedMod.RAILCRAFT)), + POLLUTION_ROCKET( + new Builder("Make Rockets Pollute").addMixinClasses("galacticraftcore.MixinGalacticraftRocketPollution") + .setPhase(Phase.LATE) + .setSide(Side.BOTH) + .setApplyIf(() -> PollutionConfig.pollution && PollutionConfig.rocketsPollute) + .addTargetedMod(TargetedMod.GALACTICRAFT_CORE)); public static final Logger LOGGER = LogManager.getLogger("GregTech-Mixin"); |