Skip to content

Commit

Permalink
Merge pull request #1009 from booky10/fix/nbt-component-booleans
Browse files Browse the repository at this point in the history
Allow any numbers when reading nbt booleans
  • Loading branch information
retrooper committed Sep 23, 2024
2 parents 4aae570 + 33dd093 commit 7218c36
Showing 1 changed file with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,27 +563,11 @@ public NBTReader(NBTCompound compound) {
}

public void useBoolean(String key, Consumer<Boolean> consumer) {
useTag(key, tag -> consumer.accept(requireType(tag, NBTType.BYTE).getAsByte() != 0));
useNumber(key, num -> consumer.accept(num.byteValue() != 0));
}

public <R> R readBoolean(String key, Function<Boolean, R> function) {
return withTag(key, tag -> function.apply(requireType(tag, NBTType.BYTE).getAsByte() != 0));
}

public void useByte(String key, Consumer<Byte> consumer) {
useTag(key, tag -> consumer.accept(requireType(tag, NBTType.BYTE).getAsByte()));
}

public <R> R readByte(String key, Function<Byte, R> function) {
return withTag(key, tag -> function.apply(requireType(tag, NBTType.BYTE).getAsByte()));
}

public void useShort(String key, Consumer<Short> consumer) {
useTag(key, tag -> consumer.accept(requireType(tag, NBTType.SHORT).getAsShort()));
}

public <R> R readShort(String key, Function<Short, R> function) {
return withTag(key, tag -> function.apply(requireType(tag, NBTType.SHORT).getAsShort()));
return readNumber(key, num -> function.apply(num.byteValue() != 0));
}

public void useNumber(String key, Consumer<Number> consumer) {
Expand Down

0 comments on commit 7218c36

Please sign in to comment.