Skip to content

Commit 9900fe1

Browse files
committed
- fix custom material crash
1 parent ccf3702 commit 9900fe1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

common/src/main/java/smartin/miapi/modules/properties/material/JsonMaterial.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.minecraft.registry.Registries;
1616
import net.minecraft.registry.tag.TagKey;
1717
import net.minecraft.util.Identifier;
18+
import net.minecraft.util.math.ColorHelper;
1819
import smartin.miapi.modules.properties.util.ModuleProperty;
1920
import smartin.miapi.registries.RegistryInventory;
2021

@@ -49,7 +50,7 @@ public String getKey() {
4950
public List<String> getGroups() {
5051
List<String> groups = new ArrayList<>();
5152
groups.add(key);
52-
if(rawJson.getAsJsonObject().has("groups")){
53+
if (rawJson.getAsJsonObject().has("groups")) {
5354
JsonArray groupsJson = rawJson.getAsJsonObject().getAsJsonArray("groups");
5455
for (JsonElement groupElement : groupsJson) {
5556
String group = groupElement.getAsString();
@@ -124,7 +125,7 @@ public String getData(String property) {
124125
@Override
125126
public List<String> getTextureKeys() {
126127
List<String> textureKeys = new ArrayList<>();
127-
if(rawJson.getAsJsonObject().has("textures")){
128+
if (rawJson.getAsJsonObject().has("textures")) {
128129
JsonArray textures = rawJson.getAsJsonObject().getAsJsonArray("textures");
129130
for (JsonElement texture : textures) {
130131
textureKeys.add(texture.getAsString());
@@ -136,8 +137,11 @@ public List<String> getTextureKeys() {
136137

137138
@Override
138139
public int getColor() {
139-
long longValue = Long.parseLong(rawJson.getAsJsonObject().get("color").getAsString(), 16);
140-
return (int) (longValue & 0xffffffffL);
140+
if (rawJson.getAsJsonObject().get("color") != null) {
141+
long longValue = Long.parseLong(rawJson.getAsJsonObject().get("color").getAsString(), 16);
142+
return (int) (longValue & 0xffffffffL);
143+
}
144+
return ColorHelper.Argb.getArgb(255, 255, 255, 255);
141145
}
142146

143147
@Override

0 commit comments

Comments
 (0)