Add some better position transformers
import org.spongepowered.math.imaginary.Quaterniond;
import org.spongepowered.math.vector.Vector3i;
+import java.util.Objects;
import java.util.function.Function;
public final class VolumePositionTranslators {
};
}
+ public static <W extends Volume, E> VolumePositionTranslator<W, E> relativeTo(final Vector3i newOrigin) {
+ return element -> VolumeElement.of(element.getVolume(), element.getType(), element.getPosition().add(newOrigin));
+ }
+
+ public static <W extends Volume, E> VolumePositionTranslator<W, E> offset(final Vector3i min) {
+ return element -> VolumeElement.of(element.getVolume(), element.getType(), element.getPosition().sub(min));
+ }
+
+ public static <W extends Volume, E> VolumePositionTranslator<W, E> position(final Function<Vector3i, Vector3i> func) {
+ Objects.requireNonNull(func, "Position function cannot be null!");
+ return element -> VolumeElement.of(element.getVolume(), element.getType(), func.apply(element.getPosition()));
+ }
+
public static <W extends Volume, E> VolumePositionTranslator<W, E> offsetPosition(final Vector3i origin,
Vector3i originalOrigin
) {
