mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 18:09:46 +00:00
add base:abstract_stairs and base:brick_stairs
This commit is contained in:
parent
607bb64307
commit
da89e2d42d
9 changed files with 139 additions and 8 deletions
48
res/content/base/blocks/abstract_stairs.json
Normal file
48
res/content/base/blocks/abstract_stairs.json
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"hidden": true,
|
||||
"model": "custom",
|
||||
"model-name": "stairs",
|
||||
"rotation": "stairs",
|
||||
"uv-lock": true,
|
||||
"hitboxes": [
|
||||
[0, 0.0, 0, 1, 0.5, 1.0],
|
||||
[0, 0.5, 0, 1, 0.5, 0.5]
|
||||
],
|
||||
"light-passing": true,
|
||||
"state-based": {
|
||||
"offset": 0,
|
||||
"bits": 3,
|
||||
"variants": [
|
||||
{
|
||||
"model-name": "stairs_inner_left",
|
||||
"hitboxes": [
|
||||
[0.0, 0.0, 0.0, 1.0, 0.5, 1.0],
|
||||
[0.0, 0.5, 0.0, 1.0, 0.5, 0.5],
|
||||
[0.0, 0.5, 0.5, 0.5, 0.5, 0.5]
|
||||
]
|
||||
},
|
||||
{
|
||||
"model-name": "stairs_inner_right",
|
||||
"hitboxes": [
|
||||
[0.0, 0.0, 0.0, 1.0, 0.5, 1.0],
|
||||
[0.0, 0.5, 0.0, 1.0, 0.5, 0.5],
|
||||
[0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
|
||||
]
|
||||
},
|
||||
{
|
||||
"model-name": "stairs_outer_left",
|
||||
"hitboxes": [
|
||||
[0.0, 0.0, 0.0, 1.0, 0.5, 1.0],
|
||||
[0.0, 0.5, 0.0, 0.5, 0.5, 0.5]
|
||||
]
|
||||
},
|
||||
{
|
||||
"model-name": "stairs_outer_right",
|
||||
"hitboxes": [
|
||||
[0.0, 0.0, 0.0, 1.0, 0.5, 1.0],
|
||||
[0.5, 0.5, 0.0, 0.5, 0.5, 0.5]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
6
res/content/base/blocks/brick_stairs.json
Normal file
6
res/content/base/blocks/brick_stairs.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "base:abstract_stairs",
|
||||
"texture": "brick",
|
||||
"hidden": false,
|
||||
"base:durability": 10.5
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"entities": [
|
||||
"drop",
|
||||
"player",
|
||||
"falling_block"
|
||||
"items": [
|
||||
"bazalt_breaker"
|
||||
],
|
||||
"blocks": [
|
||||
"dirt",
|
||||
|
|
@ -30,9 +28,13 @@
|
|||
"torch",
|
||||
"wooden_door",
|
||||
"coal_ore",
|
||||
"ice"
|
||||
"ice",
|
||||
"brick_stairs",
|
||||
"abstract_stairs"
|
||||
],
|
||||
"items": [
|
||||
"bazalt_breaker"
|
||||
"entities": [
|
||||
"drop",
|
||||
"player",
|
||||
"falling_block"
|
||||
]
|
||||
}
|
||||
65
res/content/base/scripts/abstract_stairs.lua
Normal file
65
res/content/base/scripts/abstract_stairs.lua
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
-- variants
|
||||
local DEFAULT = 0
|
||||
local INNER_LEFT = 1
|
||||
local INNER_RIGHT = 2
|
||||
local OUTER_LEFT = 3
|
||||
local OUTER_RIGHT = 4
|
||||
|
||||
local function get_stairs_info(id, x, y, z)
|
||||
if block.get(x, y, z) ~= id then
|
||||
return nil
|
||||
end
|
||||
local zx, _, zz = block.get_Z(x, y, z)
|
||||
local _, half = block.get_Y(x, y, z)
|
||||
return -zx, -zz, half
|
||||
end
|
||||
|
||||
local function detect_variant(id, x, y, z)
|
||||
local bx, bz, half = get_stairs_info(id, x, y, z)
|
||||
local lx, _, lz = block.get_X(x, y, z)
|
||||
lx, lz = -lx, -lz
|
||||
|
||||
local function is_oriented_same(ox, oz)
|
||||
local nbx, nbz, nhalf = get_stairs_info(id, x + ox, y, z + oz)
|
||||
return nbx == bx and nbz == bz and nhalf == half
|
||||
end
|
||||
|
||||
local function corner_side(ox, oz, sign)
|
||||
local nbx, nbz, nhalf = get_stairs_info(id, x + ox, y, z + oz)
|
||||
if nbx == nil or nhalf ~= half or nbx * bx + nbz * bz ~= 0 then
|
||||
return nil
|
||||
end
|
||||
if is_oriented_same(nbx * sign, nbz * sign) then
|
||||
return nil
|
||||
end
|
||||
return nbx == lx and nbz == lz
|
||||
end
|
||||
|
||||
local left = corner_side(bx, bz, -1)
|
||||
if left ~= nil then
|
||||
return left and OUTER_LEFT or OUTER_RIGHT
|
||||
end
|
||||
left = corner_side(-bx, -bz, 1)
|
||||
if left ~= nil then
|
||||
return left and INNER_LEFT or INNER_RIGHT
|
||||
end
|
||||
return DEFAULT
|
||||
end
|
||||
|
||||
local function refresh(x, y, z, keep_variant)
|
||||
local variant = detect_variant(block.get(x, y, z), x, y, z)
|
||||
if keep_variant and variant == DEFAULT then
|
||||
return
|
||||
end
|
||||
if block.get_variant(x, y, z) ~= variant then
|
||||
block.set_variant(x, y, z, variant)
|
||||
end
|
||||
end
|
||||
|
||||
function on_placed(x, y, z)
|
||||
refresh(x, y, z, false)
|
||||
end
|
||||
|
||||
function on_update(x, y, z)
|
||||
refresh(x, y, z, true)
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
@box from (0,0,0) to (1,0.5,1) delete (top,north)
|
||||
@box from (0,0.5,0) to (1,1,0.5) delete (bottom,north)
|
||||
@rect from (0,0.5,0.5) right (1,0,0) up (0,0,0.5) texture "$2"
|
||||
@rect from (1.0,0.5,1.0) right (-1,0,0) up (0,0,-0.5) texture "$2"
|
||||
@rect from (0,0,0) right (1,0,0) up (0,1,0) texture "$1"
|
||||
|
|
|
|||
3
res/models/stairs_inner_left.vcm
Normal file
3
res/models/stairs_inner_left.vcm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@box from (0,0,0) to (1,0.5,1)
|
||||
@box from (0,0.5,0) to (1,1,0.5) delete (bottom)
|
||||
@box from (0,0.5,0.5) to (0.5,1,1) delete (bottom,north)
|
||||
3
res/models/stairs_inner_right.vcm
Normal file
3
res/models/stairs_inner_right.vcm
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@box from (0,0,0) to (1,0.5,1)
|
||||
@box from (0,0.5,0) to (1,1,0.5) delete (bottom)
|
||||
@box from (0.5,0.5,0.5) to (1,1,1) delete (bottom,north)
|
||||
2
res/models/stairs_outer_left.vcm
Normal file
2
res/models/stairs_outer_left.vcm
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@box from (0,0,0) to (1,0.5,1)
|
||||
@box from (0,0.5,0) to (0.5,1,0.5) delete (bottom)
|
||||
2
res/models/stairs_outer_right.vcm
Normal file
2
res/models/stairs_outer_right.vcm
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@box from (0,0,0) to (1,0.5,1)
|
||||
@box from (0.5,0.5,0) to (1,1,0.5) delete (bottom)
|
||||
Loading…
Add table
Add a link
Reference in a new issue