From 5baa99ec8060fd42e0fae0bf14fe10cd559c1679 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 27 Aug 2016 13:47:09 +1000 Subject: [PATCH] Fix compile issues --- .../boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java | 2 +- .../com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java | 9 ++------- .../boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java | 2 +- .../fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java | 2 +- .../main/java/com/boydti/fawe/util/MathMan.java | 14 ++++++++++++++ .../com/boydti/fawe/forge/v0/ForgeQueue_All.java | 2 +- .../com/boydti/fawe/forge/v0/ForgeQueue_All.java | 6 +++--- .../com/boydti/fawe/forge/v0/ForgeQueue_All.java | 2 +- .../com/boydti/fawe/forge/v0/ForgeQueue_All.java | 2 +- .../boydti/fawe/sponge/v1_8/SpongeQueue_1_8.java | 2 +- 10 files changed, 26 insertions(+), 17 deletions(-) diff --git a/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java b/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java index f81dcb77..932ffbc5 100644 --- a/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java +++ b/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java @@ -698,7 +698,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0 entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPosition pos = new BlockPosition(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPosition pos = new BlockPosition(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(adapter, nativeTag); diff --git a/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java b/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java index feac3653..ff16f4c6 100644 --- a/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java +++ b/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java @@ -429,7 +429,7 @@ public class BukkitQueue17 extends BukkitQueue_0 entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - TileEntity tileEntity = nmsWorld.getTileEntity(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); + TileEntity tileEntity = nmsWorld.getTileEntity(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(adapter, nativeTag); tileEntity.a(tag); // ReadTagIntoTile @@ -602,12 +602,7 @@ public class BukkitQueue17 extends BukkitQueue_0(this, x, z) { - @Override - public Chunk getNewChunk() { - return BukkitQueue17.this.getWorld().getChunkAt(getX(), getZ()); - } - }; + return new BukkitChunk_1_7(this, x, z); } @Override diff --git a/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java b/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java index 24a0df44..33fd8744 100644 --- a/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java +++ b/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java @@ -403,7 +403,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0 entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPosition pos = new BlockPosition(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPosition pos = new BlockPosition(pair.get0x() + bx, pair.get1() & 0xFF, pair.get0y() + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(adapter, nativeTag); diff --git a/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java b/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java index 6d6059b7..ef91363b 100644 --- a/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java +++ b/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java @@ -665,7 +665,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0 entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPosition pos = new BlockPosition(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPosition pos = new BlockPosition(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(adapter, nativeTag); diff --git a/core/src/main/java/com/boydti/fawe/util/MathMan.java b/core/src/main/java/com/boydti/fawe/util/MathMan.java index e137b408..3d0e98ea 100644 --- a/core/src/main/java/com/boydti/fawe/util/MathMan.java +++ b/core/src/main/java/com/boydti/fawe/util/MathMan.java @@ -43,6 +43,20 @@ public class MathMan { 253, 254, 254, 255 }; + public static void main(String[] args) { + double val; + val = 10.2; + System.out.println(inverseRound(10.2) + " " + 11); + System.out.println(inverseRound(10.8) + " " + 10); + System.out.println(inverseRound(-10.2) + " " + -11); + System.out.println(inverseRound(-10.8) + " " + -10); + } + + public static long inverseRound(double val) { + long round = Math.round(val); + return (long) (round + Math.signum(val - round)); + } + public static short pairByte(int x, int y) { return (short) ((x << 8) | (y & 0xFF)); } diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index 439dfcf2..1f0d7452 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -473,7 +473,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPos pos = new BlockPos(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(null, nativeTag); diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index 5e4c0318..f86aaaa1 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -450,9 +450,9 @@ public class ForgeQueue_All extends NMSMappedFaweQueue entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - int x = MathMan.unpair16x(pair.pair[0]) + bx; - int y = pair.pair[1] & 0xFF; - int z = MathMan.unpair16y(pair.pair[0]) + bz; + int x = MathMan.unpair16x((byte) pair.get0()) + bx; + int y = pair.get1() & 0xFF; + int z = MathMan.unpair16y((byte) pair.get0()) + bz; TileEntity tileEntity = nmsWorld.getTileEntity(x, y, z); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(null, nativeTag); diff --git a/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index 9c6219bf..6611f3bc 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -418,7 +418,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPos pos = new BlockPos(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(null, nativeTag); diff --git a/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index 3fe4a384..050e0aa5 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -473,7 +473,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPos pos = new BlockPos(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(null, nativeTag); diff --git a/sponge/src/main/java/com/boydti/fawe/sponge/v1_8/SpongeQueue_1_8.java b/sponge/src/main/java/com/boydti/fawe/sponge/v1_8/SpongeQueue_1_8.java index 538b35aa..9c2804ac 100644 --- a/sponge/src/main/java/com/boydti/fawe/sponge/v1_8/SpongeQueue_1_8.java +++ b/sponge/src/main/java/com/boydti/fawe/sponge/v1_8/SpongeQueue_1_8.java @@ -476,7 +476,7 @@ public class SpongeQueue_1_8 extends NMSMappedFaweQueue entry : tilesToSpawn.entrySet()) { CompoundTag nativeTag = entry.getValue(); BytePair pair = entry.getKey(); - BlockPos pos = new BlockPos(MathMan.unpair16x(pair.pair[0]) + bx, pair.pair[1] & 0xFF, MathMan.unpair16y(pair.pair[0]) + bz); // Set pos + BlockPos pos = new BlockPos(MathMan.unpair16x((byte) pair.get0()) + bx, pair.get1() & 0xFF, MathMan.unpair16y((byte) pair.get0()) + bz); // Set pos TileEntity tileEntity = nmsWorld.getTileEntity(pos); if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) methodFromNative.invoke(null, nativeTag);