Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.6 vanilla client crashes while receiving chunks #823

Open
VenixPLL opened this issue May 26, 2024 · 0 comments
Open

1.20.6 vanilla client crashes while receiving chunks #823

VenixPLL opened this issue May 26, 2024 · 0 comments

Comments

@VenixPLL
Copy link

Sorry if im doing something wrong but there are not enough examples to write that kind of code.

Minecraft version: vanilla 1.20.6
Video of the bug: https://streamable.com/075uuw

Minecraft crash log:

---- Minecraft Crash Report ----
// Don't be sad, have a hug! <3

Time: 2024-05-26 18:52:01
Description: Getting biome
dup: Missing Palette entry for index 0.
at duo.a(SourceFile:76)

Code used to send the chunk data:

public void packetSent(Session session, Packet packet) {
    if(packet instanceof ClientboundLoginPacket){
       session.send(new ClientboundPlayerPositionPacket(0,0,0,90f,10f,0));
       session.send(new ClientboundGameEventPacket(GameEvent.LEVEL_CHUNKS_LOAD_START, new GameEventValue() {
       }));
        session.send(new ClientboundSetChunkCacheCenterPacket(0,0));
        var chunkSections = new ChunkSection[24]; // One chunk column
         for(int i=0;i<chunkSections.length;i++){
              var section = new ChunkSection(); // Initialize empty
               section.setBlock(0,0,0,1); //Every block on 0,0,0 of every section is set to stone
                chunkSections[i] = section; // Append changes
               System.out.println("Chunk section y="+i + " set! blockCount " + section.getBlockCount());
           }

           var buffer = Unpooled.buffer(); // Empty buffer
           var helper = new MinecraftCodecHelper(Int2ObjectMaps.emptyMap(), Collections.emptyMap());
           for (ChunkSection section : chunkSections) helper.writeChunkSection(buffer,section); // Write data

           var chunkData = new byte[buffer.readableBytes()];
           buffer.readBytes(chunkData);

           session.send(new ClientboundLevelChunkWithLightPacket(
              0,0,chunkData, NbtMap.EMPTY, new BlockEntityInfo[0],
              new LightUpdateData(new BitSet(), new BitSet(), new BitSet(), new BitSet(), Collections.emptyList(), Collections.emptyList())
             ));

      }
      System.out.println("Sending " + packet);
      super.packetSent(session, packet);
}`
                        
This code is written inside MinecraftProtocolTest class 
I saw something wrong with writing chunks on MCProtocolLib and wanted to investigate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant