FieldAccessException when calling NbtFactory.setItemTag()
josemmo opened this issue ยท 9 comments
- This issue is not solved in a development build
Describe the bug
Calling NbtFactory.setItemTag()
in Minecraft 1.20.6 throws a FieldAccessException
. Using latest available snapshot at the time of reporting (v5.3.0-SNAPSHOT-720).
Reporting this just in case, I assume ProtocolLib devs are already aware of the bug as the unit test that checks this was disabled a couple of weeks ago. Feel free to close this issue if duplicated.
To Reproduce
Steps to reproduce the behavior:
ItemStack itemStack = MinecraftReflection.getBukkitItemStack(new ItemStack(Material.FILLED_MAP));
NbtCompound itemStackNbt = NbtFactory.ofCompound("tag");
itemStackNbt.put("map", 123);
NbtFactory.setItemTag(itemStack, itemStackNbt); // <-- This line throws the exception
Exception trace:
com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0
at ProtocolLib-5.3.0-SNAPSHOT-720.jar/com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[ProtocolLib-5.3.0-SNAPSHOT-720.jar:?]
at ProtocolLib-5.3.0-SNAPSHOT-720.jar/com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:318) ~[ProtocolLib-5.3.0-SNAPSHOT-720.jar:?]
at ProtocolLib-5.3.0-SNAPSHOT-720.jar/com.comphenix.protocol.wrappers.nbt.NbtFactory.setItemTag(NbtFactory.java:154) ~[ProtocolLib-5.3.0-SNAPSHOT-720.jar:?]
Expected behavior
No exception is thrown.
Version Info
ProtocolLib Dump
Timestamp: 06/16/24 11:42:55
ProtocolLib Version: ProtocolLib v5.3.0-SNAPSHOT-720
Bukkit Version: 1.20.6-R0.1-SNAPSHOT
Server Version: 1.20.6-137-bd5867a (MC: 1.20.6)
Java Version: 21.0.2
ProtocolLib: com.comphenix.protocol.ProtocolLib@1d65491b[
statistics=com.comphenix.protocol.metrics.Statistics@3d92434b
packetTask=com.comphenix.protocol.scheduler.DefaultTask@71485b6f
tickCounter=4575
configExpectedMod=1
updater=com.comphenix.protocol.updater.SpigotUpdater@5a845148
redirectHandler=com.comphenix.protocol.ProtocolLib$2@6d9ef692
scheduler=com.comphenix.protocol.scheduler.DefaultScheduler@42b97871
commandProtocol=com.comphenix.protocol.CommandProtocol@7119c06a
commandPacket=com.comphenix.protocol.CommandPacket@9efd110
commandFilter=com.comphenix.protocol.CommandFilter@13df8cd9
packetLogging=com.comphenix.protocol.PacketLogging@1a2c1423
skipDisable=false
isEnabled=true
loader=io.papermc.paper.plugin.manager.DummyBukkitPluginLoader@25899d9c
server=CraftServer{serverName=Paper,serverVersion=1.20.6-137-bd5867a,minecraftVersion=1.20.6}
file=plugins\ProtocolLib-5.3.0-SNAPSHOT-720.jar
description=org.bukkit.plugin.PluginDescriptionFile@3dcf48b2
pluginMeta=org.bukkit.plugin.PluginDescriptionFile@3dcf48b2
dataFolder=plugins\ProtocolLib
classLoader=PluginClassLoader{plugin=ProtocolLib v5.3.0-SNAPSHOT-720, pluginEnabled=true, url=plugins\ProtocolLib-5.3.0-SNAPSHOT-720.jar}
naggable=true
newConfig=YamlConfiguration[path='', root='YamlConfiguration']
configFile=plugins\ProtocolLib\config.yml
logger=com.destroystokyo.paper.utils.PaperPluginLogger@2eb4de22
lifecycleEventManager=io.papermc.paper.plugin.lifecycle.event.PaperLifecycleEventManager@31c9f647
allowsLifecycleRegistration=false
]
Manager: com.comphenix.protocol.injector.PacketFilterManager@7604a214[
plugin=ProtocolLib v5.3.0-SNAPSHOT-720
server=CraftServer{serverName=Paper,serverVersion=1.20.6-137-bd5867a,minecraftVersion=1.20.6}
reporter=com.comphenix.protocol.ProtocolLib$1@77cc0b1e
minecraftVersion=(MC: 1.20.6)
asyncFilterManager=com.comphenix.protocol.async.AsyncFilterManager@7f819e0b
pluginVerifier=com.comphenix.protocol.injector.PluginVerifier@1843472
mainThreadPacketTypes=com.comphenix.protocol.concurrent.PacketTypeListenerSet@52c33254
inboundListeners=com.comphenix.protocol.injector.collection.InboundPacketListenerSet@45c047e9
outboundListeners=com.comphenix.protocol.injector.collection.OutboundPacketListenerSet@3642f89c
registeredListeners=[]
playerInjectionHandler=com.comphenix.protocol.injector.netty.manager.NetworkManagerPlayerInjector@16c56d82
networkManagerInjector=com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector@5d5fac9c
debug=false
closed=false
injected=true
]
No listeners
yeah it looks like item stacks no longer have nbt. it's been changed to a DataComponentMap. will need to look into this new format and see what we can do as far as wrappers go
i am curious though...what are you trying to do with the item's NBT tags that can't be done with Bukkit's ItemMeta API?
Thanks for the info! I'm using it to create a filled map item stack with a hardcoded map ID:
@dmulloy2 any Plans or News?
@dmulloy2 any plans or news?