Skip to content

Commit 3407107

Browse files
feat: port to 1.21.4
1 parent 787835d commit 3407107

File tree

13 files changed

+127
-268
lines changed

13 files changed

+127
-268
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
## 87.0.1
1+
## 91.0.0
22

33
### Added
44

5-
- Added KubeJS Support back to the NeoForge version
5+
- Ported to 1.21.4
6+
7+
### Changed
8+
9+
- Removed KubeJS support in preference for configs.

README.md

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ We always will attempt to use an image called `loading` and an image called `men
3535
- `menu` When the main menu is showing
3636
- `loading` When the game is loading
3737

38-
3938
## Using custom images
4039

4140
If you are not using the KubeJS integration then you will need to follow the our convention for naming images and language keys. The convention is as follows:
@@ -135,64 +134,4 @@ If you do not want to have buttons, you can leave the buttons array empty.
135134
}
136135
]
137136
}
138-
```
139-
140-
## KubeJS Integration
141-
142-
> **Note!**
143-
>
144-
> KubeJS Support is only support in 3.0.0+ for `1.19.2` and `4.0.3+` for `1.20.1+`.
145-
>
146-
> KubeJS no longer supports Forge or Fabric so support for KubeJS as of `1.20.4+` is limited to just the `NeoForge` version of our mod
147-
>
148-
> Only `KubeJS 6+` is supported!
149-
150-
Via KubeJS we expose the following methods:
151-
152-
- `SDRP.setState( String message, String imageName, String imageKey )`
153-
- `message`: message to show under the packname aka "In Overworld" or "In Nether", can be passed a string with the text to show or a lang key.
154-
- `imageName`: the text to show when hovering over the small image aka "Overworld" or "Nether", can be passed a string with the text to show or a lang key.
155-
- `imageKey` : the name Rich Present Art Asset to show, like loading, overworld, menu and so on.
156-
157-
- `SDRP.getCurrentState()`
158-
- Gets the current state the client is set to.
159-
160-
### 3.0.6+ and 4.0.3+
161-
162-
In 3.0.6+ and 4.0.3+ we expose a couple of new events to help with some KubeJS weirdness as well as the above methods.
163-
164-
`kubejs/startup_script/sdrp.js`
165-
166-
```js
167-
sdrp.dimension_change((event) => {
168-
const dimPath = event.level.dimension().location().getPath();
169-
event.updateSDRPState(`sdrp.${dimPath}.in`, `sdrp.${dimPath}`, "dimPath");
170-
});
171-
```
172-
173-
*File path for illustration purposes only, you can put this file anywhere in the `kubejs` folder.*
174-
175-
The `event` object has the following properties:
176-
177-
- `dimensionType`: The dimension the player is in
178-
- `player`: The player object
179-
- `level`: The level object
180-
181-
#### Without our events
182-
183-
Example of how to change the state when a player joins a world.
184-
185-
`kubejs/startup_script/sdrp.js`
186-
187-
```js
188-
// KubeJS 6+
189-
// This might be the wrong event class for 1.20+, I didn't check
190-
ForgeEvents.onEvent('net.minecraftforge.event.entity.EntityJoinWorldEvent', event => {
191-
if (event.getEntity().type === "entity.minecraft.player") {
192-
if (event.getWorld().isClientSide()) {
193-
const dimPath = event.getWorld().dimension().location().getPath();
194-
SDRP.setState(`sdrp.${dimPath}.in`, `sdrp.${dimPath}`, "dimPath");
195-
}
196-
}
197-
})
198-
```
137+
```

build.gradle

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import groovy.json.JsonSlurper
2+
13
plugins {
24
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
4-
id "me.modmuss50.mod-publish-plugin" version "0.4.5"
5+
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
6+
id "me.modmuss50.mod-publish-plugin" version "0.8.3"
57
}
68

79
architectury {
@@ -29,28 +31,24 @@ allprojects {
2931
def ENV = System.getenv()
3032

3133
archivesBaseName = rootProject.archives_base_name
32-
version = "${mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}+mc${minecraft_version}"
34+
version = "${mod_version}+mc${minecraft_version}"
3335
group = rootProject.maven_group
3436

3537
repositories {
3638
maven {
37-
url "https://maven.saps.dev/releases"
39+
url "https://maven.ftb.dev/releases"
3840
content {
3941
includeGroup "dev.ftb.mods"
40-
includeGroup "dev.latvian.mods"
4142
}
4243
}
43-
maven { url "https://maven.saps.dev/mirror" }
44-
maven { url 'https://jitpack.io'
44+
maven {
45+
url 'https://jitpack.io'
4546
content {
4647
includeGroup "com.github.jagrosh"
4748
}
4849
}
4950
maven {
50-
url "https://maven.blamejared.com"
51-
content {
52-
includeGroup "com.faux.ingredientextension"
53-
}
51+
url 'https://maven.neoforged.net/releases'
5452
}
5553
}
5654

@@ -90,12 +88,6 @@ publishMods {
9088
modLoaders.add("fabric")
9189
}
9290

93-
// def forgeOptions = publishOptions {
94-
// file = project.provider { project(":forge").tasks.remapJar }.flatMap { it.archiveFile }
95-
// displayName = "[FORGE][${minecraft_version}] ${project.name} ${mod_version}"
96-
// modLoaders.add("forge")
97-
// }
98-
9991
def neoforgeOptions = publishOptions {
10092
file = project.provider { project(":neoforge").tasks.remapJar }.flatMap { it.archiveFile }
10193
displayName = "[NEOFORGE][${minecraft_version}] ${project.name} ${mod_version}"
@@ -127,16 +119,6 @@ publishMods {
127119
}
128120
}
129121

130-
// curseforge("curseforgeForge") {
131-
// from(curseForgeOptions, forgeOptions)
132-
// requires {
133-
// slug = "cloth-config"
134-
// }
135-
// requires {
136-
// slug = "architectury-api"
137-
// }
138-
// }
139-
140122
curseforge("curseforgeNeoforge") {
141123
from(curseForgeOptions, neoforgeOptions)
142124
requires {
@@ -162,16 +144,6 @@ publishMods {
162144
}
163145
}
164146

165-
// modrinth("modrinthForge") {
166-
// from(modrinthOptions, forgeOptions)
167-
// requires {
168-
// slug = "cloth-config"
169-
// }
170-
// requires {
171-
// slug = "architectury-api"
172-
// }
173-
// }
174-
175147
modrinth("modrinthNeoforge") {
176148
from(modrinthOptions, neoforgeOptions)
177149
requires {
@@ -183,3 +155,32 @@ publishMods {
183155
}
184156
}
185157
}
158+
159+
160+
tasks.register("getMinecraftIncrementalId") {
161+
group = "other"
162+
163+
doLast {
164+
// Load the versions data
165+
def url = "https://launchermeta.mojang.com/mc/game/version_manifest_v2.json"
166+
def json = new JsonSlurper().parseText(url.toURL().text)
167+
def versions = json.versions
168+
169+
// Reverse the list so the oldest version is first
170+
versions = versions.reverse()
171+
172+
def currentNumber = 0;
173+
for (version in versions) {
174+
if (version.type != "release") {
175+
continue
176+
}
177+
178+
currentNumber++
179+
if (version.id == rootProject.minecraft_version) {
180+
break
181+
}
182+
}
183+
184+
println("Minecraft incremental ID: ${currentNumber}")
185+
}
186+
}

common/src/main/java/com/sunekaer/sdrp/SDRP.java

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.sunekaer.sdrp;
22

33
import com.jagrosh.discordipc.entities.pipe.PipeStatus;
4-
import com.mojang.realmsclient.RealmsMainScreen;
54
import com.sunekaer.sdrp.config.SDRPConfig;
65
import com.sunekaer.sdrp.discord.RPClient;
76
import com.sunekaer.sdrp.discord.State;
@@ -14,9 +13,6 @@
1413
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
1514
import net.minecraft.client.Minecraft;
1615
import net.minecraft.client.gui.screens.Screen;
17-
import net.minecraft.client.gui.screens.TitleScreen;
18-
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
19-
import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
2016
import net.minecraft.client.player.AbstractClientPlayer;
2117
import net.minecraft.client.resources.language.I18n;
2218
import net.minecraft.world.entity.Entity;
@@ -48,24 +44,35 @@ public static void init() {
4844
* When the screen is part of the main menu screens, attempt to update discord about it
4945
*/
5046
private static void screenEvent(Screen screen, ScreenAccess screenAccess) {
51-
if (!config.enabled || !State.PRESETS.containsKey("menu") || !config.screenEvent) {
47+
if (!config.enabled || !config.enableUpdateScreenPresence) {
5248
return;
5349
}
5450

55-
if (screen instanceof TitleScreen || screen instanceof JoinMultiplayerScreen || screen instanceof SelectWorldScreen || screen instanceof RealmsMainScreen) {
56-
var menuState = State.PRESETS.get("menu").createPresence();
57-
var currentState = RP_CLIENT.getCurrentState();
58-
if (currentState != menuState) {
59-
RP_CLIENT.setState(menuState);
60-
}
51+
updateScreen(screen);
52+
}
53+
54+
private static void updateScreen(Screen screen) {
55+
var screenClassName = screen.getClass().getName();
56+
var screenPresence = config.screens.stream()
57+
.filter(e -> e.screenClass.contains(screenClassName))
58+
.findFirst();
59+
60+
if (screenPresence.isEmpty()) {
61+
return;
62+
}
63+
64+
var state = screenPresence.get().createPresence();
65+
var currentState = RP_CLIENT.getCurrentState();
66+
if (currentState != state) {
67+
RP_CLIENT.setState(state);
6168
}
6269
}
6370

6471
/**
6572
* When the client joins, send out a setDim event to discord
6673
*/
6774
private static EventResult clientJoinEvent(Entity entity, Level level) {
68-
if (!config.enabled || !config.clientJoinEvent) {
75+
if (!config.enabled || !config.enableUpdateDimensionPresence) {
6976
return EventResult.pass();
7077
}
7178

@@ -82,16 +89,19 @@ private static EventResult clientJoinEvent(Entity entity, Level level) {
8289
* Dynamically create an entry on a dimension change
8390
*/
8491
public static void setDimension(Level level) {
85-
State dim = State.PRESETS.get(level.dimension().toString());
86-
if (dim != null) {
87-
RP_CLIENT.setState(dim.createPresence());
88-
} else {
89-
String name = I18n.get("sdrp." + level.dimension().location().getPath());
90-
String in = I18n.get("sdrp." + level.dimension().location().getPath() + ".in");
91-
String key = level.dimension().location().getPath();
92-
93-
RP_CLIENT.setState(new State(in, name, key).createPresence());
92+
var dimensionName = level.dimension().location().toString();
93+
var isInverted = config.invertWhitelist;
94+
95+
// Does the whitelist contain the dimension? But invert the check if we're using a blacklist
96+
if (config.dimensionsWhitelist.contains(dimensionName) == isInverted) {
97+
return;
9498
}
99+
100+
String name = I18n.get("sdrp." + level.dimension().location().getPath());
101+
String in = I18n.get("sdrp." + level.dimension().location().getPath() + ".in");
102+
String key = level.dimension().location().getPath();
103+
104+
RP_CLIENT.setState(new State(in, name, key).createPresence());
95105
}
96106

97107
/**

0 commit comments

Comments
 (0)