Globox1997 / tiered

https://modrinth.com/mod/tieredz
https://www.curseforge.com/minecraft/mc-mods/tieredz
MIT License
1 stars 15 forks source link

Opening Chest Crash #88

Closed PCRGaming closed 4 months ago

PCRGaming commented 7 months ago

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 commented 7 months ago

Does this happen with only this mod installed?

solonovamax commented 7 months ago

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 commented 7 months ago

Does it happen with only this mod installed?

solonovamax commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 commented 7 months ago

@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 commented 6 months ago

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

solonovamax commented 6 months ago

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

Lxrd0taku commented 6 months ago

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 commented 5 months ago

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 commented 5 months ago

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

Globox1997 commented 4 months ago

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 commented 3 months ago

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 commented 3 months ago

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