Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 04d6405

Browse files
committed
Always process the buildin ModIntegrationHints.json before the one from the filesystem.
1 parent e0974cd commit 04d6405

6 files changed

Lines changed: 58 additions & 50 deletions

File tree

changelog.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
<!-- latest begin -->
2+
### 1.1.2
3+
- brand new Simplified Chinese translation thanks to @PVWXX
4+
- profiles now support empty slots. For example in one profile you have shield in the offhend slot and another profile want it empty. For items moved out in this case an attempt will be made to move them in a free locked slot.<br>
5+
Just add the slot name without items in the configuration.
6+
- added full auto crafting. Just hold shift+alt while clicking on the crafting slot.
7+
- fixed sort in column and row buttons to. They were swapped.
8+
- fixed forge server crash.
9+
- fixed forge client complaining if IPN is not installed on the server.
10+
- made handling of ignored screens and inventories more robust.
11+
<!-- latest end -->
12+
13+
<!-- rest begin -->
14+
215
### 1.1.1
316
- fixed client crash on Forge 1.17.x
417
- fixed ignored container types handling
518
- probably fixed server crash on forge when the mod is installed. **NOTE:** Don't install it on servers it doesn't do anything.
619

20+
721
### 1.1.0
822
* Added API for integration with other mods. It is now possible for other mods to:
923
* mark their screens to be ignored so IPN won't try to interact with them.
1024
* give hints to IPN where to put its UI.
1125
* there is a configuration file that can provide the above information if the for some reason it's not possible for the other mod to provide in via the API. Entries in the default configuration file will be accepted in case official refusal from the other mod to provide integration or if the other mod is abandoned.
1226

13-
14-
<!-- latest end -->
15-
16-
<!-- rest begin -->
1727
### 1.0.3
1828
- fixes a problem where, on some servers, items were moved out of the locked slots on dimension change.
1929

common/src/main/java/org/anti_ad/mc/common/integration/HintClassData.kt

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package org.anti_ad.mc.common.integration
33
import kotlinx.serialization.ExperimentalSerializationApi
44
import kotlinx.serialization.Serializable
55
import kotlinx.serialization.SerializationException
6-
import kotlinx.serialization.builtins.MapSerializer
76
import kotlinx.serialization.json.Json
8-
import kotlinx.serialization.json.JsonObject
97
import kotlinx.serialization.json.decodeFromStream
108
import org.anti_ad.mc.common.Log
119
import org.anti_ad.mc.common.extensions.exists
@@ -31,30 +29,21 @@ data class HintClassData(val ignore: Boolean = false,
3129
}
3230

3331
@OptIn(ExperimentalSerializationApi::class)
34-
fun registerFromConfig(file: Path) {
32+
fun registerFromConfigFile(file: Path) {
33+
3534
if (file.exists()) {
35+
try {
36+
val res = HintClassData::class.java.classLoader.getResourceAsStream("assets/inventoryprofilesnext/config/ModIntegrationHints.json");
37+
val builtInConfig: Map<String, HintClassData> = if (res != null) Json.decodeFromStream(res) else mapOf();
38+
processConfig(builtInConfig)
39+
} catch (se: SerializationException) {
40+
Log.error("Builtin configuration is invalid! Please report this.", se)
41+
} catch (ioe: IOException) {
42+
Log.error("Builtin configuration is invalid! Please report this.", ioe)
43+
}
3644
try {
3745
val config: Map<String, HintClassData> = Json.decodeFromStream(file.inputStream());
38-
Log.trace("Read config: $config")
39-
config.forEach { (s, hint) ->
40-
Log.trace("Checking for class: $s")
41-
val cl: Class<*>
42-
try {
43-
cl = Class.forName(s)
44-
Log.trace("Successfully loaded class: ${cl.name}")
45-
} catch (_: Throwable) {
46-
Log.trace("Could not load class $s")
47-
return@forEach
48-
}
49-
if (hint.ignore) {
50-
Log.trace("Adding ignore for ${cl.name}")
51-
IgnoredManager.addIgnore(cl)
52-
}
53-
if (hint.buttonHints.isNotEmpty()) {
54-
Log.trace("Adding gui hints for ${cl.name}")
55-
HintsManager.addHints(cl, hint)
56-
}
57-
}
46+
processConfig(config)
5847
} catch (se: SerializationException) {
5948
Log.error("Error parsing Mod compatibility config file: ${file.name}", se)
6049
} catch (ioe: IOException) {
@@ -66,26 +55,35 @@ fun registerFromConfig(file: Path) {
6655
res?.use { input ->
6756
file.outputStream().use { output ->
6857
input.copyTo(output)
69-
registerFromConfig(file)
58+
registerFromConfigFile(file)
7059
}
7160
}
72-
/*
73-
if (res != null) {
74-
val fos = file.outputStream()
75-
res.copyTo(fos)
76-
try {
77-
fos.close()
78-
res.close()
79-
} catch(_: Throwable) {
80-
//ignored
81-
}
82-
registerFromConfig(file)
83-
}
84-
*/
85-
8661
} catch (ioe: IOException) {
8762
Log.error("Can't create default ModIntegrationHints.json", ioe)
8863
}
8964
}
9065
}
9166

67+
private fun processConfig(config: Map<String, HintClassData>) {
68+
Log.trace("Read config: $config")
69+
config.forEach { (s, hint) ->
70+
Log.trace("Checking for class: $s")
71+
val cl: Class<*>
72+
try {
73+
cl = Class.forName(s)
74+
Log.trace("Successfully loaded class: ${cl.name}")
75+
} catch (_: Throwable) {
76+
Log.trace("Could not load class $s")
77+
return@forEach
78+
}
79+
if (hint.ignore) {
80+
Log.trace("Adding ignore for ${cl.name}")
81+
IgnoredManager.addIgnore(cl)
82+
}
83+
if (hint.buttonHints.isNotEmpty()) {
84+
Log.trace("Adding gui hints for ${cl.name}")
85+
HintsManager.addHints(cl, hint)
86+
}
87+
}
88+
}
89+

platforms/fabric-1.16/src/main/java/org/anti_ad/mc/ipnext/parser/CustomDataFileLoader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.anti_ad.mc.common.extensions.tryOrPrint
1212
import org.anti_ad.mc.common.extensions.writeToFile
1313
import org.anti_ad.mc.common.gui.widgets.ButtonWidget
1414
import org.anti_ad.mc.common.gui.widgets.ConfigButtonInfo
15-
import org.anti_ad.mc.common.integration.registerFromConfig
15+
import org.anti_ad.mc.common.integration.registerFromConfigFile
1616
import org.anti_ad.mc.common.profiles.conifg.ProfileData
1717
import org.anti_ad.mc.common.profiles.conifg.ProfilesConfig
1818
import org.anti_ad.mc.common.util.LogicalStringComparator
@@ -218,7 +218,7 @@ object HintsLoader: Loader {
218218
override fun reload(clientWorld: ClientWorld?) {
219219
if (!loaded) {
220220
loaded = true
221-
registerFromConfig(configFolder / "ModIntegrationHints.json")
221+
registerFromConfigFile(configFolder / "ModIntegrationHints.json")
222222
}
223223
}
224224

platforms/fabric-1.17/src/main/java/org/anti_ad/mc/ipnext/parser/CustomDataFileLoader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.anti_ad.mc.common.extensions.tryOrPrint
1212
import org.anti_ad.mc.common.extensions.writeToFile
1313
import org.anti_ad.mc.common.gui.widgets.ButtonWidget
1414
import org.anti_ad.mc.common.gui.widgets.ConfigButtonInfo
15-
import org.anti_ad.mc.common.integration.registerFromConfig
15+
import org.anti_ad.mc.common.integration.registerFromConfigFile
1616
import org.anti_ad.mc.common.profiles.conifg.ProfileData
1717
import org.anti_ad.mc.common.profiles.conifg.ProfilesConfig
1818
import org.anti_ad.mc.common.util.LogicalStringComparator
@@ -218,7 +218,7 @@ object HintsLoader: Loader {
218218
override fun reload(clientWorld: ClientWorld?) {
219219
if (!loaded) {
220220
loaded = true
221-
registerFromConfig(configFolder / "ModIntegrationHints.json")
221+
registerFromConfigFile(configFolder / "ModIntegrationHints.json")
222222
}
223223
}
224224

platforms/forge-1.16/src/main/java/org/anti_ad/mc/ipnext/parser/CustomDataFileLoader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.anti_ad.mc.common.extensions.tryOrPrint
1212
import org.anti_ad.mc.common.extensions.writeToFile
1313
import org.anti_ad.mc.common.gui.widgets.ButtonWidget
1414
import org.anti_ad.mc.common.gui.widgets.ConfigButtonInfo
15-
import org.anti_ad.mc.common.integration.registerFromConfig
15+
import org.anti_ad.mc.common.integration.registerFromConfigFile
1616
import org.anti_ad.mc.common.profiles.conifg.ProfileData
1717
import org.anti_ad.mc.common.profiles.conifg.ProfilesConfig
1818
import org.anti_ad.mc.common.util.LogicalStringComparator
@@ -218,7 +218,7 @@ object HintsLoader: Loader {
218218
override fun reload(clientWorld: ClientWorld?) {
219219
if (!loaded) {
220220
loaded = true
221-
registerFromConfig(configFolder / "ModIntegrationHints.json")
221+
registerFromConfigFile(configFolder / "ModIntegrationHints.json")
222222
}
223223
}
224224

platforms/forge-1.17/src/main/java/org/anti_ad/mc/ipnext/parser/CustomDataFileLoader.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import org.anti_ad.mc.common.extensions.tryOrPrint
1212
import org.anti_ad.mc.common.extensions.writeToFile
1313
import org.anti_ad.mc.common.gui.widgets.ButtonWidget
1414
import org.anti_ad.mc.common.gui.widgets.ConfigButtonInfo
15-
import org.anti_ad.mc.common.integration.registerFromConfig
15+
import org.anti_ad.mc.common.integration.registerFromConfigFile
1616
import org.anti_ad.mc.common.profiles.conifg.ProfileData
1717
import org.anti_ad.mc.common.profiles.conifg.ProfilesConfig
1818
import org.anti_ad.mc.common.util.LogicalStringComparator
@@ -218,7 +218,7 @@ object HintsLoader: Loader {
218218
override fun reload(clientWorld: ClientWorld?) {
219219
if (!loaded) {
220220
loaded = true
221-
registerFromConfig(configFolder / "ModIntegrationHints.json")
221+
registerFromConfigFile(configFolder / "ModIntegrationHints.json")
222222
}
223223
}
224224

0 commit comments

Comments
 (0)