Changed

Changed

184k Downloads

CTD when switching Dark Latex Mask into offhand as Dark Pup

TheSilvertail opened this issue ยท 4 comments

commented

How to replicate:

  1. Become a Dark Latex Beast Pup.
  2. Aquire a Dark Latex Mask.
  3. Have the Dark Latex Mask on your hotbar.
  4. Select the Dark Latex Mask on your hotbar.
  5. Hit key bind for swapping offhand and mainhand.

Game will then instantly crash to desktop.

Anyways, the log mostly repeats for a great while, so here's a trimmed down version of what I believe is the relevant section.

[17:37:26] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.StackOverflowError: null
at net.ltxprogrammer.changed.item.DarkLatexMask.allowedToWear(DarkLatexMask.java:82) ~[Changed-m1.18.2-v0.14.jar%2353!/:v0.14]
at net.ltxprogrammer.changed.entity.variant.TransfurVariantInstance.canWear(TransfurVariantInstance.java:626) ~[Changed-m1.18.2-v0.14.jar%2353!/:v0.14]
at net.minecraft.world.entity.player.Player.md219269$lambda$denyInvalidArmor$3$2(Player.java:2292) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
at net.ltxprogrammer.changed.process.ProcessTransfur.ifPlayerTransfurred(ProcessTransfur.java:479) ~[Changed-m1.18.2-v0.14.jar%2353!/:v0.14]
at net.minecraft.world.entity.player.Player.handler$zbg000$denyInvalidArmor(Player.java:2291) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
at net.minecraft.world.entity.player.Player.m_8061_(Player.java) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
at net.minecraft.world.entity.player.Player.md219269$lambda$denyInvalidArmor$3$2(Player.java:2294) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
at net.ltxprogrammer.changed.process.ProcessTransfur.ifPlayerTransfurred(ProcessTransfur.java:479) ~[Changed-m1.18.2-v0.14.jar%2353!/:v0.14]
at net.minecraft.world.entity.player.Player.handler$zbg000$denyInvalidArmor(Player.java:2291) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]
at net.minecraft.world.entity.player.Player.m_8061_(Player.java) ~[client-1.18.2-20220404.173914-srg.jar%2354!/:?]

As for a full log, I think this will do.
latest.log

commented

Upon testing, this bug applies to all transfur variants with any wearable changed item, and appears to be an issue itself within the PlayerMixin's denyInvalidArmor injection as hinted by the log.

commented
@Inject(method = "setItemSlot", at = @At("HEAD"), cancellable = true)
    public void denyInvalidArmor(EquipmentSlot slot, ItemStack item, CallbackInfo ci) {
        ProcessTransfur.ifPlayerTransfurred(EntityUtil.playerOrNull(this), (player, variant) -> {
            if (!variant.canWear(player, item, slot)) {
                ci.cancel();
                this.setItemSlot(EquipmentSlot.MAINHAND, item);
            }
        });
    }

That is the line where have the issue and the part that give the erro is

net.ltxprogrammer.changed.process.ProcessTransfur.ifPlayerTransfurred(ProcessTransfur.java:479) ~[Changed-m1.18.2-v0.14.jar%2356!/:v0.14] {re:mixin,re:classloading}
   at net.minecraft.world.entity.player.Player.handler$bbe000$denyInvalidArmor(Player.java:2791)
commented
public static boolean ifPlayerTransfurred(Player player, BiConsumer<Player, TransfurVariantInstance<?>> isLatex) {
        TransfurVariantInstance<?> variant = getPlayerTransfurVariant(player);
        if (variant != null)
            isLatex.accept(player, variant); //Exactly Line where the issue happen
        return variant != null;
    }
commented

StackOverflowException caused by implementations of ExtendedItemProperties.allowedToWear() denying the MAINHAND slot, caused the code to attempt to move the invalid item to the MAINHAND, recursing until crashing.