diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f7487c42..d23d0edd 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -5,8 +5,8 @@ on: branches: - "mainline" env: - WORLDMAP_VERSION: "1.34.1" - MINIMAP_VERSION: "23.8.0" + WORLDMAP_VERSION: "1.35.0" + MINIMAP_VERSION: "23.8.3" MINECRAFT_VERSION: "1.12.2" MINECRAFT_VERSION_SHORT: "1.12" MOD_LOADER: "Forge" diff --git a/build.gradle b/build.gradle index 8e80909f..7fee8b4d 100644 --- a/build.gradle +++ b/build.gradle @@ -112,10 +112,10 @@ dependencies { } jarLibs 'com.github.ben-manes.caffeine:caffeine:2.9.3' - jarLibs 'org.xerial:sqlite-jdbc:3.42.0.0' + jarLibs 'org.xerial:sqlite-jdbc:3.43.0.0' - implementation(fg.deobf("maven.modrinth:xaeros-world-map:1.34.1_Forge_1.12")) - implementation(fg.deobf("maven.modrinth:xaeros-minimap:23.8.0_Forge_1.12")) + implementation(fg.deobf("maven.modrinth:xaeros-world-map:1.35.0_Forge_1.12")) + implementation(fg.deobf("maven.modrinth:xaeros-minimap:23.8.3_Forge_1.12")) implementation(fg.deobf('cabaletta:baritone-deobf-unoptimized-mcp-dev:1.2')).setChanging(true) compileOnly(fg.deobf("curse.maven:waystones-245755:2859589")) diff --git a/src/main/java/xaeroplus/XaeroPlus.java b/src/main/java/xaeroplus/XaeroPlus.java index 1d1395c0..6d95cb77 100644 --- a/src/main/java/xaeroplus/XaeroPlus.java +++ b/src/main/java/xaeroplus/XaeroPlus.java @@ -17,7 +17,7 @@ modid = XaeroPlus.MODID, name = XaeroPlus.NAME, version = XaeroPlus.VERSION, - dependencies = "after:xaerominimap;after:xaerobetterpvp;required-after:xaeroworldmap@[1.34.1];" + dependencies = "after:xaerominimap;after:xaerobetterpvp;required-after:xaeroworldmap@[1.35.0];" ) public class XaeroPlus { public static final String MODID = "xaeroplus"; diff --git a/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java b/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java index 920a4ab8..4d027c94 100644 --- a/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java +++ b/src/main/java/xaeroplus/mixin/client/MixinGuiMap.java @@ -171,7 +171,7 @@ protected MixinGuiMap(GuiScreen parent, GuiScreen escape) { @Shadow private long lastStartTime; @Shadow - private GuiMapSwitching dimensionSettings; + private GuiMapSwitching mapSwitchingGui; @Shadow private MapMouseButtonPress leftMouseButton; @Shadow @@ -401,10 +401,10 @@ public void customDrawScreen(int scaledMouseX, int scaledMouseY, float partialTi long startTime = System.currentTimeMillis(); MapDimension currentDim = !this.mapProcessor.isMapWorldUsable() ? null : this.mapProcessor.getMapWorld().getCurrentDimension(); if (currentDim != this.dimension) { - this.dimensionSettings.active = false; + this.mapSwitchingGui.active = false; this.setWorldAndResolution(mc, this.width, this.height); } - this.dimensionSettings.preMapRender((GuiMap)(Object) this, mc, this.width, this.height); + this.mapSwitchingGui.preMapRender((GuiMap)(Object) this, mc, this.width, this.height); long passed = this.lastStartTime == 0L ? 16L : startTime - this.lastStartTime; double passedScrolls = (double)((float)passed / 64.0F); int direction = this.buttonPressed != this.zoomInButton && !ControlsHandler.isDown(ControlsRegister.keyZoomIn) @@ -634,10 +634,7 @@ public void customDrawScreen(int scaledMouseX, int scaledMouseY, float partialTi } } - if (this.mapProcessor.getMapWorld().isMultiplayer()) { - this.drawString(mc.fontRenderer, "MultiWorld ID: " + this.mapProcessor.getMapWorld().getCurrentMultiworld(), 5, 255, -1); - } - + this.drawString(mc.fontRenderer, "MultiWorld ID: " + this.mapProcessor.getMapWorld().getCurrentMultiworld(), 5, 255, -1); LayeredRegionManager regions = this.mapProcessor.getMapWorld().getDimension(Shared.customDimensionId).getLayeredMapRegions(); this.drawString( mc.fontRenderer, @@ -1614,7 +1611,7 @@ public void customDrawScreen(int scaledMouseX, int scaledMouseY, float partialTi } } - this.dimensionSettings.renderText(mc, scaledMouseX, scaledMouseY, this.width, this.height); + this.mapSwitchingGui.renderText(mc, scaledMouseX, scaledMouseY, this.width, this.height); mc.getTextureManager().bindTexture(WorldMap.guiTextures); if (!mc.gameSettings.hideGUI) { this.drawTexturedModalRect(this.width - 34, 2, 0, 37, 32, 32); diff --git a/src/main/java/xaeroplus/mixin/client/MixinMapProcessor.java b/src/main/java/xaeroplus/mixin/client/MixinMapProcessor.java index ff7c4916..f4e047df 100644 --- a/src/main/java/xaeroplus/mixin/client/MixinMapProcessor.java +++ b/src/main/java/xaeroplus/mixin/client/MixinMapProcessor.java @@ -2,7 +2,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -16,13 +15,11 @@ import xaero.map.*; import xaero.map.biome.BiomeColorCalculator; import xaero.map.cache.BlockStateColorTypeCache; -import xaero.map.effects.Effects; import xaero.map.file.MapSaveLoad; import xaero.map.file.RegionDetection; import xaero.map.file.worldsave.WorldDataHandler; import xaero.map.gui.GuiMap; import xaero.map.misc.CaveStartCalculator; -import xaero.map.misc.Misc; import xaero.map.mods.SupportMods; import xaero.map.region.*; import xaero.map.world.MapDimension; @@ -170,64 +167,9 @@ public abstract class MixinMapProcessor implements CustomDimensionMapProcessor { @Shadow private OverlayManager overlayManager; - /** - * @author rfresh2 - * @reason custom dimension support - */ - @Overwrite - public void updateCaveStart() { - Minecraft mc = Minecraft.getMinecraft(); - MapDimension dimension = this.mapWorld.getDimension(Shared.customDimensionId); - int newCaveStart; - // cave mode type = 2 means "Full" - if (WorldMap.settings.isCaveMapsAllowed() && dimension.getCaveModeType() != 0) { - if (WorldMap.settings.caveModeStart == Integer.MAX_VALUE) { - newCaveStart = Integer.MIN_VALUE; // this renders us like the "off" mode for some reason - } else { - newCaveStart = WorldMap.settings.caveModeStart; - } - - boolean isMapScreen = mc.currentScreen instanceof GuiMap || Misc.screenShouldSkipWorldRender(mc.currentScreen, true); - if (!isMapScreen - || !Minecraft.getMinecraft().player.isPotionActive(Effects.NO_CAVE_MAPS) - && !Minecraft.getMinecraft().player.isPotionActive(Effects.NO_CAVE_MAPS_HARMFUL)) { - if (SupportMods.minimap() && (WorldMap.settings.autoCaveMode < 0 && newCaveStart == Integer.MIN_VALUE || !isMapScreen)) { - newCaveStart = SupportMods.xaeroMinimap.getCaveStart(newCaveStart, isMapScreen); - } - - if (newCaveStart == Integer.MIN_VALUE) { - long currentTime = System.currentTimeMillis(); - int nextLocalCaveMode = this.caveStartCalculator.getCaving(mc.player.posX, mc.player.posY, mc.player.posZ, mc.world); - boolean toggling = this.localCaveMode == Integer.MAX_VALUE != (nextLocalCaveMode == Integer.MAX_VALUE); - if (!toggling || currentTime - this.lastLocalCaveModeToggle > (long) WorldMap.settings.caveModeToggleTimer) { - if (toggling) { - this.lastLocalCaveModeToggle = currentTime; - } - - this.localCaveMode = nextLocalCaveMode; - } - - newCaveStart = this.localCaveMode; - } - - if (dimension.getCaveModeType() == 2) { // fixed this when height is set to "auto" so it actually does the full caving - newCaveStart = Integer.MIN_VALUE; // "Full" - } - if (newCaveStart != Integer.MAX_VALUE) { - if (dimension.getCaveModeType() != 2) { - newCaveStart = MathHelper.clamp(newCaveStart, 0, this.world.getHeight() - 1); - } - } - } else { - newCaveStart = Integer.MAX_VALUE; // "off" - } - } else { - newCaveStart = Integer.MAX_VALUE; // "off" - } - - int newCaveLayer = this.getCaveLayer(newCaveStart); - dimension.getLayeredMapRegions().getLayer(newCaveLayer).setCaveStart(newCaveStart); - this.currentCaveLayer = newCaveLayer; + @Redirect(method = "updateCaveStart", at = @At(value = "INVOKE", target = "Lxaero/map/world/MapWorld;getCurrentDimension()Lxaero/map/world/MapDimension;")) + public MapDimension getCurrentDimensionRedirect(final MapWorld instance) { + return instance.getDimension(Shared.customDimensionId); } @Redirect(method = "updateWorld", at = @At(value = "INVOKE", target = "Lxaero/map/file/MapSaveLoad;detectRegions(I)V")) @@ -260,23 +202,24 @@ public void run(MapRunner runner) { if (!this.isProcessingPaused()) { this.updateWorld(); if (this.world != null) { - this.updateCaveStart(); this.updateFootprints(this.world, Minecraft.getMinecraft().currentScreen instanceof GuiMap ? 1 : 10); } if (this.mapWorldUsable) { this.mapLimiter.applyLimit(this.mapWorld, (MapProcessor) (Object) this); long currentTime = System.currentTimeMillis(); - block11: - for (ArrayList<LeveledRegion<?>> regionsToProcess : this.toProcessLevels) { - for (int i = 0; i < regionsToProcess.size(); ++i) { + for(int l = 0; l < this.toProcessLevels.length; ++l) { + ArrayList<LeveledRegion<?>> regionsToProcess = this.toProcessLevels[l]; + + for(int i = 0; i < regionsToProcess.size(); ++i) { LeveledRegion<?> leveledRegion; - ArrayList<LeveledRegion<?>> arrayList = regionsToProcess; - synchronized (arrayList) { + synchronized(regionsToProcess) { if (i >= regionsToProcess.size()) { - continue block11; + break; } + leveledRegion = regionsToProcess.get(i); } + this.mapSaveLoad.updateSave(leveledRegion, currentTime, this.currentCaveLayer); } } @@ -329,11 +272,10 @@ synchronized void updateWorldSynced(final CallbackInfo ci) throws IOException { this.mapWorld.getFutureDimension() != this.mapWorld.getCurrentDimension() || !this.mapWorld.getFutureDimension().getFutureMultiworldUnsynced().equals(this.mapWorld.getFutureDimension().getCurrentMultiworld()) )) { - String newMultiworldId = !this.mapWorldUsableRequest ? null : this.mapWorld.getFutureMultiworldUnsynced(); + String newMWId = !this.mapWorldUsableRequest ? null : this.mapWorld.getFutureMultiworldUnsynced(); this.pushRenderPause(true, true); this.pushWriterPause(); String newWorldId = !this.mapWorldUsableRequest ? null : this.mapWorld.getMainId(); - String newMWId = !this.mapWorld.isMultiplayer() ? null : newMultiworldId; boolean shouldClearAllDimensions = this.state == 1; boolean shouldClearNewDimension = this.mapWorldUsableRequest && !this.mapWorld.getFutureMultiworldUnsynced().equals(this.mapWorld.getFutureDimension().getCurrentMultiworld()); @@ -360,7 +302,7 @@ synchronized void updateWorldSynced(final CallbackInfo ci) throws IOException { if (shouldFinishCurrentDim) { if (region.getLevel() == 0) { MapRegion leafRegion = (MapRegion) region; - if (!leafRegion.isMultiplayer() && !leafRegion.hasLookedForCache() && leafRegion.isOutdatedWithOtherLayers()) { + if (!leafRegion.isNormalMapData() && !leafRegion.hasLookedForCache() && leafRegion.isOutdatedWithOtherLayers()) { File potentialCacheFile = this.mapSaveLoad.getCacheFile(leafRegion, leafRegion.getCaveLayer(), false, false); if (potentialCacheFile.exists()) { leafRegion.setCacheFile(potentialCacheFile); @@ -506,7 +448,7 @@ synchronized void updateWorldSynced(final CallbackInfo ci) throws IOException { XaeroPlus.EVENT_BUS.post(new XaeroWorldChangeEvent(this.currentWorldId, this.currentDimId, this.currentMWId)); this.worldDataHandler.prepareSingleplayer(this.world, (MapProcessor) (Object) this); - if (this.worldDataHandler.getWorldDir() == null && this.currentWorldId != null && !this.mapWorld.isMultiplayer()) { + if (this.worldDataHandler.getWorldDir() == null && this.currentWorldId != null && this.mapWorld.getCurrentDimension().isUsingWorldSave()) { this.currentWorldId = this.currentDimId = null; } @@ -605,7 +547,7 @@ public MapRegion getMapRegionCustomDimension(int caveLayer, int regX, int regZ, regZ, caveLayer, this.getGlobalVersion(), - this.mapWorld.isMultiplayer() + !mapDimension.isUsingWorldSave() ); MapLayer mapLayer = regions.getLayer(caveLayer); region.updateCaveMode(); @@ -613,7 +555,7 @@ public MapRegion getMapRegionCustomDimension(int caveLayer, int regX, int regZ, if (regionDetection != null) { regionDetection.transferInfoTo(region); mapLayer.removeRegionDetection(regX, regZ); - } else if (!region.isMultiplayer() && mapDimension.getWorldSaveRegionDetection(regX, regZ) == null) { + } else if (!region.isNormalMapData() && mapDimension.getWorldSaveRegionDetection(regX, regZ) == null) { RegionDetection worldSaveRegionDetection = new RegionDetection( region.getWorldId(), region.getDimId(), diff --git a/src/main/java/xaeroplus/mixin/client/MixinMapSaveLoad.java b/src/main/java/xaeroplus/mixin/client/MixinMapSaveLoad.java index 13376efc..1016b7da 100644 --- a/src/main/java/xaeroplus/mixin/client/MixinMapSaveLoad.java +++ b/src/main/java/xaeroplus/mixin/client/MixinMapSaveLoad.java @@ -89,7 +89,7 @@ public void getOldFolder(final String oldUnfixedMainId, final String dim, final */ @Overwrite public boolean loadRegion(World world, MapRegion region, BlockStateColorTypeCache colourTypeCache, int extraAttempts) { - boolean multiplayer = region.isMultiplayer(); + boolean multiplayer = region.isNormalMapData(); int emptySize = multiplayer ? 0 : 8192; int saveVersion = -1; boolean versionReached = false; @@ -345,9 +345,9 @@ public boolean saveRegion(MapRegion region, int extraAttempts) { } return region.countChunks() > 0; - } else if (!region.isMultiplayer()) { + } else if (!region.isNormalMapData()) { if (WorldMap.settings.debug) { - WorldMap.LOGGER.info("Save not required for singleplayer: " + region + " " + region.getWorldId() + " " + region.getDimId()); + WorldMap.LOGGER.info("Save not required for world save map: " + region + " " + region.getWorldId() + " " + region.getDimId()); } return region.countChunks() > 0; @@ -516,12 +516,12 @@ public void detectRegionsInDimension(int attempts, final int dimId) { if (worldId != null && !this.mapProcessor.isCurrentMapLocked()) { final String dimIdStr = this.mapProcessor.getDimensionName(dimId); final String mwId = this.mapProcessor.getCurrentMWId(); - final boolean multiplayer = this.mapProcessor.isWorldMultiplayer(this.mapProcessor.isWorldRealms(worldId), worldId); + final boolean usingNormalMapData = !mapDimension.isUsingWorldSave(); Path mapFolder = this.getMWSubFolder(worldId, dimIdStr, mwId); boolean mapFolderExists = mapFolder.toFile().exists(); String multiplayerMapRegex = "^(-?\\d+)_(-?\\d+)\\.(zip|xaero)$"; final MapLayer mainLayer = mapDimension.getLayeredMapRegions().getLayer(Integer.MAX_VALUE); - if (multiplayer) { + if (usingNormalMapData) { if (mapFolderExists) { this.detectRegionsFromFiles( mapDimension, worldId, dimIdStr, mwId, mapFolder, multiplayerMapRegex, 1, 2, 0, 20, new Consumer<RegionDetection>() { @@ -575,7 +575,7 @@ public void accept(Path layerFolder) { try { int layerInt = Integer.parseInt(folderName); final MapLayer layer = mapDimension.getLayeredMapRegions().getLayer(layerInt); - if (multiplayer) { + if (usingNormalMapData) { detectRegionsFromFiles( mapDimension, worldId, diff --git a/src/main/java/xaeroplus/mixin/client/MixinMapWriter.java b/src/main/java/xaeroplus/mixin/client/MixinMapWriter.java index a4ea6daf..96feb180 100644 --- a/src/main/java/xaeroplus/mixin/client/MixinMapWriter.java +++ b/src/main/java/xaeroplus/mixin/client/MixinMapWriter.java @@ -1,7 +1,5 @@ package xaeroplus.mixin.client; -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.block.BlockGlass; @@ -36,7 +34,6 @@ import xaeroplus.settings.XaeroPlusSettingRegistry; import java.util.ArrayList; -import java.util.concurrent.TimeUnit; @Mixin(value = MapWriter.class, remap = false) public abstract class MixinMapWriter { @@ -111,19 +108,6 @@ public abstract boolean writeMap( int caveDepth ); - // insert our own limiter on new tiles being written but this one's keyed on the actual chunk - // tile "writes" also include a lot of extra operations and lookups before any writing is actually done - // when we remove existing limiters those extra operations add up to a lot of unnecessary cpu time - private final Cache<Long, Long> tileUpdateCache = Caffeine.newBuilder() - // I would usually expect even second long expiration here to be fine - // but there are some operations that make repeat invocations actually required - // perhaps another time ill rewrite those. Or make the cache lock more aware of when we don't have any new updates to write/load - // there's still alot of performance and efficiency on the table to regain - // but i think this is a good middle ground for now - .maximumSize(10000) - .expireAfterWrite(5L, TimeUnit.SECONDS) - .<Long, Long>build(); - protected MixinMapWriter() { }