Deleagted all ScriptContainer NBT based creation to IScriptUnit.createFromNBT

This commit is contained in:
bigguy345 committed 2026-01-13 22:16:51 +02:00
1 parent fbcda09fe2
commit 73db727c47
14 files changed
+61 -36

No files matched your search

@@ -105,11 +105,10 @@ public class PlayerDataScript implements INpcScriptHandler {
if (player != null) {
scripts.clear();
for (IScriptUnit script : ScriptController.Instance.playerScripts.scripts) {
if (script instanceof ScriptContainer) {
ScriptContainer s = new ScriptContainer(this);
s.readFromNBT(((ScriptContainer) script).writeToNBT(new NBTTagCompound()));
scripts.add(s);
}
// Clone the script unit by writing to NBT and reading back with factory
NBTTagCompound nbt = script.writeToNBT(new NBTTagCompound());
IScriptUnit cloned = IScriptUnit.createFromNBT(nbt, this);
scripts.add(cloned);
}
}
lastPlayerUpdate = ScriptController.Instance.lastPlayerUpdate;