More verbosely check for "scaled" in AffineTransform and override all required methods in BlockTransformExtent

- fixes #462
This commit is contained in:
dordsor21 2021-01-11 14:21:56 +00:00
parent 5903178c53
commit fa8660c7a9
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 29 additions and 12 deletions

View File

@ -84,7 +84,7 @@ public class BlockTransformExtent extends ResettableExtent {
private int[] BLOCK_ROTATION_BITMASK;
private int[][] BLOCK_TRANSFORM;
private int[][] BLOCK_TRANSFORM_INVERSE;
private int[] ALL = new int[0];
private final int[] ALL = new int[0];
public BlockTransformExtent(Extent parent) {
this(parent, new AffineTransform());
@ -436,16 +436,31 @@ public class BlockTransformExtent extends ResettableExtent {
return transformBlock(super.getBlock(position), false);
}
@Override
public BlockState getBlock(int x, int y, int z) {
return transformBlock(super.getBlock(x, y, z), false);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return transformBlock(super.getFullBlock(position), false);
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
return transformBlock(super.getFullBlock(x, y, z), false);
}
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block) throws WorldEditException {
return super.setBlock(location, transformBlock(block, true));
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return super.setBlock(x, y, z, transformInverse(block));
}
public void setTransform(Transform affine) {
this.transform = affine;
this.transformInverse = this.transform.inverse();
@ -521,14 +536,4 @@ public class BlockTransformExtent extends ResettableExtent {
private BlockState transformInverse(BlockState block) {
return transform(block, BLOCK_TRANSFORM_INVERSE, transformInverse);
}
@Override
public BlockState getBlock(int x, int y, int z) {
return transform(super.getBlock(x, y, z));
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return super.setBlock(x, y, z, transformInverse(block));
}
}

View File

@ -297,7 +297,7 @@ public class AffineTransform implements Transform, Serializable {
public boolean isScaled(Vector3 vector) {
boolean flip = false;
if (vector.getX() != 0 && m00 < 0) {
flip = !flip;
flip = true;
}
if (vector.getY() != 0 && m11 < 0) {
flip = !flip;
@ -305,6 +305,18 @@ public class AffineTransform implements Transform, Serializable {
if (vector.getZ() != 0 && m22 < 0) {
flip = !flip;
}
if (flip) {
return true;
}
if (vector.getX() != 0 && m01 != 0 && m01 == m10) {
flip = true;
}
if (vector.getY() != 0 && m02 != 0 && m02 == m20) {
flip = !flip;
}
if (vector.getZ() != 0 && m21 != 0 && m21 == m12) {
flip = !flip;
}
return flip;
}