Draw players as facing arrows on the map

The studio map showed players as plain dots. A blue arrow with a white edge and dark outline now points where the player looks, with the name in a pill above, readable on any terrain. Markers carry a yaw (rounded to 5 degrees so head turns do not flood the players event); entities keep their dot.

v3: 3914c4667
This commit is contained in:
piexel committed 2026-11-10 11:26:49 +01:00
1 parent 76dcab175b
commit d28b9d13cc
8 files changed
+174 -25

No files matched your search

@@ -18,12 +18,18 @@
package art.arcane.iris.core.gui;
public record GuiMarker(String label, double worldX, double worldY, double worldZ, double health, double maxHealth) {
public static GuiMarker player(String name, double worldX, double worldZ) {
return new GuiMarker(name, worldX, 0, worldZ, 0, 0);
/**
* @param yaw the way it faces, in Minecraft's degrees: 0 is south, 90 is west
*/
public record GuiMarker(String label, double worldX, double worldY, double worldZ, float yaw, double health, double maxHealth) {
static final float YAW_STEP_DEGREES = 5F;
/** The yaw is rounded to {@link #YAW_STEP_DEGREES}, so a turning head does not resend the player every poll. */
public static GuiMarker player(String name, double worldX, double worldZ, float yaw) {
return new GuiMarker(name, worldX, 0, worldZ, Math.round(yaw / YAW_STEP_DEGREES) * YAW_STEP_DEGREES, 0, 0);
}
public static GuiMarker entity(String label, double worldX, double worldY, double worldZ, double health, double maxHealth) {
return new GuiMarker(label, worldX, worldY, worldZ, health, maxHealth);
return new GuiMarker(label, worldX, worldY, worldZ, 0F, health, maxHealth);
}
}
@@ -0,0 +1,44 @@
/*
* Iris is a World Generator for Minecraft Servers
* Copyright (c) 2026 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package art.arcane.iris.core.gui;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class GuiMarkerTest {
private static final float EXACT = 0F;
@Test
public void playerYawIsRoundedToTheStep() {
assertEquals(90F, GuiMarker.player("a", 0, 0, 91.4F).yaw(), EXACT);
assertEquals(95F, GuiMarker.player("a", 0, 0, 92.6F).yaw(), EXACT);
assertEquals(-45F, GuiMarker.player("a", 0, 0, -44F).yaw(), EXACT);
}
@Test
public void nearbyYawsCompareEqualSoTurningSlightlyResendsNothing() {
assertEquals(GuiMarker.player("a", 1, 2, 180.2F), GuiMarker.player("a", 1, 2, 181.9F));
}
@Test
public void entitiesHaveNoFacing() {
assertEquals(0F, GuiMarker.entity("zombie", 0, 64, 0, 20, 20).yaw(), EXACT);
}
}