Skip to content

Commit

Permalink
Fix NuclearCraft No Meltdown Config
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jan 8, 2025
1 parent f9b7963 commit fc5780f
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<FissionUpdatePacket> {

@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<ItemSorption> 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<Boolean> 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();
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.nomilabs.nuclearcraft.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"mixins": [
"CoolerTypeMixin",
"GTCEuRecipeIntegration",
"TileActiveCoolerMixin"
"TileActiveCoolerMixin",
"TileFissionControllerMixin"
],
"client": [],
"server": []
Expand Down

0 comments on commit fc5780f

Please sign in to comment.