Skip to content

Commit

Permalink
Merge pull request #615 from steve6472/FixNegativeChunkSection
Browse files Browse the repository at this point in the history
Fix incorrect negative Y sub-chunk selection
  • Loading branch information
mircokroon authored Nov 18, 2023
2 parents 97fd284 + 6e4557c commit 344488b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/game/data/chunk/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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: <a href="https://wiki.vg/Protocol">https://wiki.vg/Protocol</a>
*/
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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 344488b

Please sign in to comment.