Add more directionals

- Fixes #1122
 - Levers and buttons can be flipped/rotated vertically
This commit is contained in:
dordsor21 2021-07-23 20:15:22 +01:00
parent 0d26dad397
commit 0be8746c11
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -91,6 +91,7 @@ public class BlockTransformExtent extends ResettableExtent {
PropertyKey.ROTATION, PropertyKey.ROTATION,
PropertyKey.AXIS, PropertyKey.AXIS,
PropertyKey.FACING, PropertyKey.FACING,
PropertyKey.FACE,
PropertyKey.SHAPE, PropertyKey.SHAPE,
PropertyKey.NORTH, PropertyKey.NORTH,
PropertyKey.EAST, PropertyKey.EAST,
@ -166,24 +167,21 @@ public class BlockTransformExtent extends ResettableExtent {
} else { } else {
List values = property.getValues(); List values = property.getValues();
PropertyKey key = property.getKey(); PropertyKey key = property.getKey();
if (key == PropertyKey.HALF || values.contains("top")) { switch (key.getName().toLowerCase()) {
case "half": {
return adapt(UP, DOWN); return adapt(UP, DOWN);
} }
if (values.contains("left")) { case "type": {
if (key == PropertyKey.SHAPE) { return adapt(combine(UP), combine(DOWN), 0L);
return adapt(combine(EAST, WEST), combine(NORTH, SOUTH));
} else if (key == PropertyKey.HINGE) {
return adapt(combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST), combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST));
} }
} case "rotation": {
if (key == PropertyKey.ROTATION) {
List<Direction> directions = new ArrayList<>(); List<Direction> directions = new ArrayList<>();
for (Object value : values) { for (Object value : values) {
directions.add(Direction.fromRotationIndex((Integer) value).get()); directions.add(Direction.fromRotationIndex((Integer) value).get());
} }
return adapt(directions.toArray(new Direction[0])); return adapt(directions.toArray(new Direction[0]));
} }
if (key == PropertyKey.AXIS) { case "axis": {
switch (property.getValues().size()) { switch (property.getValues().size()) {
case 3: case 3:
return adapt(combine(EAST, WEST), combine(UP, DOWN), combine(SOUTH, NORTH)); return adapt(combine(EAST, WEST), combine(UP, DOWN), combine(SOUTH, NORTH));
@ -194,14 +192,26 @@ public class BlockTransformExtent extends ResettableExtent {
return null; return null;
} }
} }
if (key == PropertyKey.FACING) { case "facing": {
List<Direction> directions = new ArrayList<>(); List<Direction> directions = new ArrayList<>();
for (Object value : values) { for (Object value : values) {
directions.add(Direction.valueOf(value.toString().toUpperCase(Locale.ROOT))); directions.add(Direction.valueOf(value.toString().toUpperCase(Locale.ROOT)));
} }
return adapt(directions.toArray(new Direction[0])); return adapt(directions.toArray(new Direction[0]));
} }
if (key == PropertyKey.SHAPE) { case "face": {
if (values.size() == 3) {
return adapt(combine(UP), combine(NORTH, EAST, SOUTH, WEST), combine(DOWN));
}
return null;
}
case "hinge": {
return adapt(combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST), combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST));
}
case "shape": {
if (values.contains("left")) {
return adapt(combine(EAST, WEST), combine(NORTH, SOUTH));
}
if (values.contains("straight")) { if (values.contains("straight")) {
ArrayList<Long> result = new ArrayList<>(); ArrayList<Long> result = new ArrayList<>();
for (Object value : values) { for (Object value : values) {
@ -271,6 +281,7 @@ public class BlockTransformExtent extends ResettableExtent {
} }
} }
} }
}
return null; return null;
} }