From 7a667b90286b2f4e5243e128c03791becdfe5e31 Mon Sep 17 00:00:00 2001 From: Nikita Savyolov Date: Mon, 18 Oct 2021 21:45:33 +0300 Subject: [PATCH] fix: correct cable with wired modem highlight The right thing would be to fix Mixin, just like it is done in Forge, but I think that's enough for now --- src/main/java/dan200/computercraft/ComputerCraft.java | 1 - .../client/render/CableHighlightRenderer.java | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 2dc474c22..c79489d7d 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -44,7 +44,6 @@ import java.util.EnumSet; import java.util.List; import java.util.concurrent.TimeUnit; -import static dan200.computercraft.shared.ComputerCraftRegistry.ModBlocks; import static dan200.computercraft.shared.ComputerCraftRegistry.init; public final class ComputerCraft implements ModInitializer diff --git a/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java b/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java index 32965f478..ee0a1e93a 100644 --- a/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/CableHighlightRenderer.java @@ -18,6 +18,7 @@ import net.minecraft.client.render.Camera; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; +import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.*; import net.minecraft.util.shape.VoxelShape; @@ -40,8 +41,12 @@ public final class CableHighlightRenderer return false; } + HitResult hitResult = MinecraftClient.getInstance().crosshairTarget; + + Vec3d hitPos = hitResult != null ? hitResult.getPos() : new Vec3d( d, e, f ); + VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), - new Vec3d( d, e, f ).subtract( pos.getX(), + hitPos.subtract( pos.getX(), pos.getY(), pos.getZ() ) ) ? CableShapes.getModemShape( state ) : CableShapes.getCableShape( state );