mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 11:05:12 +00:00
ScriptCustomItem:
-Fixed issue where NBT data was not being sent to the client side, caused by latest commit.
This commit is contained in:
1 parent
7c4965d368
commit
1ce5b7b302
5 files changed
+9
-12
No files matched your search
@@ -294,6 +294,7 @@ public class PacketHandlerServer{
|
||||
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||
if (type == EnumPacketServer.ScriptItemDataGet) {
|
||||
ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
|
||||
iw.loadScriptData();
|
||||
NBTTagCompound compound = iw.getMCNbt();
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
|
||||
@@ -305,7 +306,8 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
|
||||
wrapper.setMCNbt(compound);
|
||||
wrapper.lastInited = -1L;
|
||||
wrapper.loadScriptData();
|
||||
wrapper.loaded = false;
|
||||
wrapper.saveScriptData();
|
||||
player.sendContainerToPlayer(player.inventoryContainer);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ public class GuiScriptItem extends GuiScriptInterface {
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.item.setMCNbt(compound);
|
||||
this.item.loadScriptData();
|
||||
super.setGuiData(compound);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ public class ScriptContainer {
|
||||
if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) {
|
||||
System.setProperty("nashorn.args", "--language=es6");
|
||||
}
|
||||
this.engine = new ScriptEngineManager().getEngineByName(scriptLanguage.toLowerCase());
|
||||
this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
|
||||
|
||||
currentScriptLanguage = scriptLanguage;
|
||||
evaluated = false;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ScriptController {
|
||||
|
||||
public static ScriptController Instance;
|
||||
public static boolean HasStart = false;
|
||||
private ScriptEngineManager manager;
|
||||
private final ScriptEngineManager manager;
|
||||
public Map<String, String> languages = new HashMap<String, String>();
|
||||
public Map<String, String> scripts = new HashMap<String, String>();
|
||||
public long lastLoaded = 0;
|
||||
|
||||
@@ -19,7 +19,6 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
public List<Integer> errored = new ArrayList();
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
public boolean enabled = false;
|
||||
public long lastInited = -1L;
|
||||
public boolean loaded = false;
|
||||
|
||||
public boolean durabilityShow = false;
|
||||
@@ -47,7 +46,6 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
|
||||
public ScriptCustomItem(ItemStack item) {
|
||||
super(item);
|
||||
loadScriptData();
|
||||
loadItemData();
|
||||
}
|
||||
|
||||
@@ -74,16 +72,12 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
if (!this.loaded) {
|
||||
this.loadScriptData();
|
||||
this.loaded = true;
|
||||
if (type != EnumScriptType.INIT) {
|
||||
EventHooks.onScriptItemInit(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isEnabled()) {
|
||||
if (ScriptController.Instance.lastLoaded > this.lastInited) {
|
||||
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||
if (type != EnumScriptType.INIT) {
|
||||
EventHooks.onScriptItemInit(this);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.scripts.size(); i++) {
|
||||
ScriptContainer script = this.scripts.get(i);
|
||||
if (!this.errored.contains(i)) {
|
||||
|
||||
Reference in new issue
Block a user