Skip to content

Commit

Permalink
Prevent CastClassException on invalid duct network (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrParadox7 authored Feb 12, 2025
1 parent b18e1b9 commit a4768fe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ public class FixesConfig {
@Config.DefaultBoolean(true)
public static boolean preventThermalDynamicsNASE;

@Config.Comment("Prevent ClassCastException on forming invalid Thermal Dynamic fluid grid")
@Config.DefaultBoolean(true)
public static boolean preventFluidGridCrash;

// VoxelMap

@Config.Comment("Fix some NullPointerExceptions")
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,14 @@ public enum Mixins {
ASP_RECIPE_FIX(new Builder("MT Core recipe fix").addMixinClasses("advancedsolarpanels.MixinAdvancedSolarPanel")
.addTargetedMod(TargetedMod.ADVANCED_SOLAR_PANELS).setApplyIf(() -> FixesConfig.fixMTCoreRecipe)
.setPhase(Phase.LATE).setSide(Side.BOTH)),
TD_NASE_PREVENTION(new Builder("Prevent NegativeArraySizeException on itemduct transfers")
.addMixinClasses("thermaldynamics.MixinSimulatedInv").setSide(Side.BOTH)
.setApplyIf(() -> FixesConfig.preventThermalDynamicsNASE).addTargetedMod(TargetedMod.THERMALDYNAMICS)
.setPhase(Phase.LATE)),
TD_FLUID_GRID_CCE(new Builder("Prevent ClassCastException on forming invalid Thermal Dynamic fluid grid")
.addMixinClasses("thermaldynamics.MixinTileFluidDuctSuper").setSide(Side.BOTH)
.setApplyIf(() -> FixesConfig.preventFluidGridCrash).addTargetedMod(TargetedMod.THERMALDYNAMICS)
.setPhase(Phase.LATE)),

// Unbind Keybinds by default
UNBIND_KEYS_TRAVELLERSGEAR(new Builder("Unbind Traveller's Gear keybinds")
Expand All @@ -950,10 +958,6 @@ public enum Mixins {
IC2_CELL(new Builder("No IC2 Cell Consumption in tanks").addMixinClasses("ic2.MixinIC2ItemCell")
.setPhase(Phase.LATE).setSide(Side.BOTH).setApplyIf(() -> TweaksConfig.ic2CellWithContainer)
.addTargetedMod(TargetedMod.IC2)),
TD_NASE_PREVENTION(new Builder("Prevent NegativeArraySizeException on itemduct transfers")
.addMixinClasses("thermaldynamics.MixinSimulatedInv").setSide(Side.BOTH)
.setApplyIf(() -> FixesConfig.preventThermalDynamicsNASE).addTargetedMod(TargetedMod.THERMALDYNAMICS)
.setPhase(Phase.LATE)),

// Chunk generation/population
DISABLE_CHUNK_TERRAIN_GENERATION(new Builder("Disable chunk terrain generation").setPhase(Phase.EARLY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.mitchej123.hodgepodge.mixins.late.thermaldynamics;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import cofh.thermaldynamics.duct.fluid.FluidGridSuper;
import cofh.thermaldynamics.duct.fluid.TileFluidDuctSuper;
import cofh.thermaldynamics.multiblock.MultiBlockGrid;

@Mixin(TileFluidDuctSuper.class)
public class MixinTileFluidDuctSuper {

@Inject(method = "setGrid", at = @At(value = "HEAD"), remap = false, cancellable = true)
public void hodgepodge$setGrid(MultiBlockGrid par1, CallbackInfo ci) {
if (!(par1 instanceof FluidGridSuper)) {
par1.destroy();
ci.cancel();
}
}
}

0 comments on commit a4768fe

Please sign in to comment.