add basic chains and lantern model and API

This commit is contained in:
AFCMS 2022-02-08 10:58:25 +01:00
parent 6f44278414
commit ffa9d2d0fd
9 changed files with 305 additions and 0 deletions

@ -0,0 +1,161 @@
local S = minetest.get_translator("mcl_lanterns")
local modpath = minetest.get_modpath("mcl_lanterns")
mcl_lanterns = {}
function mcl_lanterns.register_lantern(name, def)
local itemstring_floor = "mcl_lanterns:"..name.."_floor"
local itemstring_ceiling = "mcl_lanterns:"..name.."_ceiling"
minetest.register_node(itemstring_floor, {
description = def.description,
drawtype = "mesh",
mesh = "mcl_lanterns_lantern_floor.obj",
inventory_image = def.texture_inv,
wield_image = def.texture_inv,
tiles = {{
name = def.texture,
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
light_source = def.light_level,
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1},
selection_box = {
type = "fixed",
fixed = {
{-0.1875, -0.5, -0.1875, 0.1875, -0.0625, 0.1875},
{-0.125, -0.0625, -0.125, 0.125, 0.0625, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, 0.1875, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.1875, -0.5, -0.1875, 0.1875, -0.0625, 0.1875},
{-0.125, -0.0625, -0.125, 0.125, 0.0625, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, 0.1875, 0.0625},
},
},
--sounds = default.node_sound_wood_defaults(),
on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under
local node = minetest.get_node(under)
local def = minetest.registered_nodes[node.name]
if def and def.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end
local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
local fakestack = itemstack
if wdir == 0 then
fakestack:set_name(itemstring_ceiling)
elseif wdir == 1 then
fakestack:set_name(itemstring_floor)
end
itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name(itemstring_floor)
return itemstack
end,
--floodable = true,
--on_flood = on_flood,
on_rotate = false
})
minetest.register_node(itemstring_ceiling, {
drawtype = "mesh",
mesh = "mcl_lanterns_lantern_floor.obj",
tiles = {{
name = def.texture,
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
light_source = def.light_level,
groups = {dig_immediate=3, not_in_creative_inventory=1},
drop = itemstring_floor,
selection_box = {
type = "wallmounted",
wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8},
},
--sounds = default.node_sound_wood_defaults(),
--floodable = true,
--on_flood = on_flood,
on_rotate = false
})
end
minetest.register_node("mcl_lanterns:chain", {
description = S("Chain"),
_doc_items_longdesc = S("Chains are metallic decoration blocks."),
inventory_image = "mcl_lanterns_chain_inv.png",
tiles = {"mcl_lanterns_chain.png"},
drawtype = "mesh",
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = "clip",
mesh = "mcl_lanterns_chain.obj",
is_ground_content = false,
sunlight_propagates = true,
collision_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
}
},
groups = {pickaxey = 1, deco_block = 1},
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local param2 = 0
local placer_pos = placer:get_pos()
if placer_pos then
local dir = {
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y - 1 == p1.y then
param2 = 20
elseif p0.x - 1 == p1.x then
param2 = 16
elseif p0.x + 1 == p1.x then
param2 = 12
elseif p0.z - 1 == p1.z then
param2 = 8
elseif p0.z + 1 == p1.z then
param2 = 4
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
})
dofile(modpath.."/register.lua")

@ -0,0 +1,6 @@
name = mcl_lanterns
description = Add lanterns and chains to MineClone2
depends =
optional_depends =
author = AFCMS
title = MineClone2 Lanterns

@ -0,0 +1,24 @@
# Blender v3.0.1 OBJ File: 'chain.blend'
# www.blender.org
o Plane
v 0.066291 0.500000 0.066291
v 0.066291 -0.500000 0.066291
v -0.066291 0.500000 -0.066291
v -0.066291 -0.500000 -0.066291
v -0.066291 0.500000 0.066291
v -0.066291 -0.500000 0.066291
v 0.066291 0.500000 -0.066291
v 0.066291 -0.500000 -0.066291
vt -0.000000 1.000000
vt 0.000000 -0.000000
vt 0.187500 0.000000
vt 0.187500 1.000000
vt 0.187500 1.000000
vt 0.187500 -0.000000
vt 0.375000 -0.000000
vt 0.375000 1.000000
vn 0.7071 0.0000 -0.7071
vn 0.7071 0.0000 0.7071
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 5/5/2 6/6/2 8/7/2 7/8/2

@ -0,0 +1,106 @@
# Blender v3.0.1 OBJ File: 'lantern.blend'
# www.blender.org
o Cube
v 0.187500 -0.062500 -0.187500
v 0.187500 -0.500000 -0.187500
v 0.187500 -0.062500 0.187500
v 0.187500 -0.500000 0.187500
v -0.187500 -0.062500 -0.187500
v -0.187500 -0.500000 -0.187500
v -0.187500 -0.062500 0.187500
v -0.187500 -0.500000 0.187500
v 0.125000 0.062500 -0.125000
v 0.125000 -0.062500 -0.125000
v 0.125000 0.062500 0.125000
v 0.125000 -0.062500 0.125000
v -0.125000 0.062500 -0.125000
v -0.125000 -0.062500 -0.125000
v -0.125000 0.062500 0.125000
v -0.125000 -0.062500 0.125000
v 0.066291 0.187500 0.066291
v 0.066291 0.062500 0.066291
v -0.066291 0.187500 -0.066291
v -0.066291 0.062500 -0.066291
v -0.066291 0.187500 0.066291
v -0.066291 0.062500 0.066291
v 0.066291 0.187500 -0.066291
v 0.066291 0.062500 -0.066291
vt 0.000000 0.062500
vt 0.375000 0.062500
vt 0.375000 0.437500
vt 0.000000 0.437500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt -0.000000 0.437500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt 0.000000 0.437500
vt 0.562500 0.125000
vt 0.937500 0.125000
vt 0.937500 0.250000
vt 0.562500 0.250000
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt 0.000000 0.437500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt -0.000000 0.437500
vt 0.062500 0.125000
vt 0.312500 0.125000
vt 0.312500 0.375000
vt 0.062500 0.375000
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.500000 0.770833
vt 0.500000 0.770833
vt 0.500000 0.770833
vt 0.500000 0.770833
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.687500 0.937500
vt 0.687500 0.812500
vt 0.875000 0.812500
vt 0.875000 0.937500
vt 0.687500 0.937500
vt 0.687500 0.812500
vt 0.875000 0.812500
vt 0.875000 0.937500
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 0.7071 0.0000 -0.7071
vn 0.7071 0.0000 0.7071
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/9/3 7/10/3 5/11/3 6/12/3
f 6/13/4 2/14/4 4/15/4 8/16/4
f 2/17/5 1/18/5 3/19/5 4/20/5
f 6/21/6 5/22/6 1/23/6 2/24/6
f 9/25/1 13/26/1 15/27/1 11/28/1
f 12/29/2 11/30/2 15/31/2 16/32/2
f 16/33/3 15/34/3 13/35/3 14/36/3
f 14/37/4 10/38/4 12/39/4 16/40/4
f 10/41/5 9/42/5 11/43/5 12/44/5
f 14/45/6 13/46/6 9/47/6 10/48/6
f 17/49/7 18/50/7 20/51/7 19/52/7
f 21/53/8 22/54/8 24/55/8 23/56/8

@ -0,0 +1,8 @@
local S = minetest.get_translator("mcl_lanterns")
mcl_lanterns.register_lantern("lantern", {
description = S("Lantern"),
texture = "mcl_lanterns_lantern.png",
texture_inv = "mcl_lanterns_lantern_inv.png",
light_level = 15,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB