I'm trying to make it so that you can turn a block into its mossy variant by right-clicking the block with a moss block.
The function below works like a charm for full blocks.
BlockEvents.rightClicked(bare_block, event => {
const { block, item, player } = event
if (item == moss_item) {
let state = block.blockState // Ensure block state is loaded
// Add the moss
block.set(mossy_block)
block.blockState = state // Restore block state
// Consume the moss item
if (!player.isCreative()){
item.shrink(1);
}
player.swing() //makes the hand swing as if an item was used
}
});```
However, whenever I replace stairs or slabs, the new mossy block is set to the default blockstate...
How can I set a new block with the same blockstate as the previous one?