From 867b7b3484f63bcea1e2ca55361c33f3bd3a00ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= Date: Mon, 26 Feb 2024 19:25:46 +0100 Subject: [PATCH] Fixed rendering with high view distance - Updated WorldAreaId class > Fixes #113 --- .../bukkit/plugin/renderer/WorldAreaId.java | 271 +++++++++++++----- 1 file changed, 198 insertions(+), 73 deletions(-) diff --git a/src/main/java/io/josemmo/bukkit/plugin/renderer/WorldAreaId.java b/src/main/java/io/josemmo/bukkit/plugin/renderer/WorldAreaId.java index 9c44a86..76ded50 100644 --- a/src/main/java/io/josemmo/bukkit/plugin/renderer/WorldAreaId.java +++ b/src/main/java/io/josemmo/bukkit/plugin/renderer/WorldAreaId.java @@ -76,99 +76,68 @@ public WorldAreaId(@NotNull World world, int x, int z) { return distance / 4; }); - // Size 3 (16-chunks radius) - // ···XXX··· - // ·XXXXXXX· - // ·XXXXXXX· - // XXXXXXXXX - // XXXXOXXXX - // XXXXXXXXX - // ·XXXXXXX· - // ·XXXXXXX· - // ···XXX··· - if (size == 3) { + // Size 0 (1+1+1=3) + // ·|· + // XOX + // ·|· + if (size == 0) { neighborhood = new WorldAreaId[]{ - new WorldAreaId(world, x-1, z-4), - new WorldAreaId(world, x, z-4), - new WorldAreaId(world, x+1, z-4), + new WorldAreaId(world, x, z-1), - new WorldAreaId(world, x-3, z-3), - new WorldAreaId(world, x-2, z-3), - new WorldAreaId(world, x-1, z-3), - new WorldAreaId(world, x, z-3), - new WorldAreaId(world, x+1, z-3), - new WorldAreaId(world, x+2, z-3), - new WorldAreaId(world, x+3, z-3), + new WorldAreaId(world, x-1, z), + this, + new WorldAreaId(world, x+1, z), - new WorldAreaId(world, x-3, z-2), - new WorldAreaId(world, x-2, z-2), + new WorldAreaId(world, x, z+1), + }; + return neighborhood; + } + + // Size 1 (2+1+2=5) + // ·X|X· + // XX|XX + // XXOXX + // XX|XX + // ·X|X· + if (size == 1) { + neighborhood = new WorldAreaId[]{ new WorldAreaId(world, x-1, z-2), new WorldAreaId(world, x, z-2), new WorldAreaId(world, x+1, z-2), - new WorldAreaId(world, x+2, z-2), - new WorldAreaId(world, x+3, z-2), - new WorldAreaId(world, x-4, z-1), - new WorldAreaId(world, x-3, z-1), new WorldAreaId(world, x-2, z-1), new WorldAreaId(world, x-1, z-1), new WorldAreaId(world, x, z-1), new WorldAreaId(world, x+1, z-1), new WorldAreaId(world, x+2, z-1), - new WorldAreaId(world, x+3, z-1), - new WorldAreaId(world, x+4, z-1), - new WorldAreaId(world, x-4, z), - new WorldAreaId(world, x-3, z), new WorldAreaId(world, x-2, z), new WorldAreaId(world, x-1, z), this, new WorldAreaId(world, x+1, z), new WorldAreaId(world, x+2, z), - new WorldAreaId(world, x+3, z), - new WorldAreaId(world, x+4, z), - new WorldAreaId(world, x-4, z+1), - new WorldAreaId(world, x-3, z+1), new WorldAreaId(world, x-2, z+1), new WorldAreaId(world, x-1, z+1), new WorldAreaId(world, x, z+1), new WorldAreaId(world, x+1, z+1), new WorldAreaId(world, x+2, z+1), - new WorldAreaId(world, x+3, z+1), - new WorldAreaId(world, x+4, z+1), - new WorldAreaId(world, x-3, z+2), - new WorldAreaId(world, x-2, z+2), new WorldAreaId(world, x-1, z+2), new WorldAreaId(world, x, z+2), new WorldAreaId(world, x+1, z+2), - new WorldAreaId(world, x+2, z+2), - new WorldAreaId(world, x+3, z+2), - - new WorldAreaId(world, x-3, z+3), - new WorldAreaId(world, x-2, z+3), - new WorldAreaId(world, x-1, z+3), - new WorldAreaId(world, x, z+3), - new WorldAreaId(world, x+1, z+3), - new WorldAreaId(world, x+2, z+3), - new WorldAreaId(world, x+3, z+3), - - new WorldAreaId(world, x-1, z+4), - new WorldAreaId(world, x, z+4), - new WorldAreaId(world, x+1, z+4), }; return neighborhood; } - // Size 2 (12-chunks radius) - // ··XXX·· - // ·XXXXX· - // XXXXXXX + // Size 2 (3+1+3=7) + // ··X|X·· + // ·XX|XX· + // XXX|XXX // XXXOXXX - // XXXXXXX - // ·XXXXX· - // ··XXX·· + // XXX|XXX + // ·XX|XX· + // ··X|X·· if (size == 2) { neighborhood = new WorldAreaId[]{ new WorldAreaId(world, x-1, z-3), @@ -218,55 +187,211 @@ public WorldAreaId(@NotNull World world, int x, int z) { return neighborhood; } - //// Size 1 (8-chunks radius) - // ·XXX· - // XXXXX - // XXOXX - // XXXXX - // ·XXX· - if (size == 1) { + // Size 3 (4+1+4=9) + // ···X|X··· + // ·XXX|XXX· + // ·XXX|XXX· + // XXXX|XXXX + // XXXXOXXXX + // XXXX|XXXX + // ·XXX|XXX· + // ·XXX|XXX· + // ···X|X··· + if (size == 3) { neighborhood = new WorldAreaId[]{ + new WorldAreaId(world, x-1, z-4), + new WorldAreaId(world, x, z-4), + new WorldAreaId(world, x+1, z-4), + + new WorldAreaId(world, x-3, z-3), + new WorldAreaId(world, x-2, z-3), + new WorldAreaId(world, x-1, z-3), + new WorldAreaId(world, x, z-3), + new WorldAreaId(world, x+1, z-3), + new WorldAreaId(world, x+2, z-3), + new WorldAreaId(world, x+3, z-3), + + new WorldAreaId(world, x-3, z-2), + new WorldAreaId(world, x-2, z-2), new WorldAreaId(world, x-1, z-2), new WorldAreaId(world, x, z-2), new WorldAreaId(world, x+1, z-2), + new WorldAreaId(world, x+2, z-2), + new WorldAreaId(world, x+3, z-2), + new WorldAreaId(world, x-4, z-1), + new WorldAreaId(world, x-3, z-1), new WorldAreaId(world, x-2, z-1), new WorldAreaId(world, x-1, z-1), new WorldAreaId(world, x, z-1), new WorldAreaId(world, x+1, z-1), new WorldAreaId(world, x+2, z-1), + new WorldAreaId(world, x+3, z-1), + new WorldAreaId(world, x+4, z-1), + new WorldAreaId(world, x-4, z), + new WorldAreaId(world, x-3, z), new WorldAreaId(world, x-2, z), new WorldAreaId(world, x-1, z), this, new WorldAreaId(world, x+1, z), new WorldAreaId(world, x+2, z), + new WorldAreaId(world, x+3, z), + new WorldAreaId(world, x+4, z), + new WorldAreaId(world, x-4, z+1), + new WorldAreaId(world, x-3, z+1), new WorldAreaId(world, x-2, z+1), new WorldAreaId(world, x-1, z+1), new WorldAreaId(world, x, z+1), new WorldAreaId(world, x+1, z+1), new WorldAreaId(world, x+2, z+1), + new WorldAreaId(world, x+3, z+1), + new WorldAreaId(world, x+4, z+1), + new WorldAreaId(world, x-3, z+2), + new WorldAreaId(world, x-2, z+2), new WorldAreaId(world, x-1, z+2), new WorldAreaId(world, x, z+2), new WorldAreaId(world, x+1, z+2), + new WorldAreaId(world, x+2, z+2), + new WorldAreaId(world, x+3, z+2), + + new WorldAreaId(world, x-3, z+3), + new WorldAreaId(world, x-2, z+3), + new WorldAreaId(world, x-1, z+3), + new WorldAreaId(world, x, z+3), + new WorldAreaId(world, x+1, z+3), + new WorldAreaId(world, x+2, z+3), + new WorldAreaId(world, x+3, z+3), + + new WorldAreaId(world, x-1, z+4), + new WorldAreaId(world, x, z+4), + new WorldAreaId(world, x+1, z+4), }; return neighborhood; } - //// Size 0 (4x4 chunks) - // ·X· - // XOX - // ·X· + // Size ≥4 (5+1+5=11) + // ···XX|XX··· + // ··XXX|XXX·· + // ·XXXX|XXXX· + // XXXXX|XXXXX + // XXXXX|XXXXX + // XXXXXOXXXXX + // XXXXX|XXXXX + // XXXXX|XXXXX + // ·XXXX|XXXX· + // ··XXX|XXX·· + // ···XX|XX··· neighborhood = new WorldAreaId[]{ + new WorldAreaId(world, x-2, z-5), + new WorldAreaId(world, x-1, z-5), + new WorldAreaId(world, x, z-5), + new WorldAreaId(world, x+1, z-5), + new WorldAreaId(world, x+2, z-5), + + new WorldAreaId(world, x-3, z-4), + new WorldAreaId(world, x-2, z-4), + new WorldAreaId(world, x-1, z-4), + new WorldAreaId(world, x, z-4), + new WorldAreaId(world, x+1, z-4), + new WorldAreaId(world, x+2, z-4), + new WorldAreaId(world, x+3, z-4), + + new WorldAreaId(world, x-4, z-3), + new WorldAreaId(world, x-3, z-3), + new WorldAreaId(world, x-2, z-3), + new WorldAreaId(world, x-1, z-3), + new WorldAreaId(world, x, z-3), + new WorldAreaId(world, x+1, z-3), + new WorldAreaId(world, x+2, z-3), + new WorldAreaId(world, x+3, z-3), + new WorldAreaId(world, x+4, z-3), + + new WorldAreaId(world, x-5, z-2), + new WorldAreaId(world, x-4, z-2), + new WorldAreaId(world, x-3, z-2), + new WorldAreaId(world, x-2, z-2), + new WorldAreaId(world, x-1, z-2), + new WorldAreaId(world, x, z-2), + new WorldAreaId(world, x+1, z-2), + new WorldAreaId(world, x+2, z-2), + new WorldAreaId(world, x+3, z-2), + new WorldAreaId(world, x+4, z-2), + new WorldAreaId(world, x+5, z-2), + + new WorldAreaId(world, x-5, z-1), + new WorldAreaId(world, x-4, z-1), + new WorldAreaId(world, x-3, z-1), + new WorldAreaId(world, x-2, z-1), + new WorldAreaId(world, x-1, z-1), new WorldAreaId(world, x, z-1), - + new WorldAreaId(world, x+1, z-1), + new WorldAreaId(world, x+2, z-1), + new WorldAreaId(world, x+3, z-1), + new WorldAreaId(world, x+4, z-1), + new WorldAreaId(world, x+5, z-1), + + new WorldAreaId(world, x-5, z), + new WorldAreaId(world, x-4, z), + new WorldAreaId(world, x-3, z), + new WorldAreaId(world, x-2, z), new WorldAreaId(world, x-1, z), this, new WorldAreaId(world, x+1, z), - + new WorldAreaId(world, x+2, z), + new WorldAreaId(world, x+3, z), + new WorldAreaId(world, x+4, z), + new WorldAreaId(world, x+5, z), + + new WorldAreaId(world, x-5, z+1), + new WorldAreaId(world, x-4, z+1), + new WorldAreaId(world, x-3, z+1), + new WorldAreaId(world, x-2, z+1), + new WorldAreaId(world, x-1, z+1), new WorldAreaId(world, x, z+1), + new WorldAreaId(world, x+1, z+1), + new WorldAreaId(world, x+2, z+1), + new WorldAreaId(world, x+3, z+1), + new WorldAreaId(world, x+4, z+1), + new WorldAreaId(world, x+5, z+1), + + new WorldAreaId(world, x-5, z+2), + new WorldAreaId(world, x-4, z+2), + new WorldAreaId(world, x-3, z+2), + new WorldAreaId(world, x-2, z+2), + new WorldAreaId(world, x-1, z+2), + new WorldAreaId(world, x, z+2), + new WorldAreaId(world, x+1, z+2), + new WorldAreaId(world, x+2, z+2), + new WorldAreaId(world, x+3, z+2), + new WorldAreaId(world, x+4, z+2), + new WorldAreaId(world, x+5, z+2), + + new WorldAreaId(world, x-4, z+3), + new WorldAreaId(world, x-3, z+3), + new WorldAreaId(world, x-2, z+3), + new WorldAreaId(world, x-1, z+3), + new WorldAreaId(world, x, z+3), + new WorldAreaId(world, x+1, z+3), + new WorldAreaId(world, x+2, z+3), + new WorldAreaId(world, x+3, z+3), + new WorldAreaId(world, x+4, z+3), + + new WorldAreaId(world, x-3, z+4), + new WorldAreaId(world, x-2, z+4), + new WorldAreaId(world, x-1, z+4), + new WorldAreaId(world, x, z+4), + new WorldAreaId(world, x+1, z+4), + new WorldAreaId(world, x+2, z+4), + new WorldAreaId(world, x+3, z+4), + + new WorldAreaId(world, x-2, z+5), + new WorldAreaId(world, x-1, z+5), + new WorldAreaId(world, x, z+5), + new WorldAreaId(world, x+1, z+5), + new WorldAreaId(world, x+2, z+5), }; return neighborhood; }