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

Opening Chest Crash #88

Closed
PCRGaming opened this issue Nov 21, 2023 · 18 comments
Closed

Opening Chest Crash #88

PCRGaming opened this issue Nov 21, 2023 · 18 comments
Labels
incompatibility This bug happens due to a mod incompatibility

Comments

@PCRGaming
Copy link

Minecraft Version

1.20.x

Mod Loader Version

0.14.24

Mod Version

1.3.0

Describe the Issue

Opening a chest immediately crashed the world

latest.log

crash-2023-11-21_13.56.06-client.txt

Do you use any other mods except the required ones?

Yes

@Globox1997
Copy link
Owner

Does this happen with only this mod installed?

@solonovamax
Copy link

I'm experiencing the same error, so I've implemented a temporary fix for myself. This is probably not the best solution, but it's a temporary workaround for me.

diff --git a/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java b/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java
index ff93fa6..618e6d2 100644
--- a/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java
+++ b/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java
@@ -1,5 +1,7 @@
 package draylar.tiered.mixin.client;

+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import com.google.common.collect.LinkedListMultimap;
 import com.google.common.collect.Multimap;
 import draylar.tiered.Tiered;
@@ -41,6 +43,7 @@ import java.util.Map;
 @Environment(EnvType.CLIENT)
 @Mixin(ItemStack.class)
 public abstract class ItemStackClientMixin {
+    private static final Logger logger = LoggerFactory.getLogger(ItemStackClientMixin.class);

     @Shadow
     public abstract NbtCompound getOrCreateSubNbt(String key);
@@ -201,7 +204,11 @@ public abstract class ItemStackClientMixin {
             int var8, EquipmentSlot equipmentSlot, Multimap multimap) {
         if (this.isTiered && !multimap.isEmpty() && equipmentSlot == EquipmentSlot.OFFHAND && this.getAttributeModifiers(EquipmentSlot.MAINHAND) != null
                 && !this.getAttributeModifiers(EquipmentSlot.MAINHAND).isEmpty()) {
-            multimap.clear();
+            try {
+                multimap.clear();
+            } catch (UnsupportedOperationException e) {
+                logger.warn("Tried to clear multimap with contents {}, but could not modify multimap.", multimap, e);
+            }
         }
     }

@Globox1997
Copy link
Owner

Does it happen with only this mod installed?

@solonovamax
Copy link

I have not yet attempted to reproduce without any other mods, however I will do so later.

I know which item in particular is causing this (is fully reproducible), and will do a binary search for the minimum set of mods later.

@solonovamax
Copy link

I have not yet attempted to reproduce without any other mods, however I will do so later.

I know which item in particular is causing this

@PCRGaming
Copy link
Author

The crash happens when hovering over specific items, I havent been able to know what the item's NBT tags are and whether they cause the crash

@PCRGaming
Copy link
Author

PCRGaming commented Nov 27, 2023

2023-11-27_20 36 04
main issue I have is when trying to view the tooltips of bows/crossbows and it immediately crashes

@Simiux
Copy link

Simiux commented Dec 6, 2023

I'm experiencing the same error, so I've implemented a temporary fix for myself. This is probably not the best solution, but it's a temporary workaround for me.

diff --git a/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java b/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java
index ff93fa6..618e6d2 100644
--- a/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java
+++ b/src/main/java/draylar/tiered/mixin/client/ItemStackClientMixin.java
@@ -1,5 +1,7 @@
 package draylar.tiered.mixin.client;

+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import com.google.common.collect.LinkedListMultimap;
 import com.google.common.collect.Multimap;
 import draylar.tiered.Tiered;
@@ -41,6 +43,7 @@ import java.util.Map;
 @Environment(EnvType.CLIENT)
 @Mixin(ItemStack.class)
 public abstract class ItemStackClientMixin {
+    private static final Logger logger = LoggerFactory.getLogger(ItemStackClientMixin.class);

     @Shadow
     public abstract NbtCompound getOrCreateSubNbt(String key);
@@ -201,7 +204,11 @@ public abstract class ItemStackClientMixin {
             int var8, EquipmentSlot equipmentSlot, Multimap multimap) {
         if (this.isTiered && !multimap.isEmpty() && equipmentSlot == EquipmentSlot.OFFHAND && this.getAttributeModifiers(EquipmentSlot.MAINHAND) != null
                 && !this.getAttributeModifiers(EquipmentSlot.MAINHAND).isEmpty()) {
-            multimap.clear();
+            try {
+                multimap.clear();
+            } catch (UnsupportedOperationException e) {
+                logger.warn("Tried to clear multimap with contents {}, but could not modify multimap.", multimap, e);
+            }
         }
     }

I'd love to learn how you did this I'm having the same issue. Somehow no one else in my family does

@solonovamax
Copy link

@Simiux I just cloned the repo, edit the code with that patch I sent, and then recompiled it

here is how to do that:

  1. make sure you have a java jdk and git installed
  2. open a terminal, and clone the repo
  3. cd into repo folder
  4. copy that text and save it as tiered-crash-fix.patch in that folder
  5. run git apply tiered-crash-fix.patch to apply it
  6. run gradlew.bat build for windows or ./gradlew build for linux/macos
  7. you can now copy the mod from build/libs/ into your mods folder.

@Simiux
Copy link

Simiux commented Dec 6, 2023

@solonovamax hey man dope, It took a bit of punching around, but I ended up being able to fix it, the bows don't crash me anymore. Thanks for the code, absolute machine.

@Globox1997
Copy link
Owner

If someone figures out which mod causes the incompat, let me know

@solonovamax
Copy link

I believe it may possibly be zenith, but I am unsure.
I'm probably gonna investigate a bit more, later, if I don't forgor again

@Globox1997 Globox1997 added the incompatibility This bug happens due to a mod incompatibility label Jan 1, 2024
@Lxrd0taku
Copy link

Having the same issue with bow-type weapons from the mod "Spellbound Weapons", the blowgun in particular. I also believe tools modified by the mod "Golden Age Combat" causes this bug as well. After disabling Golden Age Combat/TieredZ, I was able to use the tools that had been "balanced" by Golden Age Combat; However, using both mods always seems to crash when attempting to display the tooltip bar.

@arehfeldt
Copy link

Ran into this issue with Zenith and confirmed by removing the durability attribute added to the items nbt data to fix the crash. Crash is the same issue in getToolTipMix method in the getItemStackMixin class under tiered/src/main/java/draylar/tiered/mixin/client

@solonovamax
Copy link

I suspected it might've been zenith but never got around to testing it lol

@Globox1997
Copy link
Owner

Fixed with the solution of @Simiux on latest version.
Seems like another mod makes the multimap immutable which is not optimal, vanilla behavior is a mutable map.
Which ever mod does that, it should get changed.

@solonovamax
Copy link

Fixed with the solution of @Simiux on latest version. Seems like another mod makes the multimap immutable which is not optimal, vanilla behavior is a mutable map. Which ever mod does that, it should get changed.

wdym the "solution of Simiux" ?

it was me who gave the solution lol

@Globox1997
Copy link
Owner

Oh I am sorry, not sure how I mixed this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatibility This bug happens due to a mod incompatibility
Projects
Status: Done
Development

No branches or pull requests

6 participants