Skip to content

Commit d05cce7

Browse files
authored
fix MC-297837 (#465)
1 parent c34ea84 commit d05cce7

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package dev.isxander.debugify.mixins.basic.mc297837;
2+
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
5+
import dev.isxander.debugify.fixes.BugFix;
6+
import dev.isxander.debugify.fixes.FixCategory;
7+
import net.minecraft.server.level.ServerPlayer;
8+
import net.minecraft.world.entity.Entity;
9+
import net.minecraft.world.entity.LivingEntity;
10+
import net.minecraft.world.waypoints.WaypointTransmitter;
11+
import org.spongepowered.asm.mixin.Mixin;
12+
import org.spongepowered.asm.mixin.injection.At;
13+
14+
@BugFix(id = "MC-297837", category = FixCategory.BASIC, env = BugFix.Env.CLIENT, description = "Locator bar shows players above you as being below you when they are high enough")
15+
@Mixin(WaypointTransmitter.class)
16+
public class WaypointTransmitterMixin {
17+
/**
18+
* {@link WaypointTransmitter#isReallyFar(LivingEntity, ServerPlayer)} was being used to determine whether
19+
* waypoints should use azimuth distance (far away) or chunk/block distance (close/closer by).
20+
* <p>
21+
* The azimuth distance provides only relative yRot, which means the pitch uses the horizon,
22+
* not the waypoint itself.
23+
* <p>
24+
* Even when the waypoint is in the same chunk as the entity, the azimuth distance was used because it was
25+
* over 332 blocks away, just vertically, not horizontally, as I assume it was intended.
26+
* <p>
27+
* This mixin fixes the bug by using the block distance instead of the azimuth distance,
28+
* by changing the distance calculation to only use horizontal distance.
29+
*/
30+
@WrapOperation(method = "isReallyFar", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;distanceTo(Lnet/minecraft/world/entity/Entity;)F"))
31+
private static float useOnlyHorizontalDistance(LivingEntity entity1, Entity entity2, Operation<Float> original) {
32+
double xDist = entity1.getX() - entity2.getX();
33+
double zDist = entity1.getZ() - entity2.getZ();
34+
return (float) Math.hypot(xDist, zDist);
35+
}
36+
37+
}

src/main/resources/debugify.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"basic.mc268617.FileUtilMixin",
5959
"basic.mc271899.StructureTemplateMixin",
6060
"basic.mc272431.EnderDragonMixin",
61+
"basic.mc297837.WaypointTransmitterMixin",
6162
"basic.mc298066.LivingEntityMixin",
6263
"basic.mc299115.ProjectileMixin",
6364
"basic.mc30391.LivingEntityMixin",

0 commit comments

Comments
 (0)