Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ final def mod_dependencies = [
'curse.maven:actuallyaditions-228404:2844115' : [debug_actually_additions],
'curse.maven:advent-of-ascension-311054:3054253' : [debug_advent_of_ascension],
'curse.maven:aether-255308:6316434' : [debug_aether_legacy],
'curse.maven:ae2-extended-life-570458:5378163' : [debug_ae2uel],
'curse.maven:agricraft-225635:3317747' : [debug_agricraft],
'curse.maven:applecore-224472:2969118' : [debug_the_spice_of_life],
'curse.maven:arcanearchives-311357:3057332' : [debug_arcane_archives],
Expand Down Expand Up @@ -99,6 +100,7 @@ final def mod_dependencies = [
'curse.maven:epic-siege-mod-229449:3356157' : [debug_epic_siege_mod],
'curse.maven:evilcraft-74610:2811267' : [debug_evilcraft],
'curse.maven:extrautilities-225561:2678374' : [debug_extra_utilities_2],
'curse.maven:extreme-reactors-250277:3194746' : [debug_extreme_reactors],
'curse.maven:forestry-59751:2918418' : [debug_forestry, debug_binnies_mods],
'curse.maven:forge-backpacks-59143:2554237' : [debug_backpack],
'curse.maven:forgemultipartcbe-258426:2755790' : [debug_forgemultipartcbe, debug_project_red],
Expand All @@ -116,7 +118,7 @@ final def mod_dependencies = [
'curse.maven:item-favorites-358194:3177845' : [debug_itemfavorites],
'curse.maven:jurassic-reborn-359537:4574634' : [debug_jurassic_reborn],
'curse.maven:mantle-74924:2713386' : [debug_tinkers_construct, debug_moartinkers],
'curse.maven:mcjtylib-233105:2745846' : [debug_rftools],
'curse.maven:mcjtylib-233105:2745846' : [debug_rftools, debug_xnet],
'curse.maven:mekanism-268560:2835175' : [debug_mekanism],
'curse.maven:moartinkers-263624:2579934' : [debug_moartinkers],
'curse.maven:modtweaker-220954:3840577' : [debug_crafttweaker],
Expand Down Expand Up @@ -170,8 +172,10 @@ final def mod_dependencies = [
'curse.maven:tinkerscomplement-272671:2843439' : [debug_tinkers_construct],
'curse.maven:tinyprogressions-250850:2721018' : [debug_tiny_progressions],
'curse.maven:wanionlib-253043:4623135' : [debug_avaritiaaddons],
'curse.maven:xnet-260912:2745852' : [debug_xnet],
'curse.maven:tomb-many-graves-2-262823:2619249' : [debug_tomb_many_graves],
'curse.maven:woot-244049:2712670' : [debug_woot],
'curse.maven:zerocore-247921:3194743' : [debug_extreme_reactors],
'maven.modrinth:industrial-foregoing:1.12.13-237' : [debug_industrial_foregoing],
'net.darkhax.bookshelf:Bookshelf-1.12.2:2.3.590' : [debug_stages, debug_bookshelf],
'net.darkhax.gamestages:GameStages-1.12.2:2.0.120' : [debug_stages],
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ debug_abyssalcraft = false
debug_actually_additions = false
debug_advent_of_ascension = false
debug_aether_legacy = false
debug_ae2uel = false
debug_agricraft = false
debug_arcane_archives = false
debug_astral_sorcery = false
Expand Down Expand Up @@ -48,6 +49,7 @@ debug_epic_siege_mod = false
debug_erebus = false
debug_evilcraft = false
debug_extra_utilities_2 = false
debug_extreme_reactors = false
debug_forestry = false
debug_forgemultipartcbe = false
debug_fps_reducer = false
Expand Down Expand Up @@ -96,6 +98,7 @@ debug_tinkers_construct = false
debug_tiny_progressions = false
debug_tomb_many_graves = false
debug_woot = false
debug_xnet = false

# Gradle Settings
# Effectively applies the '--stacktrace' flag by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public class UTConfigMods
@Config.Name("Actually Additions")
public static final ActuallyAdditionsCategory ACTUALLY_ADDITIONS = new ActuallyAdditionsCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.ae2uel")
@Config.Name("Applied Energistics 2 Unofficial Extended Life")
public static final AE2UELCategory AE2UEL = new AE2UELCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.aether_legacy")
@Config.Name("Aether Legacy")
public static final AetherLegacyCategory AETHER_LEGACY = new AetherLegacyCategory();
Expand Down Expand Up @@ -167,6 +171,10 @@ public class UTConfigMods
@Config.Name("Extra Utilities 2")
public static final ExtraUtilitiesCategory EXTRA_UTILITIES = new ExtraUtilitiesCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.extreme_reactors")
@Config.Name("Extreme Reactors")
public static final ExtremeReactorsCategory EXTREME_REACTORS = new ExtremeReactorsCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.forestry")
@Config.Name("Forestry")
public static final ForestryCategory FORESTRY = new ForestryCategory();
Expand Down Expand Up @@ -283,6 +291,10 @@ public class UTConfigMods
@Config.Name("Requious Frakto")
public static final RequiousFraktoCategory REQUIOUS_FRAKTO = new RequiousFraktoCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.rftools")
@Config.Name("RFTools")
public static final RFToolsCategory RFTOOLS = new RFToolsCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.rftoolsdimensions")
@Config.Name("RFTools Dimensions")
public static final RFToolsDimensionsCategory RFTOOLS_DIMENSIONS = new RFToolsDimensionsCategory();
Expand Down Expand Up @@ -351,6 +363,10 @@ public class UTConfigMods
@Config.Name("Woot")
public static final WootCategory WOOT = new WootCategory();

@Config.LangKey("cfg.universaltweaks.modintegration.xnet")
@Config.Name("XNet")
public static final XNetCategory XNET = new XNetCategory();

public static class AbyssalCraftCategory
{
@Config.Name("Disable Plague Potion Clouds")
Expand Down Expand Up @@ -383,6 +399,14 @@ public static class ActuallyAdditionsCategory
public int utItemLaserParticlesGraphics = -1;
}

public static class AE2UELCategory
{
@Config.RequiresMcRestart
@Config.Name("Mitigate Storage Bus Crashes")
@Config.Comment("Mitigates crashes caused by misbehaving IItemHandlers.")
public boolean utItemHandlerCrash = true;
}

public static class AetherLegacyCategory
{
@Config.RequiresMcRestart
Expand Down Expand Up @@ -937,6 +961,14 @@ public static class ExtraUtilitiesCategory
public boolean utDowngradePotionLogging = true;
}

public static class ExtremeReactorsCategory
{
@Config.RequiresMcRestart
@Config.Name("Mitigate Steam Reactor Crash")
@Config.Comment("Mitigates NPE in updateServer by no-oping fluid transfers when the direction is null.")
public boolean utSteamReactorCrash = true;
}

public static class ForestryCategory
{
@Config.RequiresMcRestart
Expand Down Expand Up @@ -1000,6 +1032,11 @@ public static class InControlCategory
@Config.Name("Spawn Rule Stats Fix")
@Config.Comment("Fixes onJoin spawn rules repeatedly modifying mob attack/health/speed")
public boolean utStatsFixToggle = true;

@Config.RequiresMcRestart
@Config.Name("Fix ForgeEventHandler Crash")
@Config.Comment("Prevents the client thread from modifying a server-only static field.")
public boolean utClientCrash = true;
}

public static class IndustrialCraftCategory
Expand Down Expand Up @@ -1257,6 +1294,14 @@ public static class RequiousFraktoCategory
public boolean utParticleFixesToggle = true;
}

public static class RFToolsCategory
{
@Config.RequiresMcRestart
@Config.Name("Fix RF Tools + XNet Crash")
@Config.Comment("Fixes a sporadic crash when using a rftools.storage xnet channel")
public boolean utRFToolsStorageCrash = true;
}

public static class RFToolsDimensionsCategory
{
@Config.RequiresMcRestart
Expand Down Expand Up @@ -1596,6 +1641,14 @@ public static class WootCategory
public boolean utCleanupSimulatedKillsToggle = true;
}

public static class XNetCategory
{
@Config.RequiresMcRestart
@Config.Name("Fix Various Controller Crashes")
@Config.Comment("Patches several ArrayIndexOutOfBoundsExceptions in the controller logic")
public boolean utControllerCrashes = true;
}

static
{
ConfigAnytime.register(UTConfigMods.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins/mods/mixins.actuallyadditions.dupes.json", c -> c.isModPresent("actuallyadditions") && UTConfigMods.ACTUALLY_ADDITIONS.utDuplicationFixesToggle);
put("mixins/mods/mixins.actuallyadditions.relayupgrade.json", c -> c.isModPresent("actuallyadditions") && UTConfigMods.ACTUALLY_ADDITIONS.utLaserUpgradeVoid);
put("mixins/mods/mixins.aetherlegacy.eventdrops.json", c -> c.isModPresent("aether_legacy") && UTConfigMods.AETHER_LEGACY.utCaptureAccessoryDrops);
put("mixins/mods/mixins.ae2uel.handler_crash.json", c -> c.isModPresent("appliedenergistics2") && UTConfigMods.AE2UEL.utItemHandlerCrash);
put("mixins/mods/mixins.agricraft.json", c -> c.isModPresent("agricraft") && UTConfigMods.AGRICRAFT.utEnderIOPluginFixToggle);
put("mixins/mods/mixins.aoa3.json", c -> c.isModPresent("aoa3") && UTConfigMods.AOA.utImprovedPlayerTickToggle);
put("mixins/mods/mixins.arcanearchives.dupes.json", c -> c.isModPresent("arcanearchives") && UTConfigMods.ARCANE_ARCHIVES.utDuplicationFixesToggle);
Expand Down Expand Up @@ -133,11 +134,13 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins/mods/mixins.extrautilities.potionlogging.json", c -> c.isModPresent("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utDowngradePotionLogging);
put("mixins/mods/mixins.extrautilities.radarexception.json", c -> c.isModPresent("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utCatchRadarException);
put("mixins/mods/mixins.extrautilities.radarloot.json", c -> c.isModPresent("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utRadarSkipsLoottables);
put("mixins/mods/mixins.extreme_reactors.reactor_crash.json", c -> c.isModPresent("bigreactors") && UTConfigMods.EXTREME_REACTORS.utSteamReactorCrash);
put("mixins/mods/mixins.forestry.extratrees.json", c -> c.isModPresent("extratrees") && UTConfigMods.FORESTRY.utFOGatherWindfallToggle);
put("mixins/mods/mixins.forestry.json", c -> c.isModPresent("forestry"));
put("mixins/mods/mixins.immersiveengineering.toolevent.json", c -> c.isModPresent("immersiveengineering") && UTConfigMods.IMMERSIVE_ENGINEERING.utFireBreakEvent);
put("mixins/mods/mixins.immersiveengineering.toolhand.json", c -> c.isModPresent("immersiveengineering") && UTConfigMods.IMMERSIVE_ENGINEERING.utFixIncorrectHandReplacement);
put("mixins/mods/mixins.incontrol.json", c -> c.isModPresent("incontrol") && UTConfigMods.INCONTROL.utStatsFixToggle);
put("mixins/mods/mixins.incontrol.rule.json", c -> c.isModPresent("incontrol") && UTConfigMods.INCONTROL.utStatsFixToggle);
put("mixins/mods/mixins.incontrol.handler_crash.json", c -> c.isModPresent("incontrol") && UTConfigMods.INCONTROL.utClientCrash);
put("mixins/mods/mixins.industrialcraft.dupes.json", c -> c.isModPresent("ic2") && UTConfigMods.INDUSTRIALCRAFT.utDuplicationFixesToggle);
put("mixins/mods/mixins.industrialforegoing.dupes.json", c -> c.isModPresent("industrialforegoing") && UTConfigMods.INDUSTRIAL_FOREGOING.utDuplicationFixesToggle);
put("mixins/mods/mixins.industrialforegoing.rangeaddon.json", c -> c.isModPresent("industrialforegoing") && UTConfigMods.INDUSTRIAL_FOREGOING.utRangeAddonNumberFix);
Expand All @@ -161,6 +164,7 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins/mods/mixins.randomthings.collector.json", c -> c.isModPresent("randomthings") && UTConfigMods.RANDOM_THINGS.utItemCollectorDupe);
put("mixins/mods/mixins.requiousfrakto.json", c -> c.isModPresent("requious") && UTConfigMods.REQUIOUS_FRAKTO.utParticleFixesToggle);
put("mixins/mods/mixins.reskillable.json", c -> c.isModPresent("reskillable"));
put("mixins/mods/mixins.rftools.json", c -> c.isModPresent("rftools") && UTConfigMods.RFTOOLS.utRFToolsStorageCrash);
put("mixins/mods/mixins.rftoolsdimensions.json", c -> c.isModPresent("rftoolsdim"));
put("mixins/mods/mixins.roost.contenttweaker.json", c -> c.isModPresent("roost") && c.isModPresent("contenttweaker"));
put("mixins/mods/mixins.roots.creativepouch.json", c -> c.isModPresent("roots") && UTConfigMods.ROOTS.utDisableCreativePouchGUI);
Expand Down Expand Up @@ -188,6 +192,7 @@ public class UTMixinLoader implements ILateMixinLoader
put("mixins/mods/mixins.tombmanygraves.timestamp.json", c -> c.isModPresent("tombmanygraves") && UTConfigMods.TOMBMANYGRAVES.utISOTimestamp);
put("mixins/mods/mixins.tombmanygraves.worldsize.json", c -> c.isModPresent("tombmanygraves") && UTConfigMods.TOMBMANYGRAVES.utProperWorldSizeCheck);
put("mixins/mods/mixins.woot.json", c -> c.isModPresent("woot") && UTConfigMods.WOOT.utCleanupSimulatedKillsToggle);
put("mixins/mods/mixins.xnet.controller_crashes.json", c -> c.isModPresent("xnet") && UTConfigMods.XNET.utControllerCrashes);
}
if (UTConfigGeneral.MASTER_SWITCHES.utMasterSwitchTweaks)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package mod.acgaming.universaltweaks.mods.ae2uel.mixin;

import net.minecraft.item.ItemStack;

import appeng.util.inv.ItemHandlerIterator;
import appeng.util.inv.ItemSlot;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = ItemHandlerIterator.class, remap = false)
public class UTItemHandlerIteratorMixin {

@Shadow
@Final
private ItemSlot itemSlot;

@Shadow
private int slot;

/// As far as I can tell, this crash happens when the IItemHandler that's being iterated over changes its
/// length in the middle of being iterated over. This is obviously a bug, but AE2 has no control over how the
/// IItemHandler behaves. This mixin changes the behaviour of ItemHandlerIterator to instead pretend these
/// invalid slots are empty and cannot be extracted from, instead of crashing.
///
/// java.util.NoSuchElementException
/// at appeng.util.inv.ItemHandlerIterator.next(ItemHandlerIterator.java:48)
/// at appeng.util.inv.ItemHandlerIterator.next(ItemHandlerIterator.java:28)
/// at appeng.parts.misc.ItemHandlerAdapter$InventoryCache.update(ItemHandlerAdapter.java:272)
/// at appeng.parts.misc.ItemHandlerAdapter.onTick(ItemHandlerAdapter.java:201)
/// at appeng.parts.misc.PartStorageBus.tickingRequest(PartStorageBus.java:316)
/// at appeng.me.cache.TickManagerCache.onUpdateTick(TickManagerCache.java:91)
/// at appeng.me.GridCacheWrapper.onUpdateTick(GridCacheWrapper.java:40)
/// at appeng.me.Grid.update(Grid.java:229)
/// at appeng.hooks.TickHandler.onTick(TickHandler.java:196)
/// at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:78)
/// at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:212)
/// at net.minecraftforge.fml.common.FMLCommonHandler.onPostServerTick(FMLCommonHandler.java:277)
/// at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:712)
/// at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185)
/// at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)
/// at java.lang.Thread.run(Thread.java:1474)
@Inject(method = "next()Lappeng/util/inv/ItemSlot;", at = @At(value = "NEW", target = "()Ljava/util/NoSuchElementException;"), cancellable = true)
private void ut$preventNSEE(CallbackInfoReturnable<ItemSlot> cir) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think throwing an NoSuchElementException is the correct behavior here, and the issue lies with whatever is having variable item slots between calls. to debug the cause, i would suggest doing @WrapMethod with a try { original() } catch for this in PartStorageBus#tickingRequest and logging the position it happened to.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'd usually agree with you, this crash is very hard to reproduce and I'm not even sure what the actual cause is. Like I said, I can't be bothered to restart my game a few dozen times to test it. This is absolutely a hack but there's no reason that a misbehaving IItemHandler should crash the game.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add this: an IItemHandler reporting more slots than it has is absolutely a bug, but there's no logic error from pretending those slots exist but aren't interactable. This iterator is just used for determining what items an IItemHandler contains, so at most you're going to get false-negatives (items in storage that aren't reported to AE). Assuming the IItemHandler eventually corrects itself, this isn't even permanent because storage busses poll their attached inventories constantly.

((UTItemSlotAccessor) this.itemSlot).ut$setExtractable(false);
this.itemSlot.setItemStack(ItemStack.EMPTY);
this.itemSlot.setSlot(this.slot);
++this.slot;
cir.setReturnValue(this.itemSlot);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package mod.acgaming.universaltweaks.mods.ae2uel.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import appeng.util.inv.ItemSlot;

@Mixin(value = ItemSlot.class, remap = false)
public interface UTItemSlotAccessor {

@Invoker("setExtractable")
void ut$setExtractable(boolean isExtractable);

}
Loading