Skip to content

Commit b8d2a76

Browse files
committed
chore: update minestom
1 parent d46f28e commit b8d2a76

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
metadata.format.version = "1.1"
22

33
[versions]
4-
minestom = "1_20_5-323c75f8a5"
4+
minestom = "c976f345d1"
55
logback = "1.4.5" # For tests only
66

77
nexuspublish = "1.3.0"

src/main/java/net/hollowcube/schem/Schematic.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import net.minestom.server.instance.batch.BatchOption;
66
import net.minestom.server.instance.batch.RelativeBlockBatch;
77
import net.minestom.server.instance.block.Block;
8-
import net.minestom.server.utils.Utils;
98
import org.jetbrains.annotations.NotNull;
109
import org.jetbrains.annotations.Nullable;
1110

@@ -18,7 +17,6 @@
1817
/**
1918
* Represents a schematic file which can be manipulated in the world.
2019
*/
21-
@SuppressWarnings("UnstableApiUsage")
2220
public record Schematic(
2321
Point size,
2422
Point offset,

src/main/java/net/hollowcube/schem/SchematicBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
import net.minestom.server.coordinate.Point;
66
import net.minestom.server.coordinate.Vec;
77
import net.minestom.server.instance.block.Block;
8-
import net.minestom.server.utils.Utils;
98
import org.jetbrains.annotations.NotNull;
109

1110
import java.nio.ByteBuffer;
1211
import java.util.Map;
1312
import java.util.Objects;
1413
import java.util.concurrent.ConcurrentHashMap;
1514

16-
@SuppressWarnings("UnstableApiUsage")
1715
public class SchematicBuilder {
1816

1917
// Point -> Block, a missing value is air
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.hollowcube.schem;
2+
3+
import java.nio.ByteBuffer;
4+
5+
public class Utils {
6+
public static void writeVarInt(ByteBuffer buf, int value) {
7+
if ((value & (0xFFFFFFFF << 7)) == 0) {
8+
buf.put((byte) value);
9+
} else if ((value & (0xFFFFFFFF << 14)) == 0) {
10+
buf.putShort((short) ((value & 0x7F | 0x80) << 8 | (value >>> 7)));
11+
} else if ((value & (0xFFFFFFFF << 21)) == 0) {
12+
buf.put((byte) (value & 0x7F | 0x80));
13+
buf.put((byte) ((value >>> 7) & 0x7F | 0x80));
14+
buf.put((byte) (value >>> 14));
15+
} else if ((value & (0xFFFFFFFF << 28)) == 0) {
16+
buf.putInt((value & 0x7F | 0x80) << 24 | (((value >>> 7) & 0x7F | 0x80) << 16)
17+
| ((value >>> 14) & 0x7F | 0x80) << 8 | (value >>> 21));
18+
} else {
19+
buf.putInt((value & 0x7F | 0x80) << 24 | ((value >>> 7) & 0x7F | 0x80) << 16
20+
| ((value >>> 14) & 0x7F | 0x80) << 8 | ((value >>> 21) & 0x7F | 0x80));
21+
buf.put((byte) (value >>> 28));
22+
}
23+
}
24+
25+
public static int readVarInt(ByteBuffer buf) {
26+
// https://github.com/jvm-profiling-tools/async-profiler/blob/a38a375dc62b31a8109f3af97366a307abb0fe6f/src/converter/one/jfr/JfrReader.java#L393
27+
int result = 0;
28+
for (int shift = 0; ; shift += 7) {
29+
byte b = buf.get();
30+
result |= (b & 0x7f) << shift;
31+
if (b >= 0) {
32+
return result;
33+
}
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)