Skip to content

Commit 46e9e5a

Browse files
committed
Backport to mc1.20.1
1 parent 291e980 commit 46e9e5a

File tree

76 files changed

+962
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+962
-794
lines changed

.github/workflows/check-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
build:
1919
strategy:
2020
matrix:
21-
java: [21]
21+
java: [17]
2222
os: [ubuntu-latest, windows-latest]
2323
runs-on: ${{ matrix.os }}
2424
steps:
@@ -39,7 +39,7 @@ jobs:
3939
- name: Build
4040
run: ./gradlew build --stacktrace
4141
- name: Capture build artifacts
42-
if: ${{ runner.os == 'Linux' && matrix.java == '21' }}
42+
if: ${{ runner.os == 'Linux' && matrix.java == '17' }}
4343
uses: actions/upload-artifact@v4
4444
with:
4545
name: artifacts

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
release:
1616
strategy:
1717
matrix:
18-
java: [21]
18+
java: [17]
1919
os: [ubuntu-latest]
2020
runs-on: ${{ matrix.os }}
2121
steps:
@@ -34,15 +34,15 @@ jobs:
3434
if: ${{ runner.os != 'Windows' }}
3535
run: chmod +x ./gradlew
3636
- name: Build
37-
# run: ./gradlew build neoforge:publishGithub fabric:publishGithub --stacktrace
38-
# run: ./gradlew build neoforge:publishGithub neoforge:publishModrinth fabric:publishGithub fabric:publishModrinth --stacktrace
39-
run: ./gradlew build neoforge:publishGithub neoforge:publishModrinth neoforge:publishCurseforge fabric:publishGithub fabric:publishModrinth fabric:publishCurseforge --stacktrace
37+
# run: ./gradlew build forge:publishGithub fabric:publishGithub --stacktrace
38+
# run: ./gradlew build forge:publishGithub forge:publishModrinth fabric:publishGithub fabric:publishModrinth --stacktrace
39+
run: ./gradlew build forge:publishGithub forge:publishModrinth forge:publishCurseforge fabric:publishGithub fabric:publishModrinth fabric:publishCurseforge --stacktrace
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
4343
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
4444
- name: Capture build artifacts
45-
if: ${{ runner.os == 'Linux' && matrix.java == '21' }}
45+
if: ${{ runner.os == 'Linux' && matrix.java == '17' }}
4646
uses: actions/upload-artifact@v4
4747
with:
4848
name: artifacts

build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
plugins {
22
id("fabric-loom") version("${loom_version}") apply(false)
3-
id("net.neoforged.moddev") version("${moddev_version}") apply(false)
3+
id("net.minecraftforge.gradle") version("${forgegradle_version}") apply(false)
4+
id("org.spongepowered.gradle.vanilla") version("${vanillagradle_version}") apply(false)
5+
id("org.spongepowered.mixin") version("${mixingradle_version}") apply(false)
46
id("org.cadixdev.licenser") version("${licenser_version}") apply(false)
57
id("me.modmuss50.mod-publish-plugin") version("${mpp_version}")
68
id("org.ajoberstar.grgit.service") version("${grgitservice_version}")
@@ -55,7 +57,8 @@ subprojects {
5557

5658
afterEvaluate {
5759
publishMods {
58-
file = project.name == "fabric" ? remapJar.archiveFile : jar.archiveFile
60+
file = project.name == "fabric" ? remapJar.archiveFile : name == "forge"
61+
? project.file("build/libs/${mod_id}-${name}-${mod_version}.jar") : jar.archiveFile
5962
version = mod_version
6063
type = me.modmuss50.mpp.ReleaseType.of(release_type)
6164
displayName = "v${mod_version}-${capsLoader(project.name)}"

buildSrc/src/main/groovy/multiloader-common.gradle

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,9 @@ repositories {
2525
}
2626
filter { includeGroupAndSubgroups("org.spongepowered") }
2727
}
28-
exclusiveContent {
29-
forRepositories(
30-
maven {
31-
name = "ParchmentMC"
32-
url = "https://maven.parchmentmc.org"
33-
},
34-
maven {
35-
name = "NeoForge"
36-
url = "https://maven.neoforged.net/releases"
37-
}
38-
)
39-
filter { includeGroup("org.parchmentmc.data") }
28+
maven {
29+
name = "ParchmentMC"
30+
url = "https://maven.parchmentmc.org"
4031
}
4132
maven {
4233
name = "Modrinth"
@@ -111,19 +102,19 @@ processResources {
111102
// Java
112103
"java_version": java_version,
113104
"java_versions_fabric_list": asJsonList(java_versions_fabric),
114-
"java_versions_neoforge": java_versions_neoforge,
105+
"java_versions_forge": java_versions_forge,
115106
// Minecraft
116107
"minecraft_versions_fabric_list": asJsonList(minecraft_versions_fabric),
117-
"minecraft_versions_neoforge": minecraft_versions_neoforge,
108+
"minecraft_versions_forge": minecraft_versions_forge,
118109
// Fabric
119110
"fabric_loader_versions_list": asJsonList(fabric_loader_versions),
120111
"fabric_api_versions_list": asJsonList(fabric_api_versions),
121-
// NeoForge
122-
"neoforge_loader_versions": neoforge_loader_versions,
123-
"neoforge_versions": neoforge_versions,
112+
// Forge
113+
"forge_loader_versions": forge_loader_versions,
114+
"forge_versions": forge_versions,
124115
// Dependencies
125116
"clothconfig_versions_fabric_list": asJsonList(clothconfig_versions_fabric),
126-
"clothconfig_versions_neoforge": clothconfig_versions_neoforge,
117+
"clothconfig_versions_forge": clothconfig_versions_forge,
127118
"modmenu_versions_fabric_list": asJsonList(modmenu_versions_fabric),
128119
]
129120

common/build.gradle

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
1+
buildscript {
2+
dependencies.add("classpath", "org.spongepowered:vanillagradle:${vanillagradle_version}")
3+
}
4+
15
plugins {
26
id("multiloader-common")
3-
id("net.neoforged.moddev")
7+
id("org.spongepowered.gradle.vanilla")
8+
}
9+
10+
// Mixin plugin requires new ASM
11+
configurations.configureEach {
12+
resolutionStrategy.eachDependency { details ->
13+
if (details.requested.group == "org.ow2.asm") {
14+
details.useVersion(asm_version)
15+
details.because("Mixin requires new ASM")
16+
}
17+
}
418
}
519

620
dependencies {
21+
compileOnly "org.ow2.asm:asm:${asm_version}"
22+
compileOnly "org.ow2.asm:asm-analysis:${asm_version}"
23+
compileOnly "org.ow2.asm:asm-commons:${asm_version}"
24+
compileOnly "org.ow2.asm:asm-tree:${asm_version}"
25+
compileOnly "org.ow2.asm:asm-util:${asm_version}"
26+
727
compileOnly("org.spongepowered:mixin:${mixin_version}")
828
// compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}"))
929

1030
// Cloth Config API
11-
api("me.shedaniel.cloth:cloth-config-neoforge:${clothconfig_version}")
31+
api("me.shedaniel.cloth:cloth-config-forge:${clothconfig_version}")
1232

1333
// ItemLocks
1434
implementation("maven.modrinth:tJzrFuyy:${itemlocks_version}")
1535
}
1636

17-
neoForge {
18-
version = neoforge_version // Shut up
19-
neoFormVersion = neoform_version
20-
// Automatically enable AccessTransformers if the file exists
21-
def at = file("src/main/resources/META-INF/accesstransformer.cfg")
22-
if (at.exists()) accessTransformers.from(at.absolutePath)
23-
parchment {
24-
minecraftVersion = parchment_minecraft_version
25-
mappingsVersion = parchment_version
37+
minecraft {
38+
version(minecraft_version)
39+
if (file("src/main/resources/${mod_id}.accesswidener").exists()) {
40+
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
2641
}
2742
}
2843

common/src/main/java/dev/terminalmc/clientsort/client/compat/itemlocks/ItemLocksWrapper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package dev.terminalmc.clientsort.client.compat.itemlocks;
1818

19+
import dev.terminalmc.clientsort.client.ClientSort;
1920
import net.minecraft.world.inventory.Slot;
2021

2122
public class ItemLocksWrapper {
@@ -35,6 +36,10 @@ public static boolean isLocked(Slot slot) {
3536
} catch (NoClassDefFoundError | NoSuchMethodError ignored) {
3637
hasFailed = true;
3738
return false;
39+
} catch (Exception e) {
40+
ClientSort.LOG.error("ItemLocks isLocked check failed with error:", e);
41+
hasFailed = true;
42+
return false;
3843
}
3944
}
4045
}

common/src/main/java/dev/terminalmc/clientsort/client/config/Config.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import dev.terminalmc.clientsort.client.order.SortOrder;
2323
import dev.terminalmc.clientsort.platform.Services;
2424
import net.minecraft.resources.ResourceLocation;
25+
import net.minecraft.util.Mth;
2526
import net.minecraft.world.entity.player.Inventory;
2627
import net.minecraft.world.inventory.*;
2728
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
@@ -187,38 +188,38 @@ public enum CONTROL_BUTTON {
187188
* Ensures that all config values are valid.
188189
*/
189190
private void validate() {
190-
options.interactionInterval = Math.clamp(
191+
options.interactionInterval = Mth.clamp(
191192
options.interactionInterval,
192193
Options.INTERACTION_INTERVAL_MIN,
193194
Options.INTERACTION_INTERVAL_MAX
194195
);
195-
options.soundInterval = Math.clamp(
196+
options.soundInterval = Mth.clamp(
196197
options.soundInterval,
197198
Options.SOUND_INTERVAL_MIN,
198199
Options.SOUND_INTERVAL_MAX
199200
);
200-
options.soundPitchMin = Math.clamp(
201+
options.soundPitchMin = Mth.clamp(
201202
options.soundPitchMin,
202203
Options.SOUND_PITCH_MIN,
203204
Options.SOUND_PITCH_MAX
204205
);
205-
options.soundPitchMax = Math.clamp(
206+
options.soundPitchMax = Mth.clamp(
206207
options.soundPitchMax,
207208
options.soundPitchMin, // Not less than configured min
208209
Options.SOUND_PITCH_MAX
209210
);
210-
options.soundVolume = Math.clamp(
211+
options.soundVolume = Mth.clamp(
211212
options.soundVolume,
212213
Options.SOUND_VOLUME_MIN,
213214
Options.SOUND_VOLUME_MAX
214215
);
215216
options.buttonDefaultOffset = new Vec2i(
216-
Math.clamp(
217+
Mth.clamp(
217218
options.buttonDefaultOffset.x(),
218219
Options.BUTTON_DEFAULT_OFFSET_MIN,
219220
Options.BUTTON_DEFAULT_OFFSET_MAX
220221
),
221-
Math.clamp(
222+
Mth.clamp(
222223
options.buttonDefaultOffset.y(),
223224
Options.BUTTON_DEFAULT_OFFSET_MIN,
224225
Options.BUTTON_DEFAULT_OFFSET_MAX

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/edit/GroupSelectorScreen.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,6 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
113113
}
114114
}
115115

116-
@Override
117-
protected void renderBlurredBackground(float partialTick) {
118-
// Heavy blur, we want the widgets to really stand out
119-
int original = Minecraft.getInstance().options.menuBackgroundBlurriness().get();
120-
Minecraft.getInstance().options.menuBackgroundBlurriness().set(6);
121-
super.renderBlurredBackground(partialTick);
122-
Minecraft.getInstance().options.menuBackgroundBlurriness().set(original);
123-
}
124-
125116
@Override
126117
public void onClose() {
127118
super.onClose();

common/src/main/java/dev/terminalmc/clientsort/client/gui/screen/edit/PositionEditScreen.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,22 +359,6 @@ public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float
359359
}
360360
}
361361

362-
/**
363-
* Modifies the background blur to be constant irrespective of the
364-
* configured value.
365-
* <p>
366-
* Minimal blur is used to prevent the editable widgets disappearing under
367-
* underlay items on a higher render layer, while still keeping the underlay
368-
* detail discernible.
369-
*/
370-
@Override
371-
protected void renderBlurredBackground(float partialTick) {
372-
int original = Minecraft.getInstance().options.menuBackgroundBlurriness().get();
373-
Minecraft.getInstance().options.menuBackgroundBlurriness().set(1);
374-
super.renderBlurredBackground(partialTick);
375-
Minecraft.getInstance().options.menuBackgroundBlurriness().set(original);
376-
}
377-
378362
/**
379363
* Draws a horizontal and a vertical line to trace this widget back to its
380364
* positional origin point.

common/src/main/java/dev/terminalmc/clientsort/client/gui/widget/ControlButton.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package dev.terminalmc.clientsort.client.gui.widget;
1919

2020
import com.mojang.blaze3d.platform.InputConstants;
21+
import dev.terminalmc.clientsort.client.ClientSort;
2122
import dev.terminalmc.clientsort.client.config.ButtonLayout;
2223
import dev.terminalmc.clientsort.client.config.Vec2i;
2324
import dev.terminalmc.clientsort.client.gui.screen.edit.ContainerPositionEditScreen;
@@ -28,11 +29,11 @@
2829
import net.minecraft.client.gui.ComponentPath;
2930
import net.minecraft.client.gui.GuiGraphics;
3031
import net.minecraft.client.gui.components.Button;
31-
import net.minecraft.client.gui.components.WidgetSprites;
3232
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
3333
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
3434
import net.minecraft.network.chat.CommonComponents;
3535
import net.minecraft.resources.ResourceLocation;
36+
import net.minecraft.util.Mth;
3637
import net.minecraft.world.Container;
3738
import net.minecraft.world.inventory.Slot;
3839
import org.jetbrains.annotations.NotNull;
@@ -44,12 +45,15 @@ public abstract class ControlButton extends Button {
4445
public static final int HALF_WIDTH = WIDTH / 2;
4546
public static final int HALF_HEIGHT = HEIGHT / 2;
4647

48+
private static final ResourceLocation TEXTURE =
49+
new ResourceLocation(ClientSort.MOD_ID, "textures/gui.png");
50+
4751
private final AbstractContainerScreen<?> screen;
4852
public final Container container;
4953
public final @Nullable String layoutKey;
5054
final boolean isPlayerInv;
5155
private final Slot referenceSlot;
52-
private final WidgetSprites sprites;
56+
private final Vec2i spriteOffset;
5357

5458
public Vec2i offset;
5559

@@ -59,7 +63,7 @@ protected ControlButton(
5963
@Nullable String layoutKey,
6064
boolean isPlayerInv,
6165
Slot referenceSlot,
62-
WidgetSprites sprites,
66+
Vec2i spriteOffset,
6367
Vec2i offset,
6468
OnPress onPress,
6569
boolean active
@@ -82,7 +86,7 @@ protected ControlButton(
8286
this.layoutKey = layoutKey;
8387
this.isPlayerInv = isPlayerInv;
8488
this.referenceSlot = referenceSlot;
85-
this.sprites = sprites;
89+
this.spriteOffset = spriteOffset;
8690
this.offset = offset;
8791
this.active = active;
8892
}
@@ -127,12 +131,12 @@ public void renderWidget(@NotNull GuiGraphics graphics, int mouseX, int mouseY,
127131
AbstractContainerScreenAccessor acs = (AbstractContainerScreenAccessor) screen;
128132

129133
// Keep visible
130-
int newX = Math.clamp(
134+
int newX = Mth.clamp(
131135
acs.getLeftPos() + acs.getImageWidth() + offset.x(),
132136
0,
133137
screen.width - WIDTH
134138
);
135-
int newY = Math.clamp(
139+
int newY = Mth.clamp(
136140
acs.getTopPos() + referenceSlot.y + offset.y(),
137141
0,
138142
screen.height - HEIGHT
@@ -141,16 +145,23 @@ public void renderWidget(@NotNull GuiGraphics graphics, int mouseX, int mouseY,
141145
setX(newX);
142146
setY(newY);
143147

144-
ResourceLocation texture = sprites.get(isActive(), isHoveredOrFocused());
145-
graphics.blitSprite(texture, getX(), getY(), 0, width, height);
148+
int u = spriteOffset.x() * WIDTH;
149+
int v = spriteOffset.y() * HEIGHT;
150+
if (!isActive()) {
151+
v += HEIGHT * 2;
152+
} else if (isHovered() || isFocused()) {
153+
v += HEIGHT;
154+
}
155+
156+
graphics.blit(TEXTURE, getX(), getY(), u, v, width, height);
146157
}
147158

148159
@Override
149160
protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) {
150161
if (Minecraft.getInstance().screen instanceof PositionEditScreen) {
151162
AbstractContainerScreenAccessor acs = (AbstractContainerScreenAccessor) screen;
152-
int newX = Math.clamp((int) mouseX - HALF_WIDTH, 0, screen.width - WIDTH);
153-
int newY = Math.clamp((int) mouseY - HALF_HEIGHT, 0, screen.height - HEIGHT);
163+
int newX = Mth.clamp((int) mouseX - HALF_WIDTH, 0, screen.width - WIDTH);
164+
int newY = Mth.clamp((int) mouseY - HALF_HEIGHT, 0, screen.height - HEIGHT);
154165

155166
offset = new Vec2i(
156167
newX - (acs.getLeftPos() + acs.getImageWidth()),

0 commit comments

Comments
 (0)