forked from MineClone5/MineClone5
Implement 8 top snow layers
This commit is contained in:
parent
20baacb1fe
commit
86c24532f9
|
@ -97,6 +97,7 @@ These groups are used mostly for informational purposes
|
||||||
* `fire=1`: Fire
|
* `fire=1`: Fire
|
||||||
* `water=1`: Water
|
* `water=1`: Water
|
||||||
* `lava=1`: Lava
|
* `lava=1`: Lava
|
||||||
|
* `top_snow=X`: Top snow with X layers (1-8)
|
||||||
* `torch`: Torch or torch-like node
|
* `torch`: Torch or torch-like node
|
||||||
* `torch=1`: Torch on floor
|
* `torch=1`: Torch on floor
|
||||||
* `torch=2`: Torch at wall
|
* `torch=2`: Torch at wall
|
||||||
|
|
|
@ -878,35 +878,22 @@ for i=0,3 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_core:snow", {
|
for i=1,8 do
|
||||||
description = "Top Snow",
|
local id, desc, longdesc, help, walkable
|
||||||
_doc_items_longdesc = "Top snow is a thin layer of snow.",
|
if i == 1 then
|
||||||
_doc_items_hidden = false,
|
id = "mcl_core:snow"
|
||||||
tiles = {"default_snow.png"},
|
desc = "Top Snow"
|
||||||
wield_image = "default_snow.png",
|
longdesc = "Top snow is a thin layer of snow."
|
||||||
wield_scale = { x=1, y=1, z=1 },
|
walkable = false
|
||||||
is_ground_content = true,
|
else
|
||||||
paramtype = "light",
|
id = "mcl_core:snow_"..i
|
||||||
sunlight_propagates = true,
|
help = false
|
||||||
buildable_to = true,
|
if minetest.get_modpath("doc") then
|
||||||
drawtype = "nodebox",
|
doc.add_entry_alias("nodes", "mcl_core:snow", "nodes", id)
|
||||||
stack_max = 64,
|
end
|
||||||
floodable = true,
|
walkable = true
|
||||||
on_flood = function(pos, oldnode, newnode)
|
end
|
||||||
local npos = {x=pos.x, y=pos.y-1, z=pos.z}
|
local on_place = function(itemstack, placer, pointed_thing)
|
||||||
local node = minetest.get_node(npos)
|
|
||||||
mcl_core.clear_snow_dirt(npos, node)
|
|
||||||
end,
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-0.5, -0.5, -0.5, 0.5, -0.5+2/16, 0.5},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
groups = {shovely=1, attached_node=1,deco_block=1, dig_by_piston=1, snow_cover=1},
|
|
||||||
sounds = mcl_sounds.node_sound_snow_defaults(),
|
|
||||||
on_construct = mcl_core.on_snow_construct,
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
|
||||||
-- Placement is only allowed on top of solid blocks
|
-- Placement is only allowed on top of solid blocks
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
-- no interaction possible with entities
|
-- no interaction possible with entities
|
||||||
|
@ -916,6 +903,7 @@ minetest.register_node("mcl_core:snow", {
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local unode = minetest.get_node(under)
|
local unode = minetest.get_node(under)
|
||||||
|
|
||||||
-- Check special rightclick action of pointed node
|
-- Check special rightclick action of pointed node
|
||||||
if def and def.on_rightclick then
|
if def and def.on_rightclick then
|
||||||
if not placer:get_player_control().sneak then
|
if not placer:get_player_control().sneak then
|
||||||
|
@ -924,25 +912,79 @@ minetest.register_node("mcl_core:snow", {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local anode = minetest.get_node(above)
|
-- Get position where snow would be placed
|
||||||
local below
|
local target
|
||||||
if above.y > under.y and minetest.registered_nodes[unode.name].buildable_to then
|
if minetest.registered_nodes[unode.name].buildable_to then
|
||||||
below = {x=above.x, y=above.y-2, z=above.z}
|
target = under
|
||||||
else
|
else
|
||||||
below = {x=above.x, y=above.y-1, z=above.z}
|
target = above
|
||||||
end
|
end
|
||||||
|
local tnode = minetest.get_node(target)
|
||||||
|
|
||||||
|
-- Stack snow
|
||||||
|
local g = minetest.get_item_group(tnode.name, "top_snow")
|
||||||
|
if g > 0 then
|
||||||
|
local itemstring = itemstack:get_name()
|
||||||
|
local itemcount = itemstack:get_count()
|
||||||
|
local fakestack = ItemStack(itemstring.." "..itemcount)
|
||||||
|
fakestack:set_name("mcl_core:snow_"..math.min(8, (i+g)))
|
||||||
|
local success
|
||||||
|
itemstack, success = minetest.item_place(fakestack, placer, pointed_thing)
|
||||||
|
minetest.sound_play(mcl_sounds.node_sound_snow_defaults().place, {pos = below})
|
||||||
|
itemstack:set_name(itemstring)
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Place snow normally
|
||||||
|
local below = {x=target.x, y=target.y-1, z=target.z}
|
||||||
local bnode = minetest.get_node(below)
|
local bnode = minetest.get_node(below)
|
||||||
|
|
||||||
if minetest.get_item_group(bnode.name, "solid") == 1 then
|
if minetest.get_item_group(bnode.name, "solid") == 1 then
|
||||||
|
minetest.sound_play(mcl_sounds.node_sound_snow_defaults().place, {pos = below})
|
||||||
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
return minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||||
else
|
else
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node(id, {
|
||||||
|
description = desc,
|
||||||
|
_doc_items_longdesc = longdesc,
|
||||||
|
_doc_items_create_entry = hhelp,
|
||||||
|
_doc_items_hidden = false,
|
||||||
|
tiles = {"default_snow.png"},
|
||||||
|
wield_image = "default_snow.png",
|
||||||
|
wield_scale = { x=1, y=1, z=i },
|
||||||
|
is_ground_content = true,
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
buildable_to = true,
|
||||||
|
node_placement_prediction = "", -- to prevent client flickering when stacking snow
|
||||||
|
drawtype = "nodebox",
|
||||||
|
stack_max = 64,
|
||||||
|
walkable = walkable,
|
||||||
|
floodable = true,
|
||||||
|
on_flood = function(pos, oldnode, newnode)
|
||||||
|
local npos = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
|
local node = minetest.get_node(npos)
|
||||||
|
mcl_core.clear_snow_dirt(npos, node)
|
||||||
end,
|
end,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-0.5, -0.5, -0.5, 0.5, -0.5+(i*2)/16, 0.5},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
groups = {shovely=1, attached_node=1,deco_block=1, dig_by_piston=1, snow_cover=1, top_snow=i},
|
||||||
|
sounds = mcl_sounds.node_sound_snow_defaults(),
|
||||||
|
on_construct = mcl_core.on_snow_construct,
|
||||||
|
on_place = on_place,
|
||||||
after_destruct = mcl_core.after_snow_destruct,
|
after_destruct = mcl_core.after_snow_destruct,
|
||||||
drop = "mcl_throwing:snowball 2",
|
drop = "mcl_throwing:snowball "..(i+1),
|
||||||
_mcl_blast_resistance = 0.5,
|
_mcl_blast_resistance = 0.5,
|
||||||
_mcl_hardness = 0.1,
|
_mcl_hardness = 0.1,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("mcl_core:snowblock", {
|
minetest.register_node("mcl_core:snowblock", {
|
||||||
description = "Snow",
|
description = "Snow",
|
||||||
|
|
Loading…
Reference in New Issue