diff --git a/core/src/mindustry/mod/ContentParser.java b/core/src/mindustry/mod/ContentParser.java index d02b4e4142..519b47ff71 100644 --- a/core/src/mindustry/mod/ContentParser.java +++ b/core/src/mindustry/mod/ContentParser.java @@ -56,6 +56,8 @@ import static mindustry.Vars.*; @SuppressWarnings("unchecked") public class ContentParser{ private static final boolean ignoreUnknownFields = true; + private static final ContentType[] typesToSearch = {ContentType.block, ContentType.item, ContentType.unit, ContentType.liquid, ContentType.planet}; + ObjectMap, ContentType> contentTypes = new ObjectMap<>(); ObjectSet> implicitNullable = ObjectSet.with(TextureRegion.class, TextureRegion[].class, TextureRegion[][].class, TextureRegion[][][].class); ObjectMap> sounds = new ObjectMap<>(); @@ -397,6 +399,17 @@ public class ContentParser{ return (T)new Rect(jsonData.get(0).asFloat(), jsonData.get(1).asFloat(), jsonData.get(2).asFloat(), jsonData.get(3).asFloat()); } + //search across different content types to find one by name + if(type == UnlockableContent.class){ + for(ContentType c : typesToSearch){ + T found = (T)locate(c, jsonData.asString()); + if(found != null){ + return found; + } + } + throw new IllegalArgumentException("\"" + jsonData.name + "\": No content found with name '" + jsonData.asString() + "'."); + } + if(Content.class.isAssignableFrom(type)){ ContentType ctype = contentTypes.getThrow(type, () -> new IllegalArgumentException("No content type for class: " + type.getSimpleName())); String prefix = currentMod != null ? currentMod.name + "-" : ""; diff --git a/gradle.properties b/gradle.properties index 8c6264f749..a13171c749 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,4 +25,4 @@ org.gradle.caching=true #used for slow jitpack builds; TODO see if this actually works org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.connectionTimeout=100000 -archash=ea8fa3b50d +archash=21508dc509