added support for rotation and mirroring

This commit is contained in:
2024-05-13 12:58:42 +02:00
parent d5369823d9
commit 752ee956eb
20 changed files with 300 additions and 21 deletions

View File

@@ -1,5 +1,7 @@
package fr.adrien1106.reframed.util.blocks;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.math.Direction;
@@ -48,13 +50,19 @@ public enum Edge implements StringIdentifiable {
public Direction getSecondDirection() {
return second_direction;
}
public Direction getRightDirection() {
return Direction.from(axis, Direction.AxisDirection.NEGATIVE);
}
public Direction getLeftDirection() {
return Direction.from(axis, Direction.AxisDirection.POSITIVE);
}
public Direction getFace() {
return first_direction == Direction.UP || first_direction == Direction.DOWN ? second_direction : first_direction;
}
public boolean hasDirection(Direction direction) {
return this.first_direction.equals(direction)
|| this.second_direction.equals(direction);
@@ -97,4 +105,18 @@ public enum Edge implements StringIdentifiable {
.filter(value -> value.name().equals(name))
.findFirst().orElse(Edge.NORTH_DOWN);
}
public Edge rotate(BlockRotation rotation) {
return getByDirections(
rotation.rotate(first_direction),
rotation.rotate(second_direction)
);
}
public Edge mirror(BlockMirror mirror) {
return getByDirections(
mirror.apply(first_direction),
mirror.apply(second_direction)
);
}
}