diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java index 7926218c..fd3022a0 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitChunk_1_10.java @@ -8,6 +8,7 @@ import com.boydti.fawe.example.CharFaweChunk; import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.util.MainUtil; +import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.ReflectionUtils; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.ListTag; @@ -189,9 +190,9 @@ public class BukkitChunk_1_10 extends CharFaweChunk { if (ent instanceof EntityPlayer) { return false; } - int x = ((int) Math.round(ent.locX) & 15); - int z = ((int) Math.round(ent.locZ) & 15); - int y = ((int) Math.round(ent.locY) & 0xFF); + int x = (MathMan.roundInt(ent.locX) & 15); + int z = (MathMan.roundInt(ent.locZ) & 15); + int y = (MathMan.roundInt(ent.locY) & 0xFF); int i = FaweCache.CACHE_I[y][z][x]; int j = FaweCache.CACHE_J[y][z][x]; String id = EntityTypes.b(ent); @@ -280,9 +281,9 @@ public class BukkitChunk_1_10 extends CharFaweChunk { if (entity instanceof net.minecraft.server.v1_10_R1.EntityPlayer) { continue; } - int x = ((int) Math.round(entity.locX) & 15); - int z = ((int) Math.round(entity.locZ) & 15); - int y = (int) Math.round(entity.locY); + int x = (MathMan.roundInt(entity.locX) & 15); + int z = (MathMan.roundInt(entity.locZ) & 15); + int y = MathMan.roundInt(entity.locY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { if (copy != null) { diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java index 100e12f2..13d70a67 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java @@ -789,9 +789,9 @@ public class BukkitQueue_1_10 extends BukkitQueue_0 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { if (copy != null) { diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java index 9ab14610..6e891be4 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_11/BukkitQueue_1_11.java @@ -791,9 +791,9 @@ public class BukkitQueue_1_11 extends BukkitQueue_0 { if (ent instanceof EntityPlayer || BukkitQueue_0.getAdapter() == null) { return false; } - int x = ((int) Math.round(ent.locX) & 15); - int z = ((int) Math.round(ent.locZ) & 15); - int y = ((int) Math.round(ent.locY) & 0xFF); + int x = (MathMan.roundInt(ent.locX) & 15); + int z = (MathMan.roundInt(ent.locZ) & 15); + int y = (MathMan.roundInt(ent.locY) & 0xFF); int i = FaweCache.CACHE_I[y][z][x]; int j = FaweCache.CACHE_J[y][z][x]; String id = EntityTypes.b(ent); @@ -270,6 +271,8 @@ public class BukkitChunk_1_12 extends CharFaweChunk { } else { Collection ents = entities[i]; if (!ents.isEmpty()) { + int layerYStart = i << 4; + int layerYEnd = layerYStart + 15; char[] array = this.getIdArray(i); if (array == null) continue; Iterator iter = ents.iterator(); @@ -278,10 +281,10 @@ public class BukkitChunk_1_12 extends CharFaweChunk { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.locX) & 15); - int z = ((int) Math.round(entity.locZ) & 15); - int y = (int) Math.round(entity.locY); - if (y < 0 || y > 255) continue; + int y = MathMan.roundInt(entity.locY); + if (y > layerYEnd || y < layerYStart) continue; + int x = (MathMan.roundInt(entity.locX) & 15); + int z = (MathMan.roundInt(entity.locZ) & 15); if (array[FaweCache.CACHE_J[y][z][x]] != 0) { if (copy != null) { copy.storeEntity(entity); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitQueue_1_12.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitQueue_1_12.java index 24814dcf..b92e919f 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitQueue_1_12.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_12/BukkitQueue_1_12.java @@ -832,9 +832,9 @@ public class BukkitQueue_1_12 extends BukkitQueue_0 { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.locX) & 15); - int z = ((int) Math.round(entity.locZ) & 15); - int y = (int) Math.round(entity.locY); + int x = (MathMan.roundInt(entity.locX) & 15); + int z = (MathMan.roundInt(entity.locZ) & 15); + int y = MathMan.roundInt(entity.locY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java index c10605ed..49f9eb75 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java @@ -406,9 +406,9 @@ public class BukkitQueue17 extends BukkitQueue_0 { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.locX) & 15); - int z = ((int) Math.round(entity.locZ) & 15); - int y = (int) Math.round(entity.locY); + int x = (MathMan.roundInt(entity.locX) & 15); + int z = (MathMan.roundInt(entity.locZ) & 15); + int y = MathMan.roundInt(entity.locY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java index 4ec830ba..09f98d32 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java @@ -397,9 +397,9 @@ public class BukkitQueue18R3 extends BukkitQueue_0 { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.locX) & 15); - int z = ((int) Math.round(entity.locZ) & 15); - int y = (int) Math.round(entity.locY); + int x = (MathMan.roundInt(entity.locX) & 15); + int z = (MathMan.roundInt(entity.locZ) & 15); + int y = MathMan.roundInt(entity.locY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java index e80fcddf..703459f3 100644 --- a/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java +++ b/bukkit/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java @@ -744,9 +744,9 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 pos = (List) map.get("Pos").getValue(); - int x = (int) Math.round(pos.get(0).getValue()); - int y = (int) Math.round(pos.get(1).getValue()); - int z = (int) Math.round(pos.get(2).getValue()); + int x = MathMan.roundInt(pos.get(0).getValue()); + int y = MathMan.roundInt(pos.get(1).getValue()); + int z = MathMan.roundInt(pos.get(2).getValue()); UUID uuid = new UUID(most, least); fwee.getQueue().removeEntity(x, y, z, uuid); } else { @@ -101,9 +102,9 @@ public class MutableEntityChange implements Change { return; } List pos = (List) posTag.getValue(); - int x = (int) Math.round(pos.get(0).getValue()); - int y = (int) Math.round(pos.get(1).getValue()); - int z = (int) Math.round(pos.get(2).getValue()); + int x = MathMan.roundInt(pos.get(0).getValue()); + int y = MathMan.roundInt(pos.get(1).getValue()); + int z = MathMan.roundInt(pos.get(2).getValue()); queue.setEntity(x, y, z, tag); } } diff --git a/core/src/main/java/com/sk89q/worldedit/Vector2D.java b/core/src/main/java/com/sk89q/worldedit/Vector2D.java index 417bb53c..1a03d9a1 100644 --- a/core/src/main/java/com/sk89q/worldedit/Vector2D.java +++ b/core/src/main/java/com/sk89q/worldedit/Vector2D.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit; +import com.boydti.fawe.util.MathMan; import com.sk89q.worldedit.math.transform.AffineTransform; import java.io.IOException; import java.io.Serializable; @@ -102,7 +103,7 @@ public class Vector2D implements Serializable { * @return the x coordinate */ public int getBlockX() { - return (int) Math.round(getX()); + return MathMan.roundInt(getX()); } /** @@ -140,7 +141,7 @@ public class Vector2D implements Serializable { * @return the z coordinate */ public int getBlockZ() { - return (int) Math.round(getZ()); + return MathMan.roundInt(getZ()); } /** diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java index e824588b..7667fa8a 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java @@ -181,9 +181,9 @@ public class ForgeChunk_All extends CharFaweChunk { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeQueue_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeQueue_All.java index 2233e428..4efaa864 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeQueue_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeQueue_All.java @@ -356,9 +356,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeQueue_All.java b/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeQueue_All.java index 37ae0958..eaa6a884 100644 --- a/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeQueue_All.java +++ b/forge111/src/main/java/com/boydti/fawe/forge/v111/ForgeQueue_All.java @@ -432,9 +432,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeQueue_All.java b/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeQueue_All.java index 9532ccf3..d4d02a09 100644 --- a/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeQueue_All.java +++ b/forge112/src/main/java/com/boydti/fawe/forge/v112/ForgeQueue_All.java @@ -558,9 +558,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java index 84a38f9b..f6408e90 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java @@ -438,9 +438,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeQueue_All.java b/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeQueue_All.java index 71f9b491..2593ff66 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeQueue_All.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/v189/ForgeQueue_All.java @@ -300,9 +300,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (y < 0 || y > 255) continue; if (array[FaweCache.CACHE_J[y][z][x]] != 0) { nmsWorld.removeEntity(entity); diff --git a/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeQueue_All.java b/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeQueue_All.java index 4a0c10a3..ad8cd4a0 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeQueue_All.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/v194/ForgeQueue_All.java @@ -354,9 +354,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (array == null) { continue; } diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java index 5b6ce324..f38ba7b4 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_12/SpongeQueue_1_12.java @@ -448,9 +448,9 @@ public class SpongeQueue_1_12 extends NMSMappedFaweQueue { if (entity instanceof EntityPlayer) { continue; } - int x = ((int) Math.round(entity.posX) & 15); - int z = ((int) Math.round(entity.posZ) & 15); - int y = (int) Math.round(entity.posY); + int x = (MathMan.roundInt(entity.posX) & 15); + int z = (MathMan.roundInt(entity.posZ) & 15); + int y = MathMan.roundInt(entity.posY); if (array == null) { continue; } diff --git a/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java b/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java index a210f461..208130cd 100644 --- a/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java +++ b/sponge111/src/main/java/com/boydti/fawe/sponge/v1_11/SpongeQueue_1_11.java @@ -445,9 +445,9 @@ public class SpongeQueue_1_11 extends NMSMappedFaweQueue