Skip to content

Commit

Permalink
Fix broken error
Browse files Browse the repository at this point in the history
Off by one strikes again!
  • Loading branch information
ah-OOG-ah committed Nov 26, 2024
1 parent 32a2b80 commit 4c92360
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public class PollutionMessage implements IMessage {
private final Long2IntOpenHashMap chunks;
public int dimID;

@NotNull
public Long2IntOpenHashMap getChunks() {
return chunks;
}

// Constructor from nothing, because it's needed for registration or smth idk
@SuppressWarnings("unused")
public PollutionMessage() {
Expand All @@ -68,7 +63,7 @@ public void fromBytes(ByteBuf buf) {
final Error err = fromInt(numChunks);

switch (err) {
case NONE -> {
case NO_CHUNKS -> {
LOGGER.debug("No polluted chunks need updating, skipping rest of packet");
return;
}
Expand Down Expand Up @@ -150,7 +145,9 @@ public void toBytes(ByteBuf buf) {
*/
protected enum Error {

NONE(0),
NO_ERROR(1),

NO_CHUNKS(0),
BUFFER_OVERFLOW(-1),
UNKNOWN(Integer.MIN_VALUE);

Expand All @@ -161,8 +158,9 @@ protected enum Error {
}

static Error fromInt(int i) {
if (i >= 0) return NONE;
if (i > 0) return NO_ERROR;
return switch (i) {
case 0 -> NO_CHUNKS;
case -1 -> BUFFER_OVERFLOW;
default -> UNKNOWN;
};
Expand Down

0 comments on commit 4c92360

Please sign in to comment.