Skip to content

Commit 824a204

Browse files
committed
Sync with Framework
1 parent 2001352 commit 824a204

47 files changed

Lines changed: 553 additions & 447 deletions

Some content is hidden

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

NOTICE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Copyright 2020-2022 Siphalor
2-
Copyright 2024 NotRyken
1+
Copyright 2022 Siphalor
2+
Copyright ${year} ${owner_name}
33

44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -11,4 +11,4 @@ Unless required by applicable law or agreed to in writing, software
1111
distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
14-
limitations under the License.
14+
limitations under the License.

build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,28 @@ plugins {
55
id("net.darkhax.curseforgegradle") version("${curseforgegradle_version}")
66
id("com.github.breadmoirai.github-release") version("${githubrelease_version}")
77
id("org.ajoberstar.grgit.service") version("${grgitservice_version}")
8+
id("org.cadixdev.licenser") version("${licenser_version}")
89
}
910

1011
subprojects {
1112
version = mod_version
1213
group = mod_group
1314

15+
// License headers
16+
apply(plugin: "org.cadixdev.licenser")
17+
license {
18+
// This can be done in multiloader-common.gradle but only if the
19+
// "matching" method is not used (throws a pile of weird errors).
20+
// Also, NeoForge's update of the plugin can't handle matching at all.
21+
include("**/*.java") // Java files only
22+
header = rootProject.file("NOTICE")
23+
properties {
24+
project_name = mod_name
25+
owner_name = mod_owner
26+
year = java.time.LocalDate.now().getYear().toString()
27+
}
28+
}
29+
1430
// Publishing
1531
if (name != "common") {
1632
apply(plugin: "com.modrinth.minotaur")
@@ -63,7 +79,7 @@ subprojects {
6379
file.displayName = "v${mod_version}-${capsLoader(module)}-${minecraft_version}"
6480
file.releaseType = release_type
6581
file.changelog = rootProject.file("changelog.md").text
66-
file.changelogType = 'markdown'
82+
file.changelogType = "markdown"
6783
project.property("release_mod_loaders_${module}").split(",").each { String id ->
6884
file.addModLoader(id)
6985
}

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
base {
7-
archivesName = "${mod_id}-${project.name}-${minecraft_version}"
7+
archivesName = "${mod_id}-${project.name}"
88
}
99

1010
java {
@@ -19,32 +19,32 @@ repositories {
1919
exclusiveContent {
2020
forRepository {
2121
maven {
22-
name = 'Sponge'
23-
url = 'https://repo.spongepowered.org/repository/maven-public'
22+
name = "Sponge"
23+
url = "https://repo.spongepowered.org/repository/maven-public"
2424
}
2525
}
26-
filter { includeGroupAndSubgroups('org.spongepowered') }
26+
filter { includeGroupAndSubgroups("org.spongepowered") }
2727
}
2828
exclusiveContent {
2929
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-
}
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+
}
3838
)
39-
filter { includeGroup('org.parchmentmc.data') }
39+
filter { includeGroup("org.parchmentmc.data") }
4040
}
4141
maven {
4242
name = "Modrinth"
4343
url = "https://api.modrinth.com/maven"
4444
}
4545
maven {
4646
name = "Shedaniel"
47-
url = "https://maven.shedaniel.me/"
47+
url = "https://maven.shedaniel.me"
4848
}
4949
}
5050

@@ -103,7 +103,6 @@ processResources {
103103
"mod_authors_string": mod_authors.replace(",", ", "),
104104
"mod_contributors_string": mod_contributors.replace(",", ", "),
105105
"mod_license": mod_license,
106-
"mod_environment": mod_environment,
107106
// Links
108107
"homepage_url": homepage_url,
109108
"sources_url": sources_url,
@@ -125,7 +124,7 @@ processResources {
125124
// Dependencies
126125
"clothconfig_versions_fabric_list": asJsonList(clothconfig_versions_fabric),
127126
"clothconfig_versions_neoforge": clothconfig_versions_neoforge,
128-
"modmenu_versions_fabric_list": asJsonList(modmenu_versions),
127+
"modmenu_versions_fabric_list": asJsonList(modmenu_versions_fabric),
129128
]
130129
filesMatching(["pack.mcmeta", "*.mod.json", "META-INF/*mods.toml", "*.mixins.json"]) {
131130
expand expandProps

changelog.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
- Fix config on recent NeoForge versions

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
annotationProcessor("io.github.llamalad7:mixinextras-common:${mixinextras_version}")
1010

1111
// Mod dependencies use NeoForge version to avoid remapping complications
12-
implementation("me.shedaniel.cloth:cloth-config-neoforge:${clothconfig_version}")
12+
api("me.shedaniel.cloth:cloth-config-neoforge:${clothconfig_version}")
1313
}
1414

1515
neoForge {

common/src/main/java/dev/terminalmc/clientsort/ClientSort.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
/*
2-
* Copyright 2024 NotRyken
3-
* SPDX-License-Identifier: Apache-2.0
2+
* Copyright 2022 Siphalor
3+
* Copyright 2024 TerminalMC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
416
*/
517

618
package dev.terminalmc.clientsort;

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
/*
2-
* Copyright 2024 NotRyken
3-
* SPDX-License-Identifier: Apache-2.0
2+
* Copyright 2022 Siphalor
3+
* Copyright 2024 TerminalMC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
416
*/
517

618
package dev.terminalmc.clientsort.config;

common/src/main/java/dev/terminalmc/clientsort/screen/ClothConfigScreenProvider.java renamed to common/src/main/java/dev/terminalmc/clientsort/gui/screen/ClothScreenProvider.java

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
/*
2-
* Copyright 2024 NotRyken
3-
* SPDX-License-Identifier: Apache-2.0
2+
* Copyright 2022 Siphalor
3+
* Copyright 2024 TerminalMC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
416
*/
517

6-
package dev.terminalmc.clientsort.screen;
18+
package dev.terminalmc.clientsort.gui.screen;
719

820
import dev.terminalmc.clientsort.config.Config;
921
import dev.terminalmc.clientsort.inventory.sort.SortMode;
@@ -18,7 +30,7 @@
1830

1931
import static dev.terminalmc.clientsort.util.mod.Localization.localized;
2032

21-
public class ClothConfigScreenProvider {
33+
public class ClothScreenProvider {
2234
/**
2335
* Builds and returns a Cloth Config options screen.
2436
* @param parent the current screen.
@@ -31,17 +43,17 @@ static Screen getConfigScreen(Screen parent) {
3143

3244
ConfigBuilder builder = ConfigBuilder.create()
3345
.setParentScreen(parent)
34-
.setTitle(localized("screen", "options"))
46+
.setTitle(localized("name"))
3547
.setSavingRunnable(Config::getAndSave);
3648

3749
ConfigEntryBuilder eb = builder.entryBuilder();
3850

3951

4052
ConfigCategory general = builder.getOrCreateCategory(localized("option", "general"));
4153

42-
general.addEntry(eb.startIntField(localized("option", "interaction_rate_server"),
54+
general.addEntry(eb.startIntField(localized("option", "interactionRateServer"),
4355
options.interactionRateServer)
44-
.setTooltip(localized("option", "interaction_rate.tooltip"))
56+
.setTooltip(localized("option", "interactionRate.tooltip"))
4557
.setErrorSupplier(val -> {
4658
if (val < 1) return Optional.of(
4759
localized("option", "error.low"));
@@ -53,9 +65,9 @@ else if (val > 100) return Optional.of(
5365
.setSaveConsumer(val -> options.interactionRateServer = val)
5466
.build());
5567

56-
general.addEntry(eb.startIntField(localized("option", "interaction_rate_client"),
68+
general.addEntry(eb.startIntField(localized("option", "interactionRateClient"),
5769
options.interactionRateClient)
58-
.setTooltip(localized("option", "interaction_rate.tooltip"))
70+
.setTooltip(localized("option", "interactionRate.tooltip"))
5971
.setErrorSupplier(val -> {
6072
if (val < 1) return Optional.of(
6173
localized("option", "error.low"));
@@ -67,48 +79,48 @@ else if (val > 100) return Optional.of(
6779
.setSaveConsumer(val -> options.interactionRateClient = val)
6880
.build());
6981

70-
general.addEntry(eb.startEnumSelector(localized("option", "hotbar_mode"),
82+
general.addEntry(eb.startEnumSelector(localized("option", "hotbarMode"),
7183
Config.Options.HotbarMode.class, options.hotbarMode)
72-
.setEnumNameProvider(val -> localized("hotbar_mode",
84+
.setEnumNameProvider(val -> localized("hotbarMode",
7385
((Config.Options.HotbarMode)val).lowerName()))
7486
.setTooltipSupplier(val -> Optional.of(new Component[]{
75-
localized("hotbar_mode", val.lowerName() + ".tooltip")
87+
localized("hotbarMode", val.lowerName() + ".tooltip")
7688
}))
7789
.setDefaultValue(Config.Options.defaultHotbarMode)
7890
.setSaveConsumer(val -> options.hotbarMode = val)
7991
.build());
8092

8193
ConfigCategory sort = builder.getOrCreateCategory(localized("option", "sorting"));
8294

83-
sort.addEntry(eb.startSelector(localized("option", "sort_mode"),
95+
sort.addEntry(eb.startSelector(localized("option", "sortMode"),
8496
SortMode.SORT_MODES.keySet().toArray(), options.sortModeStr)
85-
.setNameProvider(val -> localized("sort_order", (String) val))
97+
.setNameProvider(val -> localized("sortOrder", (String)val))
8698
.setDefaultValue(Config.Options.defaultSortMode)
87-
.setSaveConsumer(val -> options.sortModeStr = (String) val)
99+
.setSaveConsumer(val -> options.sortModeStr = (String)val)
88100
.build());
89101

90-
sort.addEntry(eb.startSelector(localized("option", "shift_sort_mode"),
102+
sort.addEntry(eb.startSelector(localized("option", "shiftSortMode"),
91103
SortMode.SORT_MODES.keySet().toArray(), options.shiftSortModeStr)
92-
.setNameProvider(val -> localized("sort_order", (String) val))
104+
.setNameProvider(val -> localized("sortOrder", (String)val))
93105
.setDefaultValue(Config.Options.defaultShiftSortMode)
94-
.setSaveConsumer(val -> options.shiftSortModeStr = (String) val)
106+
.setSaveConsumer(val -> options.shiftSortModeStr = (String)val)
95107
.build());
96108

97-
sort.addEntry(eb.startSelector(localized("option", "ctrl_sort_mode"),
109+
sort.addEntry(eb.startSelector(localized("option", "ctrlSortMode"),
98110
SortMode.SORT_MODES.keySet().toArray(), options.ctrlSortModeStr)
99-
.setNameProvider(val -> localized("sort_order", (String) val))
111+
.setNameProvider(val -> localized("sortOrder", (String)val))
100112
.setDefaultValue(Config.Options.defaultCtrlSortMode)
101-
.setSaveConsumer(val -> options.ctrlSortModeStr = (String) val)
113+
.setSaveConsumer(val -> options.ctrlSortModeStr = (String)val)
102114
.build());
103115

104-
sort.addEntry(eb.startSelector(localized("option", "alt_sort_mode"),
116+
sort.addEntry(eb.startSelector(localized("option", "altSortMode"),
105117
SortMode.SORT_MODES.keySet().toArray(), options.altSortModeStr)
106-
.setNameProvider(val -> localized("sort_order", (String) val))
118+
.setNameProvider(val -> localized("sortOrder", (String)val))
107119
.setDefaultValue(Config.Options.defaultAltSortMode)
108-
.setSaveConsumer(val -> options.altSortModeStr = (String) val)
120+
.setSaveConsumer(val -> options.altSortModeStr = (String)val)
109121
.build());
110122

111-
sort.addEntry(eb.startBooleanToggle(localized("option", "optimized_creative_sorting"),
123+
sort.addEntry(eb.startBooleanToggle(localized("option", "optimizedCreativeSorting"),
112124
options.optimizedCreativeSorting)
113125
.setDefaultValue(Config.Options.defaultOptimizedCreativeSorting)
114126
.setSaveConsumer(val -> {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2022 Siphalor
3+
* Copyright 2024 TerminalMC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package dev.terminalmc.clientsort.gui.screen;
19+
20+
import net.minecraft.Util;
21+
import net.minecraft.client.gui.components.Button;
22+
import net.minecraft.client.gui.components.MultiLineTextWidget;
23+
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
24+
import net.minecraft.client.gui.screens.Screen;
25+
import net.minecraft.network.chat.CommonComponents;
26+
27+
import static dev.terminalmc.clientsort.util.mod.Localization.localized;
28+
29+
/**
30+
* Wraps the config screen implementation and provides a backup screen for
31+
* use when the config lib mod is not loaded. This allows the dependency to be
32+
* defined as optional.
33+
*/
34+
public class ConfigScreenProvider {
35+
36+
public static Screen getConfigScreen(Screen parent) {
37+
try {
38+
return ClothScreenProvider.getConfigScreen(parent);
39+
} catch (NoClassDefFoundError ignored) {
40+
return new BackupScreen(parent, "installCloth", "https://modrinth.com/mod/9s6osm5g");
41+
}
42+
}
43+
44+
static class BackupScreen extends Screen {
45+
private final Screen parent;
46+
private final String modKey;
47+
private final String modUrl;
48+
49+
public BackupScreen(Screen parent, String modKey, String modUrl) {
50+
super(localized("name"));
51+
this.parent = parent;
52+
this.modKey = modKey;
53+
this.modUrl = modUrl;
54+
}
55+
56+
@Override
57+
public void init() {
58+
MultiLineTextWidget messageWidget = new MultiLineTextWidget(
59+
width / 2 - 120, height / 2 - 40,
60+
localized("message", modKey),
61+
minecraft.font);
62+
messageWidget.setMaxWidth(240);
63+
messageWidget.setCentered(true);
64+
addRenderableWidget(messageWidget);
65+
66+
Button openLinkButton = Button.builder(localized("message", "viewModrinth"),
67+
(button) -> minecraft.setScreen(new ConfirmLinkScreen(
68+
(open) -> {
69+
if (open) Util.getPlatform().openUri(modUrl);
70+
minecraft.setScreen(parent);
71+
}, modUrl, true)))
72+
.pos(width / 2 - 120, height / 2)
73+
.size(115, 20)
74+
.build();
75+
addRenderableWidget(openLinkButton);
76+
77+
Button exitButton = Button.builder(CommonComponents.GUI_OK,
78+
(button) -> onClose())
79+
.pos(width / 2 + 5, height / 2)
80+
.size(115, 20)
81+
.build();
82+
addRenderableWidget(exitButton);
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)