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

Commit cd816d6

Browse files
authored
Merge pull request #5 from solid-resourcepack/development
feat: add support for getting textures and parents
2 parents d8bcc2c + 4471f1f commit cd816d6

3 files changed

Lines changed: 48 additions & 41 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99

1010
allprojects {
1111
group = "io.github.solid-resourcepack"
12-
version = "1.21-1.1.0"
12+
version = "1.21-1.1.1"
1313

1414
repositories {
1515
mavenCentral()

solid-material-api/src/main/kotlin/io/github/solid/resourcepack/material/SolidMaterialParent.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@ data class SolidMaterialParent(
88
) {
99
companion object {
1010
fun exists(key: Key): Boolean {
11-
if (key.namespace() != Key.MINECRAFT_NAMESPACE) return false
11+
return get(key) != null
12+
}
13+
fun get(key: Key): SolidMaterialParent? {
14+
if (key.namespace() != Key.MINECRAFT_NAMESPACE) return null
1215
val split = key.value().split("/")
1316
val type = split.first().uppercase()
1417
val value = split.last().uppercase()
1518
return when (type) {
1619
"BLOCK" -> try {
17-
SolidBlockMaterialParent.valueOf(value); true
20+
SolidBlockMaterialParent.valueOf(value).toGeneric()
1821
} catch (ignored: Exception) {
19-
false
22+
null
2023
}
2124

2225
"ITEM" -> try {
23-
SolidItemMaterialParent.valueOf(value); true
26+
SolidItemMaterialParent.valueOf(value).toGeneric()
2427
} catch (ignored: Exception) {
25-
false
28+
null
2629
}
2730

2831
"BUILTIN" -> try {
29-
SolidBuiltinMaterialParent.valueOf(value); true
32+
SolidBuiltinMaterialParent.valueOf(value).toGeneric()
3033
} catch (ignored: Exception) {
31-
false
34+
null
3235
}
3336

34-
else -> false
37+
else -> null
3538
}
3639
}
3740
}

solid-material-api/src/main/kotlin/io/github/solid/resourcepack/material/SolidMaterialTexture.kt

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,103 +6,107 @@ data class SolidMaterialTexture(
66
val key: Key
77
) {
88
companion object {
9+
910
fun exists(key: Key): Boolean {
10-
if (key.namespace() != Key.MINECRAFT_NAMESPACE) return false
11+
return get(key) != null
12+
}
13+
fun get(key: Key): SolidMaterialTexture? {
14+
if (key.namespace() != Key.MINECRAFT_NAMESPACE) return null
1115
val split = key.value().split("/")
1216
val type = split.first().uppercase()
1317
val value = split.last().uppercase()
1418
return when (type) {
1519
"BLOCK" -> try {
16-
SolidBlockMaterialTexture.valueOf(value); true
20+
SolidBlockMaterialTexture.valueOf(value).toGeneric()
1721
} catch (ignored: Exception) {
18-
false
22+
null
1923
}
2024

2125
"ITEM" -> try {
22-
SolidItemMaterialTexture.valueOf(value); true
26+
SolidItemMaterialTexture.valueOf(value).toGeneric()
2327
} catch (ignored: Exception) {
24-
false
28+
null
2529
}
2630

2731
"MODELS" -> try {
28-
SolidModelsMaterialTexture.valueOf(value); true
32+
SolidModelsMaterialTexture.valueOf(value).toGeneric()
2933
} catch (ignored: Exception) {
30-
false
34+
null
3135
}
3236

3337
"GUI" -> try {
34-
SolidGuiMaterialTexture.valueOf(value); true
38+
SolidGuiMaterialTexture.valueOf(value).toGeneric()
3539
} catch (ignored: Exception) {
36-
false
40+
null
3741
}
3842

3943
"ENTITY" -> try {
40-
SolidEntityMaterialTexture.valueOf(value); true
44+
SolidEntityMaterialTexture.valueOf(value).toGeneric()
4145
} catch (ignored: Exception) {
42-
false
46+
null
4347
}
4448

4549
"PARTICLE" -> try {
46-
SolidParticleMaterialTexture.valueOf(value); true
50+
SolidParticleMaterialTexture.valueOf(value).toGeneric()
4751
} catch (ignored: Exception) {
48-
false
52+
null
4953
}
5054

5155
"ENVIRONMENT" -> try {
52-
SolidEnvironmentMaterialTexture.valueOf(value); true
56+
SolidEnvironmentMaterialTexture.valueOf(value).toGeneric()
5357
} catch (ignored: Exception) {
54-
false
58+
null
5559
}
5660

5761
"MISC" -> try {
58-
SolidMiscMaterialTexture.valueOf(value); true
62+
SolidMiscMaterialTexture.valueOf(value).toGeneric()
5963
} catch (ignored: Exception) {
60-
false
64+
null
6165
}
6266

6367
"PAINTING" -> try {
64-
SolidPaintingMaterialTexture.valueOf(value); true
68+
SolidPaintingMaterialTexture.valueOf(value).toGeneric()
6569
} catch (ignored: Exception) {
66-
false
70+
null
6771
}
6872

6973
"FONT" -> try {
70-
SolidFontMaterialTexture.valueOf(value); true
74+
SolidFontMaterialTexture.valueOf(value).toGeneric()
7175
} catch (ignored: Exception) {
72-
false
76+
null
7377
}
7478

7579
"MAP" -> try {
76-
SolidMapMaterialTexture.valueOf(value); true
80+
SolidMapMaterialTexture.valueOf(value).toGeneric()
7781
} catch (ignored: Exception) {
78-
false
82+
null
7983
}
8084

8185
"COLORMAP" -> try {
82-
SolidColormapMaterialTexture.valueOf(value); true
86+
SolidColormapMaterialTexture.valueOf(value).toGeneric()
8387
} catch (ignored: Exception) {
84-
false
88+
null
8589
}
8690

8791
"EFFECT" -> try {
88-
SolidEffectMaterialTexture.valueOf(value); true
92+
SolidEffectMaterialTexture.valueOf(value).toGeneric()
8993
} catch (ignored: Exception) {
90-
false
94+
null
9195
}
9296

9397
"TRIMS" -> try {
94-
SolidTrimsMaterialTexture.valueOf(value); true
98+
SolidTrimsMaterialTexture.valueOf(value).toGeneric()
9599
} catch (ignored: Exception) {
96-
false
100+
null
97101
}
98102

99103
"MOB_EFFECT" -> try {
100-
SolidMobEffectMaterialTexture.valueOf(value); true
104+
SolidMobEffectMaterialTexture.valueOf(value).toGeneric()
101105
} catch (ignored: Exception) {
102-
false
106+
null
103107
}
104108

105-
else -> false
109+
else -> null
106110
}
107111
}
108112
}

0 commit comments

Comments
 (0)