66import com .hypixel .hytale .component .Store ;
77import com .hypixel .hytale .math .util .ChunkUtil ;
88import com .hypixel .hytale .math .vector .Location ;
9- import com .hypixel .hytale .math .vector .Vector3i ;
109import com .hypixel .hytale .server .core .asset .type .blocktype .config .BlockType ;
1110import com .hypixel .hytale .server .core .asset .type .blocktype .config .Rotation ;
1211import com .hypixel .hytale .server .core .asset .type .blocktype .config .RotationTuple ;
2928import io .github .syst3ms .skriptparser .util .color .Color ;
3029import org .jetbrains .annotations .NotNull ;
3130import org .jetbrains .annotations .Nullable ;
31+ import org .joml .RoundingMode ;
32+ import org .joml .Vector3i ;
3233
3334import java .util .Map ;
3435import java .util .function .Predicate ;
@@ -55,11 +56,11 @@ public Block(@NotNull Location location) {
5556 if (world == null ) {
5657 throw new IllegalArgumentException ("World '" + location .getWorld () + "' not found." );
5758 }
58- this (world , location .getPosition (). toVector3i ( ));
59+ this (world , new Vector3i ( location .getPosition (), RoundingMode . FLOOR ));
5960 }
6061
6162 public long getChunkIndex () {
62- return ChunkUtil .indexChunkFromBlock (this .pos .getX (), this .pos .getZ ());
63+ return ChunkUtil .indexChunkFromBlock (this .pos .x (), this .pos .z ());
6364 }
6465
6566 public WorldChunk getChunk () {
@@ -72,7 +73,7 @@ public WorldChunk getChunk() {
7273 }
7374
7475 public void setType (@ NotNull BlockType type , int settings ) {
75- Runnable r = () -> Block .this .world .setBlock (Block .this .pos .getX (), Block .this .pos .getY (), Block .this .pos .getZ (), type .getId (), settings );
76+ Runnable r = () -> Block .this .world .setBlock (Block .this .pos .x (), Block .this .pos .y (), Block .this .pos .z (), type .getId (), settings );
7677 if (this .world .isInThread ()) {
7778 r .run ();
7879 } else {
@@ -95,11 +96,11 @@ public void setRotation(Vector3i rotation) {
9596 BlockChunk blockChunk = chunk .getBlockChunk ();
9697 if (blockChunk == null ) return ;
9798
98- Rotation pitch = getRotationFromInt (rotation .getX ());
99- Rotation yaw = getRotationFromInt (rotation .getY ());
100- Rotation roll = getRotationFromInt (rotation .getZ ());
99+ Rotation pitch = getRotationFromInt (rotation .x ());
100+ Rotation yaw = getRotationFromInt (rotation .y ());
101+ Rotation roll = getRotationFromInt (rotation .z ());
101102 int rotationIndex = RotationTuple .of (yaw , pitch , roll ).index ();
102- blockChunk .setBlock (this .pos .getX (), this .pos .getY (), this .pos .getZ (),
103+ blockChunk .setBlock (this .pos .x (), this .pos .y (), this .pos .z (),
103104 blockId , rotationIndex , 0 );
104105 }
105106
@@ -109,7 +110,7 @@ public void setRotation(Vector3i rotation) {
109110 * @return Rotation of block represented as a Vector3i(yaw, pitch, roll).
110111 */
111112 public Vector3i getRotation () {
112- int blockRotationIndex = getWorld ().getBlockRotationIndex (this .pos .getX (), this .pos .getY (), this .pos .getZ ());
113+ int blockRotationIndex = getWorld ().getBlockRotationIndex (this .pos .x (), this .pos .y (), this .pos .z ());
113114 RotationTuple rotationTuple = RotationTuple .get (blockRotationIndex );
114115
115116 int yaw = getIntFromRotation (rotationTuple .yaw ());
@@ -138,8 +139,8 @@ public Color getTint() {
138139 BlockChunk blockChunk = getChunk ().getBlockChunk ();
139140 if (blockChunk == null ) return null ;
140141
141- int x = this .pos .getX () % 32 ;
142- int z = this .pos .getZ () % 32 ;
142+ int x = this .pos .x () % 32 ;
143+ int z = this .pos .z () % 32 ;
143144 int tintInt = blockChunk .getTint (x , z );
144145 return Color .of (tintInt );
145146 }
@@ -152,8 +153,8 @@ public void setTint(Color color, boolean updateChunk) {
152153 BlockChunk blockChunk = getChunk ().getBlockChunk ();
153154 if (blockChunk == null ) return ;
154155
155- int x = this .pos .getX () % 32 ;
156- int z = this .pos .getZ () % 32 ;
156+ int x = this .pos .x () % 32 ;
157+ int z = this .pos .z () % 32 ;
157158 blockChunk .setTint (x , z , color .toJavaColor ().getRGB ());
158159 if (updateChunk ) {
159160 updateChunk ();
@@ -169,14 +170,14 @@ public byte getFluidLevel() {
169170 ChunkColumn column = store .getComponent (columnRef , ChunkColumn .getComponentType ());
170171 if (column == null ) return 0 ;
171172
172- Ref <ChunkStore > section = column .getSection (ChunkUtil .chunkCoordinate (this .pos .getY ()));
173+ Ref <ChunkStore > section = column .getSection (ChunkUtil .chunkCoordinate (this .pos .y ()));
173174 if (section == null ) {
174175 return 0 ;
175176 } else {
176177 FluidSection fluidSection = store .getComponent (section , FluidSection .getComponentType ());
177178 if (fluidSection == null ) return 0 ;
178179
179- return fluidSection .getFluidLevel (this .pos .getX (), this .pos .getY (), this .pos .getZ ());
180+ return fluidSection .getFluidLevel (this .pos .x (), this .pos .y (), this .pos .z ());
180181 }
181182 }
182183
@@ -187,7 +188,7 @@ public void setFluidLevel(byte level) {
187188 ChunkColumn column = store .getComponent (columnRef , ChunkColumn .getComponentType ());
188189 if (column == null ) return null ;
189190
190- Ref <ChunkStore > section = column .getSection (ChunkUtil .chunkCoordinate (this .pos .getY ()));
191+ Ref <ChunkStore > section = column .getSection (ChunkUtil .chunkCoordinate (this .pos .y ()));
191192 if (section == null ) {
192193 return null ;
193194 } else {
@@ -196,17 +197,17 @@ public void setFluidLevel(byte level) {
196197 return null ;
197198 }
198199
199- Fluid fluid = fluidSection .getFluid (this .pos .getX (), this .pos .getY (), this .pos .getZ ());
200+ Fluid fluid = fluidSection .getFluid (this .pos .x (), this .pos .y (), this .pos .z ());
200201 if (fluid == null ) return null ;
201202 byte fluidLevel = (byte ) Math .clamp ((int ) level , 0 , fluid .getMaxFluidLevel ());
202- fluidSection .setFluid (this .pos .getX (), this .pos .getY (), this .pos .getZ (), fluid , fluidLevel );
203+ fluidSection .setFluid (this .pos .x (), this .pos .y (), this .pos .z (), fluid , fluidLevel );
203204 }
204205 return chunk ;
205206 });
206207 }
207208
208209 public Fluid getFluid () {
209- int fluidId = this .world .getFluidId (this .pos .getX (), this .pos .getY (), this .pos .getZ ());
210+ int fluidId = this .world .getFluidId (this .pos .x (), this .pos .y (), this .pos .z ());
210211 if (fluidId == -1 ) {
211212 return null ;
212213 }
@@ -220,7 +221,7 @@ public void setFluid(@NotNull Fluid fluid, @Nullable Integer level) {
220221 ChunkColumn column = store .getComponent (columnRef , ChunkColumn .getComponentType ());
221222 if (column == null ) return null ;
222223
223- Ref <ChunkStore > section = column .getSection (ChunkUtil .chunkCoordinate (this .pos .getY ()));
224+ Ref <ChunkStore > section = column .getSection (ChunkUtil .chunkCoordinate (this .pos .y ()));
224225 if (section == null ) {
225226 return null ;
226227 } else {
@@ -234,18 +235,18 @@ public void setFluid(@NotNull Fluid fluid, @Nullable Integer level) {
234235 if (level != null ) {
235236 fluidLevel = level .byteValue ();
236237 } else {
237- fluidLevel = fluidSection .getFluidLevel (this .pos .getX (), this .pos .getY (), this .pos .getZ ());
238+ fluidLevel = fluidSection .getFluidLevel (this .pos .x (), this .pos .y (), this .pos .z ());
238239 if (fluidLevel <= 0 ) fluidLevel = (byte ) fluid .getMaxFluidLevel ();
239240 }
240241 fluidLevel = (byte ) Math .clamp ((int ) fluidLevel , 0 , fluid .getMaxFluidLevel ());
241- fluidSection .setFluid (this .pos .getX (), this .pos .getY (), this .pos .getZ (), fluid , fluidLevel );
242+ fluidSection .setFluid (this .pos .x (), this .pos .y (), this .pos .z (), fluid , fluidLevel );
242243 }
243244 return chunk ;
244245 });
245246 }
246247
247248 public void breakBlock (int settings ) {
248- this .world .breakBlock (this .pos .getX (), this .pos .getY (), this .pos .getZ (), settings );
249+ this .world .breakBlock (this .pos .x (), this .pos .y (), this .pos .z (), settings );
249250 }
250251
251252 public void damage (@ Nullable LivingEntity performer , @ Nullable ItemStack itemStack , float damage ) {
@@ -268,7 +269,6 @@ public void damage(@Nullable LivingEntity performer, @Nullable ItemStack itemSta
268269 chunkStore );
269270 } else {
270271 BlockHarvestUtils .performBlockDamage (
271- performer ,
272272 performer .getReference (),
273273 this .pos ,
274274 itemStack ,
@@ -312,8 +312,8 @@ public void setBlockHealth(float health) {
312312
313313 if (!blockHealth .isDestroyed ()) {
314314 Predicate <PlayerRef > filter = (player ) -> true ;
315- world .getNotificationHandler ().updateBlockDamage (this .pos .getX (), this .pos .getY (),
316- this .pos .getZ (), blockHealth .getHealth (), health , filter );
315+ world .getNotificationHandler ().updateBlockDamage (this .pos .x (), this .pos .y (),
316+ this .pos .z (), blockHealth .getHealth (), health , filter );
317317 }
318318 }
319319
@@ -326,16 +326,16 @@ public void setBlockHealth(float health) {
326326 }
327327
328328 public @ NotNull Location getLocation () {
329- return new Location (this .world .getName (), this .pos .getX (), this .pos .getY (), this .pos .getZ ());
329+ return new Location (this .world .getName (), this .pos .x (), this .pos .y (), this .pos .z ());
330330 }
331331
332332 public String toTypeString () {
333333 return String .format ("[%s] block at (%s,%s,%s) in '%s'" ,
334- this .getType ().getId (), this .pos .getX (), this .pos .getY (), this .pos .getZ (), this .world .getName ());
334+ this .getType ().getId (), this .pos .x (), this .pos .y (), this .pos .z (), this .world .getName ());
335335 }
336336
337337 public String toVariableNameString () {
338- return String .format ("%s_%s_%s_%s_%s" , this .world .getName (), this .getType ().getId (), this .pos .getX (), this .pos .getY (), this .pos .getZ ());
338+ return String .format ("%s_%s_%s_%s_%s" , this .world .getName (), this .getType ().getId (), this .pos .x (), this .pos .y (), this .pos .z ());
339339 }
340340
341341 @ Override
0 commit comments