From 6e4557c8cff4c719d0a138bcd219b0db3502d40d Mon Sep 17 00:00:00 2001 From: steve6472 <20379161+steve6472@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:37:51 +0100 Subject: [PATCH] Small cleanup, Fix incorrect chunk selection --- src/main/java/game/data/chunk/Chunk.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/game/data/chunk/Chunk.java b/src/main/java/game/data/chunk/Chunk.java index 12bd068..d61c615 100644 --- a/src/main/java/game/data/chunk/Chunk.java +++ b/src/main/java/game/data/chunk/Chunk.java @@ -12,8 +12,6 @@ import game.data.dimension.Dimension; import game.protocol.Protocol; import java.util.function.BiConsumer; -import java.util.function.Consumer; -import org.apache.commons.lang3.mutable.MutableBoolean; import packets.DataTypeProvider; import packets.builder.PacketBuilder; import se.llbit.nbt.*; @@ -131,7 +129,7 @@ public void whenParsed(Runnable r) { /** - * Read a chunk column. Largely based on: https://wiki.vg/Protocol + * Read a chunk column. Largely based on: https://wiki.vg/Protocol */ public void readChunkColumn(boolean full, BitSet mask, DataTypeProvider dataProvider) { // Loop through section Y values, starting from the lowest section that has blocks inside it. Compute the index @@ -507,7 +505,7 @@ public void updateBlock(Coordinate3D coords, int blockStateId) { public void updateBlock(Coordinate3D coords, int blockStateId, boolean suppressUpdate) { raiseEvent("update block"); - int sectionY = coords.getY() / SECTION_HEIGHT; + int sectionY = (int) Math.floor((double) coords.getY() / SECTION_HEIGHT); // if there's no section, we create an empty one if (getChunkSection(sectionY) == null) { @@ -535,8 +533,8 @@ public void updateBlock(Coordinate3D coords, int blockStateId, boolean suppressU /** * Update a number of blocks. toUpdate keeps track of which blocks have changed so that we can only redraw the * chunk if that's actually needed. - * @param pos - * @param provider + * @param pos chunk selection + * @param provider network input */ public void updateBlocks(Coordinate3D pos, DataTypeProvider provider) { int count = provider.readVarInt();