From 7d4a59d45a52b5a4123777c0dfeb09d9b3117fe7 Mon Sep 17 00:00:00 2001 From: "Luis C.M" <42545778+c0508383@users.noreply.github.com> Date: Tue, 27 Dec 2022 16:46:59 -0600 Subject: [PATCH] IEntity & IWorld: -Added getStoredDataKeys() & getTempDataKeys() functions. --- src/main/java/noppes/npcs/scripted/ScriptWorld.java | 12 ++++++++++++ .../noppes/npcs/scripted/entity/ScriptEntity.java | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/noppes/npcs/scripted/ScriptWorld.java b/src/main/java/noppes/npcs/scripted/ScriptWorld.java index cf5e75a07..ed45bed23 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptWorld.java +++ b/src/main/java/noppes/npcs/scripted/ScriptWorld.java @@ -744,6 +744,10 @@ public class ScriptWorld implements IWorld { tempData.clear(); } + public String[] getTempDataKeys() { + return tempData.keySet().toArray(new String[0]); + } + /** * @param key The key of the data to be returned * @return Returns the stored data @@ -796,6 +800,14 @@ public class ScriptWorld implements IWorld { ScriptController.Instance.shouldSave = true; } + public String[] getStoredDataKeys() { + NBTTagCompound compound = ScriptController.Instance.compound; + if (compound != null) { + return (String[]) compound.func_150296_c().toArray(); + } + return new String[0]; + } + /** * @param x Position x * @param y Position y diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java index 7bbd6cc5b..d4d34e25b 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptEntity.java @@ -511,6 +511,10 @@ public class ScriptEntity implements IEntity { tempData.clear(); } + public String[] getTempDataKeys() { + return tempData.keySet().toArray(new String[0]); + } + /** * @param key The key of the data to be returned * @return Returns the stored data @@ -572,6 +576,11 @@ public class ScriptEntity implements IEntity { entity.getEntityData().removeTag("CNPCStoredData"); } + public String[] getStoredDataKeys() { + NBTTagCompound compound = getStoredCompound(); + return (String[]) compound.func_150296_c().toArray(); + } + private NBTTagCompound getStoredCompound(){ NBTTagCompound compound = entity.getEntityData().getCompoundTag("CNPCStoredData"); if(compound == null)