diff options
author | makamys <makamys@outlook.com> | 2021-05-09 07:17:04 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-09 07:17:04 +0200 |
commit | 0931696d367063a547f1e30be7fa4ac968070f76 (patch) | |
tree | 7ae600f619951a8097d44c47ddddf07cdbfe4f75 /src/main/java/makamys/lodmod | |
parent | 7ee84793385544d646be3d18dd3da8904e917939 (diff) | |
download | Neodymium-0931696d367063a547f1e30be7fa4ac968070f76.tar.gz Neodymium-0931696d367063a547f1e30be7fa4ac968070f76.tar.bz2 Neodymium-0931696d367063a547f1e30be7fa4ac968070f76.zip |
Patch RenderBlocks to not render sides of water on the edge of the world
Diffstat (limited to 'src/main/java/makamys/lodmod')
3 files changed, 43 insertions, 1 deletions
diff --git a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java index 12f1eea..9a79b46 100644 --- a/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java +++ b/src/main/java/makamys/lodmod/mixin/MixinEntityRenderer.java @@ -21,7 +21,7 @@ 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, args = "log=true", ordinal = 0)) + @Inject(method = "setupCameraTransform", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;farPlaneDistance:F", shift = At.Shift.AFTER, ordinal = 0)) private void onConstructed(CallbackInfo ci) { if(LODMod.isActive()) { farPlaneDistance *= LODMod.renderer.getFarPlaneDistanceMultiplier(); diff --git a/src/main/java/makamys/lodmod/mixin/MixinRenderBlocks.java b/src/main/java/makamys/lodmod/mixin/MixinRenderBlocks.java new file mode 100644 index 0000000..2812eff --- /dev/null +++ b/src/main/java/makamys/lodmod/mixin/MixinRenderBlocks.java @@ -0,0 +1,29 @@ +package makamys.lodmod.mixin; + +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.lodmod.LODMod; +import makamys.lodmod.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; + +@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(LODMod.isActive()) { + return LODMod.renderer.shouldSideBeRendered(block, ba, x, y, z, w); + } else { + return block.shouldSideBeRendered(ba, x, y, z, w); + } + } + +} diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 017f256..51d0519 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -1,12 +1,16 @@ package makamys.lodmod.renderer; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; +import net.minecraft.util.EnumFacing; import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.ChunkProviderServer; @@ -629,6 +633,15 @@ public class LODRenderer { return null; } + public boolean shouldSideBeRendered(Block block, IBlockAccess ba, int x, int y, int z, int w) { + EnumFacing facing = EnumFacing.values()[w]; + if(block.getMaterial() == Material.water && facing != EnumFacing.UP && facing != EnumFacing.DOWN && !Minecraft.getMinecraft().theWorld.getChunkFromBlockCoords(x, z).isChunkLoaded) { + return false; + } else { + return block.shouldSideBeRendered(ba, x, y, z, w); + } + } + public List<String> getDebugText() { return Arrays.asList( "VRAM: " + (nextMeshOffset / 1024 / 1024) + "MB / " + (BUFFER_SIZE / 1024 / 1024) + "MB", |