Try to get the chunk at all costs

This commit is contained in:
mcrcortex
2025-06-23 20:21:18 +10:00
parent d86c3b2eb8
commit 4d35fad772
5 changed files with 41 additions and 4 deletions

View File

@@ -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);
}

View File

@@ -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));
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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

View File

@@ -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
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