Trapdoors

This commit is contained in:
2026-10-03 17:52:58 -03:00
parent 91655c28c5
commit 63e6248f9f
35 changed files with 927 additions and 23 deletions
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:acacia_trapdoor",
"name": "Acacia Trapdoor",
"textures": "bworld:acacia_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:acacia_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:birch_trapdoor",
"name": "Birch Trapdoor",
"textures": "bworld:birch_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:birch_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:cherry_trapdoor",
"name": "Cherry Trapdoor",
"textures": "bworld:cherry_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:cherry_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:dark_oak_trapdoor",
"name": "Dark Oak Trapdoor",
"textures": "bworld:dark_oak_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:oak_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:jungle_trapdoor",
"name": "Jungle Trapdoor",
"textures": "bworld:jungle_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:jungle_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:oak_trapdoor",
"name": "Oak Trapdoor",
"textures": "bworld:oak_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:oak_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"format_version": 1,
"block": {
"id": "bworld:spruce_trapdoor",
"name": "Spruce Trapdoor",
"textures": "bworld:spruce_trapdoor",
"model": "bworld:trapdoor_bottom",
"item_model": "bworld:trapdoor_bottom",
"render_layer": "cutout",
"states": [
{
"name": "facing",
"bits": 2,
"default": 0
},
{
"name": "half",
"bits": 1,
"default": 0
},
{
"name": "open",
"bits": 1,
"default": 0
}
],
"variants": {
"open=0,half=1": {
"model": "bworld:trapdoor_top"
},
"open=1,half=0": {
"model": "bworld:trapdoor_open"
},
"open=1,half=1": {
"model": "bworld:trapdoor_open_top"
},
"facing=1": {
"y": 90
},
"facing=2": {
"y": 180
},
"facing=3": {
"y": 270
}
},
"mining": {
"toughness": 3,
"tool": "axe"
},
"drops": "bworld:spruce_trapdoor",
"interactive": true,
"components": {
"bworld:trapdoor": {}
}
}
}
+43
View File
@@ -0,0 +1,43 @@
{
"format_version": 1,
"model": {
"id": "bworld:trapdoor_bottom",
"elements": [
{
"from": [0, 0, 0],
"to": [16, 3, 16],
"faces": {
"top": {
"texture": "#texture",
"uv": [0, 0, 16, 16]
},
"bottom": {
"texture": "#texture",
"uv": [0, 0, 16, 16],
"cullface": "bottom"
},
"north": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "north"
},
"south": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "south"
},
"west": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "west"
},
"east": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "east"
}
}
}
]
}
}
+43
View File
@@ -0,0 +1,43 @@
{
"format_version": 1,
"model": {
"id": "bworld:trapdoor_open",
"elements": [
{
"from": [0, 0, 13],
"to": [16, 16, 16],
"faces": {
"north": {
"texture": "#texture",
"uv": [0, 0, 16, 16]
},
"south": {
"texture": "#texture",
"uv": [16, 0, 0, 16],
"cullface": "south"
},
"west": {
"texture": "#texture",
"uv": [16, 0, 13, 16],
"cullface": "west"
},
"east": {
"texture": "#texture",
"uv": [13, 0, 16, 16],
"cullface": "east"
},
"top": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "top"
},
"bottom": {
"texture": "#texture",
"uv": [0, 13, 16, 16],
"cullface": "bottom"
}
}
}
]
}
}
+43
View File
@@ -0,0 +1,43 @@
{
"format_version": 1,
"model": {
"id": "bworld:trapdoor_open_top",
"elements": [
{
"from": [0, 0, 13],
"to": [16, 16, 16],
"faces": {
"north": {
"texture": "#texture",
"uv": [16, 16, 0, 0]
},
"south": {
"texture": "#texture",
"uv": [0, 16, 16, 0],
"cullface": "south"
},
"west": {
"texture": "#texture",
"uv": [16, 16, 13, 0],
"cullface": "west"
},
"east": {
"texture": "#texture",
"uv": [13, 16, 16, 0],
"cullface": "east"
},
"top": {
"texture": "#texture",
"uv": [16, 16, 0, 13],
"cullface": "top"
},
"bottom": {
"texture": "#texture",
"uv": [16, 13, 0, 16],
"cullface": "bottom"
}
}
}
]
}
}
+43
View File
@@ -0,0 +1,43 @@
{
"format_version": 1,
"model": {
"id": "bworld:trapdoor_top",
"elements": [
{
"from": [0, 13, 0],
"to": [16, 16, 16],
"faces": {
"top": {
"texture": "#texture",
"uv": [0, 0, 16, 16],
"cullface": "top"
},
"bottom": {
"texture": "#texture",
"uv": [0, 0, 16, 16]
},
"north": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "north"
},
"south": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "south"
},
"west": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "west"
},
"east": {
"texture": "#texture",
"uv": [0, 16, 16, 13],
"cullface": "east"
}
}
}
]
}
}
@@ -0,0 +1,17 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"PPP",
"PPP"
],
"key": {
"P": "bworld:acacia_planks"
},
"result": {
"id": "bworld:acacia_trapdoor",
"count": 2
}
}
}
@@ -0,0 +1,17 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"PPP",
"PPP"
],
"key": {
"P": "bworld:birch_planks"
},
"result": {
"id": "bworld:birch_trapdoor",
"count": 2
}
}
}
@@ -0,0 +1,17 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"PPP",
"PPP"
],
"key": {
"P": "bworld:cherry_planks"
},
"result": {
"id": "bworld:cherry_trapdoor",
"count": 2
}
}
}
@@ -0,0 +1,17 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"PPP",
"PPP"
],
"key": {
"P": "bworld:jungle_planks"
},
"result": {
"id": "bworld:jungle_trapdoor",
"count": 2
}
}
}
@@ -0,0 +1,17 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"PPP",
"PPP"
],
"key": {
"P": "bworld:planks"
},
"result": {
"id": "bworld:oak_trapdoor",
"count": 2
}
}
}
@@ -0,0 +1,17 @@
{
"format_version": 1,
"recipe": {
"type": "shaped",
"pattern": [
"PPP",
"PPP"
],
"key": {
"P": "bworld:spruce_planks"
},
"result": {
"id": "bworld:spruce_trapdoor",
"count": 2
}
}
}
+24
View File
@@ -9,6 +9,7 @@ export function setup(ctx: ServerContext) {
register_furnace(ctx);
register_smithing_table(ctx);
register_fence(ctx);
register_trapdoor(ctx);
register_farming(ctx);
register_fishing(ctx);
register_curios(ctx);
@@ -58,6 +59,29 @@ function register_fence(ctx: ServerContext) {
});
}
// the facing state's values, the way a block's y turns it
const FACINGS = ["north", "east", "south", "west"];
// a trapdoor opens and closes when right clicked, like a wooden one in minecraft. placed against the side of a block
// it hangs from that block, in the half of the side that was clicked. placed on top of a block it lies in the bottom
// half, and under one in the top half, swinging open away from the player, like minecraft's TrapDoorBlock
function register_trapdoor(ctx: ServerContext) {
ctx.components.register_block("bworld:trapdoor", {
state_for_placement(placement): Record<string, number> {
if (placement.face !== "top" && placement.face !== "bottom") {
return { facing: FACINGS.indexOf(placement.face), half: placement.hit[1] > 0.5 ? 1 : 0 };
}
// facing already faces the player
return { half: placement.face === "top" ? 0 : 1 };
},
on_interact(block) {
const open = ctx.world.get_state(block.x, block.y, block.z, "open") ?? 0;
ctx.world.set_state(block.x, block.y, block.z, "open", open ? 0 : 1);
return true;
},
});
}
// the container a block keeps its items in, made the first time it's needed. blocks placed before tile data
// existed don't have one yet
function block_container(ctx: ServerContext, block: BlockRef, size: number): Container {
@@ -0,0 +1,13 @@
{
"format_version": 1,
"tag": {
"values": [
"bworld:oak_trapdoor",
"bworld:spruce_trapdoor",
"bworld:birch_trapdoor",
"bworld:jungle_trapdoor",
"bworld:acacia_trapdoor",
"bworld:cherry_trapdoor"
]
}
}
@@ -0,0 +1,13 @@
{
"format_version": 1,
"tag": {
"values": [
"bworld:oak_trapdoor",
"bworld:spruce_trapdoor",
"bworld:birch_trapdoor",
"bworld:jungle_trapdoor",
"bworld:acacia_trapdoor",
"bworld:cherry_trapdoor"
]
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB