ingest chunk section on block change on board
This commit is contained in:
@@ -6,7 +6,7 @@ import net.caffeinemc.mods.sodium.client.gl.shader.ShaderParser;
|
||||
|
||||
public class ShaderLoader {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
"iris.MixinProgramSet",
|
||||
"iris.MixinShaderPackSourceNames",
|
||||
"iris.MixinStandardMacros",
|
||||
"minecraft.MixinClientWorld",
|
||||
"minecraft.MixinClientChunkManager",
|
||||
"minecraft.MixinClientCommonNetworkHandler",
|
||||
"minecraft.MixinClientLoginNetworkHandler",
|
||||
|
||||
Reference in New Issue
Block a user