mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 03:15:42 +00:00
Fix Instance Scripts
This commit is contained in:
1 parent
42e27a873b
commit
7712b21faa
7 files changed
+34
-6
No files matched your search
@@ -315,7 +315,7 @@ public class ConfigClient {
|
||||
7.0,
|
||||
"Distance in blocks at which owner's energy projectiles reach full alpha."
|
||||
);
|
||||
ProximityAlphaDistance = (float) Math.max(1.0, ProximityAlphaDistanceProperty.getDouble(7.0));
|
||||
ProximityAlphaDistance = (float) Math.max(1.0, ProximityAlphaDistanceProperty.getDouble(10.0));
|
||||
|
||||
ProximityAlphaAgeTicksProperty = config.get(
|
||||
RENDERING,
|
||||
|
||||
@@ -71,7 +71,8 @@ public class ScriptContainer implements IScriptUnit {
|
||||
*
|
||||
* @param instanceHandler the script handler for the instance
|
||||
*/
|
||||
public ScriptContainer createInstanceScope(IScriptHandler instanceHandler) {
|
||||
@Override
|
||||
public IScriptUnit createInstanceScope(IScriptHandler instanceHandler) {
|
||||
if (this.engine == null) {
|
||||
this.setEngine(this.getLanguage());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs.controllers.data;
|
||||
import kamkeel.npcs.network.packets.request.script.ChainedAbilityScriptPacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.janino.EventJaninoScript;
|
||||
|
||||
/**
|
||||
* Script handler for chained ability scripts.
|
||||
@@ -30,6 +31,11 @@ public class ChainedAbilityScript extends SingleScriptHandler implements IScript
|
||||
this.chainId = chainId != null ? chainId : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScriptUnit createJaninoScriptUnit() {
|
||||
return new EventJaninoScript(ScriptContext.CHAINED_ABILITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptContext getContext() {
|
||||
return ScriptContext.CHAINED_ABILITY;
|
||||
|
||||
@@ -157,6 +157,17 @@ public interface IScriptUnit {
|
||||
*/
|
||||
void setErrored(boolean errored);
|
||||
|
||||
// ==================== INSTANCE SCOPE ====================
|
||||
|
||||
/**
|
||||
* Create an instance-scoped copy of this script unit for isolated execution.
|
||||
* The instance shares compiled code with the template but has isolated state.
|
||||
*
|
||||
* @param instanceHandler the script handler for the new instance
|
||||
* @return a new IScriptUnit with isolated variable state
|
||||
*/
|
||||
IScriptUnit createInstanceScope(IScriptHandler instanceHandler);
|
||||
|
||||
// ==================== EXECUTION ====================
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@ import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.constants.ScriptContext;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ScriptHookController;
|
||||
import noppes.npcs.controllers.data.IScriptHandler;
|
||||
import noppes.npcs.controllers.data.IScriptUnit;
|
||||
import noppes.npcs.janino.annotations.ParamName;
|
||||
import org.codehaus.commons.compiler.InternalCompilerException;
|
||||
@@ -123,6 +124,15 @@ public abstract class JaninoScript<T> implements IScriptUnit {
|
||||
public void unload() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScriptUnit createInstanceScope(IScriptHandler instanceHandler) {
|
||||
IScriptUnit instance = instanceHandler.createJaninoScriptUnit();
|
||||
if (instance == null) return null;
|
||||
instance.setScript(this.script);
|
||||
instance.setExternalScripts(new ArrayList<>(this.externalScripts));
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
// ==================== COMPILATION ====================
|
||||
|
||||
|
||||
Reference in new issue
Block a user