Cannot construct BlockPosition?
TheMasterKitty opened this issue ยท 0 comments
Error:
[17:31:29 WARN]: [Facility] Task #6 for Facility v1.0.0 generated an exception
java.lang.RuntimeException: Cannot construct BlockPosition.
at com.comphenix.protocol.wrappers.BlockPosition$1.getGeneric(BlockPosition.java:182) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.wrappers.BlockPosition$1.getGeneric(BlockPosition.java:165) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:357) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:321) ~[ProtocolLib.jar:?]
at themasterkitty.facility.Facility.sendCrawlPacket(Facility.java:53) ~[Facility-1.0.0.jar:?]
at themasterkitty.facility.Facility$2.lambda$run$0(Facility.java:82) ~[Facility-1.0.0.jar:?]
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) ~[?:?]
at themasterkitty.facility.Facility$2.run(Facility.java:72) ~[Facility-1.0.0.jar:?]
at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.20.2.jar:git-Paper-318]
at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480) ~[paper-1.20.2.jar:git-Paper-318]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1470) ~[paper-1.20.2.jar:git-Paper-318]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.20.2.jar:git-Paper-318]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1379) ~[paper-1.20.2.jar:git-Paper-318]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1156) ~[paper-1.20.2.jar:git-Paper-318]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-318]
at java.lang.Thread.run(Thread.java:1589) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot read field "x" because "specific" is null
at com.comphenix.protocol.wrappers.BlockPosition$1.getGeneric(BlockPosition.java:179) ~[ProtocolLib.jar:?]
... 16 more
Code:
public void sendCrawlPacket(Player player, BlockPosition pos, boolean delete) {
PacketContainer packet = protocol.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
packet.getBlockPositionModifier().write(0, pos);
packet.getBlockData().write(0, WrappedBlockData.createData(delete ? Material.AIR : Material.BARRIER));
protocol.sendServerPacket(player, packet, false);
}
Bukkit.getOnlinePlayers().forEach(player -> {
if (!player.isSneaking()) {
if (crawlingdel.containsKey(player))
sendCrawlPacket(player, crawlingdel.remove(player), true);
return;
}
BlockPosition newpos = new BlockPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() + 1, player.getLocation().getBlockZ());
if (!newpos.equals(crawlingdel.get(player))) {
sendCrawlPacket(player, newpos, false);
sendCrawlPacket(player, crawlingdel.get(player), true); // ln 82
crawlingdel.put(player, newpos);
}
});
Basically this just lets you crawl when your sneaking, but it spams that error and doesn't set the old block to air