88import com .hypixel .hytale .math .util .MathUtil ;
99import com .hypixel .hytale .math .vector .Vector3d ;
1010import com .hypixel .hytale .protocol .Packet ;
11+ import com .hypixel .hytale .protocol .packets .worldmap .ClearWorldMap ;
1112import com .hypixel .hytale .protocol .packets .worldmap .MapChunk ;
1213import com .hypixel .hytale .protocol .packets .worldmap .MapImage ;
1314import com .hypixel .hytale .protocol .packets .worldmap .UpdateWorldMap ;
1718import com .hypixel .hytale .server .core .universe .world .WorldMapTracker ;
1819import com .hypixel .hytale .server .core .universe .world .worldmap .WorldMapManager ;
1920import com .hypixel .hytale .server .core .universe .world .worldmap .WorldMapSettings ;
21+ import com .hypixel .hytale .server .core .universe .world .worldmap .markers .MapMarkerTracker ;
2022import dev .cerus .explorersmap .ExplorersMapPlugin ;
2123import dev .cerus .explorersmap .config .ExplorersMapConfig ;
2224import dev .cerus .explorersmap .storage .ExplorationData ;
2527import it .unimi .dsi .fastutil .longs .LongIterator ;
2628import it .unimi .dsi .fastutil .longs .LongSet ;
2729import java .lang .reflect .Field ;
28- import java .lang .reflect .InvocationTargetException ;
29- import java .lang .reflect .Method ;
3030import java .util .ArrayList ;
3131import java .util .Iterator ;
3232import java .util .List ;
@@ -46,20 +46,18 @@ public class CustomWorldMapTracker extends WorldMapTracker {
4646 private static final Pattern INSTANCE_SUFFIX_PATTERN = Pattern .compile ("-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" );
4747 private static final int UNLOAD_RATE = 100 ;
4848
49- private static Method POI_UPDATE_METHOD ;
5049 private static Field TRANSFORM_COMPONENT_FIELD ;
50+ private static Field MARKER_TRACKER_FIELD ;
5151
5252 static {
5353 try {
54- POI_UPDATE_METHOD = WorldMapTracker .class .getDeclaredMethod ( "updatePointsOfInterest" , World . class , int . class , int . class , int . class );
55- POI_UPDATE_METHOD .setAccessible (true );
54+ MARKER_TRACKER_FIELD = WorldMapTracker .class .getDeclaredField ( "markerTracker" );
55+ MARKER_TRACKER_FIELD .setAccessible (true );
5656
5757 TRANSFORM_COMPONENT_FIELD = WorldMapTracker .class .getDeclaredField ("transformComponent" );
5858 TRANSFORM_COMPONENT_FIELD .setAccessible (true );
59- } catch (NoSuchMethodException e ) {
60- LOGGER .atSevere ().log ("Failed to find updatePointsOfInterest()" , e );
6159 } catch (NoSuchFieldException e ) {
62- LOGGER .atSevere ().log ("Failed to find transformComponent field " , e );
60+ LOGGER .atSevere ().log ("Failed to find required fields " , e );
6361 }
6462 }
6563
@@ -70,6 +68,7 @@ public class CustomWorldMapTracker extends WorldMapTracker {
7068 private final CircleSpiralIterator spiralIterator = new CircleSpiralIterator ();
7169 private final HLongSet loaded = new HLongOpenHashSet ();
7270 private final HLongSet pendingReloadChunks = new HLongOpenHashSet ();
71+ private MapMarkerTracker mapMarkerTracker ;
7372
7473 // FIXED: Atomic reference to store position data pushed from the World Thread
7574 private final AtomicReference <TransformComponent > transformRef = new AtomicReference <>(null );
@@ -84,6 +83,12 @@ public CustomWorldMapTracker(Player player) {
8483 super (player );
8584 this .config = ExplorersMapPlugin .getInstance ().getConfig ().get ();
8685 this .currentResolution = config .getResolution ();
86+
87+ try {
88+ this .mapMarkerTracker = (MapMarkerTracker ) MARKER_TRACKER_FIELD .get (this );
89+ } catch (IllegalAccessException e ) {
90+ LOGGER .atSevere ().log ("Failed to access mapMarkerTracker" , e );
91+ }
8792 }
8893
8994 public void tick (float dt ) {
@@ -150,12 +155,8 @@ private void tick0(float dt) {
150155 }
151156 }
152157
153- if (world .isCompassUpdating ()) {
154- try {
155- POI_UPDATE_METHOD .invoke (this , world , viewRadius , playerChunkX , playerChunkZ );
156- } catch (IllegalAccessException | InvocationTargetException e ) {
157- LOGGER .atSevere ().log ("Failed to invoke updatePointsOfInterest()" , e );
158- }
158+ if (world .isCompassUpdating () && mapMarkerTracker != null ) {
159+ mapMarkerTracker .updatePointsOfInterest (dt , world , viewRadius , playerChunkX , playerChunkZ );
159160 }
160161
161162 if (worldMapManager .isWorldMapEnabled ()) {
@@ -359,23 +360,7 @@ public void reset(boolean unload) {
359360
360361 try {
361362 if (unload ) {
362- int imageSize = MathUtil .fastFloor (32.0F * currentResolution .getScale ());
363- int fullMapChunkSize = 23 + 4 * imageSize * imageSize ;
364- int packetSize = 2621427 ;
365-
366- MapImage mapImage = new MapImage (imageSize , imageSize , new int [imageSize * imageSize ]);
367-
368- List <MapChunk > toRemove = new ArrayList <>();
369- for (long index : loaded ) {
370- toRemove .add (new MapChunk (ChunkUtil .xOfChunkIndex (index ), ChunkUtil .zOfChunkIndex (index ), mapImage ));
371- packetSize -= fullMapChunkSize ;
372- if (packetSize < fullMapChunkSize ) {
373- writeUpdatePacket (toRemove );
374- toRemove .clear ();
375- packetSize = 2621427 ;
376- }
377- }
378- writeUpdatePacket (toRemove );
363+ getPlayer ().getPlayerConnection ().write (new ClearWorldMap ());
379364 }
380365
381366 explorationData = null ;
0 commit comments