Skip to content

Commit

Permalink
Update to Minecraft 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jellysquid3 committed Oct 27, 2024
1 parent 24f77ee commit 509339d
Show file tree
Hide file tree
Showing 75 changed files with 452 additions and 456 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

object BuildConfig {
val MINECRAFT_VERSION: String = "1.21.1"
val NEOFORGE_VERSION: String = "21.1.46"
val FABRIC_LOADER_VERSION: String = "0.16.4"
val FABRIC_API_VERSION: String = "0.103.0+1.21.1"
val MINECRAFT_VERSION: String = "1.21.3"
val NEOFORGE_VERSION: String = "21.3.3-beta"
val FABRIC_LOADER_VERSION: String = "0.16.7"
val FABRIC_API_VERSION: String = "0.107.0+1.21.3"

// 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.0-beta.2"
var MOD_VERSION: String = "0.6.0-beta.4"

fun createVersionString(project: Project): String {
val builder = StringBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ public void set(float[] value) {

GL30C.glUniform4fv(this.index, value);
}

public void set(float x, float y, float z, float w) {
GL30C.glUniform4f(this.index, x, y, z, w);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
import net.caffeinemc.mods.sodium.client.compatibility.workarounds.Workarounds;
import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation;
import net.minecraft.client.AttackIndicatorStatus;
import net.minecraft.client.InactivityFpsLimit;
import net.minecraft.client.CloudStatus;
import net.minecraft.client.GraphicsStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.ParticleStatus;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ParticleStatus;
import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLCapabilities;

Expand Down Expand Up @@ -126,7 +127,7 @@ public static OptionPage general() {
.setControl(option -> new SliderControl(option, 10, 260, 10, ControlValueFormatter.fpsLimit()))
.setBinding((opts, value) -> {
opts.framerateLimit().set(value);
Minecraft.getInstance().getWindow().setFramerateLimit(value);
Minecraft.getInstance().getFramerateLimitTracker().setFramerateLimit(value);
}, opts -> opts.framerateLimit().get())
.build())
.build());
Expand Down Expand Up @@ -182,7 +183,7 @@ public static OptionPage quality() {
if (Minecraft.useShaderTransparency()) {
RenderTarget framebuffer = Minecraft.getInstance().levelRenderer.getCloudsTarget();
if (framebuffer != null) {
framebuffer.clear(Minecraft.ON_OSX);
framebuffer.clear();
}
}
}, opts -> opts.cloudStatus().get())
Expand Down Expand Up @@ -334,6 +335,12 @@ public static OptionPage performance() {
.setEnabled(SodiumGameOptionPages::supportsNoErrorContext)
.setFlags(OptionFlag.REQUIRES_GAME_RESTART)
.build())
.add(OptionImpl.createBuilder(InactivityFpsLimit.class, vanillaOpts)
.setName(Component.translatable("options.inactivityFpsLimit"))
.setTooltip(v -> Component.translatable(v.getId() == 0 ? "options.inactivityFpsLimit.minimized.tooltip" : "options.inactivityFpsLimit.afk.tooltip"))
.setControl(option -> new CyclingControl<>(option, InactivityFpsLimit.class, new Component[] { Component.translatable("options.inactivityFpsLimit.minimized"), Component.translatable("options.inactivityFpsLimit.afk") }))
.setBinding((opts, value) -> opts.inactivityFpsLimit().set(value), opts -> opts.inactivityFpsLimit().get())
.build())
.build());

if (PlatformRuntimeInformation.getInstance().isDevelopmentEnvironment()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class OptionImpl<S, T> implements Option<T> {
private final EnumSet<OptionFlag> flags;

private final Component name;
private final Component tooltip;
private final Function<T, Component> tooltip;

private final OptionImpact impact;

Expand All @@ -34,7 +34,7 @@ public class OptionImpl<S, T> implements Option<T> {

private OptionImpl(OptionStorage<S> storage,
Component name,
Component tooltip,
Function<T, Component> tooltip,
OptionBinding<S, T> binding,
Function<OptionImpl<S, T>, Control<T>> control,
EnumSet<OptionFlag> flags,
Expand All @@ -59,7 +59,7 @@ public Component getName() {

@Override
public Component getTooltip() {
return this.tooltip;
return this.tooltip.apply(this.modifiedValue);
}

@Override
Expand Down Expand Up @@ -121,7 +121,7 @@ public static <S, T> OptionImpl.Builder<S, T> createBuilder(@SuppressWarnings("u
public static class Builder<S, T> {
private final OptionStorage<S> storage;
private Component name;
private Component tooltip;
private Function<T, Component> tooltip;
private OptionBinding<S, T> binding;
private Function<OptionImpl<S, T>, Control<T>> control;
private OptionImpact impact;
Expand All @@ -143,6 +143,14 @@ public Builder<S, T> setName(Component name) {
public Builder<S, T> setTooltip(Component tooltip) {
Validate.notNull(tooltip, "Argument must not be null");

this.tooltip = t -> tooltip;

return this;
}

public Builder<S, T> setTooltip(Function<T, Component> tooltip) {
Validate.notNull(tooltip, "Argument must not be null");

this.tooltip = tooltip;

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected int compute(int x, int y, int z) {
BlockState state = level.getBlockState(pos);

boolean em = state.emissiveRendering(level, pos);
boolean op = state.isViewBlocking(level, pos) && state.getLightBlock(level, pos) != 0;
boolean fo = state.isSolidRender(level, pos);
boolean op = state.isViewBlocking(level, pos) && state.getLightBlock() != 0;
boolean fo = state.isSolidRender();
boolean fc = state.isCollisionShapeFullBlock(level, pos);

int lu = PlatformBlockAccess.getInstance().getLightEmission(state, level, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,9 @@ public TextureAtlasSprite getSprite() {
public Direction getLightFace() {
return this.direction;
}

@Override
public int getMaxLightQuad(int idx) {
return getLight(idx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,11 @@ default int getAccurateNormal(int i) {

return normal == 0 ? getFaceNormal() : normal;
}

/**
* Gets the maximum light value for this vertex.
* @param idx The vertex index.
* @return Lightmap value.
*/
int getMaxLightQuad(int idx);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess;
import net.caffeinemc.mods.sodium.client.util.NativeBuffer;
import net.caffeinemc.mods.sodium.client.world.LevelRendererExtension;
import net.caffeinemc.mods.sodium.mixin.core.render.world.EntityRendererAccessor;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
Expand All @@ -31,11 +32,14 @@
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.state.EntityRenderState;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.core.BlockPos;
import net.minecraft.core.SectionPos;
import net.minecraft.server.level.BlockDestructionProgress;
import net.minecraft.util.Mth;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand Down Expand Up @@ -172,7 +176,7 @@ public void setupTerrain(Camera camera,
this.reload();
}

ProfilerFiller profiler = this.client.getProfiler();
ProfilerFiller profiler = Profiler.get();
profiler.push("camera_setup");

LocalPlayer player = this.client.player;
Expand All @@ -186,7 +190,7 @@ public void setupTerrain(Camera camera,
Matrix4f projectionMatrix = new Matrix4f(RenderSystem.getProjectionMatrix());
float pitch = camera.getXRot();
float yaw = camera.getYRot();
float fogDistance = RenderSystem.getShaderFogEnd();
float fogDistance = RenderSystem.getShaderFog().end();

if (this.lastCameraPos == null) {
this.lastCameraPos = new Vector3d(pos);
Expand Down Expand Up @@ -476,7 +480,7 @@ public void iterateVisibleBlockEntities(Consumer<BlockEntity> blockEntityConsume
* Returns whether or not the entity intersects with any visible chunks in the graph.
* @return True if the entity is visible, otherwise false
*/
public boolean isEntityVisible(Entity entity) {
public <T extends Entity, S extends EntityRenderState> boolean isEntityVisible(EntityRenderer<T, S> renderer, T entity) {
if (!this.useEntityCulling) {
return true;
}
Expand All @@ -486,7 +490,7 @@ public boolean isEntityVisible(Entity entity) {
return true;
}

AABB bb = entity.getBoundingBoxForCulling();
AABB bb = ((EntityRendererAccessor) renderer).getCullingBox(entity);

// bail on very large entities to avoid checking many sections
double entityVolume = (bb.maxX - bb.minX) * (bb.maxY - bb.minY) * (bb.maxZ - bb.minZ);
Expand All @@ -501,7 +505,7 @@ public boolean isEntityVisible(Entity entity) {
public boolean isBoxVisible(double x1, double y1, double z1, double x2, double y2, double z2) {
// Boxes outside the valid level height will never map to a rendered chunk
// Always render these boxes, or they'll be culled incorrectly!
if (y2 < this.level.getMinBuildHeight() + 0.5D || y1 > this.level.getMaxBuildHeight() - 0.5D) {
if (y2 < this.level.getMinY() + 0.5D || y1 > this.level.getMaxY() - 0.5D) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private boolean shouldUseOcclusionCulling(Camera camera, boolean spectator) {
BlockPos origin = camera.getBlockPosition();

if (spectator && this.level.getBlockState(origin)
.isSolidRender(this.level, origin))
.isSolidRender())
{
useOcclusionCulling = false;
} else {
Expand Down Expand Up @@ -626,13 +626,13 @@ private static boolean allowImportantRebuilds() {
}

private float getEffectiveRenderDistance() {
var color = RenderSystem.getShaderFogColor();
var distance = RenderSystem.getShaderFogEnd();
var alpha = RenderSystem.getShaderFog().alpha();
var distance = RenderSystem.getShaderFog().end();

var renderDistance = this.getRenderDistance();

// The fog must be fully opaque in order to skip rendering of chunks behind it
if (!Mth.equal(color[3], 1.0f)) {
if (!Mth.equal(alpha, 1.0f)) {
return renderDistance;
}

Expand Down Expand Up @@ -723,13 +723,13 @@ public boolean isSectionBuilt(int x, int y, int z) {
}

public void onChunkAdded(int x, int z) {
for (int y = this.level.getMinSection(); y < this.level.getMaxSection(); y++) {
for (int y = this.level.getMinSectionY(); y <= this.level.getMaxSectionY(); y++) {
this.onSectionAdded(x, y, z);
}
}

public void onChunkRemoved(int x, int z) {
for (int y = this.level.getMinSection(); y < this.level.getMaxSection(); y++) {
for (int y = this.level.getMinSectionY(); y <= this.level.getMaxSectionY(); y++) {
this.onSectionRemoved(x, y, z);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package net.caffeinemc.mods.sodium.client.render.chunk.compile.executor;

import com.mojang.jtracy.TracyClient;
import com.mojang.jtracy.Zone;
import net.caffeinemc.mods.sodium.client.SodiumClientMod;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.BuilderTaskOutput;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildContext;
import net.caffeinemc.mods.sodium.client.render.chunk.compile.tasks.ChunkBuilderTask;
import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexType;
import net.minecraft.SharedConstants;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.util.Mth;
import org.apache.commons.lang3.Validate;
Expand Down Expand Up @@ -48,7 +51,7 @@ public ChunkBuilder(ClientLevel level, ChunkVertexType vertexType) {

for (int i = 0; i < count; i++) {
ChunkBuildContext context = new ChunkBuildContext(level, vertexType);
WorkerRunnable worker = new WorkerRunnable(context);
WorkerRunnable worker = new WorkerRunnable("Chunk Render Task Executor #" + i, context);

Thread thread = new Thread(worker, "Chunk Render Task Executor #" + i);
thread.setPriority(Math.max(0, Thread.NORM_PRIORITY - 2));
Expand Down Expand Up @@ -184,9 +187,11 @@ public int getTotalThreadCount() {
private class WorkerRunnable implements Runnable {
// Making this thread-local provides a small boost to performance by avoiding the overhead in synchronizing
// caches between different CPU cores
private final String name;
private final ChunkBuildContext context;

public WorkerRunnable(ChunkBuildContext context) {
public WorkerRunnable(String name, ChunkBuildContext context) {
this.name = name;
this.context = context;
}

Expand All @@ -209,13 +214,17 @@ public void run() {

ChunkBuilder.this.busyThreadCount.getAndIncrement();

Zone zone = TracyClient.beginZone(name, SharedConstants.IS_RUNNING_IN_IDE);

try {
job.execute(this.context);
} finally {
this.context.cleanup();

ChunkBuilder.this.busyThreadCount.decrementAndGet();
}

zone.close();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public boolean shouldDrawSide(BlockState selfState, BlockGetter view, BlockPos s
}

// The cull shape of the block being rendered
VoxelShape selfShape = selfState.getFaceOcclusionShape(view, selfPos, facing);
VoxelShape selfShape = selfState.getFaceOcclusionShape(facing);

// If the block being rendered has an empty cull shape, intersection tests will always fail
if (selfShape.isEmpty()) {
return true;
}

// The cull shape of the block neighboring the one being rendered
VoxelShape otherShape = otherState.getFaceOcclusionShape(view, otherPos, DirectionUtil.getOpposite(facing));
VoxelShape otherShape = otherState.getFaceOcclusionShape(DirectionUtil.getOpposite(facing));

// If the other block has an empty cull shape, then it cannot hide any geometry
if (otherShape.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockP

this.posOffset.set(origin.getX(), origin.getY(), origin.getZ());
if (state.hasOffsetFunction()) {
Vec3 modelOffset = state.getOffset(this.level, pos);
Vec3 modelOffset = state.getOffset(pos);
this.posOffset.add((float) modelOffset.x, (float) modelOffset.y, (float) modelOffset.z);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private boolean isSideExposed(BlockAndTintGetter world, int x, int y, int z, Dir
BlockState blockState = world.getBlockState(pos);

if (blockState.canOcclude()) {
VoxelShape shape = blockState.getOcclusionShape(world, pos);
VoxelShape shape = blockState.getOcclusionShape();

// Hoist these checks to avoid allocating the shape below
if (shape.isEmpty()) {
Expand Down
Loading

0 comments on commit 509339d

Please sign in to comment.