|
9 | 9 | import nekiplay.meteorplus.features.modules.integrations.MapIntegration; |
10 | 10 | import net.minecraft.client.gui.screen.Screen; |
11 | 11 | import net.minecraft.util.math.BlockPos; |
| 12 | +import net.minecraft.util.math.Vec3d; |
12 | 13 | import org.spongepowered.asm.mixin.Mixin; |
13 | 14 | import org.spongepowered.asm.mixin.injection.At; |
14 | 15 | import org.spongepowered.asm.mixin.injection.Inject; |
|
23 | 24 |
|
24 | 25 | import java.util.ArrayList; |
25 | 26 |
|
| 27 | +import static meteordevelopment.meteorclient.MeteorClient.mc; |
| 28 | + |
26 | 29 | @Mixin(WaypointReader.class) |
27 | 30 | public class WaypointRendererMixin { |
28 | 31 | @Inject(method = "getRightClickOptions(Lxaero/map/mods/gui/Waypoint;Lxaero/map/gui/IRightClickableElement;)Ljava/util/ArrayList;", at = @At("HEAD"), remap = false, cancellable = true) |
@@ -87,6 +90,33 @@ public boolean isActive() { |
87 | 90 | } |
88 | 91 | }).setNameFormatArgs(new Object[]{"P"})); |
89 | 92 | } |
| 93 | + |
| 94 | + rightClickOptions.add((new RightClickOption("gui.world_map.look_at_waypoint", rightClickOptions.size(), target) { |
| 95 | + public void onAction(Screen screen) { |
| 96 | + Vec3d playerPos = mc.player.getPos(); |
| 97 | + Vec3d blockCenter = new Vec3d( |
| 98 | + element.getX() + 0.5, |
| 99 | + element.getY() + 0.5, |
| 100 | + element.getZ() + 0.5 |
| 101 | + ); |
| 102 | + |
| 103 | + // Вычисляем вектор направления от игрока к блоку |
| 104 | + Vec3d direction = blockCenter.subtract(playerPos).normalize(); |
| 105 | + |
| 106 | + // Преобразуем вектор направления в углы поворота (yaw и pitch) |
| 107 | + double distanceXZ = Math.sqrt(direction.x * direction.x + direction.z * direction.z); |
| 108 | + float yaw = (float)Math.toDegrees(Math.atan2(direction.z, direction.x)) - 90.0F; |
| 109 | + float pitch = (float)Math.toDegrees(-Math.atan2(direction.y, distanceXZ)); |
| 110 | + |
| 111 | + // Устанавливаем поворот игрока |
| 112 | + mc.player.setYaw(yaw); |
| 113 | + mc.player.setPitch(pitch); |
| 114 | + } |
| 115 | + |
| 116 | + public boolean isActive() { |
| 117 | + return true; |
| 118 | + } |
| 119 | + }).setNameFormatArgs(new Object[]{"P"})); |
90 | 120 | } |
91 | 121 |
|
92 | 122 | rightClickOptions.add((new RightClickOption("gui.xaero_right_click_waypoint_teleport", rightClickOptions.size(), target) { |
|
0 commit comments