diff --git a/.github/workflows/1.20.2.yml b/.github/workflows/1.20.2.yml index c421d5f7..db90883f 100644 --- a/.github/workflows/1.20.2.yml +++ b/.github/workflows/1.20.2.yml @@ -97,7 +97,7 @@ jobs: && wget https://api.modrinth.com/maven/maven/modrinth/xaeros-world-map/${{ env.WORLDMAP_VERSION_FABRIC }}_Fabric_${{ env.MINECRAFT_VERSION }}/xaeros-world-map-${{ env.WORLDMAP_VERSION_FABRIC }}_Fabric_${{ env.MINECRAFT_VERSION }}.jar -P run/mods/ - name: Fabric Test - uses: 3arthqu4ke/mc-runtime-test@2.4.1 + uses: 3arthqu4ke/mc-runtime-test@2.4.2 with: mc: ${{ env.MINECRAFT_VERSION }} modloader: fabric @@ -118,7 +118,7 @@ jobs: && wget https://api.modrinth.com/maven/maven/modrinth/xaeros-world-map/${{ env.WORLDMAP_VERSION_FORGE }}_Forge_${{ env.MINECRAFT_VERSION }}/xaeros-world-map-${{ env.WORLDMAP_VERSION_FORGE }}_Forge_${{ env.MINECRAFT_VERSION }}.jar -P run/mods/ - name: Forge Test - uses: 3arthqu4ke/mc-runtime-test@2.4.1 + uses: 3arthqu4ke/mc-runtime-test@2.4.2 with: mc: ${{ env.MINECRAFT_VERSION }} modloader: forge diff --git a/common/src/main/java/xaeroplus/Globals.java b/common/src/main/java/xaeroplus/Globals.java index 2ad738c5..146c0a21 100644 --- a/common/src/main/java/xaeroplus/Globals.java +++ b/common/src/main/java/xaeroplus/Globals.java @@ -4,6 +4,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; +import xaero.common.HudMod; import xaero.hud.HudSession; import xaero.map.core.XaeroWorldMapCore; import xaeroplus.event.ClientPlaySessionFinalizedEvent; @@ -28,6 +29,7 @@ public class Globals { public static int minimapScaleMultiplier = 1; public static int minimapSizeMultiplier = 1; public static boolean shouldResetFBO = false; + public static boolean minimapSettingsInitialized = false; public static ResourceKey getCurrentDimensionId() { try { var dim = XaeroWorldMapCore.currentSession.getMapProcessor().getMapWorld().getCurrentDimensionId(); @@ -69,6 +71,15 @@ public static void initStickySettings() { }, ClientPlaySessionFinalizedEvent.class); } + public static void initSyncedSettings() { + try { + boolean baseSetting = HudMod.INSTANCE.getSettings().radarHideInvisibleEntities; + Settings.REGISTRY.radarHideInvisibleEntities.setValue(baseSetting); + } catch (final Exception ex) { + XaeroPlus.LOGGER.error("Failed syncing setting: radarHideInvisibleEntities", ex); + } + } + public static void switchToDimension(final ResourceKey newDimId) { if (newDimId == null) return; try { diff --git a/common/src/main/java/xaeroplus/XaeroPlus.java b/common/src/main/java/xaeroplus/XaeroPlus.java index ed7852b5..dde1fffe 100644 --- a/common/src/main/java/xaeroplus/XaeroPlus.java +++ b/common/src/main/java/xaeroplus/XaeroPlus.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import xaero.map.platform.Services; +import xaeroplus.event.MinimapInitCompletedEvent; import xaeroplus.settings.Settings; import xaeroplus.settings.XaeroPlusSetting; @@ -23,5 +24,10 @@ public static void initializeSettings() { loadXPSettings(); Settings.REGISTRY.getAllSettings().forEach(XaeroPlusSetting::init); Globals.initStickySettings(); + XaeroPlus.EVENT_BUS.registerConsumer((e) -> { + if (Globals.minimapSettingsInitialized) return; + Globals.minimapSettingsInitialized = true; + Globals.initSyncedSettings(); + }, MinimapInitCompletedEvent.class); } } diff --git a/common/src/main/java/xaeroplus/event/MinimapInitCompletedEvent.java b/common/src/main/java/xaeroplus/event/MinimapInitCompletedEvent.java new file mode 100644 index 00000000..8e961b17 --- /dev/null +++ b/common/src/main/java/xaeroplus/event/MinimapInitCompletedEvent.java @@ -0,0 +1,5 @@ +package xaeroplus.event; + +public record MinimapInitCompletedEvent() { + public static final MinimapInitCompletedEvent INSTANCE = new MinimapInitCompletedEvent(); +} diff --git a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightBaseCacheHandler.java b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightBaseCacheHandler.java index 79b05555..fc0cbbf3 100644 --- a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightBaseCacheHandler.java +++ b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightBaseCacheHandler.java @@ -1,23 +1,13 @@ package xaeroplus.feature.render.highlights; -import it.unimi.dsi.fastutil.longs.Long2LongMap; -import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; -import it.unimi.dsi.fastutil.longs.LongArrayList; -import it.unimi.dsi.fastutil.longs.LongList; +import it.unimi.dsi.fastutil.longs.*; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; -import xaeroplus.XaeroPlus; -import xaeroplus.util.ChunkUtils; - -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.StampedLock; import static xaeroplus.util.ChunkUtils.chunkPosToLong; public abstract class ChunkHighlightBaseCacheHandler implements ChunkHighlightCache { - public final ReadWriteLock lock = new StampedLock().asReadWriteLock(); - public final Long2LongMap chunks = new Long2LongOpenHashMap(); + public final Long2LongMap chunks = Long2LongMaps.synchronize(new Long2LongOpenHashMap()); @Override public boolean addHighlight(final int x, final int z) { @@ -26,28 +16,14 @@ public boolean addHighlight(final int x, final int z) { public boolean addHighlight(final int x, final int z, final long foundTime) { final long chunkPos = chunkPosToLong(x, z); - try { - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - chunks.put(chunkPos, foundTime); - lock.writeLock().unlock(); - } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Failed to add new highlight: {}, {}", x, z, e); - } + chunks.put(chunkPos, foundTime); return true; } @Override public boolean removeHighlight(final int x, final int z) { final long chunkPos = chunkPosToLong(x, z); - try { - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - chunks.remove(chunkPos); - lock.writeLock().unlock(); - } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Failed to add new highlight: {}, {}", x, z, e); - } + chunks.remove(chunkPos); return true; } @@ -58,26 +34,11 @@ public boolean isHighlighted(final int x, final int z, ResourceKey dimens @Override public LongList getHighlightsSnapshot(final ResourceKey dimension) { - try { - if (lock.readLock().tryLock(1, TimeUnit.SECONDS)) { - // copy is memory inefficient but we need a thread safe iterator for rendering - var list = new LongArrayList(chunks.keySet()); - lock.readLock().unlock(); - return list; - } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Error getting highlights snapshot in dimension: {}", dimension.location().getPath(), e); - } - return LongList.of(); + return new LongArrayList(chunks.keySet()); } public boolean isHighlighted(final long chunkPos) { - try { - return chunks.containsKey(chunkPos); - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Error checking if chunk is highlighted: {}, {}", ChunkUtils.longToChunkX(chunkPos), ChunkUtils.longToChunkZ(chunkPos), e); - } - return false; + return chunks.containsKey(chunkPos); } @Override @@ -88,36 +49,15 @@ public Long2LongMap getHighlightsState() { @Override public void loadPreviousState(final Long2LongMap state) { if (state == null) return; - try { - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - chunks.putAll(state); - lock.writeLock().unlock(); - } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Error loading previous highlight cache state", e); - } + chunks.putAll(state); } public void replaceState(final Long2LongOpenHashMap state) { - try { - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - this.chunks.clear(); - this.chunks.putAll(state); - lock.writeLock().unlock(); - } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Failed replacing highlight cache state", e); - } + chunks.clear(); + chunks.putAll(state); } public void reset() { - try { - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - chunks.clear(); - lock.writeLock().unlock(); - } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Failed resetting highlight cache", e); - } + chunks.clear(); } } diff --git a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightCacheDimensionHandler.java b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightCacheDimensionHandler.java index c07e2cff..896c639c 100644 --- a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightCacheDimensionHandler.java +++ b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightCacheDimensionHandler.java @@ -5,12 +5,10 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; -import xaeroplus.XaeroPlus; import xaeroplus.util.ChunkUtils; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; import static xaeroplus.util.ChunkUtils.chunkPosToLong; import static xaeroplus.util.ChunkUtils.regionCoordToChunkCoord; @@ -34,11 +32,14 @@ public ChunkHighlightCacheDimensionHandler( } public void setWindow(int regionX, int regionZ, int regionSize) { + boolean windowChanged = regionX != windowRegionX || regionZ != windowRegionZ || regionSize != windowRegionSize; this.windowRegionX = regionX; this.windowRegionZ = regionZ; this.windowRegionSize = regionSize; - writeHighlightsOutsideWindowToDatabase(); - loadHighlightsInWindow(); + if (windowChanged) { + writeHighlightsOutsideWindowToDatabase(); + loadHighlightsInWindow(); + } } private void loadHighlightsInWindow() { @@ -48,16 +49,11 @@ private void loadHighlightsInWindow() { windowRegionX - windowRegionSize, windowRegionX + windowRegionSize, windowRegionZ - windowRegionSize, windowRegionZ + windowRegionSize ); - try { - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - for (int i = 0; i < chunks.size(); i++) { - final ChunkHighlightData chunk = chunks.get(i); - this.chunks.put(chunkPosToLong(chunk.x(), chunk.z()), chunk.foundTime()); - } - lock.writeLock().unlock(); + synchronized (this.chunks) { + for (int i = 0; i < chunks.size(); i++) { + final ChunkHighlightData chunk = chunks.get(i); + this.chunks.put(chunkPosToLong(chunk.x(), chunk.z()), chunk.foundTime()); } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Failed to load highlights in window for {} disk cache dimension: {}", database.databaseName, dimension.location(), e); } }); } @@ -65,29 +61,24 @@ private void loadHighlightsInWindow() { private void writeHighlightsOutsideWindowToDatabase() { executorService.execute(() -> { final List chunksToWrite = new ArrayList<>(); - try { - if (lock.writeLock().tryLock(1L, TimeUnit.SECONDS)) { - var minChunkX = regionCoordToChunkCoord(windowRegionX - windowRegionSize); - var maxChunkX = regionCoordToChunkCoord(windowRegionX + windowRegionSize); - var minChunkZ = regionCoordToChunkCoord(windowRegionZ - windowRegionSize); - var maxChunkZ = regionCoordToChunkCoord(windowRegionZ + windowRegionSize); - for (var it = chunks.long2LongEntrySet().iterator(); it.hasNext(); ) { - var entry = it.next(); - final long chunkPos = entry.getLongKey(); - final int chunkX = ChunkUtils.longToChunkX(chunkPos); - final int chunkZ = ChunkUtils.longToChunkZ(chunkPos); - if (chunkX < minChunkX - || chunkX > maxChunkX - || chunkZ < minChunkZ - || chunkZ > maxChunkZ) { - chunksToWrite.add(new ChunkHighlightData(chunkX, chunkZ, entry.getLongValue())); - it.remove(); - } + var minChunkX = regionCoordToChunkCoord(windowRegionX - windowRegionSize); + var maxChunkX = regionCoordToChunkCoord(windowRegionX + windowRegionSize); + var minChunkZ = regionCoordToChunkCoord(windowRegionZ - windowRegionSize); + var maxChunkZ = regionCoordToChunkCoord(windowRegionZ + windowRegionSize); + synchronized (this.chunks) { + for (var it = chunks.long2LongEntrySet().iterator(); it.hasNext(); ) { + var entry = it.next(); + final long chunkPos = entry.getLongKey(); + final int chunkX = ChunkUtils.longToChunkX(chunkPos); + final int chunkZ = ChunkUtils.longToChunkZ(chunkPos); + if (chunkX < minChunkX + || chunkX > maxChunkX + || chunkZ < minChunkZ + || chunkZ > maxChunkZ) { + chunksToWrite.add(new ChunkHighlightData(chunkX, chunkZ, entry.getLongValue())); + it.remove(); } - lock.writeLock().unlock(); } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Error while writing highlights outside window to {} disk cache dimension: {}", database.databaseName, dimension.location(), e); } database.insertHighlightList(chunksToWrite, dimension); }); @@ -96,19 +87,14 @@ private void writeHighlightsOutsideWindowToDatabase() { public ListenableFuture writeAllHighlightsToDatabase() { return executorService.submit(() -> { final List chunksToWrite = new ArrayList<>(chunks.size()); - try { - if (lock.readLock().tryLock(1, TimeUnit.SECONDS)) { - for (var it = chunks.long2LongEntrySet().iterator(); it.hasNext(); ) { - var entry = it.next(); - final long chunkPos = entry.getLongKey(); - final int chunkX = ChunkUtils.longToChunkX(chunkPos); - final int chunkZ = ChunkUtils.longToChunkZ(chunkPos); - chunksToWrite.add(new ChunkHighlightData(chunkX, chunkZ, entry.getLongValue())); - } - lock.readLock().unlock(); + synchronized (chunks) { + for (var it = chunks.long2LongEntrySet().iterator(); it.hasNext(); ) { + var entry = it.next(); + final long chunkPos = entry.getLongKey(); + final int chunkX = ChunkUtils.longToChunkX(chunkPos); + final int chunkZ = ChunkUtils.longToChunkZ(chunkPos); + chunksToWrite.add(new ChunkHighlightData(chunkX, chunkZ, entry.getLongValue())); } - } catch (final Exception e) { - XaeroPlus.LOGGER.error("Error while writing all chunks to {} disk cache dimension: {}", database.databaseName, dimension.location(), e); } database.insertHighlightList(chunksToWrite, dimension); }); diff --git a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightDatabase.java b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightDatabase.java index ceecea8a..569e3b15 100644 --- a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightDatabase.java +++ b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightDatabase.java @@ -15,7 +15,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.stream.Collectors; import static xaeroplus.util.ChunkUtils.regionCoordToChunkCoord; @@ -84,12 +83,16 @@ public void insertHighlightList(final List chunks, final Res private void insertHighlightsListInternal(final List chunks, final ResourceKey dimension) { try { - String statement = "INSERT OR IGNORE INTO \"" + getTableName(dimension) + "\" VALUES "; - statement += chunks.stream() - .map(chunk -> "(" + chunk.x() + ", " + chunk.z() + ", " + chunk.foundTime() + ")") - .collect(Collectors.joining(", ")); + StringBuilder sb = new StringBuilder("INSERT OR IGNORE INTO \"" + getTableName(dimension) + "\" VALUES "); + for (int i = 0; i < chunks.size(); i++) { + ChunkHighlightData chunk = chunks.get(i); + sb.append("(").append(chunk.x()).append(", ").append(chunk.z()).append(", ").append(chunk.foundTime()).append(")"); + if (i < chunks.size() - 1) { + sb.append(", "); + } + } try (var stmt = connection.createStatement()) { - stmt.executeUpdate(statement); + stmt.executeUpdate(sb.toString()); } } catch (Exception e) { XaeroPlus.LOGGER.error("Error inserting {} chunks into {} database in dimension: {}", chunks.size(), databaseName, dimension.location(), e); diff --git a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightLocalCache.java b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightLocalCache.java index 4ee2d362..dc041d96 100644 --- a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightLocalCache.java +++ b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightLocalCache.java @@ -4,7 +4,6 @@ import xaeroplus.XaeroPlus; import java.util.Map; -import java.util.concurrent.TimeUnit; public class ChunkHighlightLocalCache extends ChunkHighlightBaseCacheHandler { private static final int maxNumber = 5000; @@ -26,19 +25,15 @@ public boolean addHighlight(final int x, final int z, final long foundTime) { private void limitChunksSize() { try { if (chunks.size() > maxNumber) { - if (lock.readLock().tryLock(1, TimeUnit.SECONDS)) { + synchronized (chunks) { // remove oldest 500 chunks var toRemove = chunks.long2LongEntrySet().stream() .sorted(Map.Entry.comparingByValue()) .limit(500) .mapToLong(Long2LongMap.Entry::getLongKey) .toArray(); - lock.readLock().unlock(); - if (lock.writeLock().tryLock(1, TimeUnit.SECONDS)) { - for (int i = 0; i < toRemove.length; i++) { - chunks.remove(toRemove[i]); - } - lock.writeLock().unlock(); + for (int i = 0; i < toRemove.length; i++) { + chunks.remove(toRemove[i]); } } } diff --git a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java index c3149aba..66dc33d2 100644 --- a/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java +++ b/common/src/main/java/xaeroplus/feature/render/highlights/ChunkHighlightSavingCache.java @@ -93,13 +93,17 @@ public LongList getHighlightsSnapshot(final ResourceKey dimensionId) { @Override public void handleWorldChange() { - Futures.whenAllComplete(saveAllChunks()) - .call(() -> { + try { + Futures.whenAllComplete(saveAllChunks()) + .run(() -> { reset(); initializeWorld(); loadChunksInActualDimension(); - return null; - }, Globals.cacheRefreshExecutorService.get()); + }, Runnable::run) + .get(); + } catch (final Exception e) { + XaeroPlus.LOGGER.error("Error handling {} cache world change", databaseName, e); + } } public synchronized void reset() { @@ -163,6 +167,16 @@ public List getCachesExceptDimension(final return caches; } + public List getCachesExceptDimensions(final List> dimensions) { + var caches = new ArrayList(dimensionCacheMap.size()); + for (var entry : dimensionCacheMap.entrySet()) { + if (!dimensions.contains(entry.getKey())) { + caches.add(entry.getValue()); + } + } + return caches; + } + private synchronized void initializeWorld() { try { MapProcessor mapProcessor = XaeroWorldMapCore.currentSession.getMapProcessor(); @@ -205,10 +219,14 @@ public void onEnable() { @Override public void onDisable() { - Futures.whenAllComplete(saveAllChunks()).call(() -> { - reset(); - return null; - }, Globals.cacheRefreshExecutorService.get()); + try { + Futures.whenAllComplete(saveAllChunks()) + .run(() -> reset(), + Runnable::run) + .get(); + } catch (Exception e) { + XaeroPlus.LOGGER.error("Error handling {} cache disable", databaseName, e); + } } @Override @@ -241,22 +259,42 @@ public void handleTick() { return; } + final ResourceKey mapDimension = Globals.getCurrentDimensionId(); + final ResourceKey actualDimension = ChunkUtils.getActualDimension(); + Optional guiMapOptional = getGuiMap(); - if (guiMapOptional.isPresent()) { + if (guiMapOptional.isPresent()) { // viewing worldmap final GuiMap guiMap = guiMapOptional.get(); - final ResourceKey mapDimension = Globals.getCurrentDimensionId(); final int mapCenterX = getGuiMapCenterRegionX(guiMap); final int mapCenterZ = getGuiMapCenterRegionZ(guiMap); final int mapSize = getGuiMapRegionSize(guiMap); + final ChunkHighlightCacheDimensionHandler viewedDimCache = getCacheForDimension(mapDimension, true); + if (viewedDimCache != null) viewedDimCache.setWindow(mapCenterX, mapCenterZ, mapSize); + if (mapDimension == actualDimension) { + getCachesExceptDimension(mapDimension) + .forEach(cache -> cache.setWindow(0, 0, 0)); + } else { + final ChunkHighlightCacheDimensionHandler actualDimCache = getCacheForDimension(actualDimension, true); + if (actualDimCache != null) { + actualDimCache.setWindow(ChunkUtils.getPlayerRegionX(), ChunkUtils.getPlayerRegionZ(), mapSize); + } + getCachesExceptDimensions(List.of(mapDimension, actualDimension)) + .forEach(cache -> cache.setWindow(0, 0, 0)); + } + } else { // viewing minimap final ChunkHighlightCacheDimensionHandler cacheForDimension = getCacheForDimension(mapDimension, true); - if (cacheForDimension != null) cacheForDimension.setWindow(mapCenterX, mapCenterZ, mapSize); - getCachesExceptDimension(mapDimension) - .forEach(cache -> cache.setWindow(0, 0, 0)); - } else { - final ChunkHighlightCacheDimensionHandler cacheForDimension = getCacheForDimension(Globals.getCurrentDimensionId(), true); if (cacheForDimension != null) cacheForDimension.setWindow(ChunkUtils.getPlayerRegionX(), ChunkUtils.getPlayerRegionZ(), getMinimapRegionWindowSize()); - getCachesExceptDimension(Globals.getCurrentDimensionId()) - .forEach(cache -> cache.setWindow(0, 0, 0)); + if (mapDimension == actualDimension) { + getCachesExceptDimension(mapDimension) + .forEach(cache -> cache.setWindow(0, 0, 0)); + } else { + final ChunkHighlightCacheDimensionHandler actualDimCache = getCacheForDimension(actualDimension, true); + if (actualDimCache != null) { + actualDimCache.setWindow(ChunkUtils.getPlayerRegionX(), ChunkUtils.getPlayerRegionZ(), getMinimapRegionWindowSize()); + } + getCachesExceptDimensions(List.of(mapDimension, actualDimension)) + .forEach(cache -> cache.setWindow(0, 0, 0)); + } } } } diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinHudMod.java b/common/src/main/java/xaeroplus/mixin/client/MixinHudMod.java new file mode 100644 index 00000000..7550bb5d --- /dev/null +++ b/common/src/main/java/xaeroplus/mixin/client/MixinHudMod.java @@ -0,0 +1,18 @@ +package xaeroplus.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import xaero.common.HudMod; +import xaeroplus.XaeroPlus; +import xaeroplus.event.MinimapInitCompletedEvent; + +@Mixin(value = HudMod.class, remap = false) +public class MixinHudMod { + + @Inject(method = "loadLater", at = @At("RETURN")) + public void onClientLoadComplete(final CallbackInfo ci) { + XaeroPlus.EVENT_BUS.call(MinimapInitCompletedEvent.INSTANCE); + } +} diff --git a/common/src/main/java/xaeroplus/settings/Settings.java b/common/src/main/java/xaeroplus/settings/Settings.java index a73fce31..95f4f57a 100644 --- a/common/src/main/java/xaeroplus/settings/Settings.java +++ b/common/src/main/java/xaeroplus/settings/Settings.java @@ -1,8 +1,10 @@ package xaeroplus.settings; import net.minecraft.client.Minecraft; +import xaero.common.HudMod; import xaero.map.WorldMapSession; import xaeroplus.Globals; +import xaeroplus.XaeroPlus; import xaeroplus.module.ModuleManager; import xaeroplus.module.impl.*; import xaeroplus.util.BaritoneHelper; @@ -700,6 +702,20 @@ public String getTranslationKey() { "xaeroplus.setting.disable_internet", false), SettingLocation.WORLD_MAP_MAIN); + public final BooleanSetting radarHideInvisibleEntities = register( + BooleanSetting.create( + "Hide Invisible Entities", + "xaeroplus.setting.radar_hide_invisible_entities", + true, + (b) -> { + if (!Globals.minimapSettingsInitialized) return; + try { + HudMod.INSTANCE.getSettings().radarHideInvisibleEntities = b; + } catch (Exception e) { + XaeroPlus.LOGGER.error("Error updating radarHideInvisibleEntities", e); + } + }), + SettingLocation.MINIMAP_ENTITY_RADAR); public final BooleanSetting expandSettingEntries = register( BooleanSetting.create( "Expanded Setting Entries", diff --git a/common/src/main/resources/assets/xaeroplus/lang/en_us.json b/common/src/main/resources/assets/xaeroplus/lang/en_us.json index 747a491b..8072884c 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/en_us.json +++ b/common/src/main/resources/assets/xaeroplus/lang/en_us.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Renders the estimated time of arrival on waypoint distance text. The ETA is based on the player's current speed and movement direction", "xaeroplus.setting.disable_internet": "Disable Xaero Internet Access", "xaeroplus.setting.disable_internet.tooltip": "Disables WorldMap and Minimap mods from using the internet to check for updates and patreon subscriptions at launch.\n Xaero mods do not expose this setting in the GUI normally.\n XaeroPlus does not use the internet regardless of this setting.", + "xaeroplus.setting.radar_hide_invisible_entities": "Hide Invisible Entities", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Configures whether invisible or sneaking entities are rendered on the radar", "xaeroplus.setting.expanded_settings": "Expanded Settings", "xaeroplus.setting.expanded_settings.tooltip": "Increases the number of settings shown per page on larger screens", "xaeroplus.setting.sodium_embeddium_integration": "Sodium/Embeddium Settings Integration", diff --git a/common/src/main/resources/assets/xaeroplus/lang/es_ar.json b/common/src/main/resources/assets/xaeroplus/lang/es_ar.json index 66ddfb7e..bf973c5f 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/es_ar.json +++ b/common/src/main/resources/assets/xaeroplus/lang/es_ar.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Muestra el tiempo estimado de llegada en el texto de distancia del punto de referencia. El ETA se basa en la velocidad y dirección de movimiento actuales del jugador", "xaeroplus.setting.disable_internet": "Deshabilitar el acceso a Internet de Xaero", "xaeroplus.setting.disable_internet.tooltip": "Desactiva el uso de Internet de las modificaciones de WorldMap y Minimap para buscar actualizaciones y suscripciones a Patreon en el momento del lanzamiento.\n Los mods de Xaero normalmente no exponen esta configuración en la GUI.\n XaeroPlus no utiliza Internet independientemente de esta configuración.", + "xaeroplus.setting.radar_hide_invisible_entities": "Ocultar entidades invisibles", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Configura si las entidades invisibles o agachadas se renderizan en el radar", "xaeroplus.setting.expanded_settings": "Configuración ampliada", "xaeroplus.setting.expanded_settings.tooltip": "Aumenta la cantidad de configuraciones que se muestran por página en pantallas más grandes", "xaeroplus.setting.sodium_embeddium_integration": "Integración de Configuración de Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/fr_ca.json b/common/src/main/resources/assets/xaeroplus/lang/fr_ca.json index b1a57216..11a98131 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/fr_ca.json +++ b/common/src/main/resources/assets/xaeroplus/lang/fr_ca.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Affiche l'heure d'arrivée estimée sur le texte de distance du point de passage. L'ETA est basé sur la vitesse et la direction de déplacement actuelles du joueur", "xaeroplus.setting.disable_internet": "Désactiver l'accès Internet Xaero", "xaeroplus.setting.disable_internet.tooltip": "Empêche les mods WorldMap et Minimap d'utiliser Internet pour vérifier les mises à jour et les abonnements Patreon au lancement.\n Les mods Xaero n'exposent pas normalement ce paramètre dans l'interface graphique.\n XaeroPlus n'utilise pas Internet quel que soit ce paramètre.", + "xaeroplus.setting.radar_hide_invisible_entities": "Masquer les entités invisibles", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Configure si les entités invisibles ou accroupies sont affichées sur le radar", "xaeroplus.setting.expanded_settings": "Paramètres étendus", "xaeroplus.setting.expanded_settings.tooltip": "Augmente le nombre de paramètres affichés par page sur des écrans plus grands", "xaeroplus.setting.sodium_embeddium_integration": "Intégration des Paramètres Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/fr_fr.json b/common/src/main/resources/assets/xaeroplus/lang/fr_fr.json index b1a57216..11a98131 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/fr_fr.json +++ b/common/src/main/resources/assets/xaeroplus/lang/fr_fr.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Affiche l'heure d'arrivée estimée sur le texte de distance du point de passage. L'ETA est basé sur la vitesse et la direction de déplacement actuelles du joueur", "xaeroplus.setting.disable_internet": "Désactiver l'accès Internet Xaero", "xaeroplus.setting.disable_internet.tooltip": "Empêche les mods WorldMap et Minimap d'utiliser Internet pour vérifier les mises à jour et les abonnements Patreon au lancement.\n Les mods Xaero n'exposent pas normalement ce paramètre dans l'interface graphique.\n XaeroPlus n'utilise pas Internet quel que soit ce paramètre.", + "xaeroplus.setting.radar_hide_invisible_entities": "Masquer les entités invisibles", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Configure si les entités invisibles ou accroupies sont affichées sur le radar", "xaeroplus.setting.expanded_settings": "Paramètres étendus", "xaeroplus.setting.expanded_settings.tooltip": "Augmente le nombre de paramètres affichés par page sur des écrans plus grands", "xaeroplus.setting.sodium_embeddium_integration": "Intégration des Paramètres Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/ja_jp.json b/common/src/main/resources/assets/xaeroplus/lang/ja_jp.json index 9eb0885a..022bcf9d 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/ja_jp.json +++ b/common/src/main/resources/assets/xaeroplus/lang/ja_jp.json @@ -178,6 +178,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "プレイヤーの現在の速度と移動方向に基づいて、ウェイポイントの距離に推定到着時刻を表示します", "xaeroplus.setting.disable_internet": "Xaeroのインターネットアクセスを無効にする", "xaeroplus.setting.disable_internet.tooltip": "WorldMapとMinimapのMODが起動時にインターネットを使用してアップデートとパトロン購読をチェックするのを無効にします。\nXaeroのMODは通常GUIでこの設定を公開しません。\nXaeroPlusはこの設定に関係なくインターネットを使用しません。", + "xaeroplus.setting.radar_hide_invisible_entities": "透明なエンティティを非表示", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "透明またはスニーク中のエンティティをレーダーに表示するかどうかを設定します", "xaeroplus.setting.expanded_settings": "拡張設定", "xaeroplus.setting.expanded_settings.tooltip": "大きな画面では、ページごとに表示される設定の数が増加します", "xaeroplus.setting.sodium_embeddium_integration": "Sodium/Embeddium 設定の統合", diff --git a/common/src/main/resources/assets/xaeroplus/lang/pl_pl.json b/common/src/main/resources/assets/xaeroplus/lang/pl_pl.json index c66f1b2c..6f341e93 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/pl_pl.json +++ b/common/src/main/resources/assets/xaeroplus/lang/pl_pl.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Wyświetla szacowany czas przybycia na tekście odległości do punktu. ETA opiera się na obecnej prędkości i kierunku ruchu gracza", "xaeroplus.setting.disable_internet": "Wyłącz dostęp do Internetu Xaero", "xaeroplus.setting.disable_internet.tooltip": "Wyłącza modom WorldMap i Minimap korzystanie z Internetu w celu sprawdzania dostępności aktualizacji i subskrypcji Patreona przy uruchomieniu.\n Mody Xaero normalnie nie udostępniają tego ustawienia w GUI.\n XaeroPlus nie korzysta z Internetu niezależnie od tego ustawienia.", + "xaeroplus.setting.radar_hide_invisible_entities": "Ukryj niewidzialne jednostki", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Konfiguruje, czy niewidzialne lub skradające się jednostki są wyświetlane na radarze", "xaeroplus.setting.expanded_settings": "Rozszerzone ustawienia", "xaeroplus.setting.expanded_settings.tooltip": "Zwiększa liczbę ustawień wyświetlanych na stronie na większych ekranach", "xaeroplus.setting.sodium_embeddium_integration": "Integracja Ustawień Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/pt_pt.json b/common/src/main/resources/assets/xaeroplus/lang/pt_pt.json index 501aa098..7dfa80ce 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/pt_pt.json +++ b/common/src/main/resources/assets/xaeroplus/lang/pt_pt.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Exibe o tempo estimado de chegada no texto de distância do ponto de referência. O ETA é baseado na velocidade e direção de movimento atuais do jogador", "xaeroplus.setting.disable_internet": "Desati. Acesso à Internet ao Xaero", "xaeroplus.setting.disable_internet.tooltip": "Desativa o acesso à Internet para verificação de atualizações ou subscrição do Patreon dos mods do mapa-mundo e mini-mapa. \n Normalmente os mods Xaero não mostram esta configuração no GUI. \n O XaeroPlus não usa a Internet independentemente desta definição.", + "xaeroplus.setting.radar_hide_invisible_entities": "Ocultar entidades invisíveis", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Configura se entidades invisíveis ou agachadas são exibidas no radar", "xaeroplus.setting.expanded_settings": "Configurações expandidas", "xaeroplus.setting.expanded_settings.tooltip": "Aumenta o número de configurações mostradas por página em telas maiores", "xaeroplus.setting.sodium_embeddium_integration": "Integração de Configurações Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/ru_ru.json b/common/src/main/resources/assets/xaeroplus/lang/ru_ru.json index 51a9fc40..900d06ac 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/ru_ru.json +++ b/common/src/main/resources/assets/xaeroplus/lang/ru_ru.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Отображает расчетное время прибытия на тексте расстояния до точки. ETA основано на текущей скорости и направлении движения игрока", "xaeroplus.setting.disable_internet": "Отключить доступ Xaero в Интернет", "xaeroplus.setting.disable_internet.tooltip": "Отключает модам WorldMap и Minimap использование Интернета для проверки обновлений и подписок на Patreon при запуске.\n Моды Xaero обычно не отображают этот параметр в графическом интерфейсе.\n XaeroPlus не использует Интернет независимо от этой настройки.", + "xaeroplus.setting.radar_hide_invisible_entities": "Скрыть невидимые сущности", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Настраивает отображение невидимых или крадущихся сущностей на радаре", "xaeroplus.setting.expanded_settings": "Расширенные настройки", "xaeroplus.setting.expanded_settings.tooltip": "Увеличивает количество настроек, отображаемых на странице на больших экранах.", "xaeroplus.setting.sodium_embeddium_integration": "Интеграция Настроек Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/vi_vn.json b/common/src/main/resources/assets/xaeroplus/lang/vi_vn.json index 3a027f08..31a3b5a4 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/vi_vn.json +++ b/common/src/main/resources/assets/xaeroplus/lang/vi_vn.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "Hiển thị thời gian đến ước tính trên văn bản khoảng cách đến điểm đường. ETA dựa trên tốc độ và hướng di chuyển hiện tại của người chơi", "xaeroplus.setting.disable_internet": "Vô Hiệu Hóa Truy Cập Internet Xaero", "xaeroplus.setting.disable_internet.tooltip": "Vô hiệu hóa các mod WorldMap và Minimap từ việc sử dụng internet để kiểm tra cập nhật và đăng ký patreon khi khởi động.\n Các mod Xaero không hiển thị cài đặt này trong giao diện người dùng bình thường.\n XaeroPlus không sử dụng internet bất kể cài đặt này.", + "xaeroplus.setting.radar_hide_invisible_entities": "Ẩn thực thể vô hình", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "Cấu hình liệu các thực thể vô hình hoặc đang lén lút có được hiển thị trên radar hay không", "xaeroplus.setting.expanded_settings": "Cài đặt mở rộng", "xaeroplus.setting.expanded_settings.tooltip": "Tăng số lượng cài đặt hiển thị trên mỗi trang trên màn hình lớn hơn", "xaeroplus.setting.sodium_embeddium_integration": "Tích hợp Cài đặt Sodium/Embeddium", diff --git a/common/src/main/resources/assets/xaeroplus/lang/zh_cn.json b/common/src/main/resources/assets/xaeroplus/lang/zh_cn.json index 34af63f4..c1265207 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/zh_cn.json +++ b/common/src/main/resources/assets/xaeroplus/lang/zh_cn.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "在航点距离文本上显示预计到达时间。ETA 基于玩家当前的速度和移动方向", "xaeroplus.setting.disable_internet": "禁用 Xaero 互联网访问", "xaeroplus.setting.disable_internet.tooltip": "禁止 WorldMap 和 Minimap mods 在启动时使用互联网检查更新和 patreon 订阅。\n Xaero mods 通常不会在 GUI 中公开此设置。\n 无论此设置如何,XaeroPlus 都不会使用互联网。", + "xaeroplus.setting.radar_hide_invisible_entities": "隐藏隐形实体", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "设置是否在雷达上显示隐形或潜行的实体", "xaeroplus.setting.expanded_settings": "扩展设置", "xaeroplus.setting.expanded_settings.tooltip": "增加大屏幕上每页显示的设置数量", "xaeroplus.setting.sodium_embeddium_integration": "Sodium/Embeddium 设置集成", diff --git a/common/src/main/resources/assets/xaeroplus/lang/zh_tw.json b/common/src/main/resources/assets/xaeroplus/lang/zh_tw.json index 6c5198e8..c5898939 100644 --- a/common/src/main/resources/assets/xaeroplus/lang/zh_tw.json +++ b/common/src/main/resources/assets/xaeroplus/lang/zh_tw.json @@ -180,6 +180,8 @@ "xaeroplus.setting.waypoint_eta.tooltip": "在航點距離文本上顯示預計到達時間。ETA 基於玩家當前的速度和移動方向", "xaeroplus.setting.disable_internet": "停用 Xaero 網際網路存取", "xaeroplus.setting.disable_internet.tooltip": "停用世界地圖和小地圖模組在啟動時使用網際網路檢查更新和 Patreon 訂閱。\n Xaero 模組通常不會在介面中公開此設定。\n 無論此設定如何,XaeroPlus 都不会使用網際網路。", + "xaeroplus.setting.radar_hide_invisible_entities": "隱藏隱形實體", + "xaeroplus.setting.radar_hide_invisible_entities.tooltip": "設置是否在雷達上顯示隱形或潛行的實體", "xaeroplus.setting.expanded_settings": "擴展設定", "xaeroplus.setting.expanded_settings.tooltip": "在較大的螢幕上增加每頁顯示的設定數量", "xaeroplus.setting.sodium_embeddium_integration": "Sodium/Embeddium 設定集成", diff --git a/common/src/main/resources/xaeroplus.mixins.json b/common/src/main/resources/xaeroplus.mixins.json index 531f1a2d..1d3d5d20 100644 --- a/common/src/main/resources/xaeroplus.mixins.json +++ b/common/src/main/resources/xaeroplus.mixins.json @@ -33,6 +33,7 @@ "MixinGuiWaypointSettings", "MixinGuiWaypointsList", "MixinGuiWorldMapSettings", + "MixinHudMod", "MixinImprovedFramebuffer", "MixinKeyEventHandler", "MixinLeveledRegion", diff --git a/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java b/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java index b4f1cb1e..b30df625 100644 --- a/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java +++ b/fabric/src/main/java/xaeroplus/fabric/XaeroPlusFabric.java @@ -30,9 +30,9 @@ public static void initialize() { versionCheckResult.anyPresentMinimapVersion().map(Version::getFriendlyString).orElse("None!")); return; } + FabricWaystonesHelperInit.doInit(); XaeroPlus.initializeSettings(); Settings.REGISTRY.getKeybindings().forEach(KeyBindingHelper::registerKeyBinding); - FabricWaystonesHelperInit.doInit(); if (System.getenv("XP_CI_TEST") != null) Minecraft.getInstance().execute(XaeroPlusGameTest::applyMixinsTest); } diff --git a/settings.gradle.kts b/settings.gradle.kts index 22dc5345..37220bba 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,7 @@ pluginManagement { } } gradle.extra.apply { - set("mod_version", "2.24.5") + set("mod_version", "2.24.6") set("minecraft_version", "1.20.2") set("parchment_version", "2023.12.10") set("worldmap_version_fabric", "1.39.0")