File tree Expand file tree Collapse file tree 4 files changed +37
-5
lines changed
src/main/java/net/hollowcube/schem Expand file tree Collapse file tree 4 files changed +37
-5
lines changed Original file line number Diff line number Diff line change 1
1
metadata.format.version = " 1.1"
2
2
3
3
[versions ]
4
- minestom = " 1_20_5-323c75f8a5 "
4
+ minestom = " c976f345d1 "
5
5
logback = " 1.4.5" # For tests only
6
6
7
7
nexuspublish = " 1.3.0"
Original file line number Diff line number Diff line change 5
5
import net .minestom .server .instance .batch .BatchOption ;
6
6
import net .minestom .server .instance .batch .RelativeBlockBatch ;
7
7
import net .minestom .server .instance .block .Block ;
8
- import net .minestom .server .utils .Utils ;
9
8
import org .jetbrains .annotations .NotNull ;
10
9
import org .jetbrains .annotations .Nullable ;
11
10
18
17
/**
19
18
* Represents a schematic file which can be manipulated in the world.
20
19
*/
21
- @ SuppressWarnings ("UnstableApiUsage" )
22
20
public record Schematic (
23
21
Point size ,
24
22
Point offset ,
Original file line number Diff line number Diff line change 5
5
import net .minestom .server .coordinate .Point ;
6
6
import net .minestom .server .coordinate .Vec ;
7
7
import net .minestom .server .instance .block .Block ;
8
- import net .minestom .server .utils .Utils ;
9
8
import org .jetbrains .annotations .NotNull ;
10
9
11
10
import java .nio .ByteBuffer ;
12
11
import java .util .Map ;
13
12
import java .util .Objects ;
14
13
import java .util .concurrent .ConcurrentHashMap ;
15
14
16
- @ SuppressWarnings ("UnstableApiUsage" )
17
15
public class SchematicBuilder {
18
16
19
17
// Point -> Block, a missing value is air
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments