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

- fixes #462
Dieser Commit ist enthalten in:
dordsor21 2021-01-11 14:21:56 +00:00
Ursprung 5903178c53
Commit fa8660c7a9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
2 geänderte Dateien mit 29 neuen und 12 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -297,7 +297,7 @@ public class AffineTransform implements Transform, Serializable {
public boolean isScaled(Vector3 vector) { public boolean isScaled(Vector3 vector) {
boolean flip = false; boolean flip = false;
if (vector.getX() != 0 && m00 < 0) { if (vector.getX() != 0 && m00 < 0) {
flip = !flip; flip = true;
} }
if (vector.getY() != 0 && m11 < 0) { if (vector.getY() != 0 && m11 < 0) {
flip = !flip; flip = !flip;
@ -305,6 +305,18 @@ public class AffineTransform implements Transform, Serializable {
if (vector.getZ() != 0 && m22 < 0) { if (vector.getZ() != 0 && m22 < 0) {
flip = !flip; 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; return flip;
} }