From 74e356583a561031bfb259aa594f19aed31372c7 Mon Sep 17 00:00:00 2001 From: cup Date: Mon, 4 Aug 2025 20:51:20 +0200 Subject: [PATCH] added the ability to see players on maps inside of itemframes --- .gitignore | 3 +- README.md | 4 +++ build.gradle | 6 ++-- .../java/dev/letsgoaway/mapxyz/Config.java | 7 +++++ .../mapxyz/PlayerCursorRenderer.java | 29 ++++++++++++++++++ .../dev/letsgoaway/mapxyz/PosRenderer.java | 11 +++++-- src/main/resources/config.yml | 6 +++- src/main/resources/plugin.yml | 2 +- src/main/resources/test.png | Bin 0 -> 424 bytes 9 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/test.png diff --git a/.gitignore b/.gitignore index 2dfa67b..3cc432f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .gradle/* .idea/* -build/* \ No newline at end of file +build/* +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 41d671a..3497f17 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ enable-locator-maps: true # Make the XYZ display position show the eye level position instead of # the players feet level. This matches Legacy Console Edition but may cause confusion use-eye-level-position: false +# show players on maps inside of item frames +# barelly works lol +# requires enable-locator-maps to also be true +players-on-item-frames: false ``` ## Commands diff --git a/build.gradle b/build.gradle index 1cb8445..54f887d 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group = 'dev.letsgoaway' -version = '1.1' +version = '1.2' repositories { mavenCentral() @@ -48,8 +48,8 @@ tasks { processResources { def props = [version: version] inputs.properties props - filteringCharset 'UTF-8' + filteringCharset = 'UTF-8' filesMatching('plugin.yml') { expand props } -} +} \ No newline at end of file diff --git a/src/main/java/dev/letsgoaway/mapxyz/Config.java b/src/main/java/dev/letsgoaway/mapxyz/Config.java index 8288b27..df9f4ef 100644 --- a/src/main/java/dev/letsgoaway/mapxyz/Config.java +++ b/src/main/java/dev/letsgoaway/mapxyz/Config.java @@ -18,6 +18,8 @@ public class Config { public static boolean enableLocatorMaps = true; public static boolean useEyeLevelPosition = false; + + public static boolean playersonitemframes = false; //endregion private static FileConfiguration config; @@ -47,6 +49,10 @@ private static void updateValues() { useEyeLevelPosition = config.getBoolean("use-eye-level-position"); } + if (config.contains("players-on-item-frames", true)) { + playersonitemframes = config.getBoolean("players-on-item-frames"); + } + MapXYZ.onConfigLoad(); } @@ -57,6 +63,7 @@ private static void saveValues() { config.set("enable-reduced-debug-info", enableReducedDebugInfo); config.set("enable-locator-maps", enableLocatorMaps); config.set("use-eye-level-position", useEyeLevelPosition); + config.set("players-on-item-frames", playersonitemframes); try { config.save(MapXYZ.instance.getDataFolder().toPath().resolve("config.yml").toFile()); } catch (IOException e) { diff --git a/src/main/java/dev/letsgoaway/mapxyz/PlayerCursorRenderer.java b/src/main/java/dev/letsgoaway/mapxyz/PlayerCursorRenderer.java index 32c6023..1872b7b 100644 --- a/src/main/java/dev/letsgoaway/mapxyz/PlayerCursorRenderer.java +++ b/src/main/java/dev/letsgoaway/mapxyz/PlayerCursorRenderer.java @@ -6,6 +6,8 @@ import java.util.ArrayList; import java.util.logging.Level; +import java.io.File; +import javax.imageio.ImageIO; @SuppressWarnings("deprecation") public class PlayerCursorRenderer { @@ -24,8 +26,35 @@ public static void render(Player viewer, Player player, MapCanvas canvas, MapVie byte d = calculateRotation(player); + if (x < -62 || x > 62 || z < -62 || z > 62) + { + return; + } + + // Nether marker type matches Bedrock Edition locator maps canvas.getCursors().addCursor(new MapCursor(clampMapCoordinate(x), clampMapCoordinate(z), d, map.getWorld().getEnvironment().equals(World.Environment.NETHER) ? NETHER_MARKER_TYPE : MARKER_TYPE, true, player.getName())); + if (Config.playersonitemframes) + { + try + { + canvas.drawImage(Math.round(x) + 62, Math.round(z) + 62, ImageIO.read(MapXYZ.instance.getResource("test.png"))); + } + catch(Exception e) + { + System.out.println("error"); + } + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + if ((i == 0 || i == 2) && (j == 0 || j == 2)) + { + canvas.setPixelColor(Math.round(x) + 62 + i, Math.round(z) + 62 + j, canvas.getBasePixelColor(Math.round(x) + 62 + i, Math.round(z) + 62 + j)); + } + } + } + } } private static byte clampMapCoordinate(float coordinate) { diff --git a/src/main/java/dev/letsgoaway/mapxyz/PosRenderer.java b/src/main/java/dev/letsgoaway/mapxyz/PosRenderer.java index b35756b..dc37d90 100644 --- a/src/main/java/dev/letsgoaway/mapxyz/PosRenderer.java +++ b/src/main/java/dev/letsgoaway/mapxyz/PosRenderer.java @@ -38,18 +38,23 @@ private static int getHeldMapID(ItemStack stack) { @Override public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player) { + int ymax = 10; + if (Config.playersonitemframes) + { + ymax = 127; + } for (int x = 0; x < 127; x++) { - for (int y = 0; y < 10; y++) { + for (int y = 0; y < ymax; y++) { canvas.setPixelColor(x, y, canvas.getBasePixelColor(x, y)); } } + PlayerCursorRenderer.renderAll(player, canvas, map); + if (!Config.enableXYZDisplay) { return; } - PlayerCursorRenderer.renderAll(player, canvas, map); - /* this is for item frames, unfortunately the position is still visible if you are holding the same map of id in your hand but that's the best we can do atm diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bd8f055..2047579 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,4 +12,8 @@ enable-reduced-debug-info: true enable-locator-maps: true # Make the XYZ display position show the eye level position instead of # the players feet level. This matches Legacy Console Edition but may cause confusion -use-eye-level-position: false \ No newline at end of file +use-eye-level-position: false +# show players on maps inside of item frames +# barelly works lol +# requires enable-locator-maps to also be true +players-on-item-frames: false \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 07e7dd9..8b5dec1 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: MapXYZ -version: '1.1' +version: '1.2' main: dev.letsgoaway.mapxyz.MapXYZ api-version: '1.21' author: LetsGoAway diff --git a/src/main/resources/test.png b/src/main/resources/test.png new file mode 100644 index 0000000000000000000000000000000000000000..c2d3131e098d7070da4b4fb659682439dc30a3c9 GIT binary patch literal 424 zcmV;Z0ayNsP)EX>4Tx04R~2kg-a`P!xv0)S^Wchl+zZWDvKGW^%A91VJIj3Pz_iX|b5Zkfapf zz&Fu{=^zNcgR6qG|BVg~X7R$||2UlU|My;K*-4a^?R`kIs&M^&a2Z_LOK)^&vqqPl zFe>xD=bg}aK3}nnzVwV&^W2|jF&>qXbgs&xyr{t16FajiH>_g)cHke1AH;T?X0iB5 zyd9^pVYBO}$u#=$G`Cq9Wf$kBuiC=pm{UA#hD@1|P|=fS>Kx&)D|IOdxu+zOCXCdZ zX{O>vRLaTaKr|5PHVt{3b)Kh`p*$w?G6{F2@-%sv|NUP3IIB0Ujd>mxVcl9#wZ>z3 ze}vTly3eqD-H_G!{kDb~r=I!e8@~Yh7Eo>P-*(pk000SaNLh0L04^f{04^f|c%?sf z00007bV*G`2k8g|4-^yQ!R^Wb000=5u! SIy18X0000