diff --git a/.editorconfig b/.editorconfig index 2536421b5..3491f2db7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,8 @@ # DH Main root = true +# Note: please keep this and the core .editorconfig in sync + [*] charset = utf-8 end_of_line = crlf diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java index 9fa88020f..0b8f7791a 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/DependencySetup.java @@ -19,10 +19,12 @@ package com.seibel.distanthorizons.common.wrappers; +import com.seibel.distanthorizons.common.wrappers.gui.ClassicConfigGUI; import com.seibel.distanthorizons.common.wrappers.gui.LangWrapper; import com.seibel.distanthorizons.common.wrappers.level.KeyedClientLevelManager; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftDedicatedServerWrapper; import com.seibel.distanthorizons.core.level.IKeyedClientLevelManager; +import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui; import com.seibel.distanthorizons.core.wrapperInterfaces.config.ILangWrapper; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftClientWrapper; import com.seibel.distanthorizons.common.wrappers.minecraft.MinecraftRenderWrapper; @@ -70,6 +72,7 @@ public class DependencySetup SingletonInjector.INSTANCE.bind(IMinecraftSharedWrapper.class, MinecraftClientWrapper.INSTANCE); SingletonInjector.INSTANCE.bind(IMinecraftRenderWrapper.class, MinecraftRenderWrapper.INSTANCE); SingletonInjector.INSTANCE.bind(IReflectionHandler.class, ReflectionHandler.INSTANCE); + SingletonInjector.INSTANCE.bind(IConfigGui.class, ClassicConfigGUI.CONFIG_CORE_INTERFACE); } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java index 5e95387e6..209073efb 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockDetailMap.java @@ -23,7 +23,7 @@ public class ClientBlockDetailMap public int getColor(BlockState state, BiomeWrapper biome, DhBlockPos pos) { - return getBlockStateData(state, pos).getAndResolveFaceColor(biome); + return getBlockStateData(state, pos).getAndResolveFaceColor(biome, pos); } } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java index ea5512f28..235b196a8 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/block/cache/ClientBlockStateCache.java @@ -211,12 +211,12 @@ public class ClientBlockStateCache isColorResolved = true; } - public int getAndResolveFaceColor(BiomeWrapper biome) + public int getAndResolveFaceColor(BiomeWrapper biome, DhBlockPos pos) { // FIXME: impl per-face colors if (!needPostTinting) return baseColor; int tintColor = Minecraft.getInstance().getBlockColors() - .getColor(state, new TintWithoutLevelOverrider(biome), pos, tintIndex); + .getColor(state, new TintWithoutLevelOverrider(biome), McObjectConverter.Convert(pos), tintIndex); if (tintColor == -1) return baseColor; return ColorUtil.multiplyARGBwithRGB(baseColor, tintColor); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java index 770e1a319..894552577 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/gui/ClassicConfigGUI.java @@ -27,9 +27,10 @@ import com.seibel.distanthorizons.common.wrappers.gui.updater.ChangelogScreen; // Minecraft imports -import com.mojang.blaze3d.vertex.PoseStack; +import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.jar.updater.SelfUpdater; import com.seibel.distanthorizons.core.util.AnnotationUtil; +import com.seibel.distanthorizons.core.wrapperInterfaces.config.IConfigGui; import com.seibel.distanthorizons.coreapi.ModInfo; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; @@ -79,6 +80,9 @@ public class ClassicConfigGUI private static final Logger LOGGER = LogManager.getLogger(); + public static final ConfigCoreInterface CONFIG_CORE_INTERFACE = new ConfigCoreInterface(); + + //==============// // Initializers // @@ -225,7 +229,9 @@ public class ClassicConfigGUI public void onClose() { ConfigBase.INSTANCE.configFileINSTANCE.saveToFile(); - Objects.requireNonNull(minecraft).setScreen(this.parent); + Objects.requireNonNull(this.minecraft).setScreen(this.parent); + + CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); } @Override @@ -233,7 +239,9 @@ public class ClassicConfigGUI { super.init(); if (!reload) + { ConfigBase.INSTANCE.configFileINSTANCE.loadFromFile(); + } // Changelog button if (Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get()) @@ -285,6 +293,11 @@ public class ClassicConfigGUI e.printStackTrace(); } } + + + + CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run()); + } private void addMenuItem(AbstractConfigType info) @@ -385,6 +398,11 @@ public class ClassicConfigGUI { AbstractWidget buttonWidget = list.getHoveredButton(mouseX, mouseY).get(); Component text = ButtonEntry.buttonsWithText.get(buttonWidget); + if (text == null) + { + continue; + } + // A quick fix for tooltips on linked entries AbstractConfigType newInfo = ConfigLinkedEntry.class.isAssignableFrom(info.getClass()) ? ((ConfigLinkedEntry) info).get() : @@ -611,4 +629,29 @@ public class ClassicConfigGUI #endif } + + + + + //================// + // event handling // + //================// + + private static class ConfigCoreInterface implements IConfigGui + { + /** + * in the future it would be good to pass in the current page and other variables, + * but for now just knowing when the page is closed is good enough + */ + public final ArrayList onScreenChangeListenerList = new ArrayList<>(); + + + + @Override + public void addOnScreenChangeListener(Runnable newListener) { this.onScreenChangeListenerList.add(newListener); } + @Override + public void removeOnScreenChangeListener(Runnable oldListener) { this.onScreenChangeListenerList.remove(oldListener); } + + } + } diff --git a/coreSubProjects b/coreSubProjects index 42a84a54e..84c4ad6cd 160000 --- a/coreSubProjects +++ b/coreSubProjects @@ -1 +1 @@ -Subproject commit 42a84a54e16645b88ac250bc02bcc863cd8dcfc5 +Subproject commit 84c4ad6cdd772ffe7bace0fe56842fdbf3bcbeda diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index 561104776..16c8187b7 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -61,7 +61,7 @@ import java.util.HashSet; /** * This handles all events sent to the client, * and is the starting point for most of the mod. - * + * * @author coolGi * @author Ran * @version 2023-7-27 @@ -74,7 +74,7 @@ public class FabricClientProxy private static final Logger LOGGER = DhLoggerBuilder.getLogger(); // TODO we shouldn't be filtering keys on the Forge/Fabric side, only in ClientApi - private static final int[] KEY_TO_CHECK_FOR = {GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8, GLFW.GLFW_KEY_P}; + private static final int[] KEY_TO_CHECK_FOR = { GLFW.GLFW_KEY_F6, GLFW.GLFW_KEY_F8, GLFW.GLFW_KEY_P}; HashSet previouslyPressKeyCodes = new HashSet<>(); @@ -82,7 +82,6 @@ public class FabricClientProxy /** * Registers Fabric Events - * * @author Ran */ public void registerEvents() @@ -144,7 +143,7 @@ public class FabricClientProxy }); // (kinda) block place event - UseBlockCallback.EVENT.register((player, level, hand, hitResult) -> + UseBlockCallback.EVENT.register((player, level, hand, hitResult) -> { // if we have access to the server, use the chunk save event instead if (MC.clientConnectedToDedicatedServer()) @@ -227,7 +226,7 @@ public class FabricClientProxy // Debug keyboard event // FIXME: Use better hooks so it doesn't trigger key press events in text boxes - ClientTickEvents.END_CLIENT_TICK.register(client -> + ClientTickEvents.END_CLIENT_TICK.register(client -> { if (client.player != null && !(Minecraft.getInstance().screen instanceof TitleScreen)) { diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java index 5ee0f0718..698359389 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java @@ -55,13 +55,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(LevelRenderer.class) public class MixinLevelRenderer { - @Shadow - private ClientLevel level; - @Unique - private static float previousPartialTicks = 0; + @Shadow + private ClientLevel level; + @Unique + private static float previousPartialTicks = 0; - // Inject rendering at first call to renderChunkLayer - // HEAD or RETURN + // Inject rendering at first call to renderChunkLayer + // HEAD or RETURN #if PRE_MC_1_17_1 @Inject(at = @At("RETURN"), method = "renderSky(Lcom/mojang/blaze3d/vertex/PoseStack;F)V") private void renderSky(PoseStack matrixStackIn, float partialTicks, CallbackInfo callback) @@ -71,13 +71,12 @@ public class MixinLevelRenderer previousPartialTicks = partialTicks; } #else - @Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true) - public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) - { - // get the partial ticks since renderChunkLayer doesn't - // have access to them - previousPartialTicks = tickDelta; - } + @Inject(method = "renderClouds", at = @At("HEAD"), cancellable = true) + public void renderClouds(PoseStack poseStack, Matrix4f projectionMatrix, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) { + // get the partial ticks since renderChunkLayer doesn't + // have access to them + previousPartialTicks = tickDelta; + } #endif #if PRE_MC_1_17_1 @@ -86,53 +85,56 @@ public class MixinLevelRenderer cancellable = true) private void renderChunkLayer(RenderType renderType, PoseStack matrixStackIn, double xIn, double yIn, double zIn, CallbackInfo callback) #elif PRE_MC_1_19_4 - @Inject(at = @At("HEAD"), - method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V", - cancellable = true) - private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback) + @Inject(at = @At("HEAD"), + method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V", + cancellable = true) + private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback) #else - @Inject(at = @At("HEAD"), - method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", - cancellable = true) - private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback) + @Inject(at = @At("HEAD"), + method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V", + cancellable = true) + private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback) #endif { // FIXME completely disables rendering when sodium is installed if (Config.Client.Advanced.Debugging.lodOnlyMode.get()) { - callback.cancel(); + callback.cancel(); } - } + } - @Redirect(method = - "Lnet/minecraft/client/renderer/LevelRenderer;" + - "renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;" + - "FJZLnet/minecraft/client/Camera;" + - "Lnet/minecraft/client/renderer/GameRenderer;" + - "Lnet/minecraft/client/renderer/LightTexture;" + + @Redirect(method = + "Lnet/minecraft/client/renderer/LevelRenderer;" + + "renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;" + + "FJZLnet/minecraft/client/Camera;" + + "Lnet/minecraft/client/renderer/GameRenderer;" + + "Lnet/minecraft/client/renderer/LightTexture;" + #if PRE_MC_1_19_4 - "Lcom/mojang/math/Matrix4f;)V" - #else - "Lorg/joml/Matrix4f;)V" - #endif - , - at = @At( - value = "INVOKE", - #if PRE_MC_1_20_1 - target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I" - #else - target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I" - #endif - )) - private int callAfterRunUpdates(LevelLightEngine light #if PRE_MC_1_20_1 , int pos, boolean isQueueEmpty, boolean updateBlockLight #endif ) - { + "Lcom/mojang/math/Matrix4f;)V" + #else + "Lorg/joml/Matrix4f;)V" + #endif + , + at = @At( + value = "INVOKE", + #if PRE_MC_1_20_1 + target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I" + #else + target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I" + #endif + )) + private int callAfterRunUpdates(LevelLightEngine light #if PRE_MC_1_20_1 , int pos, boolean isQueueEmpty, boolean updateBlockLight #endif) + { #if PRE_MC_1_20_1 - int r = light.runUpdates(pos, isQueueEmpty, updateBlockLight); + int r = light.runUpdates(pos, isQueueEmpty, updateBlockLight); #else - int r = light.runLightUpdates(); + int r = light.runLightUpdates(); #endif - ChunkWrapper.syncedUpdateClientLightStatus(); - return r; - } + ChunkWrapper.syncedUpdateClientLightStatus(); + return r; + } + + + }