From 92bd6924b0d58a1227d11717288be2f7143811e8 Mon Sep 17 00:00:00 2001 From: GiantLuigi4 <49770992+GiantLuigi4@users.noreply.github.com> Date: Sat, 11 Nov 2023 17:59:15 -0500 Subject: [PATCH] undo cleanup of mouse handling, because it did not work --- .../java/net/montoyo/wd/block/ScreenBlock.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/montoyo/wd/block/ScreenBlock.java b/src/main/java/net/montoyo/wd/block/ScreenBlock.java index 0e2064c..9c34fbb 100644 --- a/src/main/java/net/montoyo/wd/block/ScreenBlock.java +++ b/src/main/java/net/montoyo/wd/block/ScreenBlock.java @@ -200,15 +200,21 @@ public class ScreenBlock extends BaseEntityBlock { } public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, ScreenBlockEntity.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) { + if(side.right.x < 0) + hitX -= 1.f; + + if(side.right.z < 0 || side == BlockSide.TOP || side == BlockSide.BOTTOM) + hitZ -= 1.f; + Vector3f rel = new Vector3f(hitX, hitY, hitZ); - // how these dot products come in is beyond me - float cx = rel.dot(side.horizontal.toFloat()) - 2.f / 16.f; - float cy = rel.dot(side.vertical.toFloat()) - 2.f / 16.f; + float cx = rel.dot(side.right.toFloat()) - 2.f / 16.f; + float cy = rel.dot(side.up.toFloat()) - 2.f / 16.f; + float sw = ((float) scr.size.x) - 4.f / 16.f; + float sh = ((float) scr.size.y) - 4.f / 16.f; - // scale coordinate to be in the size mcef expects (0 -> 1) - cx /= ((float) scr.size.x) - 4.f / 16.f; - cy /= ((float) scr.size.y) - 4.f / 16.f; + cx /= sw; + cy /= sh; if (cx >= 0.f && cx <= 1.0 && cy >= 0.f && cy <= 1.f) { if (side != BlockSide.BOTTOM)