diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java index 685323076..759d76933 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/IPlacementHelper.java @@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import java.util.Arrays; @@ -45,18 +45,18 @@ public interface IPlacementHelper { IPlacementHelper.renderArrow(VecHelper.getCenterOf(pos), VecHelper.getCenterOf(offset.getPos()), ray.getFace()); } - static void renderArrow(Vec3d center, Vec3d target, Direction arrowPlane) { + static void renderArrow(Vector3d center, Vector3d target, Direction arrowPlane) { renderArrow(center, target, arrowPlane, 1D); } - static void renderArrow(Vec3d center, Vec3d target, Direction arrowPlane, double distanceFromCenter) { - Vec3d direction = target.subtract(center).normalize(); - Vec3d facing = new Vec3d(arrowPlane.getDirectionVec()); - Vec3d start = center.add(direction); - Vec3d offset = direction.scale(distanceFromCenter-1); - Vec3d offsetA = direction.crossProduct(facing).normalize().scale(.25); - Vec3d offsetB = facing.crossProduct(direction).normalize().scale(.25); - Vec3d endA = center.add(direction.scale(.75)).add(offsetA); - Vec3d endB = center.add(direction.scale(.75)).add(offsetB); + static void renderArrow(Vector3d center, Vector3d target, Direction arrowPlane, double distanceFromCenter) { + Vector3d direction = target.subtract(center).normalize(); + Vector3d facing = Vector3d.of(arrowPlane.getDirectionVec()); + Vector3d start = center.add(direction); + Vector3d offset = direction.scale(distanceFromCenter-1); + Vector3d offsetA = direction.crossProduct(facing).normalize().scale(.25); + Vector3d offsetB = facing.crossProduct(direction).normalize().scale(.25); + Vector3d endA = center.add(direction.scale(.75)).add(offsetA); + Vector3d endB = center.add(direction.scale(.75)).add(offsetB); CreateClient.outliner.showLine("placementArrowA" + center + target, start.add(offset), endA.add(offset)).lineWidth(1/16f); CreateClient.outliner.showLine("placementArrowB" + center + target, start.add(offset), endB.add(offset)).lineWidth(1/16f); } @@ -79,31 +79,31 @@ public interface IPlacementHelper { } }*/ - static List orderedByDistanceOnlyAxis(BlockPos pos, Vec3d hit, Direction.Axis axis) { + static List orderedByDistanceOnlyAxis(BlockPos pos, Vector3d hit, Direction.Axis axis) { return orderedByDistance(pos, hit, dir -> dir.getAxis() == axis); } - static List orderedByDistanceOnlyAxis(BlockPos pos, Vec3d hit, Direction.Axis axis, Predicate includeDirection) { + static List orderedByDistanceOnlyAxis(BlockPos pos, Vector3d hit, Direction.Axis axis, Predicate includeDirection) { return orderedByDistance(pos, hit, ((Predicate) dir -> dir.getAxis() == axis).and(includeDirection)); } - static List orderedByDistanceExceptAxis(BlockPos pos, Vec3d hit, Direction.Axis axis) { + static List orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis axis) { return orderedByDistance(pos, hit, dir -> dir.getAxis() != axis); } - static List orderedByDistanceExceptAxis(BlockPos pos, Vec3d hit, Direction.Axis axis, Predicate includeDirection) { + static List orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis axis, Predicate includeDirection) { return orderedByDistance(pos, hit, ((Predicate) dir -> dir.getAxis() != axis).and(includeDirection)); } - static List orderedByDistance(BlockPos pos, Vec3d hit) { + static List orderedByDistance(BlockPos pos, Vector3d hit) { return orderedByDistance(pos, hit, _$ -> true); } - static List orderedByDistance(BlockPos pos, Vec3d hit, Predicate includeDirection) { - Vec3d centerToHit = hit.subtract(VecHelper.getCenterOf(pos)); + static List orderedByDistance(BlockPos pos, Vector3d hit, Predicate includeDirection) { + Vector3d centerToHit = hit.subtract(VecHelper.getCenterOf(pos)); return Arrays.stream(Iterate.directions) .filter(includeDirection) - .map(dir -> Pair.of(dir, new Vec3d(dir.getDirectionVec()).distanceTo(centerToHit))) + .map(dir -> Pair.of(dir, Vector3d.of(dir.getDirectionVec()).distanceTo(centerToHit))) .sorted(Comparator.comparingDouble(Pair::getSecond)) .map(Pair::getFirst) .collect(Collectors.toList()); diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java index 4d8f28faf..6b7e8818b 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/PlacementOffset.java @@ -1,31 +1,31 @@ package com.simibubi.create.foundation.utility.placement; import net.minecraft.block.BlockState; -import net.minecraft.util.math.Vec3i; +import net.minecraft.util.math.vector.Vector3i; import java.util.function.Function; public class PlacementOffset { private final boolean success; - private final Vec3i pos; + private final Vector3i pos; private final Function stateTransform; - private PlacementOffset(boolean success, Vec3i pos, Function transform) { + private PlacementOffset(boolean success, Vector3i pos, Function transform) { this.success = success; this.pos = pos; this.stateTransform = transform == null ? Function.identity() : transform; } public static PlacementOffset fail() { - return new PlacementOffset(false, Vec3i.NULL_VECTOR, null); + return new PlacementOffset(false, Vector3i.NULL_VECTOR, null); } - public static PlacementOffset success(Vec3i pos) { + public static PlacementOffset success(Vector3i pos) { return new PlacementOffset(true, pos, null); } - public static PlacementOffset success(Vec3i pos, Function transform) { + public static PlacementOffset success(Vector3i pos, Function transform) { return new PlacementOffset(true, pos, transform); } @@ -33,7 +33,7 @@ public class PlacementOffset { return success; } - public Vec3i getPos() { + public Vector3i getPos() { return pos; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java b/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java index f074a8d5c..c9f831e50 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/placement/util/PoleHelper.java @@ -5,11 +5,11 @@ import com.simibubi.create.foundation.utility.placement.IPlacementHelper; import com.simibubi.create.foundation.utility.placement.PlacementOffset; import mcp.MethodsReturnNonnullByDefault; import net.minecraft.block.BlockState; -import net.minecraft.state.IProperty; +import net.minecraft.state.Property; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.vector.Vector3d; import net.minecraft.world.World; import java.util.List; @@ -20,10 +20,10 @@ import java.util.function.Predicate; public abstract class PoleHelper> implements IPlacementHelper { protected final Predicate statePredicate; - protected final IProperty property; + protected final Property property; protected final Function axisFunction; - public PoleHelper(Predicate statePredicate, Function axisFunction, IProperty property) { + public PoleHelper(Predicate statePredicate, Function axisFunction, Property property) { this.statePredicate = statePredicate; this.axisFunction = axisFunction; this.property = property; @@ -71,7 +71,7 @@ public abstract class PoleHelper> implements IPlacementH @Override public void renderAt(BlockPos pos, BlockState state, BlockRayTraceResult ray, PlacementOffset offset) { - Vec3d centerOffset = new Vec3d(ray.getFace().getDirectionVec()).scale(.3); + Vector3d centerOffset = Vector3d.of(ray.getFace().getDirectionVec()).scale(.3); IPlacementHelper.renderArrow(VecHelper.getCenterOf(pos).add(centerOffset), VecHelper.getCenterOf(offset.getPos()).add(centerOffset), ray.getFace(), 0.75D); } }