mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 10:53:44 +01:00
Port recent changes
This commit is contained in:
parent
51229ce517
commit
1cdfa6c17e
3 changed files with 31 additions and 31 deletions
|
@ -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<Direction> orderedByDistanceOnlyAxis(BlockPos pos, Vec3d hit, Direction.Axis axis) {
|
||||
static List<Direction> orderedByDistanceOnlyAxis(BlockPos pos, Vector3d hit, Direction.Axis axis) {
|
||||
return orderedByDistance(pos, hit, dir -> dir.getAxis() == axis);
|
||||
}
|
||||
|
||||
static List<Direction> orderedByDistanceOnlyAxis(BlockPos pos, Vec3d hit, Direction.Axis axis, Predicate<Direction> includeDirection) {
|
||||
static List<Direction> orderedByDistanceOnlyAxis(BlockPos pos, Vector3d hit, Direction.Axis axis, Predicate<Direction> includeDirection) {
|
||||
return orderedByDistance(pos, hit, ((Predicate<Direction>) dir -> dir.getAxis() == axis).and(includeDirection));
|
||||
}
|
||||
|
||||
static List<Direction> orderedByDistanceExceptAxis(BlockPos pos, Vec3d hit, Direction.Axis axis) {
|
||||
static List<Direction> orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis axis) {
|
||||
return orderedByDistance(pos, hit, dir -> dir.getAxis() != axis);
|
||||
}
|
||||
|
||||
static List<Direction> orderedByDistanceExceptAxis(BlockPos pos, Vec3d hit, Direction.Axis axis, Predicate<Direction> includeDirection) {
|
||||
static List<Direction> orderedByDistanceExceptAxis(BlockPos pos, Vector3d hit, Direction.Axis axis, Predicate<Direction> includeDirection) {
|
||||
return orderedByDistance(pos, hit, ((Predicate<Direction>) dir -> dir.getAxis() != axis).and(includeDirection));
|
||||
}
|
||||
|
||||
static List<Direction> orderedByDistance(BlockPos pos, Vec3d hit) {
|
||||
static List<Direction> orderedByDistance(BlockPos pos, Vector3d hit) {
|
||||
return orderedByDistance(pos, hit, _$ -> true);
|
||||
}
|
||||
|
||||
static List<Direction> orderedByDistance(BlockPos pos, Vec3d hit, Predicate<Direction> includeDirection) {
|
||||
Vec3d centerToHit = hit.subtract(VecHelper.getCenterOf(pos));
|
||||
static List<Direction> orderedByDistance(BlockPos pos, Vector3d hit, Predicate<Direction> 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());
|
||||
|
|
|
@ -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<BlockState, BlockState> stateTransform;
|
||||
|
||||
private PlacementOffset(boolean success, Vec3i pos, Function<BlockState, BlockState> transform) {
|
||||
private PlacementOffset(boolean success, Vector3i pos, Function<BlockState, BlockState> 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<BlockState, BlockState> transform) {
|
||||
public static PlacementOffset success(Vector3i pos, Function<BlockState, BlockState> transform) {
|
||||
return new PlacementOffset(true, pos, transform);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class PlacementOffset {
|
|||
return success;
|
||||
}
|
||||
|
||||
public Vec3i getPos() {
|
||||
public Vector3i getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<T extends Comparable<T>> implements IPlacementHelper {
|
||||
|
||||
protected final Predicate<BlockState> statePredicate;
|
||||
protected final IProperty<T> property;
|
||||
protected final Property<T> property;
|
||||
protected final Function<BlockState, Direction.Axis> axisFunction;
|
||||
|
||||
public PoleHelper(Predicate<BlockState> statePredicate, Function<BlockState, Direction.Axis> axisFunction, IProperty<T> property) {
|
||||
public PoleHelper(Predicate<BlockState> statePredicate, Function<BlockState, Direction.Axis> axisFunction, Property<T> property) {
|
||||
this.statePredicate = statePredicate;
|
||||
this.axisFunction = axisFunction;
|
||||
this.property = property;
|
||||
|
@ -71,7 +71,7 @@ public abstract class PoleHelper<T extends Comparable<T>> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue