cleannrooster / extraspellattributes

MIT License
0 stars 2 forks source link

Incompatibility between Zenith and Extra RPG Attributes #3

Open Cicopath opened 3 months ago

Cicopath commented 3 months ago

Posting it here since it seems to involve this mod. Making a modpack on Fabric 1.20.1-0.16.0 with Zenith 1.2.3 and Extra RPG Attributes 1.2.8. In my modpack, I get this repeating ticking error of some sort, while just together I get an unexpected error, both occurring upon creating a world.

Modpack crash: crash-2024-08-09_03.50.52-server.txt

With the two mods together (plus Jade & REI): crash-2024-08-09_04.06.43-client.txt

Already mentioned the issue in Zenith's github here.

muon-rw commented 3 months ago

I gave a brief overview of the issue here: https://github.com/TheWinABagel/Zenith/issues/182#issuecomment-2215092497

It’s probably something that should be resolved on Zenith’s end.

That said, ExtraRPGAttr could easily implement its own failsafe to ensure onEquipStackAbsorption can never recursively call itself, by using a ThreadLocal flag

From our Discord convo:

    @Unique
    private static final ThreadLocal<Boolean> PROCESSING = ThreadLocal.withInitial(() -> false);

    @Inject(method = "onEquipStack", at = @At("HEAD"))
    private void onEquipStackAbsorption(EquipmentSlot slot, ItemStack oldStack, ItemStack newStack, CallbackInfo ci) {
        if (PROCESSING.get()) return;
        PROCESSING.set(true);
        try {
            if (this instanceof PlayerInterface playerDamageInterface) {
                if (!newStack.isEmpty() && newStack.getAttributeModifiers(slot).containsKey(WARDING)) {
                    playerDamageInterface.resetReabDamageAbsorbed();
                }
            }
        } finally {
            PROCESSING.set(false);
        }
    }