Proper directional blocks

This commit is contained in:
2026-09-29 00:10:22 -03:00
parent 445148e812
commit ad7f34a99e
9 changed files with 69 additions and 37 deletions
+8
View File
@@ -16,6 +16,9 @@
"drops": "bworld:furnace",
"interactive": true,
"variants": {
"facing=1": { "y": 90 },
"facing=2": { "y": 180 },
"facing=3": { "y": 270 },
"lit=1": {
"textures": {
"front": "bworld:furnace_front_lit",
@@ -30,6 +33,11 @@
"name": "lit",
"bits": 1,
"default": 0
},
{
"name": "facing",
"bits": 2,
"default": 0
}
],
"components": {
+8
View File
@@ -9,6 +9,9 @@
"side": "farmersdelight:stove_side"
},
"variants": {
"facing=1": { "y": 90 },
"facing=2": { "y": 180 },
"facing=3": { "y": 270 },
"lit=1": {
"textures": {
"top": "farmersdelight:stove_top_on",
@@ -29,6 +32,11 @@
"name": "lit",
"bits": 1,
"default": 1
},
{
"name": "facing",
"bits": 2,
"default": 0
}
],
"components": {
-12
View File
@@ -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);