This repository was archived by the owner on May 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +19
-13
lines changed
src/main/java/net/crystalgames/scaffolding Expand file tree Collapse file tree 5 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 12
12
import net .minestom .server .utils .chunk .ChunkUtils ;
13
13
import org .jetbrains .annotations .NotNull ;
14
14
import org .jetbrains .annotations .Nullable ;
15
+ import space .vectrix .flare .fastutil .Long2ObjectSyncMap ;
15
16
16
17
import java .util .ArrayList ;
18
+ import java .util .Collection ;
17
19
import java .util .List ;
18
20
import java .util .concurrent .CompletableFuture ;
19
21
import java .util .function .Function ;
23
25
public class SchematicChunkLoader implements IChunkLoader {
24
26
25
27
private final @ NotNull Function <@ NotNull Chunk , @ NotNull CompletableFuture <Void >> saveHandler ;
26
- private final Long2ObjectMap <ChunkBatch > batches = new Long2ObjectOpenHashMap <> ();
28
+ private final Long2ObjectMap <ChunkBatch > batches = Long2ObjectSyncMap . hashmap ();
27
29
28
30
private SchematicChunkLoader (
29
31
@ NotNull Function <@ NotNull Chunk , @ NotNull CompletableFuture <Void >> saveHandler ,
30
- @ NotNull List <Schematic > schematics ,
32
+ @ NotNull Collection <Schematic > schematics ,
31
33
int offsetX ,
32
34
int offsetY ,
33
35
int offsetZ
Original file line number Diff line number Diff line change 1
1
package net .crystalgames .scaffolding .region ;
2
2
3
+ import net .minestom .server .coordinate .Point ;
3
4
import net .minestom .server .coordinate .Pos ;
4
5
import net .minestom .server .instance .Instance ;
5
6
6
- public record Region (Instance instance , Pos lower , Pos upper ) {
7
+ public record Region (Instance instance , Point lower , Point upper ) {
7
8
8
9
public int sizeX () {
9
10
return (upper .blockX () - lower .blockX ()) + 1 ;
Original file line number Diff line number Diff line change 1
1
package net .crystalgames .scaffolding .schematic ;
2
2
3
3
import net .crystalgames .scaffolding .region .Region ;
4
+ import net .minestom .server .coordinate .Point ;
4
5
import net .minestom .server .coordinate .Pos ;
5
6
import net .minestom .server .instance .Instance ;
6
7
import net .minestom .server .instance .block .Block ;
17
18
18
19
public interface Schematic {
19
20
20
- default void read (InputStream inputStream ) throws IOException , NBTException {
21
+ default void read (@ NotNull InputStream inputStream ) throws IOException , NBTException {
21
22
NBTReader reader = new NBTReader (inputStream , CompressedProcesser .GZIP );
22
23
read ((NBTCompound ) reader .readNamed ().getSecond ());
23
24
reader .close ();
24
25
inputStream .close ();
25
26
}
26
- void read (NBTCompound nbtTag ) throws NBTException ;
27
+ void read (@ NotNull NBTCompound nbtTag ) throws NBTException ;
28
+ void write (@ NotNull OutputStream outputStream , @ NotNull Region region ) throws IOException ;
27
29
28
- void write (OutputStream outputStream , Region region ) throws IOException ;
29
- CompletableFuture <Region > build (Instance instance , Pos position );
30
+ CompletableFuture <Region > build (Instance instance , Point position );
30
31
31
32
short getWidth ();
32
33
short getHeight ();
Original file line number Diff line number Diff line change 2
2
3
3
import net .crystalgames .scaffolding .region .Region ;
4
4
import net .crystalgames .scaffolding .schematic .Schematic ;
5
+ import net .minestom .server .coordinate .Point ;
5
6
import net .minestom .server .coordinate .Pos ;
6
7
import net .minestom .server .instance .Instance ;
7
8
import net .minestom .server .instance .batch .AbsoluteBlockBatch ;
@@ -34,7 +35,7 @@ public class MCEditSchematic implements Schematic {
34
35
private int offsetZ ;
35
36
36
37
@ Override
37
- public void read (NBTCompound nbtTag ) throws NBTException {
38
+ public void read (@ NotNull NBTCompound nbtTag ) throws NBTException {
38
39
if (!nbtTag .containsKey ("Blocks" )) throw new NBTException ("Invalid Schematic: No Blocks" );
39
40
40
41
readSizes (nbtTag );
@@ -113,12 +114,12 @@ public void readBlocks() {
113
114
}
114
115
115
116
@ Override
116
- public void write (OutputStream outputStream , Region region ) {
117
+ public void write (@ NotNull OutputStream outputStream , @ NotNull Region region ) {
117
118
// TODO: Complete
118
119
}
119
120
120
121
@ Override
121
- public CompletableFuture <Region > build (Instance instance , Pos position ) {
122
+ public CompletableFuture <Region > build (Instance instance , Point position ) {
122
123
if (!read ) throw new IllegalStateException ("Schematic not read" );
123
124
CompletableFuture <Region > future = new CompletableFuture <>();
124
125
CompletableFuture .runAsync (() -> {
Original file line number Diff line number Diff line change 2
2
3
3
import net .crystalgames .scaffolding .region .Region ;
4
4
import net .crystalgames .scaffolding .schematic .Schematic ;
5
+ import net .minestom .server .coordinate .Point ;
5
6
import net .minestom .server .coordinate .Pos ;
6
7
import net .minestom .server .instance .Instance ;
7
8
import net .minestom .server .instance .batch .AbsoluteBlockBatch ;
@@ -33,7 +34,7 @@ public class SpongeSchematic implements Schematic {
33
34
private int offsetZ ;
34
35
35
36
@ Override
36
- public void read (NBTCompound nbtTag ) throws NBTException {
37
+ public void read (@ NotNull NBTCompound nbtTag ) throws NBTException {
37
38
readSizes (nbtTag );
38
39
readBlockPalette (nbtTag );
39
40
readOffsets (nbtTag );
@@ -133,12 +134,12 @@ private void readBlocks() throws NBTException {
133
134
}
134
135
135
136
@ Override
136
- public void write (OutputStream outputStream , Region region ) {
137
+ public void write (@ NotNull OutputStream outputStream , @ NotNull Region region ) {
137
138
// TODO: Complete
138
139
}
139
140
140
141
@ Override
141
- public CompletableFuture <Region > build (Instance instance , Pos position ) {
142
+ public CompletableFuture <Region > build (Instance instance , Point position ) {
142
143
if (!read ) throw new IllegalStateException ("Schematic not read" );
143
144
CompletableFuture <Region > future = new CompletableFuture <>();
144
145
CompletableFuture .runAsync (() -> {
You can’t perform that action at this time.
0 commit comments