Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch Radar Exception #492

Merged
merged 3 commits into from
Jun 16, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,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 @@ -435,6 +435,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 @@ -59,6 +59,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"]
}
Loading