Merge branch 'master' of https://git.minetest.land/MineClone2/MineClone2
This commit is contained in:
commit
fe5f61c747
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,23 +1,95 @@
|
|||
local S = minetest.get_translator("mcl_beds")
|
||||
|
||||
local function destruct_bed(pos, oldnode)
|
||||
local node = oldnode or minetest.get_node(pos)
|
||||
local minetest_get_node = minetest.get_node
|
||||
local minetest_get_node_or_nil = minetest.get_node_or_nil
|
||||
local minetest_remove_node = minetest.remove_node
|
||||
local minetest_facedir_to_dir = minetest.facedir_to_dir
|
||||
local minetest_add_item = minetest.add_item
|
||||
local vector_add = vector.add
|
||||
local vector_subtract = vector.subtract
|
||||
|
||||
local function get_bed_next_node(pos, node)
|
||||
local node = node or minetest_get_node_or_nil(pos)
|
||||
if not node then return end
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local pos2, node2
|
||||
|
||||
local dir = minetest_facedir_to_dir(node.param2)
|
||||
|
||||
local pos2, bottom
|
||||
if string.sub(node.name, -4) == "_top" then
|
||||
pos2 = vector.subtract(pos, dir)
|
||||
node2 = minetest.get_node(pos2)
|
||||
if node2 and string.sub(node2.name, -7) == "_bottom" then
|
||||
minetest.remove_node(pos2)
|
||||
pos2 = vector_subtract(pos, dir)
|
||||
else
|
||||
pos2 = vector_add(pos, dir)
|
||||
bottom = true
|
||||
end
|
||||
minetest.check_for_falling(pos)
|
||||
elseif string.sub(node.name, -7) == "_bottom" then
|
||||
minetest.add_item(pos, node.name)
|
||||
pos2 = vector.add(pos, dir)
|
||||
node2 = minetest.get_node(pos2)
|
||||
|
||||
local node2 = minetest_get_node(pos2)
|
||||
return pos2, node2, bottom, dir
|
||||
end
|
||||
|
||||
local function rotate(pos, node, user, mode, new_param2)
|
||||
if mode ~= screwdriver.ROTATE_FACE then
|
||||
return false
|
||||
end
|
||||
|
||||
local p, node2, bottom = get_bed_next_node(pos, node)
|
||||
if not node2 then return end
|
||||
|
||||
local name = node2.name
|
||||
if not minetest.get_item_group(name, "bed") == 2 or not node.param2 == node2.param2 then return false end
|
||||
|
||||
if bottom then
|
||||
name = string.sub(name, 1, -5)
|
||||
else
|
||||
name = string.sub(name, 1, -8)
|
||||
end
|
||||
|
||||
if minetest.is_protected(p, user:get_player_name()) then
|
||||
minetest.record_protection_violation(p, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
|
||||
local new_dir, newp = minetest_facedir_to_dir(new_param2)
|
||||
if bottom then
|
||||
newp = vector_add(pos, new_dir)
|
||||
else
|
||||
newp = vector_subtract(pos, new_dir)
|
||||
end
|
||||
|
||||
local node3 = minetest_get_node_or_nil(newp)
|
||||
if not node3 then return false end
|
||||
|
||||
local node_def = minetest.registered_nodes[node3.name]
|
||||
if not node_def or not node_def.buildable_to then return false end
|
||||
|
||||
if minetest.is_protected(newp, user:get_player_name()) then
|
||||
minetest.record_protection_violation(newp, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
|
||||
node.param2 = new_param2
|
||||
-- do not remove_node here - it will trigger destroy_bed()
|
||||
minetest.swap_node(p, {name = "air"})
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.swap_node(newp, {name = name .. (bottom and "_top" or "_bottom"), param2 = new_param2})
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
local function destruct_bed(pos, oldnode)
|
||||
local node = oldnode or minetest_get_node_or_nil(pos)
|
||||
if not node then return end
|
||||
|
||||
local pos2, node2, bottom = get_bed_next_node(pos, oldnode)
|
||||
|
||||
if bottom then
|
||||
minetest_add_item(pos, node.name)
|
||||
if node2 and string.sub(node2.name, -4) == "_top" then
|
||||
minetest.remove_node(pos2)
|
||||
minetest_remove_node(pos2)
|
||||
end
|
||||
else
|
||||
if node2 and string.sub(node2.name, -7) == "_bottom" then
|
||||
minetest_remove_node(pos2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -94,7 +166,7 @@ function mcl_beds.register_bed(name, def)
|
|||
local under = pointed_thing.under
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present
|
||||
local node = minetest.get_node(under)
|
||||
local node = minetest_get_node(under)
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||
|
@ -102,7 +174,7 @@ function mcl_beds.register_bed(name, def)
|
|||
end
|
||||
|
||||
local pos
|
||||
local undername = minetest.get_node(under).name
|
||||
local undername = minetest_get_node(under).name
|
||||
if minetest.registered_items[undername] and minetest.registered_items[undername].buildable_to then
|
||||
pos = under
|
||||
else
|
||||
|
@ -115,13 +187,13 @@ function mcl_beds.register_bed(name, def)
|
|||
return itemstack
|
||||
end
|
||||
|
||||
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
local node_def = minetest.registered_nodes[minetest_get_node(pos).name]
|
||||
if not node_def or not node_def.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local dir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local botpos = vector.add(pos, minetest.facedir_to_dir(dir))
|
||||
local botpos = vector_add(pos, minetest_facedir_to_dir(dir))
|
||||
|
||||
if minetest.is_protected(botpos, placer:get_player_name()) and
|
||||
not minetest.check_player_privs(placer, "protection_bypass") then
|
||||
|
@ -129,7 +201,7 @@ function mcl_beds.register_bed(name, def)
|
|||
return itemstack
|
||||
end
|
||||
|
||||
local botdef = minetest.registered_nodes[minetest.get_node(botpos).name]
|
||||
local botdef = minetest.registered_nodes[minetest_get_node(botpos).name]
|
||||
if not botdef or not botdef.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
|
@ -152,38 +224,7 @@ function mcl_beds.register_bed(name, def)
|
|||
return itemstack
|
||||
end,
|
||||
|
||||
on_rotate = function(pos, node, user, mode, new_param2)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local p = vector.add(pos, dir)
|
||||
local node2 = minetest.get_node_or_nil(p)
|
||||
if not node2 or not minetest.get_item_group(node2.name, "bed") == 2 or
|
||||
not node.param2 == node2.param2 then
|
||||
return false
|
||||
end
|
||||
if minetest.is_protected(p, user:get_player_name()) then
|
||||
minetest.record_protection_violation(p, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
if mode ~= screwdriver.ROTATE_FACE then
|
||||
return false
|
||||
end
|
||||
local newp = vector.add(pos, minetest.facedir_to_dir(new_param2))
|
||||
local node3 = minetest.get_node_or_nil(newp)
|
||||
local node_def = node3 and minetest.registered_nodes[node3.name]
|
||||
if not node_def or not node_def.buildable_to then
|
||||
return false
|
||||
end
|
||||
if minetest.is_protected(newp, user:get_player_name()) then
|
||||
minetest.record_protection_violation(newp, user:get_player_name())
|
||||
return false
|
||||
end
|
||||
node.param2 = new_param2
|
||||
-- do not remove_node here - it will trigger destroy_bed()
|
||||
minetest.set_node(p, {name = "air"})
|
||||
minetest.set_node(pos, node)
|
||||
minetest.set_node(newp, {name = name .. "_top", param2 = new_param2})
|
||||
return true
|
||||
end,
|
||||
on_rotate = rotate,
|
||||
})
|
||||
|
||||
local node_box_top, selection_box_top, collision_box_top
|
||||
|
@ -217,7 +258,7 @@ function mcl_beds.register_bed(name, def)
|
|||
mcl_beds.on_rightclick(pos, clicker, true)
|
||||
return itemstack
|
||||
end,
|
||||
on_rotate = false,
|
||||
on_rotate = rotate,
|
||||
after_destruct = destruct_bed,
|
||||
})
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ if mod_screwdriver then
|
|||
end
|
||||
|
||||
-- Register tree trunk (wood) and bark
|
||||
local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark)
|
||||
local register_tree_trunk = function(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_varient)
|
||||
minetest.register_node("mcl_core:"..subname, {
|
||||
description = description_trunk,
|
||||
_doc_items_longdesc = longdesc,
|
||||
|
@ -22,6 +22,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar
|
|||
on_rotate = on_rotate,
|
||||
_mcl_blast_resistance = 2,
|
||||
_mcl_hardness = 2,
|
||||
_mcl_stripped_varient = stripped_varient,
|
||||
})
|
||||
|
||||
minetest.register_node("mcl_core:"..subname.."_bark", {
|
||||
|
@ -37,6 +38,7 @@ local register_tree_trunk = function(subname, description_trunk, description_bar
|
|||
on_rotate = on_rotate,
|
||||
_mcl_blast_resistance = 2,
|
||||
_mcl_hardness = 2,
|
||||
_mcl_stripped_varient = stripped_varient.."_bark",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
@ -214,12 +216,12 @@ end
|
|||
|
||||
---------------------
|
||||
|
||||
register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png")
|
||||
register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png")
|
||||
register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png")
|
||||
register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png")
|
||||
register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png")
|
||||
register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png")
|
||||
register_tree_trunk("tree", S("Oak Wood"), S("Oak Bark"), S("The trunk of an oak tree."), "default_tree_top.png", "default_tree.png", "mcl_core:stripped_oak")
|
||||
register_tree_trunk("darktree", S("Dark Oak Wood"), S("Dark Oak Bark"), S("The trunk of a dark oak tree."), "mcl_core_log_big_oak_top.png", "mcl_core_log_big_oak.png", "mcl_core:stripped_dark_oak")
|
||||
register_tree_trunk("acaciatree", S("Acacia Wood"), S("Acacia Bark"), S("The trunk of an acacia."), "default_acacia_tree_top.png", "default_acacia_tree.png", "mcl_core:stripped_acacia")
|
||||
register_tree_trunk("sprucetree", S("Spruce Wood"), S("Spruce Bark"), S("The trunk of a spruce tree."), "mcl_core_log_spruce_top.png", "mcl_core_log_spruce.png", "mcl_core:stripped_spruce")
|
||||
register_tree_trunk("birchtree", S("Birch Wood"), S("Birch Bark"), S("The trunk of a birch tree."), "mcl_core_log_birch_top.png", "mcl_core_log_birch.png", "mcl_core:stripped_birch")
|
||||
register_tree_trunk("jungletree", S("Jungle Wood"), S("Jungle Bark"), S("The trunk of a jungle tree."), "default_jungletree_top.png", "default_jungletree.png", "mcl_core:stripped_jungle")
|
||||
|
||||
register_stripped_trunk("stripped_oak", S("Stripped Oak Log"), S("Stripped Oak Wood"), S("The stripped trunk of an oak tree."), "mcl_core_stripped_oak_top.png", "mcl_core_stripped_oak_side.png")
|
||||
register_stripped_trunk("stripped_acacia", S("Stripped Acacia Log"), S("Stripped Acacia Wood"), S("The stripped trunk of an acacia tree."), "mcl_core_stripped_acacia_top.png", "mcl_core_stripped_acacia_side.png")
|
||||
|
|
|
@ -352,30 +352,6 @@ minetest.register_tool("mcl_tools:shovel_diamond", {
|
|||
})
|
||||
|
||||
-- Axes
|
||||
local make_stripped_trunk_add_wear = function(itemstack, placer)
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
-- Add wear (as if digging a axey node)
|
||||
local toolname = itemstack:get_name()
|
||||
local wear = mcl_autogroup.get_wear(toolname, "axey")
|
||||
itemstack:add_wear(wear)
|
||||
end
|
||||
end
|
||||
|
||||
local stripped_table = {
|
||||
{"mcl_core:tree", "mcl_core:stripped_oak"},
|
||||
{"mcl_core:darktree", "mcl_core:stripped_dark_oak"},
|
||||
{"mcl_core:acaciatree", "mcl_core:stripped_acacia"},
|
||||
{"mcl_core:birchtree", "mcl_core:stripped_birch"},
|
||||
{"mcl_core:sprucetree", "mcl_core:stripped_spruce"},
|
||||
{"mcl_core:jungletree", "mcl_core:stripped_jungle"},
|
||||
{"mcl_core:tree_bark", "mcl_core:stripped_oak_bark"},
|
||||
{"mcl_core:darktree_bark", "mcl_core:stripped_dark_oak_bark"},
|
||||
{"mcl_core:acaciatree_bark", "mcl_core:stripped_acacia_bark"},
|
||||
{"mcl_core:birchtree_bark", "mcl_core:stripped_birch_bark"},
|
||||
{"mcl_core:sprucetree_bark", "mcl_core:stripped_spruce_bark"},
|
||||
{"mcl_core:jungletree_bark", "mcl_core:stripped_jungle_bark"},
|
||||
}
|
||||
|
||||
local make_stripped_trunk = function(itemstack, placer, pointed_thing)
|
||||
if pointed_thing.type ~= "node" then return end
|
||||
|
||||
|
@ -390,10 +366,15 @@ local make_stripped_trunk = function(itemstack, placer, pointed_thing)
|
|||
return itemstack
|
||||
end
|
||||
|
||||
for _, st in pairs(stripped_table) do
|
||||
if noddef.name == st[1] then
|
||||
minetest.swap_node(pointed_thing.under, {name=st[2], param2=node.param2})
|
||||
make_stripped_trunk_add_wear(itemstack, placer)
|
||||
if noddef._mcl_stripped_varient == nil then
|
||||
return itemstack
|
||||
else
|
||||
minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_varient, param2=node.param2})
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
-- Add wear (as if digging a axey node)
|
||||
local toolname = itemstack:get_name()
|
||||
local wear = mcl_autogroup.get_wear(toolname, "axey")
|
||||
itemstack:add_wear(wear)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
|
|
|
@ -242,7 +242,7 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
if elytra.active then
|
||||
-- set head pitch and yaw when flying
|
||||
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
|
||||
player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
|
||||
-- sets eye height, and nametag color accordingly
|
||||
player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,0.8,0.35}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
|
||||
-- control body bone when flying
|
||||
|
@ -250,18 +250,18 @@ minetest.register_globalstep(function(dtime)
|
|||
elseif parent then
|
||||
local parent_yaw = degrees(parent:get_yaw())
|
||||
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
|
||||
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0))
|
||||
player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch, -limit_vel_yaw(yaw, parent_yaw) + parent_yaw, 0))
|
||||
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0))
|
||||
elseif control.sneak then
|
||||
-- controls head pitch when sneaking
|
||||
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+36,0,0))
|
||||
player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, player_vel_yaw - yaw))
|
||||
-- sets eye height, and nametag color accordingly
|
||||
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 0, g = 225 }})
|
||||
-- sneaking body conrols
|
||||
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0))
|
||||
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0))
|
||||
elseif get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and is_sprinting(name) == true then
|
||||
-- set head pitch and yaw when swimming
|
||||
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
|
||||
player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch-degrees(dir_to_pitch(player_velocity)),player_vel_yaw - yaw,0))
|
||||
-- sets eye height, and nametag color accordingly
|
||||
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,0.8,0.312}, eye_height = 0.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
|
||||
-- control body bone when swimming
|
||||
|
@ -270,7 +270,7 @@ minetest.register_globalstep(function(dtime)
|
|||
-- sets eye height, and nametag color accordingly
|
||||
player:set_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 225, g = 225 }})
|
||||
|
||||
player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0))
|
||||
player:set_bone_position("Head_Control", vector.new(0,6.3,0), vector.new(pitch, player_vel_yaw - yaw, 0))
|
||||
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0))
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue