Skip to content

Commit

Permalink
Merge branch '1.20.x/dev' into 1.20.x/stable
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Jul 17, 2023
2 parents fbaaa84 + 510d7ba commit ae98d2e
Show file tree
Hide file tree
Showing 20 changed files with 583 additions and 308 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Upload build artifacts
run: |
chmod +x gradlew
./gradlew build
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
name: 'Sodium Extra Artifacts'
path: build/libs
15 changes: 7 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@ on:
- published

jobs:
build:
publish:
if: github.repository_owner == 'FlashyReese'
runs-on: self-hosted
steps:
- name: Checkout sources
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Upload assets to releases
run: ./gradlew build publishAllPublicationsToFlashyReeseReleasesRepository
run: |
chmod +x gradlew
./gradlew build publishAllPublicationsToFlashyReeseReleasesRepository
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
BUILD_RELEASE: ${{ github.event.prerelease == false }}
- name: Publish to Modrinth & CurseForge
uses: Kir-Antipov/mc-publish@v3.2
uses: Kir-Antipov/mc-publish@v3.3
with:
modrinth-id: PtjYWJkn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
Expand All @@ -36,9 +37,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

version-type: release

loaders: fabric

version-resolver: latest
dependencies: |
sodium | depends | *
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/self-hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@ name: Self-Hosted runner CI with Gradle
on: [ push ]

jobs:
build:
selfhost-build:
if: github.repository_owner == 'FlashyReese'
runs-on: self-hosted

steps:
- uses: actions/checkout@v3
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Grant execute permission for Gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Upload build artifacts
run: |
chmod +x gradlew
./gradlew build
- name: Upload Auild Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
name: 'Sodium Extra Artifacts'
path: build/libs
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
id 'signing'
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
id 'io.github.juuxel.loom-quiltflower' version '1.8.0'
id 'io.github.juuxel.loom-quiltflower' version '1.10.0'
}

apply plugin: 'de.guntram.mcmod.crowdin-translate'
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20
yarn_mappings=1.20+build.1
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21

# Mod Properties
mod_version=0.4.20
mod_version=0.4.21
maven_group=me.flashyreese.mods
archives_base_name=sodium-extra

# Dependencies
reeses_sodium_options=1.5.0+mc1.20-build.73
reeses_sodium_options=1.5.1+mc1.20-build.74
sodium_version=mc1.20-0.4.10
fabric_version=0.83.0+1.20
fabric_version=0.85.0+1.20.1
crowdin_translate=1.4+1.19.3
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,22 @@ public static OptionPage extra() {
.build()
)
.build());
groups.add(OptionGroup.createBuilder()
.add(OptionImpl.createBuilder(boolean.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.steady_debug_hud"))
.setTooltip(Text.translatable("sodium-extra.option.steady_debug_hud.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((options, value) -> options.extraSettings.steadyDebugHud = value, options -> options.extraSettings.steadyDebugHud)
.build()
)
.add(OptionImpl.createBuilder(int.class, sodiumExtraOpts)
.setName(Text.translatable("sodium-extra.option.steady_debug_hud_refresh_interval"))
.setTooltip(Text.translatable("sodium-extra.option.steady_debug_hud_refresh_interval.tooltip"))
.setControl(option -> new SliderControlExtended(option, 1, 20, 1, ControlValueFormatterExtended.ticks(), false))
.setBinding((options, value) -> options.extraSettings.steadyDebugHudRefreshInterval = value, options -> options.extraSettings.steadyDebugHudRefreshInterval)
.build()
)
.build());

return new OptionPage(Text.translatable("sodium-extra.option.extras"), ImmutableList.copyOf(groups));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,16 @@ public static class ExtraSettings {
public boolean tutorialToast;
public boolean instantSneak;
public boolean preventShaders;
public boolean steadyDebugHud;
public int steadyDebugHudRefreshInterval;

public ExtraSettings() {
this.overlayCorner = OverlayCorner.TOP_LEFT;
this.textContrast = TextContrast.NONE;
this.showFps = false;
this.showFPSExtended = true;
this.showCoords = false;
this.reduceResolutionOnMac = true;
this.reduceResolutionOnMac = false;
this.useAdaptiveSync = false;
this.cloudHeight = 192;
this.toasts = true;
Expand All @@ -269,6 +271,8 @@ public ExtraSettings() {
this.tutorialToast = true;
this.instantSneak = false;
this.preventShaders = false;
this.steadyDebugHud = true;
this.steadyDebugHudRefreshInterval = 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ static ControlValueFormatter fogDistance() {
}
};
}

static ControlValueFormatter ticks() {
return (v) -> Text.translatable("sodium-extra.units.ticks", v).getString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ protected CaffeineConfig createConfig() {
.addMixinOption("gui", true)
.addMixinOption("instant_sneak", true)
.addMixinOption("light_updates", true)
.addMixinOption("optimizations", true)
.addMixinOption("optimizations.beacon_beam_rendering", true)
.addMixinOption("particle", true)
.addMixinOption("prevent_shaders", true)
.addMixinOption("reduce_resolution_on_mac", true)
Expand All @@ -37,6 +39,7 @@ protected CaffeineConfig createConfig() {
.addMixinOption("sodium.scrollable_page", true)
.addMixinOption("sodium.vsync", true)
.addMixinOption("stars", true)
.addMixinOption("steady_debug_hud", true)
.addMixinOption("sun_moon", true)
.addMixinOption("toasts", true)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package me.flashyreese.mods.sodiumextra.mixin.optimizations.beacon_beam_rendering;

import me.jellysquid.mods.sodium.client.render.RenderGlobal;
import me.jellysquid.mods.sodium.client.render.vertex.VertexBufferWriter;
import me.jellysquid.mods.sodium.client.render.vertex.formats.ModelVertex;
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
import me.jellysquid.mods.sodium.common.util.MatrixHelper;
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BeaconBlockEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RotationAxis;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.lwjgl.system.MemoryStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Unique;

@Mixin(BeaconBlockEntityRenderer.class)
public class MixinBeaconBlockEntityRenderer {

/**
* For Sodium 0.5 is method will only reduce allocations
*
* @author FlashyReese
* @reason Use optimized vertex writer, also avoids unnecessary allocations
*/
@Overwrite
public static void renderBeam(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, Identifier textureId, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, float[] color, float innerRadius, float outerRadius) {
int height = yOffset + maxY;
matrices.push();
matrices.translate(0.5, 0.0, 0.5);
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;
float innerZ2;
float innerX3 = -innerRadius;
float innerZ4 = -innerRadius;
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 = RenderGlobal.VERTEX_DATA.push()) {
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);
VertexBufferWriter.of(vertexConsumerProvider.getBuffer(RenderLayer.getBeaconBeam(textureId, false))).push(stack, buffer, 16, ModelVertex.FORMAT);

matrices.pop();
innerX1 = -outerRadius;
float outerZ1 = -outerRadius;
innerZ2 = -outerRadius;
innerX3 = -outerRadius;
innerV2 = -1.0F + fractionalPart;
innerV1 = (float) maxY * heightScale + innerV2;

ptr = writeBeamLayerVertices(ptr, matrices, colorTranslucent, 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();
}

@Unique
private static long writeBeamLayerVertices(long ptr, MatrixStack matrixStack, int color, int yOffset, int height, float x1, float z1, float x2, float z2, float x3, float z3, float x4, float z4, float v1, float v2) {
MatrixStack.Entry entry = matrixStack.peek();
Matrix4f positionMatrix = entry.getPositionMatrix();
Matrix3f normalMatrix = entry.getNormalMatrix();

var normal = MatrixHelper.transformNormal(normalMatrix, (float) 0.0, (float) 1.0, (float) 0.0);

ptr = transformAndWriteVertex(ptr, positionMatrix, x1, height, z1, color, 1.0f, v1, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x1, yOffset, z1, color, 1.0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x2, yOffset, z2, color, 0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x2, height, z2, color, 0f, v1, normal);

ptr = transformAndWriteVertex(ptr, positionMatrix, x4, height, z4, color, 1.0f, v1, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x4, yOffset, z4, color, 1.0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x3, yOffset, z3, color, 0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x3, height, z3, color, 0f, v1, normal);

ptr = transformAndWriteVertex(ptr, positionMatrix, x2, height, z2, color, 1.0f, v1, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x2, yOffset, z2, color, 1.0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x4, yOffset, z4, color, 0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x4, height, z4, color, 0f, v1, normal);

ptr = transformAndWriteVertex(ptr, positionMatrix, x3, height, z3, color, 1.0f, v1, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x3, yOffset, z3, color, 1.0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x1, yOffset, z1, color, 0f, v2, normal);
ptr = transformAndWriteVertex(ptr, positionMatrix, x1, height, z1, color, 0f, v1, normal);
return ptr;
}

@Unique
private static long transformAndWriteVertex(long ptr, Matrix4f positionMatrix, float x, float y, float z, int color, float u, float v, int normal) {
float transformedX = MatrixHelper.transformPositionX(positionMatrix, x, y, z);
float transformedY = MatrixHelper.transformPositionY(positionMatrix, x, y, z);
float transformedZ = MatrixHelper.transformPositionZ(positionMatrix, x, y, z);

ModelVertex.write(ptr, transformedX, transformedY, transformedZ, color, u, v, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV, normal);
ptr += ModelVertex.STRIDE;
return ptr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(BeaconBlockEntityRenderer.class)
@Mixin(value = BeaconBlockEntityRenderer.class, priority = 999)
public class MixinBeaconBlockEntityRenderer {
@Inject(method = "render(Lnet/minecraft/block/entity/BeaconBlockEntity;FLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;II)V", at = @At(value = "HEAD"), cancellable = true)
public void render(BeaconBlockEntity beaconBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j, CallbackInfo ci) {
Expand Down
Loading

0 comments on commit ae98d2e

Please sign in to comment.