#How can i remove 1x of the holding item

1 messages · Page 1 of 1 (latest)

polar oasis
#

I want to remove 1 amount of the currently Holding Item, already have:

const container = player.getComponent("minecraft:inventory")?.container
twin shale
#
const equip = <Entity>.getComponent('equippable');
const item = equip.getEquipment('Mainhand');

if(!item) return;

item.amount--;
equip.setEquipment('Mainhand', item);
river thunder
#
        player.getComponent(`equippable`).getEquipmentSlot(EquipmentSlot.Mainhand)
``` I know so far helps with there holding
#

Oh he already helped

#

Idk how to remove 1

polar oasis
#

Ty that helped me

polar oasis
twin shale
#

Oh true!

prime mountain
#

You can do
container.setItem(x, (item.amount === 1 ? undefined : (item.amount--, item)))

polar oasis
polar oasis
#
let x = 2
#

?

#

yes

#

and now?

#

let x = 2

#

HOW

#
let x = 2