#How do I remove one item, not the whole stack, from anywhere in a player's inventory?

8 messages · Page 1 of 1 (latest)

jovial salmon
#

So, I'm trying to change the blockstate of a composter. I got that working, but have no idea how to consume an item from the inventory. Also, I can't seem to get the arm to swing upon using the item on the composter.

BlockEvents.rightClicked('minecraft:composter', event => {
  const {player,item} = event

  if (item == 'test_thingy' && event.player.inventory.count('minecraft:redstone')) {
    event.block.set("minecraft:composter", {level: '7'})
  }
  event.player.swingArm(event.hand)
})```

I'm sorry in advance. I'm new to literally anything beyond adding an item or block to the game.
karmic solarBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

jovial salmon
#

How do I remove one item, not the whole stack, from anywhere in a player's inventory?

cunning holly
#

item.count--

jovial salmon
cunning holly
#
let index = event.player.inventory.find('minecraft:redstone')
if (index == -1) console.error('no redstofe dust found')
let redstoneItem = event.player.inventory.get(index)
redstoneItem.count--
tepid torrent
#

isnt itemstack.shrink() safer

cunning holly
#

yes, but that didnt exist in 1.18 and below so im used to use .count--