Skip to content

Commit

Permalink
Merge pull request #492 from WaitingIdly/radar-erroring
Browse files Browse the repository at this point in the history
Catch Radar Exception
  • Loading branch information
ACGaming authored Jun 16, 2024
2 parents 331f89c + d8e4d82 commit 9af4769
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ItemStack> 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;
}
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.mods.extrautilities.radar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.mods.extrautilities.radar.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTRadarPingMixin"]
}

0 comments on commit 9af4769

Please sign in to comment.