Skip to content

Fake dirt blocks appear when sending CHUNK_DATA packet in specific chunk coordinates #1464

@IloveeCobrakai

Description

@IloveeCobrakai

Describe the bug
I am experiencing a strange visual issue when manipulating a chunk using PacketType.Play.Server.CHUNK_DATA.

When I modify the chunk at:

Chunk X: -11
Chunk Z: -65
Y range: 15 to 31 (Chunk Column 2)

the client shows a large amount of dirt blocks, even though those blocks do not actually exist on the server. These dirt blocks are completely fake and only visible on the client side.

Important details:

The issue only occurs in the chunk (-11, -65).
The issue only occurs within the Y range 15–31 (Column 2).
The dirt blocks appear only when I set two different block types in that chunk section. Example block types:

  • OAK_WOOD
  • SPRUCE_WOOD

If I only one block type, the issue does not occur.
If I modify multiple blocks in any other chunk, the issue does not occur.
The server world itself remains completely correct — only the client renders dirt blocks.

Expected Behavior

The client should render the blocks exactly as defined in the CHUNK_DATA packet without replacing them with dirt blocks.

Actual Behavior

The client renders random dirt blocks in that specific chunk section when both OAK_WOOD and SPRUCE_WOOD are present in the modified chunk data.

Software brand
Server: Paper 1.12.2
On all Clients and all Versions

Plugins
Image

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots

Active
Image

Fake Blocks
Image

Only set one block type SPRUCE_WOOD
Image

Disabled
Image

Code
Listener

       getPacketEventsAPI().getEventManager().registerListener(
                new PacketListenerAbstract() {
                    @Override
                    public void onPacketSend(PacketSendEvent event) {
                        if (event.getPacketType() != PacketType.Play.Server.CHUNK_DATA) return;

                        WrapperPlayServerChunkData packet = new WrapperPlayServerChunkData(event);

                        Column column = packet.getColumn();
                        if (column == null || column.getX() != -11 || column.getZ() != -65) return;

                        BaseChunk[] chunks = column.getChunks();

                        List<ReplaceBlock> replaces = new ArrayList<>();
                        replaces.add(new ReplaceBlock(5, getColumnInChunk(24), 2, StateTypes.OAK_WOOD.createBlockState()));
                        replaces.add(new ReplaceBlock(3, getColumnInChunk(24), 2, StateTypes.SPRUCE_WOOD.createBlockState()));
                        replaces.add(new ReplaceBlock(4, getColumnInChunk(24), 2, StateTypes.SPRUCE_WOOD.createBlockState()));
                        replaces.add(new ReplaceBlock(3, getColumnInChunk(25), 2, StateTypes.SPRUCE_WOOD.createBlockState()));
                        replaces.add(new ReplaceBlock(4, getColumnInChunk(25), 2, StateTypes.SPRUCE_WOOD.createBlockState()));

                        BaseChunk chunk = chunks[1];

                        for (ReplaceBlock replace : replaces) {
                            chunk.set(replace.getX(), replace.getY(), replace.getZ(), replace.getWrappedBlockState());
                        }
                    }
                }
        );

Column calculator

public int getColumnInChunk(int cord) {
        return cord & 15;
    }

Data Class

    @Getter
    public class ReplaceBlock {
        private final int x;
        private final int y;
        private final int z;
        private final WrappedBlockState wrappedBlockState;

        public ReplaceBlock(int x, int y, int z, WrappedBlockState wrappedBlockState) {
            this.x = x;
            this.y = y;
            this.z = z;
            this.wrappedBlockState = wrappedBlockState;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions