From c1766fb4396e3f55209d5cfa16eed1568cd4fbfa Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 5 Apr 2026 17:30:09 -0500 Subject: [PATCH] lightmap update --- .../mixins/client/MixinLightTexture.java | 17 +++++++- .../mixins/client/MixinLightTexture.java | 39 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java index 8329d4148..203052ddc 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLightTexture.java @@ -24,7 +24,6 @@ import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; -import net.minecraft.client.renderer.LightTexture; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -43,8 +42,19 @@ import com.mojang.blaze3d.opengl.GlTexture; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.textures.GpuTexture; #endif +#if MC_VER <= MC_1_21_11 +import net.minecraft.client.renderer.LightTexture; +#else +import net.minecraft.client.renderer.state.LightmapRenderState; +import net.minecraft.client.renderer.Lightmap; +#endif + +#if MC_VER <= MC_1_21_11 @Mixin(LightTexture.class) +#else +@Mixin(Lightmap.class) +#endif public class MixinLightTexture { @@ -67,8 +77,13 @@ public class MixinLightTexture + #if MC_VER <= MC_1_21_11 @Inject(method = "updateLightTexture(F)V", at = @At("RETURN")) public void updateLightTexture(float partialTicks, CallbackInfo ci) + #else + @Inject(method = "render(Lnet/minecraft/client/renderer/state/LightmapRenderState;)V", at = @At("RETURN")) + public void render(LightmapRenderState renderState, CallbackInfo ci) + #endif { IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); if (mc == null) diff --git a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLightTexture.java b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLightTexture.java index a7890a1f0..5612b9f76 100644 --- a/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLightTexture.java +++ b/neoforge/src/main/java/com/seibel/distanthorizons/neoforge/mixins/client/MixinLightTexture.java @@ -25,11 +25,11 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftCli import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper; import com.seibel.distanthorizons.core.wrapperInterfaces.world.IClientLevelWrapper; import com.seibel.distanthorizons.neoforge.wrappers.NeoforgeTextureUnwrapper; -import net.minecraft.client.renderer.LightTexture; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -43,12 +43,23 @@ import com.mojang.blaze3d.opengl.GlTexture; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.textures.GpuTexture; #else -import net.neoforged.neoforge.client.blaze3d.validation.ValidationGpuTexture; import com.mojang.blaze3d.opengl.GlTexture; import com.mojang.blaze3d.textures.GpuTexture; #endif +#if MC_VER <= MC_1_21_11 +import net.minecraft.client.renderer.LightTexture; +#else +import net.minecraft.client.renderer.Lightmap; +import net.minecraft.client.renderer.state.LightmapRenderState; +#endif + + +#if MC_VER <= MC_1_21_11 @Mixin(LightTexture.class) +#else +@Mixin(Lightmap.class) +#endif public class MixinLightTexture { #if MC_VER < MC_1_21_3 @@ -65,8 +76,19 @@ public class MixinLightTexture private GpuTexture texture; #endif + @Unique + private MinecraftRenderWrapper renderWrapper = null; + + + + + #if MC_VER <= MC_1_21_11 @Inject(method = "updateLightTexture(F)V", at = @At("RETURN")) public void updateLightTexture(float partialTicks, CallbackInfo ci) + #else + @Inject(method = "render(Lnet/minecraft/client/renderer/state/LightmapRenderState;)V", at = @At("RETURN")) + public void render(LightmapRenderState renderState, CallbackInfo ci) + #endif { IMinecraftClientWrapper mc = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); if (mc == null || mc.getWrappedClientLevel() == null) @@ -74,9 +96,18 @@ public class MixinLightTexture return; } - IClientLevelWrapper clientLevel = mc.getWrappedClientLevel(); - MinecraftRenderWrapper renderWrapper = (MinecraftRenderWrapper)SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class); + if (clientLevel == null) + { + return; + } + + // lazy initialization to make sure we don't call this too early + if (this.renderWrapper == null) + { + this.renderWrapper = (MinecraftRenderWrapper)SingletonInjector.INSTANCE.get(IMinecraftRenderWrapper.class); + } + #if MC_VER < MC_1_21_3 renderWrapper.updateLightmap(this.lightPixels, clientLevel);