How do you add an item to inventory? All I have for the section where it gives an item is this: Code: Santa.getInventory(); How do I tell it to add one diamond to the player's inventory?
Thanks What's wrong with this? An error comes up on "Santa" (I named the player Santa instead of p). The error is "cannot be resolved to a type." Code: Santa.getInventory Inventory = Inventory(Inventory.addItem(Material.DIAMOND)); EDIT by Moderator: merged posts, please use the edit button instead of double posting.
@KaiBB The compiler thinks that Santa.getInventory is a Type and you are creating a variable Inventory of type Santa.getInventory
I still don't understand the fix. I don't exactly want you to straight up gimme the fix, but can you tell me HOW to fix it? Please? Thanks!
@KaiBB To understand the fix, you have to understand the problem! But ill give you the answer again. Code: final Inventory inventory = Player.getInventory(); inventory.addItem(ItemStack)
Using add doesn't work. I have exactly what you guys suggested, and it says "The method add(Material) is undefined for type PlayerInventory." Oh you answered my question above. Thanks ^^ EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Sorry, I wasn't quite sure if you could add a material, but figured you could since you tried to Oops, never again
I did what you said, just changed this: Code: addItem(Material.DIAMOND); To this: Code: addItem(new Itemstack(Material.DIAMOND, 1);