diff --git a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java index 37978e7a8..731838dc7 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/PonderScene.java @@ -35,7 +35,6 @@ import com.simibubi.create.foundation.ponder.ui.PonderUI; import com.simibubi.create.foundation.render.ForcedDiffuseState; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.animation.LerpedFloat; @@ -135,14 +134,14 @@ public class PonderScene { } public Pair rayTraceScene(Vec3 from, Vec3 to) { - MutableObject>> nearestHit = new MutableObject<>(); + MutableObject>> nearestHit = new MutableObject<>(); MutableDouble bestDistance = new MutableDouble(0); forEach(WorldSectionElement.class, wse -> { wse.resetSelectedBlock(); if (!wse.isVisible()) return; - Pair rayTrace = wse.rayTrace(world, from, to); + Pair rayTrace = wse.rayTrace(world, from, to); if (rayTrace == null) return; double distanceTo = rayTrace.getFirst() @@ -157,13 +156,10 @@ public class PonderScene { if (nearestHit.getValue() == null) return Pair.of(ItemStack.EMPTY, null); - Pair selectedHit = nearestHit.getValue() + Pair selectedHit = nearestHit.getValue() .getSecond(); BlockPos selectedPos = selectedHit.getSecond() - .getPos(); - Direction selectedFace = selectedHit.getSecond() - .getFace(); - Vec3 selectedVec = selectedHit.getFirst(); + .getBlockPos(); BlockPos origin = new BlockPos(basePlateOffsetX, 0, basePlateOffsetZ); if (!world.getBounds() @@ -182,9 +178,14 @@ public class PonderScene { .getFirst() .selectBlock(selectedPos); BlockState blockState = world.getBlockState(selectedPos); - ItemStack pickBlock = - blockState.getCloneItemStack(new BlockHitResult(selectedVec, selectedFace, selectedPos, true), world, - selectedPos, Minecraft.getInstance().player); + + Direction direction = selectedHit.getSecond() + .getDirection(); + Vec3 location = selectedHit.getSecond() + .getLocation(); + + ItemStack pickBlock = blockState.getCloneItemStack(new BlockHitResult(location, direction, selectedPos, true), + world, selectedPos, Minecraft.getInstance().player); return Pair.of(pickBlock, selectedPos); } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java b/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java index 19056286d..a4bfb3537 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/element/WorldSectionElement.java @@ -26,7 +26,6 @@ import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.TileEntityRenderHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; -import com.simibubi.create.foundation.utility.BlockFace; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.outliner.AABBOutline; @@ -182,7 +181,7 @@ public class WorldSectionElement extends AnimatedSceneElement { BlockPos worldPos; } - public Pair rayTrace(PonderWorld world, Vec3 source, Vec3 target) { + public Pair rayTrace(PonderWorld world, Vec3 source, Vec3 target) { world.setMask(this.section); Vec3 transformedTarget = reverseTransformVec(target); BlockHitResult rayTraceBlocks = world.clip(new ClipContext(reverseTransformVec(source), transformedTarget, @@ -200,7 +199,7 @@ public class WorldSectionElement extends AnimatedSceneElement { / source.subtract(target) .lengthSqr(); Vec3 actualHit = VecHelper.lerp((float) t, target, source); - return Pair.of(actualHit, new BlockFace(rayTraceBlocks.getBlockPos(), rayTraceBlocks.getDirection())); + return Pair.of(actualHit, rayTraceBlocks); } private Vec3 reverseTransformVec(Vec3 in) {