Skip to content

Commit

Permalink
change: Update for 1.21-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Jun 12, 2024
1 parent 85164c4 commit b9fc3a9
Show file tree
Hide file tree
Showing 23 changed files with 184 additions and 167 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

//modImplementation "me.jellysquid.mods:sodium-fabric:0.5.6+git.d2b4c1f"
modImplementation "maven.modrinth:sodium:${project.sodium_version}"
modImplementation "me.jellysquid.mods:sodium:0.5.9-snapshot+mc1.21-pre3-build.9"
//modImplementation "maven.modrinth:sodium:${project.sodium_version}"
/*modImplementation("me.flashyreese.mods:reeses-sodium-options:${project.reeses_sodium_options}") {
exclude group: "net.coderbot.iris_mc1_19", module: "iris"
}*/
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
minecraft_version=1.21-rc1
yarn_mappings=1.21-rc1+build.1
loader_version=0.15.11

# Mod Properties
mod_version=0.5.5
Expand All @@ -14,5 +14,5 @@ org.gradle.jvmargs=-Xmx1G
# Dependencies
reeses_sodium_options=1.7.3+mc1.20.5-build.74
sodium_version=mc1.20.6-0.5.8
fabric_version=0.97.8+1.20.6
fabric_version=0.100.1+1.21
crowdin_translate=1.4+1.19.3
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import java.util.Queue;

public class ClientTickHandler {
private int averageFps, lowestFps, highestFps;
private final Queue<Integer> fpsQueue = EvictingQueue.create(200);
private int averageFps, lowestFps, highestFps;

public void onClientInitialize() {
ClientTickEvents.START_CLIENT_TICK.register(minecraftClient -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.flashyreese.mods.sodiumextra.client;

import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraHud;
import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraGameOptions;
import me.flashyreese.mods.sodiumextra.client.gui.SodiumExtraHud;
import net.caffeinemc.caffeineconfig.CaffeineConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,13 @@ public static OptionPage extra() {
)
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
.setName(Text.translatable("sodium-extra.option.advanced_item_tooltips"))
.setTooltip(Text.translatable("sodium-extra.option.advanced_item_tooltips.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.advancedItemTooltips = value, opts -> opts.advancedItemTooltips)
.build()
)
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
.setName(Text.translatable("sodium-extra.option.advanced_item_tooltips"))
.setTooltip(Text.translatable("sodium-extra.option.advanced_item_tooltips.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.advancedItemTooltips = value, opts -> opts.advancedItemTooltips)
.build()
)
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.text.Text;
import net.minecraft.util.math.Vec3d;

Expand Down Expand Up @@ -46,8 +47,9 @@ public void onStartTick(MinecraftClient client) {
this.textList.add(text);
}
}

@Override
public void onHudRender(DrawContext drawContext, float tickDelta) {
public void onHudRender(DrawContext drawContext, RenderTickCounter renderTickCounter) {
if (!this.client.getDebugHud().shouldShowDebugHud() && !this.client.options.hudHidden) {
SodiumExtraGameOptions.OverlayCorner overlayCorner = SodiumExtraClientMod.options().extraSettings.overlayCorner;
// Calculate starting position based on the overlay corner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import org.lwjgl.system.MemoryUtil;

public class TextureColorVertex {
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(VertexFormats.POSITION_COLOR_TEXTURE);
public static final VertexFormatDescription FORMAT = VertexFormatRegistry.instance().get(VertexFormats.POSITION_TEXTURE_COLOR);

public static final int STRIDE = 24;

private static final int OFFSET_POSITION = 0;
private static final int OFFSET_COLOR = 12;
private static final int OFFSET_TEXTURE = 16;
private static final int OFFSET_TEXTURE = 12;
private static final int OFFSET_COLOR = 20;

public static void write(long ptr, Matrix4f matrix, float x, float y, float z, int color, float u, float v) {
float xt = MatrixHelper.transformPositionX(matrix, x, y, z);
Expand All @@ -29,9 +29,10 @@ public static void write(long ptr, float x, float y, float z, int color, float u
MemoryUtil.memPutFloat(ptr + OFFSET_POSITION + 4, y);
MemoryUtil.memPutFloat(ptr + OFFSET_POSITION + 8, z);

MemoryUtil.memPutInt(ptr + OFFSET_COLOR, color);

MemoryUtil.memPutFloat(ptr + OFFSET_TEXTURE, u);
MemoryUtil.memPutFloat(ptr + OFFSET_TEXTURE + 4, v);

MemoryUtil.memPutInt(ptr + OFFSET_COLOR, color);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatDescription;
import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry;
import net.minecraft.client.render.VertexFormats;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;

public final class WeatherVertex {
Expand All @@ -18,14 +17,14 @@ public final class WeatherVertex {
private static final int OFFSET_COLOR = 20;
private static final int OFFSET_LIGHT = 24;

public static void put(long ptr, float x, float y, float z, int color, float u, float v, int light) {
public static void put(long ptr, float x, float y, float z, float u, float v, int color, int light) {
PositionAttribute.put(ptr + OFFSET_POSITION, x, y, z);
TextureAttribute.put(ptr + OFFSET_TEXTURE, u, v);
ColorAttribute.set(ptr + OFFSET_COLOR, color);
LightAttribute.set(ptr + OFFSET_LIGHT, light);
}

public static void put(long ptr, float x, float y, float z, int color, float u, float v, int lightU, int lightV) {
public static void put(long ptr, float x, float y, float z, float u, float v, int color, int lightU, int lightV) {
PositionAttribute.put(ptr + OFFSET_POSITION, x, y, z);
TextureAttribute.put(ptr + OFFSET_TEXTURE, u, v);
ColorAttribute.set(ptr + OFFSET_COLOR, color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class IrisCompat {
terrainFormat = (VertexFormat) terrainField.get(null);

irisPresent = true;
} catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | IllegalAccessException | InvocationTargetException e) {
} catch (ClassNotFoundException | NoSuchMethodException | NoSuchFieldException | IllegalAccessException |
InvocationTargetException e) {
irisPresent = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class ModelVertexToTerrainSerializer implements VertexSerializer {
@Override
public void serialize(long src, long dst, int vertexCount) {
for(int i = 0; i < vertexCount; ++i) {
for (int i = 0; i < vertexCount; ++i) {
MemoryUtil.memCopy(src, dst, 24); // Copies position, color and texture
// todo: overlay src + 24L
MemoryUtil.memCopy(src + 28L, dst + 24L, 8); // Copies light and normal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,56 @@ public abstract class MixinSpriteAtlasTexture extends AbstractTexture {
@Unique
private final Map<Supplier<Boolean>, List<Identifier>> animatedSprites = Map.of(
() -> SodiumExtraClientMod.options().animationSettings.water, List.of(
new Identifier("minecraft", "block/water_still"),
new Identifier("minecraft", "block/water_flow")
Identifier.of("minecraft", "block/water_still"),
Identifier.of("minecraft", "block/water_flow")
),
() -> SodiumExtraClientMod.options().animationSettings.lava, List.of(
new Identifier("minecraft", "block/lava_still"),
new Identifier("minecraft", "block/lava_flow")
Identifier.of("minecraft", "block/lava_still"),
Identifier.of("minecraft", "block/lava_flow")
),
() -> SodiumExtraClientMod.options().animationSettings.portal, List.of(
new Identifier("minecraft", "block/nether_portal")
Identifier.of("minecraft", "block/nether_portal")
),
() -> SodiumExtraClientMod.options().animationSettings.fire, List.of(
new Identifier("minecraft", "block/fire_0"),
new Identifier("minecraft", "block/fire_1"),
new Identifier("minecraft", "block/soul_fire_0"),
new Identifier("minecraft", "block/soul_fire_1"),
new Identifier("minecraft", "block/campfire_fire"),
new Identifier("minecraft", "block/campfire_log_lit"),
new Identifier("minecraft", "block/soul_campfire_fire"),
new Identifier("minecraft", "block/soul_campfire_log_lit")
Identifier.of("minecraft", "block/fire_0"),
Identifier.of("minecraft", "block/fire_1"),
Identifier.of("minecraft", "block/soul_fire_0"),
Identifier.of("minecraft", "block/soul_fire_1"),
Identifier.of("minecraft", "block/campfire_fire"),
Identifier.of("minecraft", "block/campfire_log_lit"),
Identifier.of("minecraft", "block/soul_campfire_fire"),
Identifier.of("minecraft", "block/soul_campfire_log_lit")
),
() -> SodiumExtraClientMod.options().animationSettings.blockAnimations, List.of(
new Identifier("minecraft", "block/magma"),
new Identifier("minecraft", "block/lantern"),
new Identifier("minecraft", "block/sea_lantern"),
new Identifier("minecraft", "block/soul_lantern"),
new Identifier("minecraft", "block/kelp"),
new Identifier("minecraft", "block/kelp_plant"),
new Identifier("minecraft", "block/seagrass"),
new Identifier("minecraft", "block/tall_seagrass_top"),
new Identifier("minecraft", "block/tall_seagrass_bottom"),
new Identifier("minecraft", "block/warped_stem"),
new Identifier("minecraft", "block/crimson_stem"),
new Identifier("minecraft", "block/blast_furnace_front_on"),
new Identifier("minecraft", "block/smoker_front_on"),
new Identifier("minecraft", "block/stonecutter_saw"),
new Identifier("minecraft", "block/prismarine"),
new Identifier("minecraft", "block/respawn_anchor_top"),
new Identifier("minecraft", "entity/conduit/wind"),
new Identifier("minecraft", "entity/conduit/wind_vertical")
Identifier.of("minecraft", "block/magma"),
Identifier.of("minecraft", "block/lantern"),
Identifier.of("minecraft", "block/sea_lantern"),
Identifier.of("minecraft", "block/soul_lantern"),
Identifier.of("minecraft", "block/kelp"),
Identifier.of("minecraft", "block/kelp_plant"),
Identifier.of("minecraft", "block/seagrass"),
Identifier.of("minecraft", "block/tall_seagrass_top"),
Identifier.of("minecraft", "block/tall_seagrass_bottom"),
Identifier.of("minecraft", "block/warped_stem"),
Identifier.of("minecraft", "block/crimson_stem"),
Identifier.of("minecraft", "block/blast_furnace_front_on"),
Identifier.of("minecraft", "block/smoker_front_on"),
Identifier.of("minecraft", "block/stonecutter_saw"),
Identifier.of("minecraft", "block/prismarine"),
Identifier.of("minecraft", "block/respawn_anchor_top"),
Identifier.of("minecraft", "entity/conduit/wind"),
Identifier.of("minecraft", "entity/conduit/wind_vertical")
),
() -> SodiumExtraClientMod.options().animationSettings.sculkSensor, List.of(
new Identifier("minecraft", "block/sculk"),
new Identifier("minecraft", "block/sculk_catalyst_top_bloom"),
new Identifier("minecraft", "block/sculk_catalyst_side_bloom"),
new Identifier("minecraft", "block/sculk_shrieker_inner_top"),
new Identifier("minecraft", "block/sculk_vein"),
new Identifier("minecraft", "block/sculk_shrieker_can_summon_inner_top"),
new Identifier("minecraft", "block/sculk_sensor_tendril_inactive"),
new Identifier("minecraft", "block/sculk_sensor_tendril_active"),
new Identifier("minecraft", "vibration")
Identifier.of("minecraft", "block/sculk"),
Identifier.of("minecraft", "block/sculk_catalyst_top_bloom"),
Identifier.of("minecraft", "block/sculk_catalyst_side_bloom"),
Identifier.of("minecraft", "block/sculk_shrieker_inner_top"),
Identifier.of("minecraft", "block/sculk_vein"),
Identifier.of("minecraft", "block/sculk_shrieker_can_summon_inner_top"),
Identifier.of("minecraft", "block/sculk_sensor_tendril_inactive"),
Identifier.of("minecraft", "block/sculk_sensor_tendril_active"),
Identifier.of("minecraft", "vibration")
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import com.mojang.blaze3d.systems.RenderSystem;
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
import net.minecraft.block.enums.CameraSubmersionType;
import net.minecraft.client.render.BackgroundRenderer;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.CameraSubmersionType;
import net.minecraft.entity.Entity;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import me.flashyreese.mods.sodiumextra.compat.IrisCompat;
import net.caffeinemc.mods.sodium.api.math.MatrixHelper;
import net.caffeinemc.mods.sodium.api.util.ColorABGR;
import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter;
import net.caffeinemc.mods.sodium.api.vertex.format.common.ModelVertex;
import net.minecraft.block.entity.BeaconBlockEntity;
Expand All @@ -12,6 +11,7 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix3f;
Expand All @@ -30,8 +30,8 @@ public abstract class MixinBeaconBlockEntityRenderer {
* @author FlashyReese
* @reason Use optimized vertex writer, also avoids unnecessary allocations
*/
@Inject(method = "renderBeam(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/util/Identifier;FFJII[FFF)V", at = @At(value = "HEAD"), cancellable = true)
private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, Identifier textureId, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, float[] color, float innerRadius, float outerRadius, CallbackInfo ci) {
@Inject(method = "renderBeam(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/util/Identifier;FFJIIIFF)V", at = @At(value = "HEAD"), cancellable = true)
private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, Identifier textureId, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, int color, float innerRadius, float outerRadius, CallbackInfo ci) {
ci.cancel();
if (IrisCompat.isIrisPresent()) {
if (IrisCompat.isRenderingShadowPass()) {
Expand All @@ -45,9 +45,6 @@ private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvi
float time = (float) Math.floorMod(worldTime, 40) + tickDelta;
float negativeTime = maxY < 0 ? time : -time;
float fractionalPart = MathHelper.fractionalPart(negativeTime * 0.2F - (float) MathHelper.floor(negativeTime * 0.1F));
float red = color[0];
float green = color[1];
float blue = color[2];
matrices.push();
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(time * 2.25F - 45.0F));
float innerX1;
Expand All @@ -57,13 +54,10 @@ private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvi
float innerV2 = -1.0F + fractionalPart;
float innerV1 = (float) maxY * heightScale * (0.5F / innerRadius) + innerV2;

int colorNoneTranslucent = ColorABGR.pack(red, green, blue, 1.0F);
int colorTranslucent = ColorABGR.pack(red, green, blue, 0.125F);

try (MemoryStack stack = MemoryStack.stackPush()) {
long buffer = stack.nmalloc(2 * 16 * ModelVertex.STRIDE);
long ptr = buffer;
ptr = writeBeamLayerVertices(ptr, matrices, colorNoneTranslucent, yOffset, height, 0.0F, innerRadius, innerRadius, 0.0F, innerX3, 0.0F, 0.0F, innerZ4, innerV1, innerV2);
ptr = writeBeamLayerVertices(ptr, matrices, color, yOffset, height, 0.0F, innerRadius, innerRadius, 0.0F, innerX3, 0.0F, 0.0F, innerZ4, innerV1, innerV2);
VertexBufferWriter.of(vertexConsumerProvider.getBuffer(RenderLayer.getBeaconBeam(textureId, false))).push(stack, buffer, 16, ModelVertex.FORMAT);

matrices.pop();
Expand All @@ -75,7 +69,7 @@ private static void optimizeRenderBeam(MatrixStack matrices, VertexConsumerProvi
innerV1 = (float) maxY * heightScale + innerV2;

buffer = ptr;
ptr = writeBeamLayerVertices(ptr, matrices, colorTranslucent, yOffset, height, innerX1, outerZ1, outerRadius, innerZ2, innerX3, outerRadius, outerRadius, outerRadius, innerV1, innerV2);
ptr = writeBeamLayerVertices(ptr, matrices, ColorHelper.Argb.withAlpha(32, color), yOffset, height, innerX1, outerZ1, outerRadius, innerZ2, innerX3, outerRadius, outerRadius, outerRadius, innerV1, innerV2);
VertexBufferWriter.of(vertexConsumerProvider.getBuffer(RenderLayer.getBeaconBeam(textureId, true))).push(stack, buffer, 16, ModelVertex.FORMAT);
}
matrices.pop();
Expand Down
Loading

0 comments on commit b9fc3a9

Please sign in to comment.