Proper directional blocks
This commit is contained in:
@@ -317,9 +317,6 @@ function register_cooking_pot(ctx: ServerContext) {
|
||||
|
||||
// cutting board
|
||||
|
||||
// its facing state, the way its front points: north, east, south or west, like the java mod's HORIZONTAL_FACING
|
||||
const FACINGS = 4;
|
||||
|
||||
// a farmersdelight:cutting recipe, like the java mod's: one ingredient (an item, or a list any of which will do), the
|
||||
// tool type that cuts it, and everything one of it is cut into
|
||||
interface CuttingRecipe {
|
||||
@@ -364,15 +361,6 @@ function register_cutting_board(ctx: ServerContext) {
|
||||
const set_on_board = (block: BlockRef, item: ItemStack | undefined) =>
|
||||
ctx.world.set_block_item(block.x, block.y, block.z, item);
|
||||
|
||||
// placed facing whoever placed it, like getStateForPlacement. they look along (-sin yaw, -cos yaw), so the way
|
||||
// back to them is (sin yaw, cos yaw), and north (-z) is 0 going clockwise
|
||||
ctx.events.after.block_place.subscribe(({ player, block }) => {
|
||||
if (block.id !== "farmersdelight:cutting_board") return;
|
||||
const quarter = Math.round((Math.PI - player.yaw) / (Math.PI / 2));
|
||||
const facing = ((quarter % FACINGS) + FACINGS) % FACINGS;
|
||||
ctx.world.set_state(block.x, block.y, block.z, "facing", facing);
|
||||
});
|
||||
|
||||
ctx.components.register_block("farmersdelight:cutting_board", {
|
||||
on_interact(block, _params, player) {
|
||||
const held = player.inventory.get(player.selected_slot);
|
||||
|
||||
Reference in New Issue
Block a user