diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index f2d5f5f2b..ba381ec0e 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -428,6 +428,29 @@ public class ScriptDBCPlayer extends ScriptPlayer i return compound.getCompoundTag("JRMCEP").getString("extracode"); } + public void setInventoryItem(byte slot, IItemStack itemStack) { + NBTTagCompound compound = new NBTTagCompound(); + this.player.writeToNBT(compound); + + NBTTagList newList = new NBTTagList(); + NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10); + for (int i = 0; i < list.tagCount(); i++) { + if (list.getCompoundTagAt(i).getByte("Slot") != slot) { + newList.appendTag(list.getCompoundTagAt(i)); + } + } + + NBTTagCompound compoundItem = new NBTTagCompound(); + if (itemStack != null) { + itemStack.getMCItemStack().writeToNBT(compoundItem); + } + compoundItem.setByte("Slot", slot); + newList.appendTag(compoundItem); + + compound.getCompoundTag("JRMCEP").setTag("dbcExtraInvTag", newList); + this.player.readFromNBT(compound); + } + public IItemStack[] getInventory(){ NBTTagCompound compound = new NBTTagCompound(); this.player.writeToNBT(compound); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java b/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java index 73531eafb..1eb7aa022 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/entity/IDBCPlayer.java @@ -45,6 +45,22 @@ public interface IDBCPlayer extends IPlayer { void setExtraCode(String extraCode); String getExtraCode(); + /** + * @param slot The DBC extra inventory slot the item stack parameter will go into: + * 0 - Weight + * 1 - Body + * 2 - Head + * 3 - 4th Vanity Slot Down to the left + * 4 - 3rd Vanity Slot Down to the left + * 5 - 2nd Vanity Slot Down to the left + * 6 - 1st Vanity Slot Down to the left + * 7 - 4th Vanity Slot Down to the right + * 8 - 3rd Vanity Slot Down to the right + * 9 - 2nd Vanity Slot Down to the right + * 10 - 1st Vanity Slot Down to the right + * @param itemStack The item stack to be set into the slot. Set to null to remove the stack in that slot. + */ + void setInventoryItem(byte slot, IItemStack itemStack); IItemStack[] getInventory(); void setForm(byte form);