Skip to content

Commit

Permalink
Fix IllegalAccessError crash on forge
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed May 26, 2024
1 parent bb3cd98 commit e96a388
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
------------------------------------------------------
Numismatics 1.0.6
------------------------------------------------------
Fixes
- Fix IllegalAccessError on forge
------------------------------------------------------
Numismatics 1.0.5
------------------------------------------------------
Fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,7 +23,7 @@ public TrustListContainer(List<UUID> 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);
Expand All @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ItemStack> numismatics$getItems();
}
1 change: 1 addition & 0 deletions common/src/main/resources/numismatics-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"client.MixinChatScreen"
],
"mixins": [
"AccessorSimpleContainer",
"MixinAbstractContainerMenu",
"MixinServerPlayer",
"compat.carryon.MixinPickupHandler"
Expand Down

0 comments on commit e96a388

Please sign in to comment.