ingest chunk section on block change on board

This commit is contained in:
mcrcortex
2025-09-22 11:29:36 +10:00
parent 7b15dbbea3
commit 301d587535
3 changed files with 80 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ import net.caffeinemc.mods.sodium.client.gl.shader.ShaderParser;
public class ShaderLoader { public class ShaderLoader {
public static String parse(String id) { public static String parse(String id) {
return "#version 460 core\n"+ShaderParser.parseShader("#import <" + id + ">\n//beans", ShaderConstants.builder().build()).replaceFirst("\n#version .+\n", "\n"); return "#version 460 core\n"+ShaderParser.parseShader("\n#import <" + id + ">\n//beans", ShaderConstants.builder().build()).replaceAll("\r\n", "\n").replaceFirst("\n#version .+\n", "\n");
//return me.jellysquid.mods.sodium.client.gl.shader.ShaderLoader.getShaderSource(new Identifier(id)); //return me.jellysquid.mods.sodium.client.gl.shader.ShaderLoader.getShaderSource(new Identifier(id));
} }
} }

View File

@@ -0,0 +1,78 @@
package me.cortex.voxy.client.mixin.minecraft;
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
import me.cortex.voxy.common.world.service.VoxelIngestService;
import me.cortex.voxy.commonImpl.VoxyCommon;
import net.minecraft.block.BlockState;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.world.ClientChunkManager;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientWorld.class)
public abstract class MixinClientWorld {
@Unique
private int bottomSectionY;
@Shadow @Final public WorldRenderer worldRenderer;
@Shadow public abstract ClientChunkManager getChunkManager();
@Inject(method = "<init>", at = @At("TAIL"))
private void voxy$getBottom(
ClientPlayNetworkHandler networkHandler,
ClientWorld.Properties properties,
RegistryKey<World> registryRef,
RegistryEntry<DimensionType> dimensionType,
int loadDistance,
int simulationDistance,
WorldRenderer worldRenderer,
boolean debugWorld,
long seed,
int seaLevel,
CallbackInfo cir) {
this.bottomSectionY = ((World)(Object)this).getBottomY()>>4;
}
@Inject(method = "scheduleBlockRerenderIfNeeded", at = @At("TAIL"))
private void voxy$injectIngestOnStateChange(BlockPos pos, BlockState old, BlockState updated, CallbackInfo cir) {
if (old == updated) return;
var system = ((IGetVoxyRenderSystem)(this.worldRenderer)).getVoxyRenderSystem();
if (system == null) {
return;
}
int x = pos.getX()&15;
int y = pos.getY()&15;
int z = pos.getZ()&15;
if (x == 0 || x==15 || y==0 || y==15 || z==0||z==15) {//Update if there is a statechange on the boarder
var world = (World)(Object)this;
var csp = ChunkSectionPos.from(pos);
var section = world.getChunk(pos).getSection(csp.getSectionY()-this.bottomSectionY);
var lp = world.getLightingProvider();
var blp = lp.get(LightType.BLOCK).getLightSection(csp);
var slp = lp.get(LightType.SKY).getLightSection(csp);
VoxelIngestService.rawIngest(system.getEngine(), section, csp.getSectionX(), csp.getSectionY(), csp.getSectionZ(), blp==null?null:blp.copy(), slp==null?null:slp.copy());
}
}
}

View File

@@ -16,6 +16,7 @@
"iris.MixinProgramSet", "iris.MixinProgramSet",
"iris.MixinShaderPackSourceNames", "iris.MixinShaderPackSourceNames",
"iris.MixinStandardMacros", "iris.MixinStandardMacros",
"minecraft.MixinClientWorld",
"minecraft.MixinClientChunkManager", "minecraft.MixinClientChunkManager",
"minecraft.MixinClientCommonNetworkHandler", "minecraft.MixinClientCommonNetworkHandler",
"minecraft.MixinClientLoginNetworkHandler", "minecraft.MixinClientLoginNetworkHandler",