aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/mixin/unused/lod
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-09 13:26:00 +0200
committermakamys <makamys@outlook.com>2022-06-09 13:26:04 +0200
commitb71b950132db103d85000cf322a4217e6b7c5e53 (patch)
tree88f9be28947f565c846d8cd951010aa1b2168e2d /src/main/java/makamys/neodymium/mixin/unused/lod
parentdd14fdbec57d9953fc9a7484c74af32809ccc94e (diff)
downloadNeodymium-b71b950132db103d85000cf322a4217e6b7c5e53.tar.gz
Neodymium-b71b950132db103d85000cf322a4217e6b7c5e53.tar.bz2
Neodymium-b71b950132db103d85000cf322a4217e6b7c5e53.zip
Clean up and document mixins
Diffstat (limited to 'src/main/java/makamys/neodymium/mixin/unused/lod')
-rw-r--r--src/main/java/makamys/neodymium/mixin/unused/lod/MixinChunkCache.java30
-rw-r--r--src/main/java/makamys/neodymium/mixin/unused/lod/MixinEntityRenderer.java36
-rw-r--r--src/main/java/makamys/neodymium/mixin/unused/lod/MixinRenderBlocks.java30
3 files changed, 96 insertions, 0 deletions
diff --git a/src/main/java/makamys/neodymium/mixin/unused/lod/MixinChunkCache.java b/src/main/java/makamys/neodymium/mixin/unused/lod/MixinChunkCache.java
new file mode 100644
index 0000000..f1da9bb
--- /dev/null
+++ b/src/main/java/makamys/neodymium/mixin/unused/lod/MixinChunkCache.java
@@ -0,0 +1,30 @@
+package makamys.neodymium.mixin.unused.lod;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import makamys.neodymium.Neodymium;
+import makamys.neodymium.renderer.FarChunkCache;
+import makamys.neodymium.renderer.NeoRenderer;
+import net.minecraft.world.ChunkCache;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+
+/** Unused remnant from LODMod. Handles reusage of Chunks when a LOD chunk becomes loaded. */
+@Mixin(ChunkCache.class)
+abstract class MixinChunkCache {
+
+ @Redirect(method = "<init>*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getChunkFromChunkCoords(II)Lnet/minecraft/world/chunk/Chunk;"))
+ private Chunk redirectGetChunkFromChunkCoords(World world, int p1, int p2) {
+ Chunk chunk = world.getChunkFromChunkCoords(p1, p2);
+ if(Neodymium.isActive() && FarChunkCache.class.isInstance(this.getClass()) && chunk.isEmpty()) {
+ Chunk myChunk = Neodymium.renderer.getChunkFromChunkCoords(p1, p2);
+ if(myChunk != null) {
+ chunk = myChunk;
+ }
+ }
+ return chunk;
+ }
+
+}
diff --git a/src/main/java/makamys/neodymium/mixin/unused/lod/MixinEntityRenderer.java b/src/main/java/makamys/neodymium/mixin/unused/lod/MixinEntityRenderer.java
new file mode 100644
index 0000000..a88ac72
--- /dev/null
+++ b/src/main/java/makamys/neodymium/mixin/unused/lod/MixinEntityRenderer.java
@@ -0,0 +1,36 @@
+package makamys.neodymium.mixin.unused.lod;
+
+import org.lwjgl.opengl.GL11;
+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.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import makamys.neodymium.Neodymium;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.EntityRenderer;
+import net.minecraft.entity.EntityLivingBase;
+
+/** Unused remnant from LODMod. Handles changing fog distance. */
+@Mixin(EntityRenderer.class)
+abstract class MixinEntityRenderer {
+
+ @Shadow
+ private float farPlaneDistance;
+
+ @Inject(method = "setupCameraTransform", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;farPlaneDistance:F", shift = At.Shift.AFTER, ordinal = 1))
+ private void onConstructed(CallbackInfo ci) {
+ if(Neodymium.isActive()) {
+ farPlaneDistance *= Neodymium.renderer.getFarPlaneDistanceMultiplier();
+ }
+ }
+
+ @Inject(method = "setupFog", at = @At(value = "RETURN"))
+ private void afterSetupFog(int mode, float alpha, CallbackInfo ci) {
+ if(Neodymium.isActive()) {
+ Neodymium.renderer.afterSetupFog(mode, alpha, farPlaneDistance);
+ }
+ }
+}
diff --git a/src/main/java/makamys/neodymium/mixin/unused/lod/MixinRenderBlocks.java b/src/main/java/makamys/neodymium/mixin/unused/lod/MixinRenderBlocks.java
new file mode 100644
index 0000000..27b0605
--- /dev/null
+++ b/src/main/java/makamys/neodymium/mixin/unused/lod/MixinRenderBlocks.java
@@ -0,0 +1,30 @@
+package makamys.neodymium.mixin.unused.lod;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import makamys.neodymium.Neodymium;
+import makamys.neodymium.renderer.FarChunkCache;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+
+/** Unused remnant from LODMod. Disables a wall being drawn on the edges of chunks facing unloaded chunks. */
+@Mixin(RenderBlocks.class)
+abstract class MixinRenderBlocks {
+
+ @Redirect(method = "renderBlockLiquid", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;shouldSideBeRendered(Lnet/minecraft/world/IBlockAccess;IIII)Z"))
+ public boolean shouldSideBeRendered(Block block, IBlockAccess ba, int x, int y, int z, int w) {
+ if(Neodymium.isActive()) {
+ return Neodymium.renderer.shouldSideBeRendered(block, ba, x, y, z, w);
+ } else {
+ return block.shouldSideBeRendered(ba, x, y, z, w);
+ }
+ }
+
+}