Help make chunks disappear for clients.

Discussion in 'Spigot Plugin Development' started by tommy__123__, Jun 14, 2015.

  1. I am trying to make certain chunks appear as void to certain clients using protocol lib. I have the packet listener listening for map chunk packets and map chunk bulk packets. I am trying to use packet wrapper to intercept the packets with the chunk data, and change the packets to make them void. Currently I have the following code:
    Code (Text):
    try

                {
                    ChunkPacketProcessor p = ChunkPacketProcessor.fromMapPacket(event.getPacket(), event.getPlayer().getWorld());
                    p.process(new ChunkletProcessor()
                    {
                       
                        @Override
                        public void processChunklet(Location loc, byte[] bytes, ChunkOffsets offset)
                        {
                            System.out.println("Processing at loc (" + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ() + ")");
                        }
                       
                        @Override
                        public void processBiomeArray(Location arg0, byte[] arg1, int arg2)
                        {
                           
                        }
                    });
                   
                   
                } catch (Exception e)
                {
                    System.out.println("Error handeling chunk " + e.getMessage());
                    e.printStackTrace();
                }
    However when the server sends the packet, I get the following error:
    [14:16:51 INFO]: Error handeling chunk Field index out of bounds. (Index: 2, Size: 2)

    [14:16:51 WARN]: FieldAccessException: Field index out of bounds. (Index: 2, Size: 2)

    [14:16:51 WARN]: at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:221)

    [14:16:51 WARN]: at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:196)

    [14:16:51 WARN]: at com.comphenix.packetwrapper.ChunkPacketProcessor.fromMapPacket(ChunkPacketProcessor.java:206)

    [14:16:51 WARN]: at com.tommysource.library.admin.PacketListener.onPacketSending(PacketListener.java:30)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:637)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:613)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.NettyProtocolInjector.packetQueued(NettyProtocolInjector.java:288)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.NettyProtocolInjector.onPacketSending(NettyProtocolInjector.java:254)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:395)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.ChannelInjector.access$500(ChannelInjector.java:62)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.ChannelInjector$6.handleScheduled(ChannelInjector.java:361)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.ChannelInjector$6.onMessageScheduled(ChannelInjector.java:329)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:110)

    [14:16:51 WARN]: at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:79)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:192)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.NetworkManager.handle(NetworkManager.java:141)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.sendPacket(PlayerConnection.java:880)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PlayerChunkMap$PlayerChunk.b(PlayerChunkMap.java:389)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PlayerChunkMap.movePlayer(PlayerChunkMap.java:243)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PlayerList.d(PlayerList.java:336)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:454)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPositionLook.a(SourceFile:18)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)

    [14:16:51 WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

    [14:16:51 WARN]: at java.util.concurrent.FutureTask.run(FutureTask.java:266)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:718)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:367)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657)

    [14:16:51 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560)

    [14:16:51 WARN]: at java.lang.Thread.run(Thread.java:745)
    Can someone please explain to me the correct way to use the chunk packet processor class.
     
  2. I have exactly the same error, it looks like ChunkPacketProcessor class isn't updated to be compatible with the latest ProtocolLib... If you got an answer post it here..