#How do i replace block when placed

14 messages · Page 1 of 1 (latest)

lone berryBOT
#

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

bleak estuary
#

well if you want to affect a block when being right-clicked by an item, you could use this code:

ItemEvents.rightClicked('item_id', event => {
  const { player, item, target: {block} } = event
  ...
})
#

as for things like smelting, not 100% sure, but it sounds possible

azure dove
#

where should i put the block id?

bleak estuary
#

you could just do something like if (block.id != 'your_custom_block_id') return

#

then put all of the block-affecting code after

azure dove
#

what about the nbt inventory data and its state

bleak estuary
#

what do you mean

#

you mean like the torch?

#

for flint and steel you can just damage it. there should be a damage method

#

as for the torch, you can decrease its total count by one

azure dove
#

for example i want to replace the vanilla container with my custom container but also transfer the inventory that was inside the vanilla container to my custom container

bleak estuary
#

that sounds like block entity or nbt stuff

#

which I haven't worked with before