Read the stack fields from a NBT object.
(NBTTagCompound nbt)
| 199 | * Read the stack fields from a NBT object. |
| 200 | */ |
| 201 | public void readFromNBT(NBTTagCompound nbt) |
| 202 | { |
| 203 | if (nbt.hasKey("id", 8)) |
| 204 | { |
| 205 | this.item = Item.getByNameOrId(nbt.getString("id")); |
| 206 | } |
| 207 | else |
| 208 | { |
| 209 | this.item = Item.getItemById(nbt.getShort("id")); |
| 210 | } |
| 211 | |
| 212 | this.stackSize = nbt.getByte("Count"); |
| 213 | this.itemDamage = nbt.getShort("Damage"); |
| 214 | |
| 215 | if (this.itemDamage < 0) |
| 216 | { |
| 217 | this.itemDamage = 0; |
| 218 | } |
| 219 | |
| 220 | if (nbt.hasKey("tag", 10)) |
| 221 | { |
| 222 | this.stackTagCompound = nbt.getCompoundTag("tag"); |
| 223 | |
| 224 | if (this.item != null) |
| 225 | { |
| 226 | this.item.updateItemStackNBT(this.stackTagCompound); |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Returns maximum size of the stack. |
no test coverage detected