forked from kvverti/colormatic
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/io/github/kvverti/colormatic/mixin/render/GameRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.github.kvverti.colormatic.mixin.render; | ||
|
||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import io.github.kvverti.colormatic.Lightmaps; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.render.GameRenderer; | ||
import net.minecraft.client.render.LightmapTextureManager; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
|
||
/*** | ||
* | ||
* @author Velnias75 | ||
* | ||
*/ | ||
@Mixin(GameRenderer.class) | ||
public abstract class GameRendererMixin { | ||
|
||
@Shadow | ||
@Final | ||
private MinecraftClient client; | ||
|
||
@Shadow | ||
@Final | ||
private LightmapTextureManager lightmapTextureManager; | ||
|
||
@Inject(method = "renderWorld", at = @At("INVOKE")) | ||
private void onRenderWorldHead(final CallbackInfo info) { | ||
Lightmaps.setWorldRenderFinished(false); | ||
} | ||
|
||
@Inject(method = "renderWorld", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILHARD) | ||
private void onRenderWorldReturn(float tickDelta, long limitTime, MatrixStack matrices, final CallbackInfo info) { | ||
|
||
Lightmaps.setWorldRenderFinished(true); | ||
|
||
if (Lightmaps.get(client.world) != null) { | ||
lightmapTextureManager.update(tickDelta); | ||
lightmapTextureManager.tick(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters