json-able attributes (#8334)
This commit is contained in:
@@ -79,7 +79,11 @@ public class ContentParser{
|
||||
put(Interp.class, (type, data) -> field(Interp.class, data));
|
||||
put(Blending.class, (type, data) -> field(Blending.class, data));
|
||||
put(CacheLayer.class, (type, data) -> field(CacheLayer.class, data));
|
||||
put(Attribute.class, (type, data) -> Attribute.get(data.asString()));
|
||||
put(Attribute.class, (type, data) -> {
|
||||
String attr = data.asString();
|
||||
if(Attribute.exists(attr)) return Attribute.get(attr);
|
||||
return Attribute.add(attr);
|
||||
});
|
||||
put(BuildVisibility.class, (type, data) -> field(BuildVisibility.class, data));
|
||||
put(Schematic.class, (type, data) -> {
|
||||
Object result = fieldOpt(Loadouts.class, data);
|
||||
|
||||
@@ -47,6 +47,11 @@ public class Attribute{
|
||||
return map.getThrow(name, () -> new IllegalArgumentException("Unknown Attribute type: " + name));
|
||||
}
|
||||
|
||||
/** @return Whether an attribute exists. */
|
||||
public static boolean exists(String name){
|
||||
return map.containsKey(name);
|
||||
}
|
||||
|
||||
/** Automatically registers this attribute for use. Do not call after mod init. */
|
||||
public static Attribute add(String name){
|
||||
Attribute a = new Attribute(all.length, name);
|
||||
|
||||
Reference in New Issue
Block a user