tutorial:inventory
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
tutorial:inventory [2019/08/07 06:59] – fudge | tutorial:inventory [2019/08/21 20:24] – change giveItemStack to inventory.offerOrDrop fudge | ||
---|---|---|---|
Line 198: | Line 198: | ||
// If the player is not holding anything we'll get give him the items in the block entity one by one | // If the player is not holding anything we'll get give him the items in the block entity one by one | ||
- | | + | // Find the first slot that has an item and give it to the player |
if (!blockEntity.getInvStack(1).isEmpty()) { | if (!blockEntity.getInvStack(1).isEmpty()) { | ||
// Give the player the stack in the inventory | // Give the player the stack in the inventory | ||
- | player.giveItemStack(blockEntity.getInvStack(1)); | + | player.inventory.offerOrDrop(world, |
// Remove the stack from the inventory | // Remove the stack from the inventory | ||
blockEntity.removeInvStack(1); | blockEntity.removeInvStack(1); | ||
} else if (!blockEntity.getInvStack(0).isEmpty()) { | } else if (!blockEntity.getInvStack(0).isEmpty()) { | ||
- | player.giveItemStack(blockEntity.getInvStack(0)); | + | player.inventory.offerOrDrop(world, |
blockEntity.removeInvStack(0); | blockEntity.removeInvStack(0); | ||
} | } |
tutorial/inventory.txt · Last modified: 2023/11/06 23:28 by binaris00