Skip to content

Commit

Permalink
change: Initial port to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Oct 26, 2024
1 parent f348eaf commit e18c008
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 36 deletions.
13 changes: 7 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
id("java")
id("fabric-loom") version ("1.7.2") apply (false)
id("fabric-loom") version ("1.8.9") apply (false)
}

val MINECRAFT_VERSION by extra { "1.21.1" }
val NEOFORGE_VERSION by extra { "21.1.23" }
val FABRIC_LOADER_VERSION by extra { "0.16.2" }
val FABRIC_API_VERSION by extra { "0.102.1+1.21.1" }
val MINECRAFT_VERSION by extra { "1.21.3" }
val NEOFORGE_VERSION by extra { "21.3.3-beta" }
val FABRIC_LOADER_VERSION by extra { "0.16.7" }
val FABRIC_API_VERSION by extra { "0.106.1+1.21.3" }

// This value can be set to null to disable Parchment.
val PARCHMENT_VERSION by extra { null }
Expand All @@ -15,7 +15,7 @@ val PARCHMENT_VERSION by extra { null }
val MAVEN_GROUP by extra { "me.flashyreese.mods" }
val ARCHIVE_NAME by extra { "reeses-sodium-options" }
val MOD_VERSION by extra { "1.8.0-beta.4" }
val SODIUM_VERSION by extra { "mc1.21-0.6.0-beta.2" }
val SODIUM_VERSION by extra { "mc1.21.2-0.6.0-beta.3" }

allprojects {
apply(plugin = "java")
Expand All @@ -34,6 +34,7 @@ subprojects {
repositories {
maven("https://maven.parchmentmc.org/")
maven("https://api.modrinth.com/maven")
maven("https://libraries.minecraft.net/")
}

base {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import net.fabricmc.loom.task.AbstractRemapJarTask
plugins {
id("java")
id("idea")
id("fabric-loom") version "1.7.2"
id("fabric-loom") version "1.8.9"
}

val MINECRAFT_VERSION: String by rootProject.extra
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package me.flashyreese.mods.reeses_sodium_options.client.gui.frame;

import com.mojang.blaze3d.systems.RenderSystem;
import net.caffeinemc.mods.sodium.client.gui.options.control.ControlElement;
import net.caffeinemc.mods.sodium.client.gui.widgets.AbstractWidget;
import net.caffeinemc.mods.sodium.client.util.Dim2i;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.ContainerEventHandler;
Expand All @@ -20,7 +18,6 @@
public abstract class AbstractFrame extends AbstractWidget implements ContainerEventHandler {
protected final Dim2i dim;
protected final List<AbstractWidget> children = new ArrayList<>();
protected final List<Renderable> renderable = new ArrayList<>();
protected final List<ControlElement<?>> controlElements = new ArrayList<>();
protected boolean renderOutline;
private GuiEventListener focused;
Expand All @@ -34,15 +31,12 @@ public AbstractFrame(Dim2i dim, boolean renderOutline) {

public void buildFrame() {
for (GuiEventListener element : this.children) {
if (element instanceof AbstractFrame) {
this.controlElements.addAll(((AbstractFrame) element).controlElements);
if (element instanceof AbstractFrame abstractFrame) {
this.controlElements.addAll(abstractFrame.controlElements);
}
if (element instanceof ControlElement<?>) {
this.controlElements.add((ControlElement<?>) element);
}
if (element instanceof Renderable) {
this.renderable.add((Renderable) element);
}
}
}

Expand All @@ -51,17 +45,15 @@ public void render(GuiGraphics drawContext, int mouseX, int mouseY, float delta)
if (this.renderOutline) {
this.drawBorder(drawContext, this.dim.x(), this.dim.y(), this.dim.getLimitX(), this.dim.getLimitY(), 0xFFAAAAAA);
}
for (Renderable renderable : this.renderable) {
for (Renderable renderable : this.children) {
renderable.render(drawContext, mouseX, mouseY, delta);
}
}

public void applyScissor(int x, int y, int width, int height, Runnable action) {
double scale = Minecraft.getInstance().getWindow().getGuiScale();
RenderSystem.enableScissor((int) (x * scale), (int) (Minecraft.getInstance().getWindow().getHeight() - (y + height) * scale),
(int) (width * scale), (int) (height * scale));
public void applyScissor(GuiGraphics guiGraphics, int x, int y, int width, int height, Runnable action) {
guiGraphics.enableScissor(x, y, x + width, y + height);
action.run();
RenderSystem.disableScissor();
guiGraphics.disableScissor();
}

public void registerFocusListener(Consumer<GuiEventListener> focusListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static Builder builder() {
@Override
public void buildFrame() {
this.children.clear();
this.renderable.clear();
this.controlElements.clear();

this.functions.forEach(function -> this.children.add(function.apply(dim)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public static Builder builder() {

public void setupFrame() {
this.children.clear();
this.renderable.clear();
this.controlElements.clear();

int y = 0;
Expand Down Expand Up @@ -72,7 +71,6 @@ public void buildFrame() {
if (this.page == null) return;

this.children.clear();
this.renderable.clear();
this.controlElements.clear();

int y = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void setupFrame(AtomicReference<Integer> verticalScrollBarOffset, AtomicR
@Override
public void buildFrame() {
this.children.clear();
this.renderable.clear();
this.controlElements.clear();

if (this.canScrollHorizontal) {
Expand Down Expand Up @@ -138,7 +137,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
if (this.renderOutline) {
this.drawBorder(guiGraphics, this.dim.x(), this.dim.y(), this.dim.getLimitX(), this.dim.getLimitY(), 0xFFAAAAAA);
}
this.applyScissor(this.viewPortDimension.x(), this.viewPortDimension.y(), this.viewPortDimension.width(), this.viewPortDimension.height(), () -> super.render(guiGraphics, mouseX, mouseY, delta));
this.applyScissor(guiGraphics, this.viewPortDimension.x(), this.viewPortDimension.y(), this.viewPortDimension.width(), this.viewPortDimension.height(), () -> super.render(guiGraphics, mouseX, mouseY, delta));
} else {
super.render(guiGraphics, mouseX, mouseY, delta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ public void setTab(Optional<Tab<?>> tab) {
@Override
public void buildFrame() {
this.children.clear();
this.renderable.clear();
this.controlElements.clear();

if (this.selectedTab.isEmpty() || this.selectedTab.isEmpty()) {
if (this.selectedTab.isEmpty()) {
if (!this.tabs.isEmpty()) {
// Just use the first tab for now
this.selectedTab = Optional.ofNullable(this.tabs.getFirst());
Expand Down Expand Up @@ -143,7 +142,7 @@ private void rebuildTabFrame() {

@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
this.applyScissor(this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height(), () -> {
this.applyScissor(guiGraphics, this.dim.x(), this.dim.y(), this.dim.width(), this.dim.height(), () -> {
for (AbstractWidget widget : this.children) {
if (widget != this.selectedFrame) {
widget.render(guiGraphics, mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.flashyreese.mods.reeses_sodium_options.mixin.sodium;

import com.llamalad7.mixinextras.sugar.Local;
import me.flashyreese.mods.reeses_sodium_options.client.gui.SliderControlElementExtended;
import net.caffeinemc.mods.sodium.client.gui.options.Option;
import net.caffeinemc.mods.sodium.client.gui.options.control.ControlElement;
Expand All @@ -9,7 +8,6 @@
import net.minecraft.client.gui.navigation.CommonInputs;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Mth;
import org.lwjgl.glfw.GLFW;
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("java")
id("idea")
id("fabric-loom") version ("1.7.2")
id("fabric-loom") version ("1.8.9")
}

val MINECRAFT_VERSION: String by rootProject.extra
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"depends": {
"minecraft": ">=1.21",
"sodium": ">=0.6.0-beta.2"
"sodium": ">=0.6.0-beta.3"
},
"breaks": {
"iris": "<1.1.4",
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Replaces Sodium's Options Screen
[[dependencies.reeses_sodium_options]]
modId = "minecraft"
type = "required"
versionRange = "[1.20.4,1.21.1)"
versionRange = "[1.20.4,1.21.4)"
ordering = "NONE"
side = "CLIENT"

[[dependencies.reeses_sodium_options]]
modId = "sodium"
type = "required"
versionRange = "[0.6.0-beta.2,0.6.0)"
versionRange = "[0.6.0-beta.3,0.6.0)"
ordering = "NONE"
side = "CLIENT"

Expand Down

0 comments on commit e18c008

Please sign in to comment.