Skip to content

Commit

Permalink
Merge branch 'CaffeineMC:1.18.x/dev' into vanilla-sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
Madis0 committed Nov 25, 2021
2 parents bef4be8 + 93c0447 commit 39914d8
Show file tree
Hide file tree
Showing 51 changed files with 479 additions and 651 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 16
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 16
java-version: 17
- name: Cache/Uncache Sodium
uses: actions/cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set up JDK 16
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 16
java-version: 17
- name: Build artifacts
run: ./gradlew build
- name: Upload assets to GitHub
Expand Down
20 changes: 3 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'org.ajoberstar.grgit' version '4.1.0'
}

sourceCompatibility = "16"
targetCompatibility = "16"
sourceCompatibility = "17"
targetCompatibility = "17"

archivesBaseName = "${project.archives_base_name}-mc${project.minecraft_version}"
version = "${project.mod_version}+${getVersionMetadata()}"
Expand Down Expand Up @@ -38,20 +38,6 @@ dependencies {
modIncludeImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_version))
}

if (project.use_third_party_mods) {
repositories {
maven { url = "https://maven.gegy.dev" }
}

dependencies {
// DataBreaker applies a number of patches to eliminate the loading of data fixers
// This greatly reduces the amount of time needed to start the game, but is generally unsafe in production
modRuntime ("supercoder79:databreaker:${project.databreaker_version}") {
transitive = false
}
}
}

processResources {
inputs.property "version", project.version

Expand Down
16 changes: 6 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.1
loader_version=0.11.6
fabric_version=0.36.1+1.17
minecraft_version=1.18-pre8
yarn_mappings=1.18-pre8+build.2
loader_version=0.12.5
fabric_version=0.43.0+1.18

# Mod Properties
mod_version=0.3.3
mod_version=0.4.0
maven_group=me.jellysquid.mods
archives_base_name=sodium-fabric

# If true, third-party mods will be loaded during runtime in the developer run configurations
use_third_party_mods = true
databreaker_version = 0.2.7
archives_base_name=sodium-fabric
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public static OptionPage general() {
.setImpact(OptionImpact.HIGH)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build())
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(new TranslatableText("options.simulationDistance"))
.setTooltip(new TranslatableText("sodium.options.simulation_distance.tooltip"))
.setControl(option -> new SliderControl(option, 5, 32, 1, ControlValueFormatter.translateVariable("options.chunks")))
.setBinding((options, value) -> options.simulationDistance = value, options -> options.simulationDistance)
.setImpact(OptionImpact.HIGH)
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
.build())
.add(OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(new TranslatableText("options.gamma"))
.setTooltip(new TranslatableText("sodium.options.brightness.tooltip"))
Expand Down Expand Up @@ -132,6 +140,12 @@ public static OptionPage general() {
.setControl(opts -> new CyclingControl<>(opts, AttackIndicator.class, new Text[] { new TranslatableText("options.off"), new TranslatableText("options.attack.crosshair"), new TranslatableText("options.attack.hotbar") }))
.setBinding((opts, value) -> opts.attackIndicator = value, (opts) -> opts.attackIndicator)
.build())
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
.setName(new TranslatableText("options.autosaveIndicator"))
.setTooltip(new TranslatableText("sodium.options.autosave_indicator.tooltip"))
.setControl(TickBoxControl::new)
.setBinding((opts, value) -> opts.showAutosaveIndicator = value, opts -> opts.showAutosaveIndicator)
.build())
.build());

return new OptionPage(new TranslatableText("stat.generalButton"), ImmutableList.copyOf(groups));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private void openDonationPage() {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_P && (modifiers & GLFW.GLFW_MOD_SHIFT) != 0) {
MinecraftClient.getInstance().openScreen(new VideoOptionsScreen(this.prevScreen, MinecraftClient.getInstance().options));
MinecraftClient.getInstance().setScreen(new VideoOptionsScreen(this.prevScreen, MinecraftClient.getInstance().options));

return true;
}
Expand All @@ -304,6 +304,6 @@ public boolean shouldCloseOnEsc() {

@Override
public void onClose() {
this.client.openScreen(this.prevScreen);
this.client.setScreen(this.prevScreen);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void init() {

this.addDrawableChild(new ButtonWidget(32, this.height - 40, 174, 20, TEXT_BUTTON_RESTORE_DEFAULTS, (btn) -> {
SodiumClientMod.restoreDefaultOptions();
MinecraftClient.getInstance().openScreen(this.child.get());
MinecraftClient.getInstance().setScreen(this.child.get());
}));

this.addDrawableChild(new ButtonWidget(this.width - 174 - 32, this.height - 40, 174, 20, TEXT_BUTTON_CLOSE_GAME, (btn) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,59 +34,69 @@ public <T> int[] getColors(BlockRenderView world, BlockPos origin, ModelQuadView
private <T> int getVertexColor(ModelQuadColorProvider<T> colorizer, BlockRenderView world, T state, BlockPos origin,
ModelQuadView quad, int vertexIdx) {
final int x = origin.getX() + (int) quad.getX(vertexIdx);
final int y = origin.getY() + (int) quad.getY(vertexIdx);
final int z = origin.getZ() + (int) quad.getZ(vertexIdx);

final int color = this.getBlockColor(colorizer, world, state, origin, x, z, quad.getColorIndex());
final int color = this.getBlockColor(colorizer, world, state, x, y, z, quad.getColorIndex());

return ColorARGB.toABGR(color);
}

private <T> int getBlockColor(ModelQuadColorProvider<T> colorizer, BlockRenderView world, T state, BlockPos origin,
int x, int z, int colorIdx) {
return colorizer.getColor(state, world, this.mpos.set(x, origin.getY(), z), colorIdx);
private <T> int getBlockColor(ModelQuadColorProvider<T> colorizer, BlockRenderView world, T state,
int x, int y, int z, int colorIdx) {
return colorizer.getColor(state, world, this.mpos.set(x, y, z), colorIdx);
}

private <T> int getInterpolatedVertexColor(ModelQuadColorProvider<T> colorizer, BlockRenderView world, T state,
BlockPos origin, ModelQuadView quad, int vertexIdx) {
final float x = quad.getX(vertexIdx);
final float y = quad.getY(vertexIdx);
final float z = quad.getZ(vertexIdx);

final int intX = (int) x;
final int intY = (int) y;
final int intZ = (int) z;

// Integer component of position vector
final int originX = origin.getX() + intX;
final int originY = origin.getY() + intY;
final int originZ = origin.getZ() + intZ;

// Retrieve the color values for each neighbor
final int c1 = this.getBlockColor(colorizer, world, state, origin, originX, originZ, quad.getColorIndex());
final int c2 = this.getBlockColor(colorizer, world, state, origin, originX, originZ + 1, quad.getColorIndex());
final int c3 = this.getBlockColor(colorizer, world, state, origin, originX + 1, originZ, quad.getColorIndex());
final int c4 = this.getBlockColor(colorizer, world, state, origin, originX + 1, originZ + 1, quad.getColorIndex());
final int c000 = this.getBlockColor(colorizer, world, state, originX, originY, originZ, quad.getColorIndex());
final int c001 = this.getBlockColor(colorizer, world, state, originX, originY, originZ + 1, quad.getColorIndex());
final int c100 = this.getBlockColor(colorizer, world, state, originX + 1, originY, originZ, quad.getColorIndex());
final int c101 = this.getBlockColor(colorizer, world, state, originX + 1, originY, originZ + 1, quad.getColorIndex());

final int result;
final int c010 = this.getBlockColor(colorizer, world, state, originX, originY + 1, originZ, quad.getColorIndex());
final int c011 = this.getBlockColor(colorizer, world, state, originX, originY + 1, originZ + 1, quad.getColorIndex());
final int c110 = this.getBlockColor(colorizer, world, state, originX + 1, originY + 1, originZ, quad.getColorIndex());
final int c111 = this.getBlockColor(colorizer, world, state, originX + 1, originY + 1, originZ + 1, quad.getColorIndex());

// All the colors are the same, so the results of interpolation will be useless.
if (c1 == c2 && c2 == c3 && c3 == c4) {
result = c1;
} else {
// Fraction component of position vector
final float fracX = x - intX;
final float fracZ = z - intZ;
// Fraction component of position vector
final float fracX = x - intX;
final float fracY = y - intY;
final float fracZ = z - intZ;

int z1 = ColorMixer.getStartRatio(fracZ);
int z2 = ColorMixer.getEndRatio(fracZ);
int dx1 = ColorMixer.getStartRatio(fracX);
int dx2 = ColorMixer.getEndRatio(fracX);

int r1 = ColorMixer.mixARGB(c1, c2, z1, z2);
int r2 = ColorMixer.mixARGB(c3, c4, z1, z2);
int dy1 = ColorMixer.getStartRatio(fracY);
int dy2 = ColorMixer.getEndRatio(fracY);

int x1 = ColorMixer.getStartRatio(fracX);
int x2 = ColorMixer.getEndRatio(fracX);
int dz1 = ColorMixer.getStartRatio(fracZ);
int dz2 = ColorMixer.getEndRatio(fracZ);

result = ColorMixer.mixARGB(r1, r2, x1, x2);
}
int c00 = ColorMixer.mixARGB(c000, c001, dz1, dz2);
int c01 = ColorMixer.mixARGB(c100, c101, dz1, dz2);
int c10 = ColorMixer.mixARGB(c010, c011, dz1, dz2);
int c11 = ColorMixer.mixARGB(c110, c111, dz1, dz2);

return ColorARGB.toABGR(result);
}
int c0 = ColorMixer.mixARGB(c00, c01, dy1, dy2);
int c1 = ColorMixer.mixARGB(c10, c11, dy1, dy2);

int c = ColorMixer.mixARGB(c0, c1, dx1, dx2);

return ColorARGB.toABGR(c);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public interface QuadVertexSink extends VertexSink {
* @param matrices The matrices to transform the vertex's position and normal vectors by
*/
default void writeQuad(MatrixStack.Entry matrices, float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
Matrix4fExtended modelMatrix = MatrixUtil.getExtendedMatrix(matrices.getModel());
Matrix4fExtended positionMatrix = MatrixUtil.getExtendedMatrix(matrices.getPositionMatrix());

float x2 = modelMatrix.transformVecX(x, y, z);
float y2 = modelMatrix.transformVecY(x, y, z);
float z2 = modelMatrix.transformVecZ(x, y, z);
float x2 = positionMatrix.transformVecX(x, y, z);
float y2 = positionMatrix.transformVecY(x, y, z);
float z2 = positionMatrix.transformVecZ(x, y, z);

int norm = MatrixUtil.transformPackedNormal(normal, matrices.getNormal());
int norm = MatrixUtil.transformPackedNormal(normal, matrices.getNormalMatrix());

this.writeQuad(x2, y2, z2, color, u, v, light, overlay, norm);
}
Expand Down
Loading

0 comments on commit 39914d8

Please sign in to comment.