ProtocolLib

3M Downloads

Error null when using WrappedBlockData.setData

soshimee opened this issue ยท 3 comments

commented

Describe the bug
An error occurs and says null when I try to use WrappedBlockData.setData.

To Reproduce
Steps to reproduce the behavior:

  1. Use code:
WrappedBlockData blockData = WrappedBlockData.createData(randomBlock.getBlockData().getMaterial());
blockData.setData(WrappedBlockData.createData(randomBlock.getBlockData()).getData());
  1. See error null

Expected behavior
No errors appearing and data being set

Screenshots
Not a screenshot, but here's a stacktrace:

[17:24:01 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin FakeBlock v1.0.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.16.5.jar:git-Airplane-9]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Airplane-9]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:826) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2267) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:2082) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2035) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:7) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:55) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1325) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1318) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1294) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1138) ~[patched_1.16.5.jar:git-Airplane-9]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:292) ~[patched_1.16.5.jar:git-Airplane-9]
        at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.IllegalArgumentException
        at jdk.internal.reflect.GeneratedMethodAccessor31.invoke(Unknown Source) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
        at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:16) ~[?:?]
        at com.comphenix.protocol.wrappers.WrappedBlockData$NewBlockData.setTypeAndData(WrappedBlockData.java:144) ~[?:?]
        at com.comphenix.protocol.wrappers.WrappedBlockData$NewBlockData.setData(WrappedBlockData.java:139) ~[?:?]
        at me.soshimee.FakeBlock.Command.Test.onCommand(Test.java:29) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Airplane-9]
        ... 19 more

Version Info
dump-2021-08-14_17.37.38.txt

Additional context
On 1.16.5.

commented

Could be that randomBlock has null block data

commented

I can confirm that randomBlock has block data by printing getBlockData().
To be exact, randomBlock is from player.getTargetBlockExact().

commented

Any updates?