zh_cn:tutorial:inventory
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
zh_cn:tutorial:inventory [2023/08/28 10:14] – [从物品栏(或任何物品栏)中提取和放入] wjz_p | zh_cn:tutorial:inventory [2023/08/28 10:14] (current) – [从物品栏(或任何物品栏)中提取和放入] wjz_p | ||
---|---|---|---|
Line 196: | Line 196: | ||
[...] | [...] | ||
@Override | @Override | ||
- | public | + | public |
... | ... | ||
if (!player.getStackInHand(hand).isEmpty()) { | if (!player.getStackInHand(hand).isEmpty()) { | ||
... | ... | ||
} else { | } else { | ||
- | // 如果玩家没有持有任何东西,我们依次将方块实体中的物品给予玩家 | + | // If the player is not holding anything we'll get give him the items in the block entity one by one |
- | + | ||
- | // | + | // |
- | if (!blockEntity.getInvStack(1).isEmpty()) { | + | if (!blockEntity.getStack(1).isEmpty()) { |
- | // 给予玩家物品栏中的物品堆 | + | // Give the player the stack in the inventory |
- | player.inventory.offerOrDrop(world, | + | player.getInventory().offerOrDrop(blockEntity.getStack(1)); |
// Remove the stack from the inventory | // Remove the stack from the inventory | ||
- | blockEntity.removeInvStack(1); | + | blockEntity.removeStack(1); |
- | } else if (!blockEntity.getInvStack(0).isEmpty()) { | + | } else if (!blockEntity.getStack(0).isEmpty()) { |
- | player.inventory.offerOrDrop(world, | + | player.getInventory().offerOrDrop(blockEntity.getStack(0)); |
- | blockEntity.removeInvStack(0); | + | blockEntity.removeStack(0); |
} | } | ||
} | } | ||
- | | + | |
- | return | + | return |
} | } | ||
} | } |
zh_cn/tutorial/inventory.txt · Last modified: 2023/08/28 10:14 by wjz_p