diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 77f25efd0..6a8b80ba9 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -351,6 +351,7 @@ public class ScriptContainer implements IScriptUnit { } this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase()); this.evaluated = false; + this.lastGlobalsVersion = -1; } } diff --git a/src/main/java/noppes/npcs/controllers/data/AuctionClaim.java b/src/main/java/noppes/npcs/controllers/data/AuctionClaim.java index 604ff1023..534e7ae6d 100644 --- a/src/main/java/noppes/npcs/controllers/data/AuctionClaim.java +++ b/src/main/java/noppes/npcs/controllers/data/AuctionClaim.java @@ -2,6 +2,7 @@ package noppes.npcs.controllers.data; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.handler.data.IAuctionClaim; import noppes.npcs.api.item.IItemStack; import noppes.npcs.config.ConfigMarket; @@ -209,9 +210,7 @@ public class AuctionClaim implements IAuctionClaim { compound.setInteger("Type", type.ordinal()); if (item != null) { - NBTTagCompound itemTag = new NBTTagCompound(); - item.writeToNBT(itemTag); - compound.setTag("Item", itemTag); + compound.setTag("Item", NoppesUtilServer.writeItem(item, new NBTTagCompound())); } compound.setString("ItemName", itemName != null ? itemName : ""); @@ -235,7 +234,7 @@ public class AuctionClaim implements IAuctionClaim { type = EnumClaimType.fromOrdinal(compound.getInteger("Type")); if (compound.hasKey("Item")) { - item = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Item")); + item = NoppesUtilServer.readItem(compound.getCompoundTag("Item")); } else { item = null; } diff --git a/src/main/java/noppes/npcs/controllers/data/AuctionListing.java b/src/main/java/noppes/npcs/controllers/data/AuctionListing.java index 93fc70674..0c021174c 100644 --- a/src/main/java/noppes/npcs/controllers/data/AuctionListing.java +++ b/src/main/java/noppes/npcs/controllers/data/AuctionListing.java @@ -2,6 +2,7 @@ package noppes.npcs.controllers.data; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.handler.data.IAuctionListing; import noppes.npcs.api.item.IItemStack; import noppes.npcs.config.ConfigMarket; @@ -214,9 +215,7 @@ public class AuctionListing implements IAuctionListing { compound.setString("SellerName", sellerName != null ? sellerName : ""); if (item != null) { - NBTTagCompound itemTag = new NBTTagCompound(); - item.writeToNBT(itemTag); - compound.setTag("Item", itemTag); + compound.setTag("Item", NoppesUtilServer.writeItem(item, new NBTTagCompound())); } compound.setLong("StartingPrice", startingPrice); @@ -243,7 +242,7 @@ public class AuctionListing implements IAuctionListing { sellerName = compound.getString("SellerName"); if (compound.hasKey("Item")) { - item = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Item")); + item = NoppesUtilServer.readItem(compound.getCompoundTag("Item")); } startingPrice = compound.getLong("StartingPrice"); diff --git a/src/main/java/noppes/npcs/controllers/data/DataScript.java b/src/main/java/noppes/npcs/controllers/data/DataScript.java index 1d98933ef..14f5544da 100644 --- a/src/main/java/noppes/npcs/controllers/data/DataScript.java +++ b/src/main/java/noppes/npcs/controllers/data/DataScript.java @@ -45,7 +45,7 @@ public class DataScript implements IScriptHandlerPacket { public String scriptLanguage = "ECMAScript"; private EntityNPCInterface npc; public boolean enabled = false; - private long lastGlobalsVersion = -1; + private final Map engineGlobalsVersion = new IdentityHashMap<>(); public ICustomNpc dummyNpc; public IWorld dummyWorld; @@ -273,12 +273,13 @@ public class DataScript implements IScriptHandlerPacket { } long currentGlobalsVersion = NpcAPI.engineObjectsVersion; - if (lastGlobalsVersion != currentGlobalsVersion) { + Long lastVersion = engineGlobalsVersion.get(engine); + if (lastVersion == null || lastVersion != currentGlobalsVersion) { engine.put("API", NpcAPI.Instance()); for (Map.Entry engineObjects : NpcAPI.engineObjects.entrySet()) { engine.put(engineObjects.getKey(), engineObjects.getValue()); } - lastGlobalsVersion = currentGlobalsVersion; + engineGlobalsVersion.put(engine, currentGlobalsVersion); } }