3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-02 17:40:09 +01:00

Fix flipping of chests and stairs (#526)

* Fix flipping of chests and stairs

* Check if the new property value is valid before updating

* Only for horizontal flips double chests/stairs should be modified
Dieser Commit ist enthalten in:
Brokkonaut 2019-11-12 12:09:28 +01:00 committet von Matthew Miller
Ursprung 23a3929051
Commit 89bc664f69
2 geänderte Dateien mit 41 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.registry.state.DirectionalProperty;
@ -162,6 +163,38 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
}
}
}
} else if (property.getName().equals("type") && transform instanceof AffineTransform) {
// chests
if (((AffineTransform) transform).isHorizontalFlip()) {
String value = (String) block.getState(property);
String newValue = null;
if ("left".equals(value)) {
newValue = "right";
} else if ("right".equals(value)) {
newValue = "left";
}
if (newValue != null && enumProp.getValues().contains(newValue)) {
result = result.with(enumProp, newValue);
}
}
} else if (property.getName().equals("shape") && transform instanceof AffineTransform) {
// stairs
if (((AffineTransform) transform).isHorizontalFlip()) {
String value = (String) block.getState(property);
String newValue = null;
if ("outer_left".equals(value)) {
newValue = "outer_right";
} else if ("outer_right".equals(value)) {
newValue = "outer_left";
} else if ("inner_left".equals(value)) {
newValue = "inner_right";
} else if ("inner_right".equals(value)) {
newValue = "inner_left";
}
if (newValue != null && enumProp.getValues().contains(newValue)) {
result = result.with(enumProp, newValue);
}
}
}
} else if (property instanceof IntegerProperty) {
IntegerProperty intProp = (IntegerProperty) property;

Datei anzeigen

@ -312,6 +312,14 @@ public class AffineTransform implements Transform {
}
}
/**
* Returns if this affine transform is representing a horizontal flip.
*/
public boolean isHorizontalFlip() {
// use the determinant of the x-z submatrix to check if this is a horizontal flip
return m00 * m22 - m02 * m20 < 0;
}
@Override
public String toString() {
return String.format("Affine[%g %g %g %g, %g %g %g %g, %g %g %g %g]}", m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23);