diff --git a/common/src/main/java/cn/zbx1425/mtrsteamloco/data/EyeCandyRegistry.java b/common/src/main/java/cn/zbx1425/mtrsteamloco/data/EyeCandyRegistry.java index 5164e4a2..60230787 100644 --- a/common/src/main/java/cn/zbx1425/mtrsteamloco/data/EyeCandyRegistry.java +++ b/common/src/main/java/cn/zbx1425/mtrsteamloco/data/EyeCandyRegistry.java @@ -125,7 +125,7 @@ MtrModelRegistryUtil.resourceManager, new ResourceLocation(obj.get("atlasIndex" ResourceLocation scriptLocation = new ResourceLocation(scriptFiles.get(i).getAsString()); scripts.put(scriptLocation, ResourceUtil.readResource(resourceManager, scriptLocation)); } - scriptContext.load("EyeCandy " + key, resourceManager, scripts); + scriptContext.load("EyeCandy " + key, "Block", resourceManager, scripts); return new EyeCandyProperties(Text.translatable(obj.get("name").getAsString()), scriptContext); } else { diff --git a/common/src/main/java/cn/zbx1425/mtrsteamloco/data/ScriptedCustomTrains.java b/common/src/main/java/cn/zbx1425/mtrsteamloco/data/ScriptedCustomTrains.java index 7e3a3a46..ed2e776e 100644 --- a/common/src/main/java/cn/zbx1425/mtrsteamloco/data/ScriptedCustomTrains.java +++ b/common/src/main/java/cn/zbx1425/mtrsteamloco/data/ScriptedCustomTrains.java @@ -58,7 +58,7 @@ public static void init(ResourceManager resourceManager) { scripts.put(scriptLocation, null); } } - scriptContext.load("Train " + entry.getKey(), resourceManager, scripts); + scriptContext.load("Train " + entry.getKey(), "Train", resourceManager, scripts); boolean dummyBaseTrain = jsonObject.has("base_type"); String baseTrainType = dummyBaseTrain ? jsonObject.get("base_type").getAsString() : prevTrainProp.baseTrainType; diff --git a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/AbstractScriptContext.java b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/AbstractScriptContext.java index 6ecbeb83..b9ee479f 100644 --- a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/AbstractScriptContext.java +++ b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/AbstractScriptContext.java @@ -22,8 +22,6 @@ public abstract class AbstractScriptContext { public abstract Object getWrapperObject(); - public abstract String getContextTypeName(); - public abstract boolean isBearerAlive(); public void setDebugInfo(String key, Object value) { diff --git a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/ScriptHolder.java b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/ScriptHolder.java index b3981655..c4cd6419 100644 --- a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/ScriptHolder.java +++ b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/ScriptHolder.java @@ -37,10 +37,12 @@ public class ScriptHolder { public Exception failException = null; public String name; + public String contextTypeName; private Map scripts; - public void load(String name, ResourceManager resourceManager, Map scripts) throws Exception { + public void load(String name, String contextTypeName, ResourceManager resourceManager, Map scripts) throws Exception { this.name = name; + this.contextTypeName = contextTypeName; this.scripts = scripts; Context rhinoCtx = Context.enter(); rhinoCtx.setLanguageVersion(Context.VERSION_ES6); @@ -105,8 +107,11 @@ public void load(String name, ResourceManager resourceManager, Map target) { diff --git a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/eyecandy/EyeCandyScriptContext.java b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/eyecandy/EyeCandyScriptContext.java index f55fce1d..464a1bd2 100644 --- a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/eyecandy/EyeCandyScriptContext.java +++ b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/eyecandy/EyeCandyScriptContext.java @@ -37,11 +37,6 @@ public Object getWrapperObject() { return entity; } - @Override - public String getContextTypeName() { - return "Block"; - } - @Override public boolean isBearerAlive() { return !entity.isRemoved(); diff --git a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/train/TrainScriptContext.java b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/train/TrainScriptContext.java index 37cc9e5c..692a9d75 100644 --- a/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/train/TrainScriptContext.java +++ b/common/src/main/java/cn/zbx1425/mtrsteamloco/render/scripting/train/TrainScriptContext.java @@ -51,11 +51,6 @@ public Object getWrapperObject() { return trainExtra; } - @Override - public String getContextTypeName() { - return "Train"; - } - @Override public boolean isBearerAlive() { return !train.isRemoved && ClientData.TRAINS.contains(train);