From e96a38844c077c03aa68385a8c1e18fd3ec7607b Mon Sep 17 00:00:00 2001 From: IThundxr Date: Sun, 26 May 2024 15:50:09 -0400 Subject: [PATCH] Fix IllegalAccessError crash on forge --- changelog.md | 5 +++++ .../backend/trust_list/TrustListContainer.java | 7 ++++--- .../mixin/AccessorSimpleContainer.java | 13 +++++++++++++ .../main/resources/numismatics-common.mixins.json | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/dev/ithundxr/createnumismatics/mixin/AccessorSimpleContainer.java diff --git a/changelog.md b/changelog.md index 1150a231..4a9365b1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,9 @@ ------------------------------------------------------ +Numismatics 1.0.6 +------------------------------------------------------ +Fixes +- Fix IllegalAccessError on forge +------------------------------------------------------ Numismatics 1.0.5 ------------------------------------------------------ Fixes diff --git a/common/src/main/java/dev/ithundxr/createnumismatics/content/backend/trust_list/TrustListContainer.java b/common/src/main/java/dev/ithundxr/createnumismatics/content/backend/trust_list/TrustListContainer.java index 02bcc064..c3767d6d 100644 --- a/common/src/main/java/dev/ithundxr/createnumismatics/content/backend/trust_list/TrustListContainer.java +++ b/common/src/main/java/dev/ithundxr/createnumismatics/content/backend/trust_list/TrustListContainer.java @@ -1,6 +1,7 @@ package dev.ithundxr.createnumismatics.content.backend.trust_list; import dev.ithundxr.createnumismatics.content.bank.IDCardItem; +import dev.ithundxr.createnumismatics.mixin.AccessorSimpleContainer; import dev.ithundxr.createnumismatics.registry.NumismaticsTags; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.ContainerHelper; @@ -22,7 +23,7 @@ public TrustListContainer(List trustList, Runnable changeNotifier) { @Override public void setChanged() { trustList.clear(); - for (ItemStack stack : items) { + for (ItemStack stack : ((AccessorSimpleContainer) this).numismatics$getItems()) { UUID id; if ((id = IDCardItem.get(stack)) != null) trustList.add(id); @@ -36,12 +37,12 @@ public boolean canPlaceItem(int index, ItemStack stack) { } public CompoundTag save(CompoundTag nbt) { - ContainerHelper.saveAllItems(nbt, items); + ContainerHelper.saveAllItems(nbt, ((AccessorSimpleContainer) this).numismatics$getItems()); return nbt; } public void load(CompoundTag nbt) { - ContainerHelper.loadAllItems(nbt, items); + ContainerHelper.loadAllItems(nbt, ((AccessorSimpleContainer) this).numismatics$getItems()); setChanged(); } diff --git a/common/src/main/java/dev/ithundxr/createnumismatics/mixin/AccessorSimpleContainer.java b/common/src/main/java/dev/ithundxr/createnumismatics/mixin/AccessorSimpleContainer.java new file mode 100644 index 00000000..7d4248c7 --- /dev/null +++ b/common/src/main/java/dev/ithundxr/createnumismatics/mixin/AccessorSimpleContainer.java @@ -0,0 +1,13 @@ +package dev.ithundxr.createnumismatics.mixin; + +import net.minecraft.core.NonNullList; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(SimpleContainer.class) +public interface AccessorSimpleContainer { + @Accessor("items") + NonNullList numismatics$getItems(); +} diff --git a/common/src/main/resources/numismatics-common.mixins.json b/common/src/main/resources/numismatics-common.mixins.json index e96df23b..143d3939 100644 --- a/common/src/main/resources/numismatics-common.mixins.json +++ b/common/src/main/resources/numismatics-common.mixins.json @@ -8,6 +8,7 @@ "client.MixinChatScreen" ], "mixins": [ + "AccessorSimpleContainer", "MixinAbstractContainerMenu", "MixinServerPlayer", "compat.carryon.MixinPickupHandler"