3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-26 02:50:06 +01:00

Add more directionals

- Fixes #1122
 - Levers and buttons can be flipped/rotated vertically
Dieser Commit ist enthalten in:
dordsor21 2021-07-23 20:15:22 +01:00
Ursprung 0d26dad397
Commit 0be8746c11
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B

Datei anzeigen

@ -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,108 +167,118 @@ 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()) {
return adapt(UP, DOWN); case "half": {
} return adapt(UP, DOWN);
if (values.contains("left")) { }
if (key == PropertyKey.SHAPE) { case "type": {
return adapt(combine(EAST, WEST), combine(NORTH, SOUTH)); return adapt(combine(UP), combine(DOWN), 0L);
} else if (key == PropertyKey.HINGE) { }
case "rotation": {
List<Direction> directions = new ArrayList<>();
for (Object value : values) {
directions.add(Direction.fromRotationIndex((Integer) value).get());
}
return adapt(directions.toArray(new Direction[0]));
}
case "axis": {
switch (property.getValues().size()) {
case 3:
return adapt(combine(EAST, WEST), combine(UP, DOWN), combine(SOUTH, NORTH));
case 2:
return adapt(combine(EAST, WEST), combine(SOUTH, NORTH));
default:
LOGGER.error("Invalid {} {}", property.getName(), property.getValues());
return null;
}
}
case "facing": {
List<Direction> directions = new ArrayList<>();
for (Object value : values) {
directions.add(Direction.valueOf(value.toString().toUpperCase(Locale.ROOT)));
}
return adapt(directions.toArray(new Direction[0]));
}
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)); return adapt(combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST), combine(NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST));
} }
} case "shape": {
if (key == PropertyKey.ROTATION) { if (values.contains("left")) {
List<Direction> directions = new ArrayList<>(); return adapt(combine(EAST, WEST), combine(NORTH, SOUTH));
for (Object value : values) {
directions.add(Direction.fromRotationIndex((Integer) value).get());
}
return adapt(directions.toArray(new Direction[0]));
}
if (key == PropertyKey.AXIS) {
switch (property.getValues().size()) {
case 3:
return adapt(combine(EAST, WEST), combine(UP, DOWN), combine(SOUTH, NORTH));
case 2:
return adapt(combine(EAST, WEST), combine(SOUTH, NORTH));
default:
LOGGER.error("Invalid {} {}", property.getName(), property.getValues());
return null;
}
}
if (key == PropertyKey.FACING) {
List<Direction> directions = new ArrayList<>();
for (Object value : values) {
directions.add(Direction.valueOf(value.toString().toUpperCase(Locale.ROOT)));
}
return adapt(directions.toArray(new Direction[0]));
}
if (key == PropertyKey.SHAPE) {
if (values.contains("straight")) {
ArrayList<Long> result = new ArrayList<>();
for (Object value : values) {
// [straight, inner_left, inner_right, outer_left, outer_right]
switch (value.toString()) {
case "straight":
result.add(combine(NORTH, EAST, SOUTH, WEST));
continue;
case "inner_left":
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
continue;
case "inner_right":
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
continue;
case "outer_left":
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
continue;
case "outer_right":
result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
continue;
default:
LOGGER.warn("Unknown direction {}", value);
result.add(0L);
}
} }
return adapt(result.toArray(new Long[0])); if (values.contains("straight")) {
} else { ArrayList<Long> result = new ArrayList<>();
List<Long> directions = new ArrayList<>(); for (Object value : values) {
for (Object value : values) { // [straight, inner_left, inner_right, outer_left, outer_right]
switch (value.toString()) { switch (value.toString()) {
case "north_south": case "straight":
directions.add(combine(NORTH, SOUTH)); result.add(combine(NORTH, EAST, SOUTH, WEST));
break; continue;
case "east_west": case "inner_left":
directions.add(combine(EAST, WEST)); result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
break; continue;
case "ascending_east": case "inner_right":
directions.add(combine(ASCENDING_EAST)); result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("outer_right"), property.getIndexFor("outer_left")));
break; continue;
case "ascending_west": case "outer_left":
directions.add(combine(ASCENDING_WEST)); result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
break; continue;
case "ascending_north": case "outer_right":
directions.add(combine(ASCENDING_NORTH)); result.add(orIndex(combine(NORTHEAST, NORTHWEST, SOUTHWEST, SOUTHEAST), property.getIndexFor("inner_left"), property.getIndexFor("inner_right")));
break; continue;
case "ascending_south": default:
directions.add(combine(ASCENDING_SOUTH)); LOGGER.warn("Unknown direction {}", value);
break; result.add(0L);
case "south_east": }
directions.add(combine(SOUTHEAST));
break;
case "south_west":
directions.add(combine(SOUTHWEST));
break;
case "north_west":
directions.add(combine(NORTHWEST));
break;
case "north_east":
directions.add(combine(NORTHEAST));
break;
default:
LOGGER.warn("Unknown direction {}", value);
directions.add(0L);
} }
return adapt(result.toArray(new Long[0]));
} else {
List<Long> directions = new ArrayList<>();
for (Object value : values) {
switch (value.toString()) {
case "north_south":
directions.add(combine(NORTH, SOUTH));
break;
case "east_west":
directions.add(combine(EAST, WEST));
break;
case "ascending_east":
directions.add(combine(ASCENDING_EAST));
break;
case "ascending_west":
directions.add(combine(ASCENDING_WEST));
break;
case "ascending_north":
directions.add(combine(ASCENDING_NORTH));
break;
case "ascending_south":
directions.add(combine(ASCENDING_SOUTH));
break;
case "south_east":
directions.add(combine(SOUTHEAST));
break;
case "south_west":
directions.add(combine(SOUTHWEST));
break;
case "north_west":
directions.add(combine(NORTHWEST));
break;
case "north_east":
directions.add(combine(NORTHEAST));
break;
default:
LOGGER.warn("Unknown direction {}", value);
directions.add(0L);
}
}
return adapt(directions.toArray(new Long[0]));
} }
return adapt(directions.toArray(new Long[0]));
} }
} }
} }