aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorFalsePattern <me@falsepattern.com>2024-01-07 13:51:03 +0100
committermakamys <makamys@outlook.com>2024-01-08 22:49:40 +0100
commitcaec6f115cc42e2f2cf73e136892110ba3726251 (patch)
treefa8004e3f600c62ddf5780195fc58784e09cec69 /src/main/java
parentad42f10bad1aa7417ebeb9c3c1f31cd5b19b9220 (diff)
downloadNeodymium-caec6f115cc42e2f2cf73e136892110ba3726251.tar.gz
Neodymium-caec6f115cc42e2f2cf73e136892110ba3726251.tar.bz2
Neodymium-caec6f115cc42e2f2cf73e136892110ba3726251.zip
more robust mixins
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java7
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinGuiMainMenu.java4
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java13
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java8
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinTessellator.java5
-rw-r--r--src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java41
6 files changed, 60 insertions, 18 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java b/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java
index 43fa0b9..2e3fb0d 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinGameSettings_OptiFine.java
@@ -1,5 +1,6 @@
package makamys.neodymium.mixin;
+import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Shadow;
@@ -7,10 +8,12 @@ import org.spongepowered.asm.mixin.Shadow;
import makamys.neodymium.ducks.IMixinGameSettings_OptiFine;
import net.minecraft.client.settings.GameSettings;
-@Mixin(value = GameSettings.class, remap = false)
+@Mixin(value = GameSettings.class,
+ remap = false)
@Pseudo
public class MixinGameSettings_OptiFine implements IMixinGameSettings_OptiFine {
-
+
+ @Dynamic
@Shadow
private int ofFogType;
diff --git a/src/main/java/makamys/neodymium/mixin/MixinGuiMainMenu.java b/src/main/java/makamys/neodymium/mixin/MixinGuiMainMenu.java
index 27f6b07..2851830 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinGuiMainMenu.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinGuiMainMenu.java
@@ -15,7 +15,9 @@ abstract class MixinGuiMainMenu {
@Shadow
private String splashText;
- @Inject(method = "<init>*", at = @At("RETURN"))
+ @Inject(method = "<init>",
+ at = @At("RETURN"),
+ require = 1)
private void postConstructor(CallbackInfo ci) {
splashText = Neodymium.modifySplash(splashText);
}
diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java
index 791dd5d..c430bf6 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal.java
@@ -23,7 +23,10 @@ abstract class MixinRenderGlobal {
private boolean nd$isInsideUpdateRenderers;
- @Inject(method = "renderAllRenderLists", at = @At(value = "HEAD"), cancellable = true)
+ @Inject(method = "renderAllRenderLists",
+ at = @At(value = "HEAD"),
+ cancellable = true,
+ require = 1)
private void blockVanillaChunkRendering(int p1, double p2, CallbackInfo ci) {
if(!Neodymium.shouldRenderVanillaWorld()) {
ci.cancel();
@@ -40,12 +43,16 @@ abstract class MixinRenderGlobal {
}
}
- @Inject(method = "loadRenderers", at = @At(value = "HEAD"))
+ @Inject(method = "loadRenderers",
+ at = @At(value = "HEAD"),
+ require = 1)
public void preLoadRenderers(CallbackInfo ci) {
Neodymium.destroyRenderer();
}
- @Inject(method = "updateRenderers", at = @At(value = "RETURN"))
+ @Inject(method = "updateRenderers",
+ at = @At(value = "RETURN"),
+ require = 1)
public void speedUpChunkUpdatesForDebug(EntityLivingBase entity, boolean flag, CallbackInfoReturnable<Boolean> cir) {
if(Neodymium.isActive() && !nd$isInsideUpdateRenderers) {
nd$isInsideUpdateRenderers = true;
diff --git a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java
index e79f4b7..8d491d0 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinRenderGlobal_OptiFine.java
@@ -3,6 +3,7 @@ package makamys.neodymium.mixin;
import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
+import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -15,7 +16,12 @@ import net.minecraft.client.renderer.RenderGlobal;
abstract class MixinRenderGlobal_OptiFine {
// for OptiFine's Fast Render option
- @Redirect(method = "renderSortedRenderersFast", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glCallLists(Ljava/nio/IntBuffer;)V"), remap=false)
+ @Dynamic
+ @Redirect(method = "renderSortedRenderersFast",
+ at = @At(value = "INVOKE",
+ target = "Lorg/lwjgl/opengl/GL11;glCallLists(Ljava/nio/IntBuffer;)V"),
+ remap=false,
+ require = 1)
private void redirectRenderAllRenderLists(IntBuffer buffer) {
if(Neodymium.shouldRenderVanillaWorld()) {
GL11.glCallLists(buffer);
diff --git a/src/main/java/makamys/neodymium/mixin/MixinTessellator.java b/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
index cdd4ffe..935b860 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinTessellator.java
@@ -20,7 +20,10 @@ abstract class MixinTessellator implements ITessellator {
@Shadow private boolean isDrawing;
- @Inject(method = "draw", at = @At(value = "HEAD"), cancellable = true)
+ @Inject(method = "draw",
+ at = @At(value = "HEAD"),
+ cancellable = true,
+ require = 1)
private void preDraw(CallbackInfoReturnable<Integer> cir) {
if(nd$captureMeshes) {
ChunkMesh.preTessellatorDraw((Tessellator)(Object)this);
diff --git a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
index 6ddf377..4daa525 100644
--- a/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
+++ b/src/main/java/makamys/neodymium/mixin/MixinWorldRenderer.java
@@ -39,12 +39,16 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
private List<ChunkMesh> nd$chunkMeshes;
- @Inject(method = {"updateRenderer"}, at = @At(value = "HEAD"))
+ @Inject(method = {"updateRenderer"},
+ at = @At(value = "HEAD"),
+ require = 1)
private void preUpdateRenderer(CallbackInfo ci) {
preUpdateRenderer(false);
}
- @Inject(method = {"updateRendererSort"}, at = @At(value = "HEAD"))
+ @Inject(method = {"updateRendererSort"},
+ at = @At(value = "HEAD"),
+ require = 1)
private void preUpdateRendererSort(CallbackInfo ci) {
preUpdateRenderer(true);
}
@@ -62,12 +66,16 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
}
}
- @Inject(method = {"updateRenderer"}, at = @At(value = "RETURN"))
+ @Inject(method = {"updateRenderer"},
+ at = @At(value = "RETURN"),
+ require = 1)
private void postUpdateRenderer(CallbackInfo ci) {
postUpdateRenderer(false);
}
- @Inject(method = {"updateRendererSort"}, at = @At(value = "RETURN"))
+ @Inject(method = {"updateRendererSort"},
+ at = @At(value = "RETURN"),
+ require = 1)
private void postUpdateRendererSort(CallbackInfo ci) {
postUpdateRenderer(true);
}
@@ -84,7 +92,9 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
}
}
- @Inject(method = "preRenderBlocks", at = @At("HEAD"))
+ @Inject(method = "preRenderBlocks",
+ at = @At("HEAD"),
+ require = 1)
private void prePreRenderBlocks(int pass, CallbackInfo ci) {
if(Neodymium.isActive()) {
((ITessellator)Tessellator.instance).enableMeshCapturing(true);
@@ -113,7 +123,10 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
GL11.glEndList();
}
- @Inject(method = "postRenderBlocks", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;draw()I"))
+ @Inject(method = "postRenderBlocks",
+ at = @At(value = "INVOKE",
+ target = "Lnet/minecraft/client/renderer/Tessellator;draw()I"),
+ require = 1)
private void prePostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) {
/*if(Neodymium.isActive()) {
if(nd$chunkMeshes != null) {
@@ -125,7 +138,9 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
}*/
}
- @Inject(method = "postRenderBlocks", at = @At("RETURN"))
+ @Inject(method = "postRenderBlocks",
+ at = @At("RETURN"),
+ require = 1)
private void postPostRenderBlocks(int pass, EntityLivingBase entity, CallbackInfo ci) {
if(Neodymium.isActive()) {
nd$chunkMeshes.get(pass).finishConstruction();
@@ -134,7 +149,9 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
}
}
- @Inject(method = "setDontDraw", at = @At(value = "HEAD"))
+ @Inject(method = "setDontDraw",
+ at = @At(value = "HEAD"),
+ require = 1)
private void preSetDontDraw(CallbackInfo ci) {
if(Neodymium.isActive()) {
Neodymium.renderer.onWorldRendererChanged(WorldRenderer.class.cast(this), NeoRenderer.WorldRendererChange.DELETED);
@@ -146,12 +163,16 @@ abstract class MixinWorldRenderer implements IWorldRenderer {
return nd$chunkMeshes;
}
- @Inject(method = "updateInFrustum", at = @At(value = "HEAD"))
+ @Inject(method = "updateInFrustum",
+ at = @At(value = "HEAD"),
+ require = 1)
private void preUpdateInFrustum(CallbackInfo ci) {
saveDrawnStatus();
}
- @Inject(method = "updateInFrustum", at = @At(value = "RETURN"))
+ @Inject(method = "updateInFrustum",
+ at = @At(value = "RETURN"),
+ require = 1)
private void postUpdateInFrustum(CallbackInfo ci) {
notifyIfDrawnStatusChanged();
}