#How to restrict item within inventory slot??

1 messages · Page 1 of 1 (latest)

molten token
#

How could I make a slot only accept one type of item and not just any?

dapper umbra
#

inside a tick event track all players and their said slot

if the item is not what u want move it to any empty slot

tidal rock
#
const inventory = player.getComponent("inventory").container

for (let i = 0; i < inventory.size; i++) {
  const item = inventory.getItem(i)

  if (item?.typeId !== "minecraft:apple") {
    inventory.setItem(i)
  }
}
molten token
#

Thanks

molten token
tidal rock
#

Just delete the for loop and specify on the .getItem()

#
const inventory = player.getComponent("inventory").container
const item = inventory.getItem(0) // First slot of the inventory

if (item?.typeId !== "minecraft:apple") {
  inventory.setItem(i)
}
dapper umbra
#

Inventory | How to restrict item within inventory slot??