Skip to content

Commit

Permalink
WM1.35.0 MM23.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Oct 15, 2023
1 parent 12526f8 commit f4db161
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xaeroplus/XaeroPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/xaeroplus/mixin/client/MixinGuiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
90 changes: 16 additions & 74 deletions src/main/java/xaeroplus/mixin/client/MixinMapProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -605,15 +547,15 @@ 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();
RegionDetection regionDetection = mapLayer.getRegionDetection(regX, 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(),
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/xaeroplus/mixin/client/MixinMapSaveLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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>() {
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/xaeroplus/mixin/client/MixinMapWriter.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
}

Expand Down

0 comments on commit f4db161

Please sign in to comment.