Skip to content

Commit

Permalink
Update to Minecraft 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 authored and jellysquid3 committed Dec 3, 2024
1 parent 731a95f commit 366f0df
Show file tree
Hide file tree
Showing 49 changed files with 552 additions and 503 deletions.
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/BuildConfig.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import org.gradle.api.Project
import org.gradle.api.Project

object BuildConfig {
val MINECRAFT_VERSION: String = "1.21.3"
val NEOFORGE_VERSION: String = "21.3.56"
val MINECRAFT_VERSION: String = "1.21.4"
val NEOFORGE_VERSION: String = "21.4.0-beta"
val FABRIC_LOADER_VERSION: String = "0.16.9"
val FABRIC_API_VERSION: String = "0.110.0+1.21.3"
val FABRIC_API_VERSION: String = "0.110.5+1.21.4"

// This value can be set to null to disable Parchment.
// TODO: Re-add Parchment
val PARCHMENT_VERSION: String? = null

// https://semver.org/
var MOD_VERSION: String = "0.6.1"
var MOD_VERSION: String = "0.6.2"

fun createVersionString(project: Project): String {
val builder = StringBuilder()
Expand Down
2 changes: 0 additions & 2 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ dependencies {
addDependentFabricModule("fabric-renderer-api-v1")
addDependentFabricModule("fabric-rendering-data-attachment-v1")

modCompileOnly("net.fabricmc.fabric-api:fabric-renderer-api-v1:3.2.9+1172e897d7")

// We need to be careful during pre-launch that we don't touch any Minecraft classes, since other mods
// will not yet have an opportunity to apply transformations.
configurationPreLaunch("org.lwjgl:lwjgl:3.3.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public record SodiumResourcePackMetadata(List<String> ignoredShaders) {
.apply(instance, SodiumResourcePackMetadata::new)
);
public static final MetadataSectionType<SodiumResourcePackMetadata> SERIALIZER =
MetadataSectionType.fromCodec("sodium", CODEC);
new MetadataSectionType<>("sodium", CODEC);
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ public Dim2i getDimensions() {
public ScreenRectangle getRectangle() {
return new ScreenRectangle(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height());
}

@Override
public boolean isMouseOver(double x, double y) {
return this.dim.containsCursor(x, y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,7 @@ protected void drawBorder(GuiGraphics graphics, int x1, int y1, int x2, int y2,
graphics.fill(x1, y1, x1 + 1, y2, color);
graphics.fill(x2 - 1, y1, x2, y2, color);
}

@Override
public abstract boolean isMouseOver(double x, double y);
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public Component getLabel() {
return super.nextFocusPath(event);
}

@Override
public boolean isMouseOver(double x, double y) {
return this.dim.containsCursor(x, y);
}

@Override
public ScreenRectangle getRectangle() {
return new ScreenRectangle(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.renderer.BiomeColors;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;

import java.util.Arrays;

public class DefaultColorProviders {
Expand Down Expand Up @@ -50,7 +50,7 @@ private VanillaAdapter(BlockColor color) {

@Override
public void getColors(LevelSlice slice, BlockPos pos, BlockPos.MutableBlockPos scratchPos, BlockState state, ModelQuadView quad, int[] output) {
Arrays.fill(output, 0xFF000000 | this.color.getColor(state, slice, pos, quad.getColorIndex()));
Arrays.fill(output, 0xFF000000 | this.color.getColor(state, slice, pos, quad.getTintIndex()));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ModelQuad implements ModelQuadViewMutable {
private TextureAtlasSprite sprite;
private Direction direction;

private int colorIdx;
private int tintIdx;
private int faceNormal;

@Override
Expand Down Expand Up @@ -74,8 +74,8 @@ public void setSprite(TextureAtlasSprite sprite) {
}

@Override
public void setColorIndex(int index) {
this.colorIdx = index;
public void setTintIndex(int index) {
this.tintIdx = index;
}

@Override
Expand All @@ -84,8 +84,8 @@ public void setLightFace(Direction direction) {
}

@Override
public int getColorIndex() {
return this.colorIdx;
public int getTintIndex() {
return this.tintIdx;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public interface ModelQuadView {
int getFlags();

/**
* @return The color index of this quad.
* @return The tint index of this quad.
*/
int getColorIndex();
int getTintIndex();

/**
* @return The sprite texture used by this quad, or null if none is attached
Expand All @@ -75,7 +75,7 @@ public interface ModelQuadView {
Direction getLightFace();

default boolean hasColor() {
return this.getColorIndex() != -1;
return this.getTintIndex() != -1;
}

default int calculateNormal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface ModelQuadViewMutable extends ModelQuadView {
void setLightFace(Direction direction);

/**
* Sets the color index used by this quad
* Sets the tint index used by this quad
*/
void setColorIndex(int index);
void setTintIndex(int index);
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockP

for (RenderType type : renderTypes) {
this.type = type;
((FabricBakedModel) model).emitBlockQuads(this.level, state, pos, this.randomSupplier, this);
((FabricBakedModel) model).emitBlockQuads(getEmitter(), this.level, state, pos, this.randomSupplier, this::isFaceCulled);
}

type = null;
Expand All @@ -115,7 +115,6 @@ public void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockP
@Override
protected void processQuad(MutableQuadViewImpl quad) {
final RenderMaterial mat = quad.material();
final int colorIndex = mat.disableColorIndex() ? -1 : quad.colorIndex();
final TriState aoMode = mat.ambientOcclusion();
final ShadeMode shadeMode = mat.shadeMode();
final LightMode lightMode;
Expand All @@ -135,13 +134,15 @@ protected void processQuad(MutableQuadViewImpl quad) {
material = DefaultMaterials.forRenderLayer(blendMode.blockRenderLayer == null ? type : blendMode.blockRenderLayer);
}

this.colorizeQuad(quad, colorIndex);
this.tintQuad(quad);
this.shadeQuad(quad, lightMode, emissive, shadeMode);
this.bufferQuad(quad, this.quadLightData.br, material);
}

private void colorizeQuad(MutableQuadViewImpl quad, int colorIndex) {
if (colorIndex != -1) {
private void tintQuad(MutableQuadViewImpl quad) {
int tintIndex = quad.tintIndex();

if (tintIndex != -1) {
ColorProvider<BlockState> colorProvider = this.colorProvider;

if (colorProvider != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import net.caffeinemc.mods.sodium.client.render.frapi.material.MaterialFinderImpl;
import net.caffeinemc.mods.sodium.client.render.frapi.material.RenderMaterialImpl;
import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MeshBuilderImpl;
import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableMeshImpl;
import net.fabricmc.fabric.api.renderer.v1.Renderer;
import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder;
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder;
import net.fabricmc.fabric.api.renderer.v1.mesh.MutableMesh;
import net.minecraft.resources.ResourceLocation;

import java.util.HashMap;
Expand All @@ -36,16 +36,16 @@ public class SodiumRenderer implements Renderer {
public static final RenderMaterial STANDARD_MATERIAL = INSTANCE.materialFinder().find();

static {
INSTANCE.registerMaterial(RenderMaterial.MATERIAL_STANDARD, STANDARD_MATERIAL);
INSTANCE.registerMaterial(RenderMaterial.STANDARD_ID, STANDARD_MATERIAL);
}

private final HashMap<ResourceLocation, RenderMaterial> materialMap = new HashMap<>();

private SodiumRenderer() { }

@Override
public MeshBuilder meshBuilder() {
return new MeshBuilderImpl();
public MutableMesh mutableMesh() {
return new MutableMeshImpl();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import org.joml.Vector3f;
import org.joml.Vector3fc;

/**
* Static routines of general utility for renderer implementations.
Expand Down Expand Up @@ -49,7 +50,7 @@ public static boolean isQuadParallelToFace(Direction face, QuadView quad) {
* <p>Derived from the quad face normal and expects convex quads with all points co-planar.
*/
public static Direction lightFace(QuadView quad) {
final Vector3f normal = quad.faceNormal();
final Vector3fc normal = quad.faceNormal();
return switch (GeometryHelper.longestAxis(normal)) {
case X -> normal.x() > 0 ? Direction.EAST : Direction.WEST;
case Y -> normal.y() > 0 ? Direction.UP : Direction.DOWN;
Expand All @@ -63,7 +64,7 @@ public static Direction lightFace(QuadView quad) {
/**
* @see #longestAxis(float, float, float)
*/
public static Direction.Axis longestAxis(Vector3f vec) {
public static Direction.Axis longestAxis(Vector3fc vec) {
return longestAxis(vec.x(), vec.y(), vec.z());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class MaterialFinderImpl extends MaterialViewImpl implements MaterialFind
static {
MaterialFinderImpl finder = new MaterialFinderImpl();
finder.ambientOcclusion(TriState.DEFAULT);
finder.glint(TriState.DEFAULT);
finder.shadeMode(ShadeMode.ENHANCED);
defaultBits = finder.bits;

Expand All @@ -48,12 +47,6 @@ public MaterialFinder blendMode(BlendMode blendMode) {
return this;
}

@Override
public MaterialFinder disableColorIndex(boolean disable) {
bits = disable ? (bits | COLOR_DISABLE_FLAG) : (bits & ~COLOR_DISABLE_FLAG);
return this;
}

@Override
public MaterialFinder emissive(boolean isEmissive) {
bits = isEmissive ? (bits | EMISSIVE_FLAG) : (bits & ~EMISSIVE_FLAG);
Expand All @@ -75,10 +68,10 @@ public MaterialFinder ambientOcclusion(TriState mode) {
}

@Override
public MaterialFinder glint(TriState mode) {
Objects.requireNonNull(mode, "glint TriState may not be null");
public MaterialFinder glintMode(GlintMode mode) {
Objects.requireNonNull(mode, "GlintMode may not be null");

bits = (bits & ~GLINT_MASK) | (mode.ordinal() << GLINT_BIT_OFFSET);
bits = (bits & ~GLINT_MODE_MASK) | (mode.ordinal() << GLINT_MODE_BIT_OFFSET);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package net.caffeinemc.mods.sodium.client.render.frapi.material;

import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
import net.fabricmc.fabric.api.renderer.v1.material.GlintMode;
import net.fabricmc.fabric.api.renderer.v1.material.MaterialView;
import net.fabricmc.fabric.api.renderer.v1.material.ShadeMode;
import net.fabricmc.fabric.api.util.TriState;
Expand All @@ -33,32 +34,32 @@ public class MaterialViewImpl implements MaterialView {
private static final int BLEND_MODE_COUNT = BLEND_MODES.length;
private static final TriState[] TRI_STATES = TriState.values();
private static final int TRI_STATE_COUNT = TRI_STATES.length;
private static final GlintMode[] GLINT_MODES = GlintMode.values();
private static final int GLINT_MODE_COUNT = GLINT_MODES.length;
private static final ShadeMode[] SHADE_MODES = ShadeMode.values();
private static final int SHADE_MODE_COUNT = SHADE_MODES.length;

protected static final int BLEND_MODE_BIT_LENGTH = Mth.ceillog2(BLEND_MODE_COUNT);
protected static final int COLOR_DISABLE_BIT_LENGTH = 1;
protected static final int EMISSIVE_BIT_LENGTH = 1;
protected static final int DIFFUSE_BIT_LENGTH = 1;
protected static final int AO_BIT_LENGTH = Mth.ceillog2(TRI_STATE_COUNT);
protected static final int GLINT_BIT_LENGTH = Mth.ceillog2(TRI_STATE_COUNT);
protected static final int GLINT_MODE_BIT_LENGTH = Mth.ceillog2(GLINT_MODE_COUNT);
protected static final int SHADE_MODE_BIT_LENGTH = Mth.ceillog2(SHADE_MODE_COUNT);

protected static final int BLEND_MODE_BIT_OFFSET = 0;
protected static final int COLOR_DISABLE_BIT_OFFSET = BLEND_MODE_BIT_OFFSET + BLEND_MODE_BIT_LENGTH;
protected static final int EMISSIVE_BIT_OFFSET = COLOR_DISABLE_BIT_OFFSET + COLOR_DISABLE_BIT_LENGTH;
protected static final int EMISSIVE_BIT_OFFSET = BLEND_MODE_BIT_OFFSET + BLEND_MODE_BIT_LENGTH;
protected static final int DIFFUSE_BIT_OFFSET = EMISSIVE_BIT_OFFSET + EMISSIVE_BIT_LENGTH;
protected static final int AO_BIT_OFFSET = DIFFUSE_BIT_OFFSET + DIFFUSE_BIT_LENGTH;
protected static final int GLINT_BIT_OFFSET = AO_BIT_OFFSET + AO_BIT_LENGTH;
protected static final int SHADE_MODE_BIT_OFFSET = GLINT_BIT_OFFSET + GLINT_BIT_LENGTH;
protected static final int GLINT_MODE_BIT_OFFSET = AO_BIT_OFFSET + AO_BIT_LENGTH;
protected static final int SHADE_MODE_BIT_OFFSET = GLINT_MODE_BIT_OFFSET + GLINT_MODE_BIT_LENGTH;
protected static final int TOTAL_BIT_LENGTH = SHADE_MODE_BIT_OFFSET + SHADE_MODE_BIT_LENGTH;

protected static final int BLEND_MODE_MASK = bitMask(BLEND_MODE_BIT_LENGTH, BLEND_MODE_BIT_OFFSET);
protected static final int COLOR_DISABLE_FLAG = bitMask(COLOR_DISABLE_BIT_LENGTH, COLOR_DISABLE_BIT_OFFSET);
protected static final int EMISSIVE_FLAG = bitMask(EMISSIVE_BIT_LENGTH, EMISSIVE_BIT_OFFSET);
protected static final int DIFFUSE_FLAG = bitMask(DIFFUSE_BIT_LENGTH, DIFFUSE_BIT_OFFSET);
protected static final int AO_MASK = bitMask(AO_BIT_LENGTH, AO_BIT_OFFSET);
protected static final int GLINT_MASK = bitMask(GLINT_BIT_LENGTH, GLINT_BIT_OFFSET);
protected static final int GLINT_MODE_MASK = bitMask(GLINT_MODE_BIT_LENGTH, GLINT_MODE_BIT_OFFSET);
protected static final int SHADE_MODE_MASK = bitMask(SHADE_MODE_BIT_LENGTH, SHADE_MODE_BIT_OFFSET);

protected static int bitMask(int bitLength, int bitOffset) {
Expand All @@ -68,12 +69,12 @@ protected static int bitMask(int bitLength, int bitOffset) {
protected static boolean areBitsValid(int bits) {
int blendMode = (bits & BLEND_MODE_MASK) >>> BLEND_MODE_BIT_OFFSET;
int ao = (bits & AO_MASK) >>> AO_BIT_OFFSET;
int glint = (bits & GLINT_MASK) >>> GLINT_BIT_OFFSET;
int glintMode = (bits & GLINT_MODE_MASK) >>> GLINT_MODE_BIT_OFFSET;
int shadeMode = (bits & SHADE_MODE_MASK) >>> SHADE_MODE_BIT_OFFSET;

return blendMode < BLEND_MODE_COUNT
&& ao < TRI_STATE_COUNT
&& glint < TRI_STATE_COUNT
&& glintMode < GLINT_MODE_COUNT
&& shadeMode < SHADE_MODE_COUNT;
}

Expand All @@ -88,11 +89,6 @@ public BlendMode blendMode() {
return BLEND_MODES[(bits & BLEND_MODE_MASK) >>> BLEND_MODE_BIT_OFFSET];
}

@Override
public boolean disableColorIndex() {
return (bits & COLOR_DISABLE_FLAG) != 0;
}

@Override
public boolean emissive() {
return (bits & EMISSIVE_FLAG) != 0;
Expand All @@ -109,8 +105,8 @@ public TriState ambientOcclusion() {
}

@Override
public TriState glint() {
return TRI_STATES[(bits & GLINT_MASK) >>> GLINT_BIT_OFFSET];
public GlintMode glintMode() {
return GLINT_MODES[(bits & GLINT_MODE_MASK) >>> GLINT_MODE_BIT_OFFSET];
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.mojang.blaze3d.vertex.VertexFormat;
import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing;
import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFlags;
import net.caffeinemc.mods.sodium.client.render.frapi.SodiumRenderer;
import net.caffeinemc.mods.sodium.client.render.frapi.material.RenderMaterialImpl;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadView;
import net.fabricmc.fabric.api.renderer.v1.model.ModelHelper;
Expand All @@ -37,7 +38,7 @@ private EncodingFormat() { }

static final int HEADER_BITS = 0;
static final int HEADER_FACE_NORMAL = 1;
static final int HEADER_COLOR_INDEX = 2;
static final int HEADER_TINT_INDEX = 2;
static final int HEADER_TAG = 3;
public static final int HEADER_STRIDE = 4;

Expand Down
Loading

0 comments on commit 366f0df

Please sign in to comment.