Bug Closed · Resolved

Dropping some items throws IllegalArgumentException in ItemDropEffectsListener (VolatileCompoundTag is not of expected type StringTag)

#10162 opened by Janvitos 5 days ago

Janvitosreported this bug

Summary

When a player drops certain items, ItemDropEffectsListener.applyFancyEffects throws an IllegalArgumentException and Paper logs Could not pass event PlayerDropItemEvent to MythicMobs. The drop itself still happens, but the error is logged every time such an item is dropped.

Cause

The item check (ItemExecutor.getMythicTypeFromItem → isMythicItem → VolatileItemHandlerImpl.getNBTData) converts the item's whole NBT through VolatileCompoundTag.fromNMSTag. When it meets a list, ListTagBuilder fixes the list's type from the first entry and throws when a later entry has a different type. Here a list holding a compound was expected to hold StringTags.

Minecraft 26.1 allows lists with mixed entry types, so such items exist.

Still present in 5.14.0

ItemDropEffectsListener, ListTagBuilder and v26_1.VolatileCompoundTag are byte-identical between 5.13.0 and 5.14.0.

Suggested fix

  • Make fromNMSTag / ListTagBuilder accept lists with mixed entry types, or
  • At least catch the exception in applyFancyEffects, so a non-Mythic item never breaks the drop event.

Steps to reproduce

  1. Run MythicMobs 5.13.0 or 5.14.0 on Paper 26.1.2.
  2. Get an item whose NBT has a list with entries of different types (for example a compound and a string in the same list).
  3. Drop it from the inventory.
  4. The console shows the error below.

Environment

  • MythicMobs: 5.13.0-aad3f1c9 (free edition, Modrinth). Same code in 5.14.0.
  • Server: Paper 26.1.2-74 (e4e17fc)

Note: the jar in the trace carries a local patch to an unrelated class (core.spawning.random.PlayerGroup). No class in this stack trace was modified.

Stack trace

[14:49:13] [Server thread/ERROR]: Could not pass event PlayerDropItemEvent to MythicMobs v5.13.0-aad3f1c9
java.lang.IllegalArgumentException: io.lumine.mythic.core.volatilecode.v26_1.VolatileCompoundTag is not of expected type io.lumine.mythic.core.utils.jnbt.StringTag
        at io.lumine.mythic.core.utils.jnbt.ListTagBuilder.add(ListTagBuilder.java:55)
        at io.lumine.mythic.core.volatilecode.v26_1.VolatileCompoundTag.fromNMSTag(VolatileCompoundTag.java:188)
        at io.lumine.mythic.core.volatilecode.v26_1.VolatileCompoundTag.fromNMSTag(VolatileCompoundTag.java:164)
        at io.lumine.mythic.core.volatilecode.v26_1.VolatileCompoundTag.fromNMSTag(VolatileCompoundTag.java:164)
        at io.lumine.mythic.core.volatilecode.v26_1.VolatileCompoundTag.fromNMSTag(VolatileCompoundTag.java:164)
        at io.lumine.mythic.core.volatilecode.v26_1.VolatileCompoundTag.fromNMSTag(VolatileCompoundTag.java:188)
        at io.lumine.mythic.core.volatilecode.v26_1.VolatileItemHandlerImpl.getNBTData(VolatileItemHandlerImpl.java:94)
        at io.lumine.mythic.core.items.ItemExecutor.isMythicItem(ItemExecutor.java:249)
        at io.lumine.mythic.core.items.ItemExecutor.getMythicTypeFromItem(ItemExecutor.java:228)
        at io.lumine.mythic.bukkit.listeners.ItemDropEffectsListener.applyFancyEffects(ItemDropEffectsListener.java:183)
        at io.lumine.mythic.bukkit.listeners.ItemDropEffectsListener.onItemDrop(ItemDropEffectsListener.java:112)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:71)
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54)
        at net.minecraft.world.entity.LivingEntity.drop(LivingEntity.java:823)
        at net.minecraft.server.level.ServerPlayer.drop(ServerPlayer.java:2703)
        at net.minecraft.world.entity.player.Player.drop(Player.java:621)
        at net.minecraft.world.inventory.AbstractContainerMenu.doClick(AbstractContainerMenu.java:632)
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3368)
Sign in to join the discussion.