From fc5780f45b1b3f97d20eb019cc5a859fe133e4fe Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Thu, 9 Jan 2025 00:04:20 +0800 Subject: [PATCH] Fix NuclearCraft No Meltdown Config --- dependencies.gradle | 3 + .../TileFissionControllerMixin.java | 98 +++++++++++++++++++ .../mixins.nomilabs.nuclearcraft.json | 3 +- 3 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/nuclearcraft/TileFissionControllerMixin.java diff --git a/dependencies.gradle b/dependencies.gradle index f623d410..5243d3a3 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -141,6 +141,9 @@ dependencies { compileOnly rfg.deobf("curse.maven:nuclearcraft-mod-226254:3074246") // Version 2.18y (Newer versions have unneeded balancing changes and break stuff) compileOnly rfg.deobf("curse.maven:extra-utilities-225561:2678374") // Version 1.9.9, also has remapping to remove frequency + // IC2, Compile Time Dep of NuclearCraft + compileOnly "curse.maven:ic2-242638:3838713" // Version 2.8.222 + // Brandon Core & Redstone Flux, Runtime and Compile Dep of Draconic Evolution (from CurseForge) compileOnly rfg.deobf("curse.maven:brandons-core-231382:3408276") // Version 2.4.20 compileOnly rfg.deobf("curse.maven:redstone-flux-270789:2920436") // Version 2.1.1.1 diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/nuclearcraft/TileFissionControllerMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/nuclearcraft/TileFissionControllerMixin.java new file mode 100644 index 00000000..17ee4280 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/nuclearcraft/TileFissionControllerMixin.java @@ -0,0 +1,98 @@ +package com.nomiceu.nomilabs.mixin.nuclearcraft; + +import java.util.List; + +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import nc.config.NCConfig; +import nc.network.tile.FissionUpdatePacket; +import nc.recipe.ProcessorRecipeHandler; +import nc.tile.IGui; +import nc.tile.generator.TileFissionController; +import nc.tile.generator.TileItemGenerator; +import nc.tile.internal.inventory.ItemSorption; + +@Mixin(value = TileFissionController.class, remap = false) +public abstract class TileFissionControllerMixin extends TileItemGenerator implements IGui { + + @Shadow + public double heat; + + @Shadow + public abstract int getMaxHeat(); + + @Shadow + public double heatChange; + + @Shadow + public abstract boolean isProcessing(); + + @Shadow + public double cooling; + + @Shadow + public abstract int getComparatorStrength(); + + @Shadow + public abstract boolean findAdjacentComparator(); + + @Shadow + public int comparatorStrength; + + @Unique + private boolean labs$prevProcessing = false; + + /** + * Mandatory Ignored Constructor + */ + private TileFissionControllerMixin(String name, int itemInSize, int itemOutSize, int otherSize, + @NotNull List itemSorptions, int capacity, + @NotNull ProcessorRecipeHandler recipeHandler) { + super(name, itemInSize, itemOutSize, otherSize, itemSorptions, capacity, recipeHandler); + } + + @Inject(method = "updateGenerator", at = @At("HEAD")) + private void saveProcessing(CallbackInfo ci) { + labs$prevProcessing = isProcessing(); + } + + @Inject(method = "overheat", at = @At("RETURN"), cancellable = true) + private void properOverheatReturn(CallbackInfoReturnable cir) { + if (heat < getMaxHeat() || NCConfig.fission_overheat) + return; + + cir.setReturnValue(true); + getRadiationSource().setRadiationLevel(0.0); + + boolean processing = isProcessing(); + + // Remove Heat from Fuels, then Add Cooling Heat + heat = Math.max(0, heat - heatChange + cooling); + + /* Update Tile If Needed */ + boolean shouldUpdate = false; + if (labs$prevProcessing != processing) { + shouldUpdate = true; + this.updateBlockType(); + this.sendUpdateToAllPlayers(); + } + + int compStrength = getComparatorStrength(); + if (comparatorStrength != compStrength && findAdjacentComparator()) { + shouldUpdate = true; + } + + this.comparatorStrength = compStrength; + this.sendUpdateToListeningPlayers(); + if (shouldUpdate) { + this.markDirty(); + } + } +} diff --git a/src/main/resources/mixins.nomilabs.nuclearcraft.json b/src/main/resources/mixins.nomilabs.nuclearcraft.json index c06b58b9..c550ca2c 100644 --- a/src/main/resources/mixins.nomilabs.nuclearcraft.json +++ b/src/main/resources/mixins.nomilabs.nuclearcraft.json @@ -7,7 +7,8 @@ "mixins": [ "CoolerTypeMixin", "GTCEuRecipeIntegration", - "TileActiveCoolerMixin" + "TileActiveCoolerMixin", + "TileFissionControllerMixin" ], "client": [], "server": []