@@ -28,17 +28,36 @@ public class MCEditSchematic implements Schematic {
28
28
29
29
private boolean read = false ;
30
30
31
+ private int offsetX ;
32
+ private int offsetY ;
33
+ private int offsetZ ;
34
+
31
35
@ Override
32
36
public void read (NBTCompound nbtTag ) throws NBTException {
33
37
if (!nbtTag .containsKey ("Blocks" )) throw new NBTException ("Invalid Schematic: No Blocks" );
34
38
35
39
readSizes (nbtTag );
36
40
readBlocksData (nbtTag );
41
+ readOffsets (nbtTag );
37
42
readBlocks ();
38
43
39
44
read = true ;
40
45
}
41
46
47
+ private void readOffsets (@ NotNull NBTCompound nbtTag ) throws NBTException {
48
+ Integer weOffsetX = nbtTag .getInt ("WEOffsetX" );
49
+ if (weOffsetX == null ) throw new NBTException ("Invalid Schematic: No WEOffsetX" );
50
+ this .offsetX = weOffsetX ;
51
+
52
+ Integer weOffsetY = nbtTag .getInt ("WEOffsetY" );
53
+ if (weOffsetY == null ) throw new NBTException ("Invalid Schematic: No WEOffsetY" );
54
+ this .offsetY = weOffsetY ;
55
+
56
+ Integer weOffsetZ = nbtTag .getInt ("WEOffsetZ" );
57
+ if (weOffsetZ == null ) throw new NBTException ("Invalid Schematic: No WEOffsetZ" );
58
+ this .offsetZ = weOffsetZ ;
59
+ }
60
+
42
61
private void readSizes (@ NotNull NBTCompound nbtTag ) throws NBTException {
43
62
Short width = nbtTag .getShort ("Width" );
44
63
if (width == null ) throw new NBTException ("Invalid Schematic: No Width" );
@@ -86,7 +105,7 @@ public void readBlocks() {
86
105
for (int z = 0 ; z < length ; ++z ) {
87
106
int index = y * width * length + z * width + x ;
88
107
short stateId = this .blocks [index ];
89
- regionBlocks .add (new Region .Block (new Pos (x , y , z ), stateId ));
108
+ regionBlocks .add (new Region .Block (new Pos (x + offsetX , y + offsetY , z + offsetZ ), stateId ));
90
109
}
91
110
}
92
111
}
@@ -114,7 +133,7 @@ public CompletableFuture<Region> build(Instance instance, Pos position) {
114
133
}
115
134
}
116
135
117
- blockBatch .apply (instance , () -> future .complete (new Region (instance , position , position . add ( width , height , length ) )));
136
+ blockBatch .apply (instance , () -> future .complete (new Region (instance , position , position )));
118
137
});
119
138
return future ;
120
139
}
0 commit comments