diff --git a/README.md b/README.md index 19acaf59..cd9648de 100644 --- a/README.md +++ b/README.md @@ -305,6 +305,7 @@ All changes are toggleable via config files. * **Epic Siege Mod** * **Disable Digger AI Debug:** Disables leftover debug logging inside the digger AI of the beta builds * **Extra Utilities 2** + * **Catch Radar Exception:** Fixes the Radar feature (find in nearby inventories) entirely breaking when near some inventories * **Duplication Fixes:** Fixes various duplication exploits * **Fix Deep Dark Stats:** Fixes Mob Attack and Health Statistics being repeatedly doubled * **Mutable Machine Block Drops:** Fixes Machine Block drops being immutable, causing a crash on attempting to remove entries from the list. diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java index 97fc0995..15ecaa20 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigMods.java @@ -439,6 +439,15 @@ public static class ErebusCategory public static class ExtraUtilitiesCategory { + @Config.RequiresMcRestart + @Config.Name("Catch Radar Exception") + @Config.Comment + ({ + "When near some inventories, the Radar feature (find in nearby inventories) will entirely break", + "this catches the AbstractMethodException thrown, allowing other nearby inventories to be searched" + }) + public boolean utCatchRadarException = true; + @Config.RequiresMcRestart @Config.Name("Fix Deep Dark Stats") @Config.Comment("Fixes Mob Attack and Health Statistics being repeatedly doubled") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java index ba76d635..7baab647 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTMixinLoader.java @@ -60,6 +60,7 @@ public class UTMixinLoader implements ILateMixinLoader put("mixins.mods.extrautilities.deepdarkstats.json", () -> loaded("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utDeepDarkStats); put("mixins.mods.extrautilities.dupes.json", () -> loaded("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utDuplicationFixesToggle); put("mixins.mods.extrautilities.mutabledrops.json", () -> loaded("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utMutableBlockDrops); + put("mixins.mods.extrautilities.radar.json", () -> loaded("extrautils2") && UTConfigMods.EXTRA_UTILITIES.utCatchRadarException); put("mixins.mods.forestry.cocoa.json", () -> loaded("forestry") && UTConfigMods.FORESTRY.utFOCocoaBeansToggle); put("mixins.mods.forestry.dupes.json", () -> loaded("forestry") && UTConfigMods.FORESTRY.utDuplicationFixesToggle); put("mixins.mods.forestry.extratrees.json", () -> loaded("extratrees")); diff --git a/src/main/java/mod/acgaming/universaltweaks/mods/extrautilities/radar/mixin/UTRadarPingMixin.java b/src/main/java/mod/acgaming/universaltweaks/mods/extrautilities/radar/mixin/UTRadarPingMixin.java new file mode 100644 index 00000000..bcdd468e --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/mods/extrautilities/radar/mixin/UTRadarPingMixin.java @@ -0,0 +1,32 @@ +package mod.acgaming.universaltweaks.mods.extrautilities.radar.mixin; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandler; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.rwtema.extrautils2.crafting.Radar; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigMods; + +// Courtesy of WaitingIdly +@Mixin(value = Radar.PacketPing.class, remap = false) +public abstract class UTRadarPingMixin +{ + @WrapOperation(method = "lambda$doStuffServer$1", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/items/IItemHandler;getStackInSlot(I)Lnet/minecraft/item/ItemStack;")) + private ItemStack utCatchItemHandlerException(IItemHandler instance, int slot, Operation original) + { + if (!UTConfigMods.EXTRA_UTILITIES.utCatchRadarException) return original.call(instance, slot); + try + { + return original.call(instance, slot); + } + catch (AbstractMethodError e) + { + e.printStackTrace(); + return ItemStack.EMPTY; + } + } +} diff --git a/src/main/resources/mixins.mods.extrautilities.radar.json b/src/main/resources/mixins.mods.extrautilities.radar.json new file mode 100644 index 00000000..3f2a04b6 --- /dev/null +++ b/src/main/resources/mixins.mods.extrautilities.radar.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.mods.extrautilities.radar.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTRadarPingMixin"] +} \ No newline at end of file