MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / readFromNBT

Method readFromNBT

src/main/java/net/minecraft/item/ItemStack.java:201–229  ·  view source on GitHub ↗

Read the stack fields from a NBT object.

(NBTTagCompound nbt)

Source from the content-addressed store, hash-verified

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.

Callers 2

loadItemStackFromNBTMethod · 0.95
onItemUseMethod · 0.45

Calls 8

getByNameOrIdMethod · 0.95
getItemByIdMethod · 0.95
hasKeyMethod · 0.80
getCompoundTagMethod · 0.80
getStringMethod · 0.45
getShortMethod · 0.45
getByteMethod · 0.45
updateItemStackNBTMethod · 0.45

Tested by

no test coverage detected