mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
add hook for custom engine modes
This commit is contained in:
@@ -200,7 +200,7 @@ public class IrisEngine implements Engine {
|
|||||||
mode.close();
|
mode.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
mode = getDimension().getMode().getType().create(this);
|
mode = getDimension().getMode().create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.object;
|
package com.volmit.iris.engine.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.framework.EngineMode;
|
||||||
import com.volmit.iris.engine.object.annotations.Desc;
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
|
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -35,4 +38,19 @@ public class IrisDimensionMode {
|
|||||||
@Desc("The dimension type")
|
@Desc("The dimension type")
|
||||||
private IrisDimensionModeType type = IrisDimensionModeType.OVERWORLD;
|
private IrisDimensionModeType type = IrisDimensionModeType.OVERWORLD;
|
||||||
|
|
||||||
|
@RegistryListResource(IrisScript.class)
|
||||||
|
@Desc("The script to create the dimension mode instead of using provided types")
|
||||||
|
private String script;
|
||||||
|
|
||||||
|
public EngineMode create(Engine engine) {
|
||||||
|
if (script == null) {
|
||||||
|
return type.create(engine);
|
||||||
|
}
|
||||||
|
Object result = engine.getExecution().evaluate(script);
|
||||||
|
if (result instanceof EngineMode) {
|
||||||
|
return (EngineMode) result;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalStateException("The script '" + script + "' did not return an engine mode!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user