Skip to content

Commit 335c48d

Browse files
committed
Port to 1.21.1 neoforge
1 parent 810f45a commit 335c48d

File tree

11 files changed

+100
-152
lines changed

11 files changed

+100
-152
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
### Maintenance Update
22

3-
- **Use** fully semantic versioning.
3+
- **Port** to 1.21.1 neoforge

README.md

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,6 @@
22

33
![Banner](https://github.com/KessokuTeaTime/Splasher/blob/artwork/banner.png)
44

5-
**Customize Minecraft's Splash Texts at Your Will!**
6-
7-
## Contributing a Translation
8-
9-
Splasher turns Minecraft `splashes.txt` into `.json` files, and supports multi languages.
10-
11-
You will find `en_us.json` under `assets/splasher/lang/` and feel free translate it into your favorite language.
12-
13-
After translation, rename it to `xx_xx.json` (e.g., `zh_cn.json`), and enjoy! You can also create a pull request to contribute.
14-
15-
## Adding a Customization
16-
17-
Splasher supports custom splash texts to append, or replace the original ones.
18-
19-
Custom splash texts are `.txt` files stored under `.minecraft/config/splasher/` and should be named the same as your target language (`en_us.txt` etc.).
20-
21-
In these files, every single splash takes a single line, and `§ Formatting Code` is under supported, the same as the Minecraft `splashes.txt` under directory `.minecraft/assets/minecraft/texts/`.
5+
### Splasher for NeoForge `1.21.1`
226

23-
## Configuring Splasher
24-
25-
Splasher is using **[Cloth Config API](https://modrinth.com/mod/cloth-config)** and is fully configurable, you can find the config file under `.minecraft/config/splasher.toml`.
26-
27-
Every option is well documented, and you can achieve different effects by changing the values, for example:
28-
29-
- Disabling all splashes
30-
- Only enabling custom splashes
31-
- Enabling both original and custom splashes, and not following the client language
32-
- And more...
33-
34-
## License
35-
36-
**Splasher** is licensed under the **[GNU General Public License v3.](LICENSE)**
37-
38-
## Screenshots
39-
40-
> ![Custom Splash Text](https://github.com/KessokuTeaTime/Splasher/blob/artwork/content/splash.png)
41-
>
42-
> Splasher displaying custom splash text `Splasher!`
7+
**Customize Minecraft's Splash Texts at Your Will!**

build.gradle.kts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ plugins {
33
java
44
idea
55
`maven-publish`
6-
alias(libs.plugins.fabric.loom)
7-
alias(libs.plugins.modpublisher)
6+
alias(libs.plugins.architectury.loom)
7+
alias(libs.plugins.modpublisher)
88
}
99

1010
val display = libs.versions.display
@@ -21,15 +21,17 @@ repositories {
2121
maven { url = uri("https://jitpack.io") }
2222
maven { url = uri("https://api.modrinth.com/maven") }
2323
maven { url = uri("https://maven.shedaniel.me/") } // Cloth Config
24-
maven { url = uri("https://maven.terraformersmc.com/releases/") } // Mod Menu
24+
maven { url = uri("https://maven.neoforged.net/releases/") }
2525
}
2626

2727
dependencies {
2828
minecraft(libs.minecraft)
29-
mappings(libs.yarn) { artifact { classifier = "v2" } }
30-
modImplementation(libs.bundles.fabric)
29+
mappings(loom.layered {
30+
mappings(variantOf(libs.yarn) { classifier("v2") })
31+
mappings(libs.yarn.patch)
32+
})
33+
neoForge(libs.neoforge)
3134

32-
modApi(libs.modmenu)
3335
modApi(libs.night.auto.config)
3436

3537
modCompileOnly(libs.bounced)
@@ -44,7 +46,7 @@ java {
4446

4547
tasks {
4648
processResources {
47-
filesMatching("fabric.mod.json") {
49+
filesMatching("META-INF/neoforge.mods.toml") {
4850
expand(mapOf(
4951
"version" to libs.versions.mod.get(),
5052
"display" to display

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.jvmargs=-Xmx4G
2+
org.gradle.parallel=true
3+
4+
loom.platform=neoforge

gradle/libs.versions.toml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,36 @@
22
maven-group = "band.kessokuteatime"
33
archives-name = "splasher"
44
mod = "6.2.3"
5-
loader = "fabric"
5+
loader = "neoforge"
66

7-
minecraft = "1.21"
8-
yarn = "1.21+build.1"
9-
fabric-loader = "0.15.11"
10-
fabric-api = "0.100.6+1.21"
11-
fabric-loom = "1.6-SNAPSHOT"
12-
modpublisher = "2.1.0"
7+
minecraft = "1.21.1"
8+
yarn = "1.21.1+build.1"
9+
yarn-patch = "1.21+build.6"
10+
neoforge = "21.1.213"
11+
architectury-loom = "1.10-SNAPSHOT"
12+
modpublisher = "2.+"
1313

14-
modmenu = "11.0.1"
15-
night-auto-config = "1.0.6-fabric.1.21"
16-
bounced = "4.1.3-fabric.1.21"
14+
night-auto-config = "1.1.0-alpha.4-neoforge.1.21.1"
15+
bounced = "4.1.0-neoforge.1.21.1"
1716

1817
# id
1918
id-modrinth = "4yIZUuyx"
2019
id-curseforge = "844451"
2120

2221
# display
2322
display-name = "Splasher!"
24-
display-loader = "Fabric"
23+
display-loader = "NeoForge"
2524
display-version = "1.21+"
2625

2726
[libraries]
2827
minecraft = { group = "com.mojang", name = "minecraft", version.ref = "minecraft" }
2928
yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" }
30-
fabric-loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric-loader" }
31-
fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric-api" }
29+
yarn-patch = { group = "dev.architectury", name = "yarn-mappings-patch-neoforge", version.ref = "yarn-patch"}
30+
neoforge = { group = "net.neoforged", name = "neoforge", version.ref = "neoforge" }
3231

33-
modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu" }
3432
night-auto-config = { group = "com.github.KessokuTeaTime", name = "Night-Auto-Config", version.ref = "night-auto-config" }
3533
bounced = { group = "maven.modrinth", name = "bounced", version.ref = "bounced" }
3634

3735
[plugins]
38-
fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }
36+
architectury-loom = { id = "dev.architectury.loom", version.ref = "architectury-loom" }
3937
modpublisher = { id = "com.hypherionmc.modutils.modpublisher", version.ref = "modpublisher" }
40-
41-
[bundles]
42-
fabric = ["fabric-loader", "fabric-api"]

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pluginManagement {
44
name = "Fabric"
55
url = uri("https://maven.fabricmc.net/")
66
}
7+
maven { url = uri("https://maven.architectury.dev/") }
8+
maven { url = uri("https://maven.neoforged.net/releases/") }
79
maven { url = uri("https://maven.firstdark.dev/releases") } // modpublisher
810
mavenCentral()
911
gradlePluginPortal()

src/main/java/band/kessokuteatime/splasher/Splasher.java

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@
44
import band.kessokuteatime.nightautoconfig.config.base.ConfigType;
55
import me.shedaniel.autoconfig.AutoConfig;
66
import me.shedaniel.autoconfig.ConfigHolder;
7-
import net.fabricmc.api.ClientModInitializer;
8-
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
9-
import net.fabricmc.fabric.api.client.screen.v1.ScreenMouseEvents;
10-
import net.fabricmc.loader.api.FabricLoader;
117
import band.kessokuteatime.splasher.config.SplasherConfig;
128
import net.minecraft.client.MinecraftClient;
9+
import net.minecraft.client.gui.screen.Screen;
1310
import net.minecraft.client.gui.screen.TitleScreen;
1411
import net.minecraft.client.sound.PositionedSoundInstance;
1512
import net.minecraft.sound.SoundEvents;
1613
import net.minecraft.text.MutableText;
1714
import net.minecraft.text.Text;
1815
import net.minecraft.util.Formatting;
16+
import net.neoforged.fml.ModList;
17+
import net.neoforged.fml.ModLoadingContext;
18+
import net.neoforged.fml.common.Mod;
19+
import net.neoforged.neoforge.client.event.ScreenEvent;
20+
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
21+
import net.neoforged.neoforge.common.NeoForge;
1922
import org.slf4j.Logger;
2023
import org.slf4j.LoggerFactory;
2124

2225
import java.util.ArrayList;
2326
import java.util.Objects;
2427
import java.util.concurrent.atomic.AtomicBoolean;
2528

26-
public class Splasher implements ClientModInitializer {
29+
@Mod(Splasher.ID)
30+
public class Splasher {
2731
public static final String NAME = "Splasher", ID = "splasher";
2832
public static final Logger LOGGER = LoggerFactory.getLogger(ID);
2933
public static final ConfigHolder<SplasherConfig> CONFIG;
@@ -79,25 +83,33 @@ public static boolean shouldSplash() {
7983
private static float height = 0, width = 0;
8084
public static boolean initialized = false;
8185

82-
@Override
83-
public void onInitializeClient() {
84-
boolean isBouncedLoaded = FabricLoader.getInstance().isModLoaded("bounced");
85-
86-
ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
87-
if (screen instanceof TitleScreen) {
88-
ScreenMouseEvents.beforeMouseClick(screen)
89-
.register((currentScreen, mouseX, mouseY, button) -> {
90-
// Linkage with Bounced
91-
if (isBouncedLoaded)
92-
mouseY -= Bounced.primaryPos();
93-
94-
if (isMouseHovering(scaledWidth, mouseX, mouseY) && CONFIG.get().texts.randomRate.onClick()) {
95-
push();
96-
playClickingSound();
97-
}
98-
});
99-
}
100-
});
86+
public Splasher() {
87+
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (modContainer, screen) -> {
88+
CONFIG.load();
89+
return AutoConfig.getConfigScreen(SplasherConfig.class, screen).get();
90+
});
91+
92+
boolean isBouncedLoaded = ModList.get().isLoaded("bounced");
93+
94+
NeoForge.EVENT_BUS.addListener(ScreenEvent.Init.Post.class, screenInitEvent -> {
95+
Screen screen = screenInitEvent.getScreen();
96+
if (screen instanceof TitleScreen) {
97+
NeoForge.EVENT_BUS.addListener(ScreenEvent.MouseButtonPressed.Post.class, screenMousePressedEvent -> {
98+
double mouseX = screenMousePressedEvent.getMouseX();
99+
double mouseY = screenMousePressedEvent.getMouseY();
100+
double scaledWidth = screen.width;
101+
102+
// Linkage with Bounced
103+
if (isBouncedLoaded)
104+
mouseY -= Bounced.primaryPos();
105+
106+
if (isMouseHovering(scaledWidth, mouseX, mouseY) && CONFIG.get().texts.randomRate.onClick()) {
107+
push();
108+
playClickingSound();
109+
}
110+
});
111+
}
112+
});
101113
}
102114

103115
public static void playClickingSound() {

src/main/java/band/kessokuteatime/splasher/config/modmenu/SplasherModMenuIntegration.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/main/java/band/kessokuteatime/splasher/supplier/SplashTextSupplier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import band.kessokuteatime.splasher.Splasher;
44
import band.kessokuteatime.splasher.base.FormattingType;
5-
import net.fabricmc.loader.api.FabricLoader;
65
import band.kessokuteatime.splasher.loader.SplashTextLoader;
76
import net.minecraft.client.MinecraftClient;
87
import net.minecraft.client.session.Session;
98
import net.minecraft.text.Text;
9+
import net.neoforged.fml.loading.FMLPaths;
1010
import org.apache.commons.compress.utils.Lists;
1111
import org.jetbrains.annotations.Nullable;
1212

@@ -17,7 +17,7 @@ public class SplashTextSupplier {
1717
private static int lastRandomIndex = -1;
1818

1919
@Nullable public static String getSplashes(Session session, List<String> splashTexts) {
20-
Path path = FabricLoader.getInstance().getConfigDir().resolve(Splasher.ID);
20+
Path path = FMLPaths.CONFIGDIR.get().resolve(Splasher.ID);
2121

2222
String language = !Splasher.CONFIG.get().followsClientLanguage ? "en_us" : MinecraftClient.getInstance().getLanguageManager().getLanguage();
2323
List<String> customSplashTexts = Lists.newArrayList();
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
modLoader = "javafml"
2+
loaderVersion = "[1,)"
3+
license = "GPL-3.0"
4+
5+
[[mods]]
6+
modId = "splasher"
7+
version = "${version}"
8+
displayName = "${display.name.get()}"
9+
displayURL = "https://github.com/KessokuTeaTime/Splasher"
10+
authors = "Kessoku Tea Time"
11+
description = '''
12+
Why don't splash? Splasher is a mod which makes splash texts fully customizable.
13+
'''
14+
logoFile = "assets/splasher/icon.png"
15+
16+
[[mixins]]
17+
config = "splasher.mixins.json"
18+
19+
[[dependencies.splasher]]
20+
modId = "neoforge"
21+
type = "required"
22+
versionRange = "[21.0,)"
23+
ordering = "NONE"
24+
side = "BOTH"
25+
26+
[[dependencies.splasher]]
27+
modId = "minecraft"
28+
type = "required"
29+
versionRange = "[1.21,)"
30+
ordering = "NONE"
31+
side = "BOTH"

0 commit comments

Comments
 (0)