diff --git a/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java b/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java new file mode 100644 index 00000000..2fc7e88e --- /dev/null +++ b/src/main/java/me/cortex/voxy/client/ICheekyClientChunkManager.java @@ -0,0 +1,7 @@ +package me.cortex.voxy.client; + +import net.minecraft.world.chunk.WorldChunk; + +public interface ICheekyClientChunkManager { + WorldChunk voxy$cheekyGetChunk(int x, int z); +} diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java new file mode 100644 index 00000000..568b880c --- /dev/null +++ b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java @@ -0,0 +1,18 @@ +package me.cortex.voxy.client.mixin.minecraft; + +import me.cortex.voxy.client.ICheekyClientChunkManager; +import net.minecraft.client.world.ClientChunkManager; +import net.minecraft.world.chunk.WorldChunk; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(ClientChunkManager.class) +public class MixinClientChunkManager implements ICheekyClientChunkManager { + @Shadow volatile ClientChunkManager.ClientChunkMap chunks; + + @Override + public WorldChunk voxy$cheekyGetChunk(int x, int z) { + //This doesnt do the in range check stuff, it just gets the chunk at all costs + return this.chunks.getChunk(this.chunks.getIndex(x, z)); + } +} diff --git a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java index 5fcefec1..81168bb6 100644 --- a/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java +++ b/src/main/java/me/cortex/voxy/client/mixin/sodium/MixinRenderSectionManager.java @@ -1,6 +1,7 @@ package me.cortex.voxy.client.mixin.sodium; import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import me.cortex.voxy.client.ICheekyClientChunkManager; import me.cortex.voxy.client.VoxyClientInstance; import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.core.IGetVoxyRenderSystem; @@ -65,7 +66,13 @@ public class MixinRenderSectionManager { private void injectIngest(int x, int z, CallbackInfo ci) { //TODO: Am not quite sure if this is right if (VoxyConfig.CONFIG.ingestEnabled) { - VoxelIngestService.tryAutoIngestChunk(this.level.getChunk(x, z)); + var cccm = (ICheekyClientChunkManager)this.level.getChunkManager(); + if (cccm != null) { + var chunk = cccm.voxy$cheekyGetChunk(x, z); + if (chunk != null) { + VoxelIngestService.tryAutoIngestChunk(chunk); + } + } } } diff --git a/src/main/resources/client.voxy.mixins.json b/src/main/resources/client.voxy.mixins.json index c34a6d0e..a4e9c449 100644 --- a/src/main/resources/client.voxy.mixins.json +++ b/src/main/resources/client.voxy.mixins.json @@ -3,6 +3,7 @@ "package": "me.cortex.voxy.client.mixin", "compatibilityLevel": "JAVA_17", "client": [ + "minecraft.MixinClientChunkManager", "minecraft.MixinClientCommonNetworkHandler", "minecraft.MixinClientLoginNetworkHandler", "minecraft.MixinDebugHud", @@ -12,10 +13,10 @@ "minecraft.MixinThreadExecutor", "minecraft.MixinWindow", "minecraft.MixinWorldRenderer", + "nvidium.MixinRenderPipeline", "sodium.MixinDefaultChunkRenderer", "sodium.MixinRenderSectionManager", - "sodium.MixinSodiumOptionsGUI", - "nvidium.MixinRenderPipeline" + "sodium.MixinSodiumOptionsGUI" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/voxy.accesswidener b/src/main/resources/voxy.accesswidener index dd90cf30..bd734284 100644 --- a/src/main/resources/voxy.accesswidener +++ b/src/main/resources/voxy.accesswidener @@ -27,4 +27,8 @@ accessible field net/minecraft/client/gl/GlGpuBuffer id I accessible field net/minecraft/client/gl/GlCommandEncoder currentProgram Lnet/minecraft/client/gl/ShaderProgram; accessible field net/minecraft/client/gl/GlCommandEncoder currentPipeline Lcom/mojang/blaze3d/pipeline/RenderPipeline; -accessible class net/minecraft/client/gl/GlDebug$DebugMessage \ No newline at end of file +accessible class net/minecraft/client/gl/GlDebug$DebugMessage + +accessible class net/minecraft/client/world/ClientChunkManager$ClientChunkMap +accessible method net/minecraft/client/world/ClientChunkManager$ClientChunkMap getChunk (I)Lnet/minecraft/world/chunk/WorldChunk; +accessible method net/minecraft/client/world/ClientChunkManager$ClientChunkMap getIndex (II)I \ No newline at end of file