#placement filter when using set block or similar methods

1 messages · Page 1 of 1 (latest)

left tusk
#

Is there an easy way to have any script based placement method honor the placement rules of a block without having to also script the breaking of it and redoing all those rules script side?

north comet
left tusk
#

be easier to just check the block tags same as in the block JSON at that point though wouldn't it?

atomic garden
#

There is the canPlace method, but its currently in beta. I haven't used it myself yet though.
-# (I could use this to make an offhand addon probably)

/**
 * @beta
 * @remarks
 * Checks to see whether it is valid to place the specified
 * block type or block permutation, on a specified face on this
 * block.
 *
 * @param blockToPlace
 * Block type or block permutation to check placement for.
 * @param faceToPlaceOn
 * Optional specific face of this block to check placement
 * against.
 * @returns
 * Returns `true` if the block type or permutation can be
 * placed on this block, else `false`.
 * @throws This function can throw errors.
 *
 * {@link Error}
 *
 * {@link LocationInUnloadedChunkError}
 *
 * {@link LocationOutOfWorldBoundariesError}
 */
canPlace(blockToPlace: BlockPermutation | BlockType | string, faceToPlaceOn?: Direction): boolean;
#

That's a method on the Block class.