Merge pull request 'Add lanterns and chains' (#1983) from AFCMS/MineClone2:lanterns into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1983
This commit is contained in:
NO11 2022-02-11 13:28:55 +00:00
commit f3c814bf8f
14 changed files with 560 additions and 0 deletions

View File

@ -0,0 +1,284 @@
local S = minetest.get_translator("mcl_lanterns")
local modpath = minetest.get_modpath("mcl_lanterns")
mcl_lanterns = {}
--[[
TODO:
- add lantern specific sounds
- remove the hack arround walmounted nodes
]]
local allowed_non_solid_nodes_floor = {
"mcl_core:ice",
"mcl_nether:soul_sand",
"mcl_mobspawners:spawner",
"mcl_core:barrier",
"mcl_end:chorus_flower",
"mcl_end:chorus_flower_dead",
"mcl_end:end_rod",
"mcl_end:dragon_egg",
"mcl_portals:end_portal_frame_eye",
"mcl_lanterns:chain"
}
local allowed_non_solid_groups_floor = {"anvil", "wall", "glass", "fence", "fence_gate", "pane"}
local allowed_non_solid_nodes_ceiling = {
"mcl_core:ice",
"mcl_nether:soul_sand",
"mcl_mobspawners:spawner",
"mcl_core:barrier",
"mcl_end:chorus_flower",
"mcl_end:chorus_flower_dead",
"mcl_end:end_rod",
"mcl_core:grass_path",
"mcl_lanterns:chain"
}
local allowed_non_solid_groups_ceiling = {"anvil", "wall", "glass", "fence", "fence_gate", "soil", "pane", "end_portal_frame"}
local function check_placement(node, wdir)
local nn = node.name
local def = minetest.registered_nodes[nn]
if not def then
return false
else
--wdir:
--0: ceiling
--1: floor
if wdir == 0 then
if def.groups.solid or def.groups.opaque then
return true
else
for _,i in ipairs(allowed_non_solid_nodes_ceiling) do
if nn == i then
return true
end
end
for _,j in ipairs(allowed_non_solid_groups_ceiling) do
if def.groups[j] then
return true
end
end
return false
end
else --assuming wdir == 1
if def.groups.solid or def.groups.opaque then
return true
else
for _,i in ipairs(allowed_non_solid_nodes_floor) do
if nn == i then
return true
end
end
for _,j in ipairs(allowed_non_solid_groups_floor) do
if def.groups[j] then
return true
end
end
return false
end
end
end
end
function mcl_lanterns.register_lantern(name, def)
local itemstring_floor = "mcl_lanterns:"..name.."_floor"
local itemstring_ceiling = "mcl_lanterns:"..name.."_ceiling"
local sounds = mcl_sounds.node_sound_metal_defaults()
minetest.register_node(itemstring_floor, {
description = def.description,
_doc_items_longdesc = def.longdesc,
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",
place_param2 = 1,
node_placement_prediction = "",
sunlight_propagates = true,
light_source = def.light_level,
groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 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 = sounds,
on_place = function(itemstack, placer, pointed_thing)
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if new_stack then
return new_stack
end
local under = pointed_thing.under
local above = pointed_thing.above
local node = minetest.get_node(under)
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
local fakestack = itemstack
if check_placement(node, wdir) == false then
return itemstack
end
if wdir == 0 then
fakestack:set_name(itemstring_ceiling)
elseif wdir == 1 then
fakestack:set_name(itemstring_floor)
end
local success
itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name(itemstring_floor)
if success then
minetest.sound_play(sounds.place, {pos = under, gain = 1}, true)
end
return itemstack
end,
on_rotate = false,
_mcl_hardness = 3.5,
_mcl_blast_resistance = 3.5,
})
minetest.register_node(itemstring_ceiling, {
description = def.description,
_doc_items_create_entry = false,
drawtype = "mesh",
mesh = "mcl_lanterns_lantern_ceiling.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",
place_param2 = 0,
node_placement_prediction = "",
sunlight_propagates = true,
light_source = def.light_level,
groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1, not_in_creative_inventory = 1},
drop = itemstring_floor,
selection_box = {
type = "fixed",
fixed = {
{-0.1875, 0, -0.1875, 0.1875, 0.4375, 0.1875},
{-0.125, -0.125, -0.125, 0.125, 0, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, -0.125, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.1875, 0, -0.1875, 0.1875, 0.4375, 0.1875},
{-0.125, -0.125, -0.125, 0.125, 0, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, -0.125, 0.0625},
},
},
sounds = sounds,
on_rotate = false,
_mcl_hardness = 3.5,
_mcl_blast_resistance = 3.5,
})
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},
sounds = mcl_sounds.node_sound_metal_defaults(),
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,
})
minetest.register_craft({
output = "mcl_lanterns:chain",
recipe = {
{"mcl_core:iron_nugget"},
{"mcl_core:iron_ingot"},
{"mcl_core:iron_nugget"},
},
})
dofile(modpath.."/register.lua")

View File

@ -0,0 +1,6 @@
# textdomain: mcl_lanterns
Lantern=Lanterne
Soul Lantern=Lanterne des âmes
Lanterns are light sources which can be placed on the top or the bottom of most blocks.=Les lanternes sont des blocs lumineux qui peuvent être placés au dessus ou en dessous de la plupart des blocs.
Chain=Chaîne
Chains are metallic decoration blocks.=La chaîne est un bloc de décoration métalique.

View File

@ -0,0 +1,6 @@
# textdomain: mcl_lanterns
Lantern=
Soul Lantern=
Lanterns are light sources which can be placed on the top or the bottom of most blocks.=
Chain=
Chains are metallic decoration blocks.=

View File

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

View File

@ -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

View File

@ -0,0 +1,104 @@
# Blender v3.0.1 OBJ File: 'lantern.blend'
# www.blender.org
o Lantern_Ceiling
v 0.187500 -0.000000 0.187500
v 0.187500 0.437500 0.187500
v 0.187500 0.000000 -0.187500
v 0.187500 0.437500 -0.187500
v -0.187500 -0.000000 0.187500
v -0.187500 0.437500 0.187500
v -0.187500 0.000000 -0.187500
v -0.187500 0.437500 -0.187500
v 0.125000 -0.125000 0.125000
v 0.125000 -0.000000 0.125000
v 0.125000 -0.125000 -0.125000
v 0.125000 0.000000 -0.125000
v -0.125000 -0.125000 0.125000
v -0.125000 -0.000000 0.125000
v -0.125000 -0.125000 -0.125000
v -0.125000 0.000000 -0.125000
v 0.066291 -0.500000 -0.066291
v 0.066291 -0.125000 -0.066291
v -0.066291 -0.500000 0.066291
v -0.066291 -0.125000 0.066291
v -0.066291 -0.500000 -0.066291
v -0.066291 -0.125000 -0.066291
v 0.066291 -0.500000 0.066291
v 0.066291 -0.125000 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.000000 0.062500
vt 0.375000 0.062500
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.625000
vt 0.687500 0.250000
vt 0.875000 0.250000
vt 0.875000 0.625000
vt 0.687500 1.000000
vt 0.687500 0.625000
vt 0.875000 0.625000
vt 0.875000 1.000000
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/5/4 8/8/4
f 2/15/5 1/16/5 3/17/5 4/18/5
f 6/19/6 5/20/6 1/21/6 2/22/6
f 9/23/1 13/24/1 15/25/1 11/26/1
f 12/27/2 11/28/2 15/29/2 16/30/2
f 16/31/3 15/32/3 13/33/3 14/34/3
f 14/35/4 10/36/4 12/37/4 16/38/4
f 10/39/5 9/40/5 11/41/5 12/42/5
f 14/43/6 13/44/6 9/45/6 10/46/6
f 17/47/7 18/48/7 20/49/7 19/50/7
f 21/51/8 22/52/8 24/53/8 23/54/8

View File

@ -0,0 +1,104 @@
# Blender v3.0.1 OBJ File: 'lantern.blend'
# www.blender.org
o Lantern_Floor
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.000000 0.062500
vt 0.375000 0.062500
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/5/4 8/8/4
f 2/15/5 1/16/5 3/17/5 4/18/5
f 6/19/6 5/20/6 1/21/6 2/22/6
f 9/23/1 13/24/1 15/25/1 11/26/1
f 12/27/2 11/28/2 15/29/2 16/30/2
f 16/31/3 15/32/3 13/33/3 14/34/3
f 14/35/4 10/36/4 12/37/4 16/38/4
f 10/39/5 9/40/5 11/41/5 12/42/5
f 14/43/6 13/44/6 9/45/6 10/46/6
f 17/47/7 18/48/7 20/49/7 19/50/7
f 21/51/8 22/52/8 24/53/8 23/54/8

View File

@ -0,0 +1,26 @@
local S = minetest.get_translator("mcl_lanterns")
mcl_lanterns.register_lantern("lantern", {
description = S("Lantern"),
longdesc = S("Lanterns are light sources which can be placed on the top or the bottom of most blocks."),
texture = "mcl_lanterns_lantern.png",
texture_inv = "mcl_lanterns_lantern_inv.png",
light_level = 14,
})
mcl_lanterns.register_lantern("soul_lantern", {
description = S("Soul Lantern"),
longdesc = S("Lanterns are light sources which can be placed on the top or the bottom of most blocks."),
texture = "mcl_lanterns_soul_lantern.png",
texture_inv = "mcl_lanterns_soul_lantern_inv.png",
light_level = 10,
})
minetest.register_craft({
output = "mcl_lanterns:lantern_floor",
recipe = {
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_torches:torch" , "mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB