Is there a way I can detect where a user is looking on a block? I'm trying to manually place a slab but i can only place a bottom half slab.
world.beforeEvents.worldInitialize.subscribe(initEvent => {
initEvent.blockTypeRegistry.registerCustomComponent('quark:trowel_buffer', {
beforeOnPlayerPlace: e => {
if(!e.player) return;
let blocks = getHotBarBlocks(e.player);
if(blocks.length === 0) {
e.cancel = true;
return;
}
let blockToPlace = pickRandom(blocks);
let permutation = BlockPermutation.resolve(blockToPlace.typeId);
let cardinalDirState = permutation.getState('minecraft:cardinal_direction');
world.sendMessage(JSON.stringify(permutation.getAllStates()));
if(cardinalDirState) {
let cardinalDir = getCardinalDirection(e.player);
e.permutationToPlace = permutation.withState('minecraft:cardinal_direction', cardinalDir.toLowerCase());
} else {
e.permutationToPlace = permutation;
}
}
});
});
my current code. Assume blockToPlace is a slab itemStack