Skip to content

Commit 87dddf0

Browse files
committed
fix: resolve issues with latest update
1 parent 8b9de3f commit 87dddf0

5 files changed

Lines changed: 24 additions & 44 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>dev.cerus</groupId>
88
<artifactId>hytale-explorers-map</artifactId>
9-
<version>1.0.8</version>
9+
<version>1.0.9</version>
1010

1111
<properties>
1212
<maven.compiler.source>21</maven.compiler.source>

src/main/java/dev/cerus/explorersmap/ExplorersMapPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
1919
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
2020
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapSettings;
21-
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.PlayerIconMarkerProvider;
21+
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.providers.PlayerIconMarkerProvider;
2222
import com.hypixel.hytale.server.core.util.Config;
2323
import com.hypixel.hytale.unsafe.UnsafeUtil;
2424
import dev.cerus.explorersmap.command.ExplorersMapCommand;

src/main/java/dev/cerus/explorersmap/map/CustomPlayerIconMarkerProvider.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
import com.hypixel.hytale.math.vector.Transform;
44
import com.hypixel.hytale.math.vector.Vector3d;
55
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
6-
import com.hypixel.hytale.server.core.asset.type.gameplay.GameplayConfig;
76
import com.hypixel.hytale.server.core.asset.type.gameplay.WorldMapConfig;
87
import com.hypixel.hytale.server.core.entity.entities.Player;
98
import com.hypixel.hytale.server.core.universe.PlayerRef;
109
import com.hypixel.hytale.server.core.universe.world.World;
11-
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
1210
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
13-
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.PlayerIconMarkerProvider;
11+
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker;
1412
import com.hypixel.hytale.server.core.util.PositionUtil;
1513
import dev.cerus.explorersmap.ExplorersMapPlugin;
1614
import java.util.function.Predicate;
@@ -28,19 +26,16 @@ public CustomPlayerIconMarkerProvider(WorldMapManager.MarkerProvider original) {
2826
}
2927

3028
@Override
31-
public void update(@Nonnull World world, @Nonnull GameplayConfig gameplayConfig, @Nonnull WorldMapTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) {
29+
public void update(@Nonnull World world, @Nonnull MapMarkerTracker tracker, int chunkViewRadius, int playerChunkX, int playerChunkZ) {
3230
if (!ExplorersMapPlugin.getInstance().getConfig().get().isUnlimitedPlayerTracking()) {
33-
original.update(world, gameplayConfig, tracker, chunkViewRadius, playerChunkX, playerChunkZ);
31+
original.update(world, tracker, chunkViewRadius, playerChunkX, playerChunkZ);
3432
return;
3533
}
3634

37-
WorldMapConfig worldMapConfig = gameplayConfig.getWorldMapConfig();
35+
WorldMapConfig worldMapConfig = world.getGameplayConfig().getWorldMapConfig();
3836
if (!worldMapConfig.isDisplayPlayers()) {
3937
return;
4038
}
41-
if (!tracker.shouldUpdatePlayerMarkers()) {
42-
return;
43-
}
4439

4540
Player player = tracker.getPlayer();
4641
Predicate<PlayerRef> playerMapFilter = tracker.getPlayerMapFilter();
@@ -56,7 +51,7 @@ public void update(@Nonnull World world, @Nonnull GameplayConfig gameplayConfig,
5651
Transform otherPlayerTransform = otherPlayer.getTransform();
5752
Vector3d otherPos = otherPlayerTransform.getPosition();
5853

59-
if (tracker instanceof CustomWorldMapTracker customTracker) {
54+
if (player.getWorldMapTracker() instanceof CustomWorldMapTracker customTracker) {
6055
int otherChunkX = (int)otherPos.x >> 5;
6156
int otherChunkZ = (int)otherPos.z >> 5;
6257
if (!customTracker.isLoaded(otherChunkX, otherChunkZ)) {

src/main/java/dev/cerus/explorersmap/map/CustomWorldMapTracker.java

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.hypixel.hytale.math.util.MathUtil;
99
import com.hypixel.hytale.math.vector.Vector3d;
1010
import com.hypixel.hytale.protocol.Packet;
11+
import com.hypixel.hytale.protocol.packets.worldmap.ClearWorldMap;
1112
import com.hypixel.hytale.protocol.packets.worldmap.MapChunk;
1213
import com.hypixel.hytale.protocol.packets.worldmap.MapImage;
1314
import com.hypixel.hytale.protocol.packets.worldmap.UpdateWorldMap;
@@ -17,6 +18,7 @@
1718
import com.hypixel.hytale.server.core.universe.world.WorldMapTracker;
1819
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
1920
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapSettings;
21+
import com.hypixel.hytale.server.core.universe.world.worldmap.markers.MapMarkerTracker;
2022
import dev.cerus.explorersmap.ExplorersMapPlugin;
2123
import dev.cerus.explorersmap.config.ExplorersMapConfig;
2224
import dev.cerus.explorersmap.storage.ExplorationData;
@@ -25,8 +27,6 @@
2527
import it.unimi.dsi.fastutil.longs.LongIterator;
2628
import it.unimi.dsi.fastutil.longs.LongSet;
2729
import java.lang.reflect.Field;
28-
import java.lang.reflect.InvocationTargetException;
29-
import java.lang.reflect.Method;
3030
import java.util.ArrayList;
3131
import java.util.Iterator;
3232
import 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;

src/main/resources/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Group": "Cerus",
33
"Name": "ExplorersMap",
4-
"Version": "1.0.8",
4+
"Version": "1.0.9",
55
"Description": "Only show discovered places on your map like a true explorer!",
66
"Authors": [
77
{

0 commit comments

Comments
 (0)