|
|
|
@@ -67,9 +67,11 @@ public class VideoAnchorRenderer implements BlockEntityRenderer<VideoAnchorBlock
|
|
|
|
pose.translate(0.5F, 0.5F, 0.5F);
|
|
|
|
pose.translate(0.5F, 0.5F, 0.5F);
|
|
|
|
// 2) Rotate local +Z to align with the wall's outward normal.
|
|
|
|
// 2) Rotate local +Z to align with the wall's outward normal.
|
|
|
|
applyFaceRotation(pose, f);
|
|
|
|
applyFaceRotation(pose, f);
|
|
|
|
// 3) Center the quad on origin (local XY) and push it back 0.5 - ε so it lands on the
|
|
|
|
// 3) Place the quad's local origin (0,0) at the bottom-left corner of the anchor block's
|
|
|
|
// wall surface (the boundary face between the anchor's air block and the wall block).
|
|
|
|
// wall face, so the clicked block becomes the lower-left and the video grows up & right.
|
|
|
|
pose.translate(-w / 2.0F, -h / 2.0F, -0.5F + SURFACE_EPSILON);
|
|
|
|
// Push it onto the wall surface (-0.5 along local +Z, the outward normal) plus a tiny
|
|
|
|
|
|
|
|
// epsilon outward so the quad doesn't z-fight with the wall.
|
|
|
|
|
|
|
|
pose.translate(-0.5F, -0.5F, -0.5F + SURFACE_EPSILON);
|
|
|
|
|
|
|
|
|
|
|
|
final Matrix4f mat = new Matrix4f(pose.last().pose());
|
|
|
|
final Matrix4f mat = new Matrix4f(pose.last().pose());
|
|
|
|
RenderType rt = RenderTypes.entityCutout(tex);
|
|
|
|
RenderType rt = RenderTypes.entityCutout(tex);
|
|
|
|
@@ -89,15 +91,21 @@ public class VideoAnchorRenderer implements BlockEntityRenderer<VideoAnchorBlock
|
|
|
|
pose.popPose();
|
|
|
|
pose.popPose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Rotate so local +Z (the quad's outward normal in its base orientation) becomes world {@code f}. */
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Rotate so local +Z (the quad's outward normal in its base orientation) becomes world {@code f},
|
|
|
|
|
|
|
|
* with local +X mapped to the natural "right" direction the player sees when looking at the face.
|
|
|
|
|
|
|
|
* Derivation: for each face {@code f}, pick the rotation that maps local +Z → f, +Y → world up
|
|
|
|
|
|
|
|
* (or a sensible substitute for top/bottom), so the quad lies flush against the wall, oriented
|
|
|
|
|
|
|
|
* the way the player intuits.
|
|
|
|
|
|
|
|
*/
|
|
|
|
private static void applyFaceRotation(PoseStack pose, Direction f) {
|
|
|
|
private static void applyFaceRotation(PoseStack pose, Direction f) {
|
|
|
|
switch (f) {
|
|
|
|
switch (f) {
|
|
|
|
case SOUTH -> { /* identity: local +Z already faces world +Z (south) */ }
|
|
|
|
case SOUTH -> { /* identity: local +Z = world +Z (south). +X = east, +Y = up. */ }
|
|
|
|
case NORTH -> pose.mulPose(Axis.YP.rotationDegrees(180F));
|
|
|
|
case NORTH -> pose.mulPose(Axis.YP.rotationDegrees(180F)); // +Z → -Z, +X → -X (west)
|
|
|
|
case EAST -> pose.mulPose(Axis.YP.rotationDegrees(-90F));
|
|
|
|
case EAST -> pose.mulPose(Axis.YP.rotationDegrees(90F)); // +Z → +X, +X → -Z (north)
|
|
|
|
case WEST -> pose.mulPose(Axis.YP.rotationDegrees(90F));
|
|
|
|
case WEST -> pose.mulPose(Axis.YP.rotationDegrees(-90F)); // +Z → -X, +X → +Z (south)
|
|
|
|
case UP -> pose.mulPose(Axis.XP.rotationDegrees(-90F));
|
|
|
|
case UP -> pose.mulPose(Axis.XP.rotationDegrees(-90F)); // +Z → +Y, +Y → -Z (north)
|
|
|
|
case DOWN -> pose.mulPose(Axis.XP.rotationDegrees(90F));
|
|
|
|
case DOWN -> pose.mulPose(Axis.XP.rotationDegrees(90F)); // +Z → -Y, +Y → +Z (south)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|