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 [2020/10/15 19:50] – [Implementing Inventory] Changed "canPlayerUseInv(..." to "canPlayerUse(..." to reflect current mappings nshak | tutorial:inventory [2020/12/27 16:21] – [Inventory] Update Inventory and SidedInventory to recent yarn names (thank you Arbee!) technici4n | ||
---|---|---|---|
Line 188: | Line 188: | ||
if (!player.getStackInHand(hand).isEmpty()) { | if (!player.getStackInHand(hand).isEmpty()) { | ||
// Check what is the first open slot and put an item from the player' | // Check what is the first open slot and put an item from the player' | ||
- | if (blockEntity.getInvStack(0).isEmpty()) { | + | if (blockEntity.getStack(0).isEmpty()) { |
// Put the stack the player is holding into the inventory | // Put the stack the player is holding into the inventory | ||
- | blockEntity.setInvStack(0, player.getStackInHand(hand).copy()); | + | blockEntity.setStack(0, player.getStackInHand(hand).copy()); |
// Remove the stack from the player' | // Remove the stack from the player' | ||
player.getStackInHand(hand).setCount(0); | player.getStackInHand(hand).setCount(0); | ||
- | } else if (blockEntity.getInvStack(1).isEmpty()) { | + | } else if (blockEntity.getStack(1).isEmpty()) { |
- | blockEntity.setInvStack(1, player.getStackInHand(hand).copy()); | + | blockEntity.setStack(1, player.getStackInHand(hand).copy()); |
player.getStackInHand(hand).setCount(0); | player.getStackInHand(hand).setCount(0); | ||
} else { | } else { | ||
// If the inventory is full we'll print it's contents | // If the inventory is full we'll print it's contents | ||
System.out.println(" | System.out.println(" | ||
- | + blockEntity.getInvStack(0) + " and the second slot holds " + blockEntity.getInvStack(1)); | + | + blockEntity.getStack(0) + " and the second slot holds " + blockEntity.getStack(1)); |
} | } | ||
} | } | ||
Line 222: | Line 222: | ||
// Find the first slot that has an item and give it to the player | // Find the first slot that has an item and give it to the player | ||
- | if (!blockEntity.getInvStack(1).isEmpty()) { | + | if (!blockEntity.getStack(1).isEmpty()) { |
// Give the player the stack in the inventory | // Give the player the stack in the inventory | ||
- | player.inventory.offerOrDrop(world, | + | player.inventory.offerOrDrop(world, |
// 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.inventory.offerOrDrop(world, |
- | blockEntity.removeInvStack(0); | + | blockEntity.removeStack(0); |
} | } | ||
} | } | ||
Line 257: | Line 257: | ||
@Override | @Override | ||
- | public boolean | + | public boolean |
return direction != Direction.UP; | return direction != Direction.UP; | ||
} | } | ||
@Override | @Override | ||
- | public boolean | + | public boolean |
return true; | return true; | ||
} | } |
tutorial/inventory.txt · Last modified: 2023/11/06 23:28 by binaris00