diff --git a/server/src/main/java/server/clipboard/BlockTransform.java b/server/src/main/java/server/clipboard/Mat2i.java similarity index 70% rename from server/src/main/java/server/clipboard/BlockTransform.java rename to server/src/main/java/server/clipboard/Mat2i.java index b8c15789..bc6c5eae 100755 --- a/server/src/main/java/server/clipboard/BlockTransform.java +++ b/server/src/main/java/server/clipboard/Mat2i.java @@ -1,25 +1,25 @@ package server.clipboard; -public class BlockTransform { +public class Mat2i { private final int xx; private final int zx; private final int xz; private final int zz; - public BlockTransform(int theta, boolean x, boolean z) { - int cot = dCos(theta); - int sit = dSin(theta); - this.xx = cot * (x ? -1 : 1); - this.zx = sit * (z ? -1 : 1); - this.xz = -sit * (x ? -1 : 1); - this.zz = cot * (z ? -1 : 1); + public Mat2i(int rotationY, boolean flipX, boolean flipZ) { + int cot = dCos(-rotationY); + int sit = dSin(-rotationY); + this.xx = cot * (flipX ? -1 : 1); + this.zx = sit * (flipZ ? -1 : 1); + this.xz = -sit * (flipX ? -1 : 1); + this.zz = cot * (flipZ ? -1 : 1); } - public int applyX(int x, int z) { + public int mulX(int x, int z) { return x * this.xx + z * this.zx; } - public int applyZ(int x, int z) { + public int mulZ(int x, int z) { return x * this.xz + z * this.zz; } diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index bdc12ee8..231e585a 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -121,7 +121,7 @@ import common.world.BlockArray; import common.world.State; import common.world.World; import server.Server; -import server.clipboard.BlockTransform; +import server.clipboard.Mat2i; import server.clipboard.ClipboardBlock; import server.clipboard.ClipboardPlacer; import server.clipboard.RotationRegistry; @@ -1419,9 +1419,9 @@ public class Player extends User implements ICrafting, Executor, IPlayer int nz = this.clipboard[0][0].length; BlockPos to = this.entity.getPosition(); ClipboardPlacer placer = new ClipboardPlacer(this.getEntityWorld()); - BlockTransform transform = null; + Mat2i transform = null; if(this.rotation != 0 || this.flipX || this.flipZ) { - transform = new BlockTransform(-this.rotation, this.flipX, this.flipZ); + transform = new Mat2i(this.rotation, this.flipX, this.flipZ); } else { to = to.add(this.selOffset); @@ -1434,21 +1434,21 @@ public class Player extends User implements ICrafting, Executor, IPlayer } else { ClipboardBlock block = transformBlock(transform, this.clipboard[x][y][z]); - placer.setBlock(to.add(transform.applyX(x + this.selOffset.getX(), z + this.selOffset.getZ()), y + this.selOffset.getY(), - transform.applyZ(x + this.selOffset.getX(), z + this.selOffset.getZ())), block); + placer.setBlock(to.add(transform.mulX(x + this.selOffset.getX(), z + this.selOffset.getZ()), y + this.selOffset.getY(), + transform.mulZ(x + this.selOffset.getX(), z + this.selOffset.getZ())), block); } } } } if(transform != null) { - to = to.add(transform.applyX(this.selOffset.getX(), this.selOffset.getZ()), this.selOffset.getY(), transform.applyZ(this.selOffset.getX(), this.selOffset.getZ())); + to = to.add(transform.mulX(this.selOffset.getX(), this.selOffset.getZ()), this.selOffset.getY(), transform.mulZ(this.selOffset.getX(), this.selOffset.getZ())); } placer.commit(); this.addHotbar(TextColor.YELLOW + "Zwischenablage wurde bei %d, %d, %d eingefügt", to.getX(), to.getY(), to.getZ()); return true; } - private static ClipboardBlock transformBlock(BlockTransform transform, ClipboardBlock block) { + private static ClipboardBlock transformBlock(Mat2i transform, ClipboardBlock block) { RotationValue[] state = RotationRegistry.getRotation(block.getState().getBlock()); if(state == null) return block; @@ -1469,9 +1469,9 @@ public class Player extends User implements ICrafting, Executor, IPlayer return (x1 / l1) * (x2 / l2) + (z1 / l1) * (z2 / l2); } - private static RotationValue getNewRotation(BlockTransform transform, RotationValue[] state, RotationValue value) { - int x = transform.applyX(value.getX(), value.getZ()); - int z = transform.applyZ(value.getX(), value.getZ()); + private static RotationValue getNewRotation(Mat2i transform, RotationValue[] state, RotationValue value) { + int x = transform.mulX(value.getX(), value.getZ()); + int z = transform.mulZ(value.getX(), value.getZ()); RotationValue newValue = null; double closest = -2; for(RotationValue v : state) {