From c5236c66b0da8c0a799da001fefc12584b0cff1a Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:09:05 -0700 Subject: [PATCH] correct dim tint while cross-dim writing --- .../mixin/client/MixinMapTileChunk.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/xaeroplus/mixin/client/MixinMapTileChunk.java b/common/src/main/java/xaeroplus/mixin/client/MixinMapTileChunk.java index 3e63bd17..648ca340 100644 --- a/common/src/main/java/xaeroplus/mixin/client/MixinMapTileChunk.java +++ b/common/src/main/java/xaeroplus/mixin/client/MixinMapTileChunk.java @@ -1,5 +1,7 @@ package xaeroplus.mixin.client; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -7,18 +9,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import xaero.map.MapProcessor; import xaero.map.cache.BlockStateShortShapeCache; +import xaero.map.region.MapRegion; import xaero.map.region.MapTile; import xaero.map.region.MapTileChunk; import xaero.map.region.texture.LeafRegionTexture; +import xaero.map.world.MapDimension; +import xaero.map.world.MapWorld; import xaeroplus.feature.extensions.SeenChunksTrackingMapTileChunk; +import xaeroplus.settings.XaeroPlusSettingRegistry; import java.io.DataInputStream; @Mixin(value = MapTileChunk.class, remap = false) -public class MixinMapTileChunk implements SeenChunksTrackingMapTileChunk { +public abstract class MixinMapTileChunk implements SeenChunksTrackingMapTileChunk { private final boolean[][] seenTiles = new boolean[4][4]; @Shadow private LeafRegionTexture leafTexture; + + @Shadow public abstract MapRegion getInRegion(); + @Override public boolean[][] getSeenTiles() { return seenTiles; @@ -47,4 +56,16 @@ public void readCacheData( } } } + + @WrapOperation(method = "updateBuffers", at = @At( + value = "INVOKE", + target = "Lxaero/map/world/MapWorld;getCurrentDimension()Lxaero/map/world/MapDimension;" + )) + public MapDimension useRegionDimensionInsteadOfMapWorld(final MapWorld mapWorld, final Operation original) { + if (XaeroPlusSettingRegistry.writesWhileDimSwitched.getValue()) { + return getInRegion().getDim(); + } else { + return original.call(mapWorld); + } + } }