diff --git a/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java b/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java index c193629..f76a4fc 100644 --- a/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java +++ b/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java @@ -1130,6 +1130,14 @@ public ISBPLObject toISBPL(Class clazz) { for(Class c : interfaces) { type.superTypes.add(toISBPL(c).type); } + for (Class subclass : clazz.getDeclaredClasses()) { + addFunction(type, subclass.getSimpleName(), stack -> { + if(debug) + ISBPL.gErrorStream.println("Java GetSubclass: " + subclass.getName()); + stack.pop(); + stack.push(toISBPL(subclass)); + }); + } if (clazz.isEnum()) { for (Object o : clazz.getEnumConstants()) { String name = PolyFire.obfMap.get(clazz.getName().replaceAll("\\.", "/") + "/" + o.toString(), o.toString()); @@ -1352,6 +1360,11 @@ public Object fromISBPL(ISBPLObject o, Class expectedType) { if(expectedType == byte.class) return (byte) o.toLong(); } + if(expectedType == Runnable.class) { + return (Runnable) () -> { + ((ISBPLCallable) o.object).call(new ISBPLStack<>()); + }; + } if(!expectedType.isAssignableFrom(o.object.getClass())) typeError(o.type.name, expectedType.getName()); return o.object; diff --git a/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java.original b/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java.original index 2eda61f..88dfb4e 100644 --- a/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java.original +++ b/src/main/java/tudbut/mod/polyfire/utils/isbpl/ISBPL.java.original @@ -1126,6 +1126,14 @@ public class ISBPL { for(Class c : interfaces) { type.superTypes.add(toISBPL(c).type); } + for (Class subclass : clazz.getDeclaredClasses()) { + addFunction(type, subclass.getSimpleName(), stack -> { + if(debug) + ISBPL.gErrorStream.println("Java GetSubclass: " + subclass.getName()); + stack.pop(); + stack.push(toISBPL(subclass)); + }); + } if (clazz.isEnum()) { for (Object o : clazz.getEnumConstants()) { addFunction(type, o.toString(), stack -> { @@ -1342,6 +1350,11 @@ public class ISBPL { if(expectedType == byte.class) return (byte) o.toLong(); } + if(expectedType == Runnable.class) { + return (Runnable) () -> { + ((ISBPLCallable) o.object).call(new ISBPLStack<>()); + }; + } if(!expectedType.isAssignableFrom(o.object.getClass())) typeError(o.type.name, expectedType.getName()); return o.object;