ProtocolLib

3M Downloads

NBTCompound returning null

Olzie-12 opened this issue ยท 14 comments

commented

Describe the bug
I'm getting an error on 1.18 saying that NbtCompound is null, i'm honestly not sure if this is a 1.18 issue or a ProtocolLib issue but i cannot get it to work with this error.

To Reproduce
Check screenshots

Expected behavior
It shouldn't return null

Screenshots
https://img.olziedev.com/D381UbWLZ381383811U.png

Version Info
https://haste.olziedev.com/lofidebexi.kotlin

Additional context
Add any other context about the problem here.

commented

So I should use TILE_ENTITY_DATA?

on Spigot 1.8-1.9, use UPDATE_SIGN else, use MAP_CHUNK + TILE_ENTITY_DATA You should realize that on 1.18 these packets have been changed. You can check my codes, just finished them: https://github.com/Rothes/ProtocolStringReplacer/tree/master/src/main/java/me/rothes/protocolstringreplacer/packetlisteners/server/sign

alrighty, i will look into it when i can

commented

Can you please share more code? Can you give us the information from which packet you are trying to read?

commented

I'm using the UPDATE_SIGN packet, i just realized its deprecated. Is there not anyway i can use another packet and how to?

commented

As described you should use TILE_ENTITY_DATA (for outbound packets). UpdateSign doesn't contain a Tag, only the lines and the position of the sign:

public class PacketPlayInUpdateSign implements Packet<PacketListenerPlayIn> {
  private static final int a = 384;
  
  private final BlockPosition b;
  
  private final String[] c;
commented

I just noticed NBTBase#getTypeId() is Obfuscated to NBTBase#a()

commented

I just noticed NBTBase#getTypeId() is Obfuscated to NBTBase#a()

This is relevant, because...?

commented

I just noticed NBTBase#getTypeId() is Obfuscated to NBTBase#a()

This is relevant, because...?

com/comphenix/protocol/wrappers/nbt/WrappedElement.java
ProtocolLib use this method to convert it.

commented

Not really. The actual implementation will only use the name when it's unable to retreive the method by the given paramters:

		List<Method> methods = getMethodListByParameters(returnType, args);
		
		if (methods.size() > 0) {
			return methods.get(0);
		} else {
			// That sucks
			throw new IllegalArgumentException("Unable to find " + name + " in " + source.getName());
		}
commented

Not really. The actual implementation will only use the name when it's unable to retreive the method by the given paramters:

		List<Method> methods = getMethodListByParameters(returnType, args);
		
		if (methods.size() > 0) {
			return methods.get(0);
		} else {
			// That sucks
			throw new IllegalArgumentException("Unable to find " + name + " in " + source.getName());
		}

Um yeah I was wrong. Not really took into that.

commented

So I should use TILE_ENTITY_DATA?

commented

So I should use TILE_ENTITY_DATA?

on Spigot 1.8-1.9, use UPDATE_SIGN
else, use MAP_CHUNK + TILE_ENTITY_DATA
You should realize that on 1.18 these packets have been changed.
You can check my codes, just finished them: https://github.com/Rothes/ProtocolStringReplacer/tree/master/src/main/java/me/rothes/protocolstringreplacer/packetlisteners/server/sign

commented

Not sure if this is related, but I assume it is so I quickly post this here.
I too receive an error about NBTCompoint and that a <parameter1> is null. I didn't make the plugin but the dev told me it could be a bug on ProtocolLib's end... Not sure, but I want to share the error anyway:

[14:40:11 ERROR]: Could not pass event InventoryClickEvent to LoneLibs v1.0.16
java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.wrappers.nbt.NbtCompound.put(String, String)" because "<parameter1>" is null
        at dev.lone.itemsadder.main.gs.a(SourceFile:132) ~[ItemsAdder.jar:?]
        at java.util.stream.Streams$RangeIntSpliterator.forEachRemaining(Streams.java:104) ~[?:?]
        at java.util.stream.IntPipeline$Head.forEach(IntPipeline.java:617) ~[?:?]
        at dev.lone.itemsadder.main.gs.aK(SourceFile:132) ~[ItemsAdder.jar:?]
        at dev.lone.itemsadder.main.gj.D(SourceFile:418) ~[ItemsAdder.jar:?]
        at dev.lone.itemsadder.main.gj.c(SourceFile:321) ~[ItemsAdder.jar:?]
        at fr.mrmicky.fastinv.FastInv.handleClick(FastInv.java:316) ~[LoneLibs.jar:?]
        at fr.mrmicky.fastinv.FastInvManager$1.onInventoryClick(FastInvManager.java:50) ~[LoneLibs.jar:?]
        at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:37) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:git-Paper-71]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:2817) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:58) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:13) ~[?:?]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.util.thread.BlockableEventLoop.runAllTasks(BlockableEventLoop.java:110) ~[?:?]
        at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1518) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1264) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-71]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
commented

Seems now the NBTTagCompound field is not initialized by default when createPacket(PacketType.Play.Server.TILE_ENTITY_DATA) is called.

I had to initialize it by myself: NbtFactory.ofCompound("")

commented

I'm getting this issue when trying to write the packet type to tile entity data.
Any alternatives?

[17:33:20 WARN]: [ProtocolLib] Loaded class com.olziedev.playerwarps.f.d$_b from PlayerWarps v6.12.0-pre6 which is not a depend, softdepend or loadbefore of this plugin.
[17:33:20 WARN]: FieldAccessException: No field with type int exists in class PacketPlayOutTileEntityData.
[17:33:20 WARN]:        at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:365)
[17:33:20 WARN]:        at ProtocolLib.jar//com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:345)

https://img.olziedev.com/J886486464oNe864_.png