inital 1.21.6

This commit is contained in:
mcrcortex
2025-06-13 14:49:03 +10:00
parent 84c07c4115
commit 3aa1c94c6a
7 changed files with 51 additions and 54 deletions

View File

@@ -6,12 +6,12 @@ org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.5 minecraft_version=1.21.6-rc1
yarn_mappings=1.21.5+build.1 yarn_mappings=1.21.6-rc1+build.1
loader_version=0.16.10 loader_version=0.16.14
# Fabric API # Fabric API
fabric_version=0.119.5+1.21.5 fabric_version=0.126.1+1.21.6
# Mod Properties # Mod Properties
mod_version = 0.2.0-alpha mod_version = 0.2.0-alpha

View File

@@ -2,19 +2,15 @@ package me.cortex.voxy.client.core;
import com.mojang.blaze3d.opengl.GlConst; import com.mojang.blaze3d.opengl.GlConst;
import com.mojang.blaze3d.opengl.GlStateManager; import com.mojang.blaze3d.opengl.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import me.cortex.voxy.client.TimingStatistics; import me.cortex.voxy.client.TimingStatistics;
import me.cortex.voxy.client.VoxyClient; import me.cortex.voxy.client.VoxyClient;
import me.cortex.voxy.client.config.VoxyConfig; import me.cortex.voxy.client.config.VoxyConfig;
import me.cortex.voxy.client.core.gl.Capabilities; import me.cortex.voxy.client.core.gl.Capabilities;
import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.gl.GlBuffer;
import me.cortex.voxy.client.core.gl.GlTexture; import me.cortex.voxy.client.core.gl.GlTexture;
import me.cortex.voxy.client.core.model.ModelBakerySubsystem;
import me.cortex.voxy.client.core.rendering.ChunkBoundRenderer; import me.cortex.voxy.client.core.rendering.ChunkBoundRenderer;
import me.cortex.voxy.client.core.rendering.RenderDistanceTracker; import me.cortex.voxy.client.core.rendering.RenderDistanceTracker;
import me.cortex.voxy.client.core.rendering.RenderService; import me.cortex.voxy.client.core.rendering.RenderService;
import me.cortex.voxy.client.core.rendering.building.RenderDataFactory;
import me.cortex.voxy.client.core.rendering.building.RenderGenerationService;
import me.cortex.voxy.client.core.rendering.post.PostProcessing; import me.cortex.voxy.client.core.rendering.post.PostProcessing;
import me.cortex.voxy.client.core.rendering.util.DownloadStream; import me.cortex.voxy.client.core.rendering.util.DownloadStream;
import me.cortex.voxy.client.core.rendering.util.PrintfDebugUtil; import me.cortex.voxy.client.core.rendering.util.PrintfDebugUtil;
@@ -24,31 +20,19 @@ import me.cortex.voxy.client.core.util.IrisUtil;
import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.thread.ServiceThreadPool; import me.cortex.voxy.common.thread.ServiceThreadPool;
import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldSection;
import me.cortex.voxy.common.world.other.Mapper;
import me.cortex.voxy.commonImpl.VoxyCommon;
import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices;
import net.caffeinemc.mods.sodium.client.render.chunk.terrain.DefaultTerrainRenderPasses;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.GlBackend;
import net.minecraft.client.render.Camera; import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Frustum; import net.minecraft.client.render.Frustum;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Matrix4fc; import org.joml.Matrix4fc;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import static org.lwjgl.opengl.GL11.GL_ONE;
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
import static org.lwjgl.opengl.GL11.GL_VIEWPORT; import static org.lwjgl.opengl.GL11.GL_VIEWPORT;
import static org.lwjgl.opengl.GL11.glGetIntegerv; import static org.lwjgl.opengl.GL11.glGetIntegerv;
import static org.lwjgl.opengl.GL11C.*; import static org.lwjgl.opengl.GL11C.glFinish;
import static org.lwjgl.opengl.GL14.glBlendFuncSeparate;
import static org.lwjgl.opengl.GL30C.GL_DRAW_FRAMEBUFFER_BINDING; import static org.lwjgl.opengl.GL30C.GL_DRAW_FRAMEBUFFER_BINDING;
import static org.lwjgl.opengl.GL30C.glBindFramebuffer; import static org.lwjgl.opengl.GL30C.glBindFramebuffer;
import static org.lwjgl.opengl.GL33.glBindSampler; import static org.lwjgl.opengl.GL33.glBindSampler;

View File

@@ -18,6 +18,7 @@ import net.minecraft.block.LeavesBlock;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.color.block.BlockColorProvider; import net.minecraft.client.color.block.BlockColorProvider;
import net.minecraft.client.render.BlockRenderLayer;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderLayers; import net.minecraft.client.render.RenderLayers;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
@@ -256,19 +257,19 @@ public class ModelFactory {
this.fluidStateLUT[modelId] = clientFluidStateId; this.fluidStateLUT[modelId] = clientFluidStateId;
} }
RenderLayer blockRenderLayer = null; BlockRenderLayer blockRenderLayer = null;
if (blockState.getBlock() instanceof FluidBlock) { if (blockState.getBlock() instanceof FluidBlock) {
blockRenderLayer = RenderLayers.getFluidLayer(blockState.getFluidState()); blockRenderLayer = RenderLayers.getFluidLayer(blockState.getFluidState());
} else { } else {
if (blockState.getBlock() instanceof LeavesBlock) { if (blockState.getBlock() instanceof LeavesBlock) {
blockRenderLayer = RenderLayer.getSolid(); blockRenderLayer = BlockRenderLayer.SOLID;
} else { } else {
blockRenderLayer = RenderLayers.getBlockLayer(blockState); blockRenderLayer = RenderLayers.getBlockLayer(blockState);
} }
} }
int checkMode = blockRenderLayer==RenderLayer.getSolid()?TextureUtils.WRITE_CHECK_STENCIL:TextureUtils.WRITE_CHECK_ALPHA; int checkMode = blockRenderLayer==BlockRenderLayer.SOLID?TextureUtils.WRITE_CHECK_STENCIL:TextureUtils.WRITE_CHECK_ALPHA;
if (Capabilities.INSTANCE.isMesa) { if (Capabilities.INSTANCE.isMesa) {
//Mesa does not work with GL_DEPTH_STENCIL_TEXTURE_MODE GL_STENCIL_INDEX //Mesa does not work with GL_DEPTH_STENCIL_TEXTURE_MODE GL_STENCIL_INDEX
@@ -339,7 +340,7 @@ public class ModelFactory {
//Each face gets 1 byte, with the top 2 bytes being for whatever //Each face gets 1 byte, with the top 2 bytes being for whatever
long metadata = 0; long metadata = 0;
metadata |= isBiomeColourDependent?1:0; metadata |= isBiomeColourDependent?1:0;
metadata |= blockRenderLayer == RenderLayer.getTranslucent()?2:0; metadata |= blockRenderLayer == BlockRenderLayer.TRANSLUCENT?2:0;
metadata |= needsDoubleSidedQuads?4:0; metadata |= needsDoubleSidedQuads?4:0;
metadata |= ((!isFluid) && !blockState.getFluidState().isEmpty())?8:0;//Has a fluid state accosiacted with it and is not itself a fluid metadata |= ((!isFluid) && !blockState.getFluidState().isEmpty())?8:0;//Has a fluid state accosiacted with it and is not itself a fluid
metadata |= isFluid?16:0;//Is a fluid metadata |= isFluid?16:0;//Is a fluid
@@ -373,7 +374,7 @@ public class ModelFactory {
//TODO: add alot of config options for the following //TODO: add alot of config options for the following
boolean occludesFace = true; boolean occludesFace = true;
occludesFace &= blockRenderLayer != RenderLayer.getTranslucent();//If its translucent, it doesnt occlude occludesFace &= blockRenderLayer != BlockRenderLayer.TRANSLUCENT;//If its translucent, it doesnt occlude
//TODO: make this an option, basicly if the face is really close, it occludes otherwise it doesnt //TODO: make this an option, basicly if the face is really close, it occludes otherwise it doesnt
occludesFace &= offset < 0.1;//If the face is rendered far away from the other face, then it doesnt occlude occludesFace &= offset < 0.1;//If the face is rendered far away from the other face, then it doesnt occlude
@@ -393,7 +394,7 @@ public class ModelFactory {
metadata |= canBeOccluded?4:0; metadata |= canBeOccluded?4:0;
//Face uses its own lighting if its not flat against the adjacent block & isnt traslucent //Face uses its own lighting if its not flat against the adjacent block & isnt traslucent
metadata |= (offset > 0.01 || blockRenderLayer == RenderLayer.getTranslucent())?0b1000:0; metadata |= (offset > 0.01 || blockRenderLayer == BlockRenderLayer.TRANSLUCENT)?0b1000:0;
@@ -411,11 +412,11 @@ public class ModelFactory {
int area = (faceSize[1]-faceSize[0]+1) * (faceSize[3]-faceSize[2]+1); int area = (faceSize[1]-faceSize[0]+1) * (faceSize[3]-faceSize[2]+1);
boolean needsAlphaDiscard = ((float)writeCount)/area<0.9;//If the amount of area covered by written pixels is less than a threashold, disable discard as its not needed boolean needsAlphaDiscard = ((float)writeCount)/area<0.9;//If the amount of area covered by written pixels is less than a threashold, disable discard as its not needed
needsAlphaDiscard |= blockRenderLayer != RenderLayer.getSolid(); needsAlphaDiscard |= blockRenderLayer != BlockRenderLayer.SOLID;
needsAlphaDiscard &= blockRenderLayer != RenderLayer.getTranslucent();//Translucent doesnt have alpha discard needsAlphaDiscard &= blockRenderLayer != BlockRenderLayer.TRANSLUCENT;//Translucent doesnt have alpha discard
faceModelData |= needsAlphaDiscard?1<<22:0; faceModelData |= needsAlphaDiscard?1<<22:0;
faceModelData |= ((!faceCoversFullBlock)&&blockRenderLayer != RenderLayer.getTranslucent())?1<<23:0;//Alpha discard override, translucency doesnt have alpha discard faceModelData |= ((!faceCoversFullBlock)&&blockRenderLayer != BlockRenderLayer.TRANSLUCENT)?1<<23:0;//Alpha discard override, translucency doesnt have alpha discard
@@ -435,8 +436,8 @@ public class ModelFactory {
int modelFlags = 0; int modelFlags = 0;
modelFlags |= colourProvider != null?1:0; modelFlags |= colourProvider != null?1:0;
modelFlags |= isBiomeColourDependent?2:0;//Basicly whether to use the next int as a colour or as a base index/id into a colour buffer for biome dependent colours modelFlags |= isBiomeColourDependent?2:0;//Basicly whether to use the next int as a colour or as a base index/id into a colour buffer for biome dependent colours
modelFlags |= blockRenderLayer == RenderLayer.getTranslucent()?4:0;//Is translucent modelFlags |= blockRenderLayer == BlockRenderLayer.TRANSLUCENT?4:0;//Is translucent
modelFlags |= blockRenderLayer == RenderLayer.getCutout()?0:8;//Dont use mipmaps (AND ALSO FKING SPECIFIES IF IT HAS AO, WHY??? GREAT QUESTION, TODO FIXE THIS) modelFlags |= blockRenderLayer == BlockRenderLayer.CUTOUT?0:8;//Dont use mipmaps (AND ALSO FKING SPECIFIES IF IT HAS AO, WHY??? GREAT QUESTION, TODO FIXE THIS)
//modelFlags |= blockRenderLayer == RenderLayer.getSolid()?0:1;// should discard alpha //modelFlags |= blockRenderLayer == RenderLayer.getSolid()?0:1;// should discard alpha
MemoryUtil.memPutInt(uploadPtr, modelFlags); MemoryUtil.memPutInt(uploadPtr, modelFlags);

View File

@@ -46,6 +46,21 @@ public class BakedBlockEntityModel {
this.layers.forEach(layer->layer.consumer.free()); this.layers.forEach(layer->layer.consumer.free());
} }
private static int getMetaFromLayer(RenderLayer layer) {
boolean hasDiscard = layer == RenderLayer.getCutout() ||
layer == RenderLayer.getCutoutMipped() ||
layer == RenderLayer.getTripwire();
boolean isMipped = layer == RenderLayer.getCutoutMipped() ||
layer == RenderLayer.getSolid() ||
layer.isTranslucent() ||
layer == RenderLayer.getTripwire();
int meta = hasDiscard?1:0;
meta |= isMipped?2:0;
return meta;
}
public static BakedBlockEntityModel bake(BlockState state) { public static BakedBlockEntityModel bake(BlockState state) {
Map<RenderLayer, LayerConsumer> map = new HashMap<>(); Map<RenderLayer, LayerConsumer> map = new HashMap<>();
var entity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(BlockPos.ORIGIN, state); var entity = ((BlockEntityProvider)state.getBlock()).createBlockEntity(BlockPos.ORIGIN, state);
@@ -56,7 +71,7 @@ public class BakedBlockEntityModel {
entity.setWorld(MinecraftClient.getInstance().world); entity.setWorld(MinecraftClient.getInstance().world);
if (renderer != null) { if (renderer != null) {
try { try {
renderer.render(entity, 0.0f, new MatrixStack(), layer->map.computeIfAbsent(layer, rl -> new LayerConsumer(rl, new ReuseVertexConsumer().setDefaultMeta(ModelTextureBakery.getMetaFromLayer(rl)))).consumer, 0, 0, new Vec3d(0,0,0)); renderer.render(entity, 0.0f, new MatrixStack(), layer->map.computeIfAbsent(layer, rl -> new LayerConsumer(rl, new ReuseVertexConsumer().setDefaultMeta(getMetaFromLayer(rl)))).consumer, 0, 0, new Vec3d(0,0,0));
} catch (Exception e) { } catch (Exception e) {
Logger.error("Unable to bake block entity: " + entity, e); Logger.error("Unable to bake block entity: " + entity, e);
} }

View File

@@ -6,7 +6,7 @@ import net.minecraft.block.FluidBlock;
import net.minecraft.block.LeavesBlock; import net.minecraft.block.LeavesBlock;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.BlockRenderLayer;
import net.minecraft.client.render.RenderLayers; import net.minecraft.client.render.RenderLayers;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.fluid.FluidState; import net.minecraft.fluid.FluidState;
@@ -43,22 +43,22 @@ public class ModelTextureBakery {
this.height = height; this.height = height;
} }
public static int getMetaFromLayer(RenderLayer layer) { public static int getMetaFromLayer(BlockRenderLayer layer) {
boolean hasDiscard = layer == RenderLayer.getCutout() || boolean hasDiscard = layer == BlockRenderLayer.CUTOUT ||
layer == RenderLayer.getCutoutMipped() || layer == BlockRenderLayer.CUTOUT_MIPPED ||
layer == RenderLayer.getTripwire(); layer == BlockRenderLayer.TRIPWIRE;
boolean isMipped = layer == RenderLayer.getCutoutMipped() || boolean isMipped = layer == BlockRenderLayer.CUTOUT_MIPPED ||
layer == RenderLayer.getSolid() || layer == BlockRenderLayer.SOLID ||
layer == RenderLayer.getTranslucent() || layer == BlockRenderLayer.TRANSLUCENT ||
layer == RenderLayer.getTripwire(); layer == BlockRenderLayer.TRIPWIRE;
int meta = hasDiscard?1:0; int meta = hasDiscard?1:0;
meta |= isMipped?2:0; meta |= isMipped?2:0;
return meta; return meta;
} }
private void bakeBlockModel(BlockState state, RenderLayer layer) { private void bakeBlockModel(BlockState state, BlockRenderLayer layer) {
var model = MinecraftClient.getInstance() var model = MinecraftClient.getInstance()
.getBakedModelManager() .getBakedModelManager()
.getBlockModels() .getBlockModels()
@@ -79,7 +79,7 @@ public class ModelTextureBakery {
} }
private void bakeFluidState(BlockState state, RenderLayer layer, int face) { private void bakeFluidState(BlockState state, BlockRenderLayer layer, int face) {
this.vc.setDefaultMeta(getMetaFromLayer(layer));//Set the meta while baking this.vc.setDefaultMeta(getMetaFromLayer(layer));//Set the meta while baking
MinecraftClient.getInstance().getBlockRenderManager().renderFluid(BlockPos.ORIGIN, new BlockRenderView() { MinecraftClient.getInstance().getBlockRenderManager().renderFluid(BlockPos.ORIGIN, new BlockRenderView() {
@Override @Override
@@ -163,13 +163,13 @@ public class ModelTextureBakery {
public void renderToStream(BlockState state, int streamBuffer, int streamOffset) { public void renderToStream(BlockState state, int streamBuffer, int streamOffset) {
this.capture.clear(); this.capture.clear();
boolean isBlock = true; boolean isBlock = true;
RenderLayer layer; BlockRenderLayer layer;
if (state.getBlock() instanceof FluidBlock) { if (state.getBlock() instanceof FluidBlock) {
layer = RenderLayers.getFluidLayer(state.getFluidState()); layer = RenderLayers.getFluidLayer(state.getFluidState());
isBlock = false; isBlock = false;
} else { } else {
if (state.getBlock() instanceof LeavesBlock) { if (state.getBlock() instanceof LeavesBlock) {
layer = RenderLayer.getSolid(); layer = BlockRenderLayer.SOLID;
} else { } else {
layer = RenderLayers.getBlockLayer(state); layer = RenderLayers.getBlockLayer(state);
} }
@@ -189,7 +189,7 @@ public class ModelTextureBakery {
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
if (layer == RenderLayer.getTranslucent()) { if (layer == BlockRenderLayer.TRANSLUCENT) {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glBlendFuncSeparate(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} else { } else {
@@ -311,7 +311,7 @@ public class ModelTextureBakery {
glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id); glBindFramebuffer(GL_FRAMEBUFFER, this.capture.framebuffer.id);
glClearDepth(1); glClearDepth(1);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
if (layer == RenderLayer.getTranslucent()) { if (layer == BlockRenderLayer.TRANSLUCENT) {
//reset the blend func //reset the blend func
GL14.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); GL14.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} }

View File

@@ -15,6 +15,6 @@ import static org.lwjgl.opengl.GL45.glBindTextureUnit;
public class LightMapHelper { public class LightMapHelper {
public static void bind(int lightingIndex) { public static void bind(int lightingIndex) {
glBindSampler(lightingIndex, 0); glBindSampler(lightingIndex, 0);
glBindTextureUnit(lightingIndex, ((net.minecraft.client.texture.GlTexture)(MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().getGlTexture())).getGlId()); glBindTextureUnit(lightingIndex, ((net.minecraft.client.texture.GlTexture)(MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().getGlTextureView().texture())).getGlId());
} }
} }

View File

@@ -6,9 +6,6 @@ accessible class net/minecraft/client/render/RenderLayer$MultiPhaseParameters
accessible field net/minecraft/client/texture/SpriteContents image Lnet/minecraft/client/texture/NativeImage; accessible field net/minecraft/client/texture/SpriteContents image Lnet/minecraft/client/texture/NativeImage;
accessible field net/minecraft/client/render/Frustum frustumIntersection Lorg/joml/FrustumIntersection; accessible field net/minecraft/client/render/Frustum frustumIntersection Lorg/joml/FrustumIntersection;
accessible field net/minecraft/client/color/block/BlockColors providers Lnet/minecraft/util/collection/IdList; accessible field net/minecraft/client/color/block/BlockColors providers Lnet/minecraft/util/collection/IdList;
accessible field net/minecraft/client/render/GameRenderer zoomX F
accessible field net/minecraft/client/render/GameRenderer zoomY F
accessible field net/minecraft/client/render/GameRenderer zoom F
accessible field net/minecraft/client/world/ClientWorld worldRenderer Lnet/minecraft/client/render/WorldRenderer; accessible field net/minecraft/client/world/ClientWorld worldRenderer Lnet/minecraft/client/render/WorldRenderer;
accessible field net/minecraft/world/biome/source/BiomeAccess seed J accessible field net/minecraft/world/biome/source/BiomeAccess seed J
@@ -27,7 +24,7 @@ accessible field net/minecraft/world/chunk/PalettedContainer$Data palette Lnet/m
accessible field net/minecraft/client/gl/GlGpuBuffer id I accessible field net/minecraft/client/gl/GlGpuBuffer id I
accessible field net/minecraft/client/gl/GlResourceManager currentProgram Lnet/minecraft/client/gl/ShaderProgram; accessible field net/minecraft/client/gl/GlCommandEncoder currentProgram Lnet/minecraft/client/gl/ShaderProgram;
accessible field net/minecraft/client/gl/GlResourceManager currentPipeline Lcom/mojang/blaze3d/pipeline/RenderPipeline; 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