mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
add module 'item_models'
This commit is contained in:
parent
cf448def59
commit
27a7d7eb44
2 changed files with 38 additions and 25 deletions
32
res/modules/item_models.lua
Normal file
32
res/modules/item_models.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
local function setup(id, rig)
|
||||
local icon = item.icon(id)
|
||||
local size = {1.0, 1.0, 1.0}
|
||||
if icon:find("^block%-previews%:") then
|
||||
local bid = block.index(icon:sub(16))
|
||||
model = block.get_model(bid)
|
||||
if model == "X" then
|
||||
size = {1.0, 0.3, 1.0}
|
||||
rig:set_model(0, "drop-item")
|
||||
rig:set_texture("$0", icon)
|
||||
else
|
||||
if model == "aabb" then
|
||||
local rot = block.get_rotation_profile(bid) == "pipe" and 4 or 0
|
||||
size = block.get_hitbox(bid, rot)[2]
|
||||
vec3.mul(size, 2.0, size)
|
||||
end
|
||||
local textures = block.get_textures(bid)
|
||||
for i,t in ipairs(textures) do
|
||||
rig:set_texture("$"..tostring(i-1), "blocks:"..textures[i])
|
||||
end
|
||||
end
|
||||
else
|
||||
size = {1.0, 0.3, 1.0}
|
||||
rig:set_model(0, "drop-item")
|
||||
rig:set_texture("$0", icon)
|
||||
end
|
||||
return size
|
||||
end
|
||||
|
||||
return {
|
||||
setup=setup,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue