1
0
Fork 0

Merge remote-tracking branch 'origin/master' into mineclone5

This commit is contained in:
kay27 2021-04-14 01:18:34 +04:00
commit 7fa0767b13
4 changed files with 116 additions and 55 deletions

View File

@ -323,7 +323,7 @@ mobs:register_mob("mobs_mc:enderman", {
-- self:teleport(nil)
-- self.state = ""
--else
if self.attack ~= nil then
if self.attack ~= nil and not minetest.settings:get_bool("creative_mode") then
self.state = 'attack'
end
--end

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator("mcl_doors")
local minetest_get_meta = minetest.get_meta
-- This helper function calls on_place_node callbacks.
local function on_place_node(place_to, newnode,
@ -164,14 +165,14 @@ function mcl_doors:register_door(name, def)
end
if def.only_placer_can_open then
local meta = minetest.get_meta(pt)
local meta = minetest_get_meta(pt)
meta:set_string("doors_owner", "")
meta = minetest.get_meta(pt2)
meta = minetest_get_meta(pt2)
meta:set_string("doors_owner", "")
end
local meta1 = minetest.get_meta(pt)
local meta2 = minetest.get_meta(pt2)
local meta1 = minetest_get_meta(pt)
local meta2 = minetest_get_meta(pt2)
-- save mirror state for the correct door
if left_node.name:sub(1, #name) == name then
meta1:set_int("is_mirrored", 1)
@ -198,9 +199,9 @@ function mcl_doors:register_door(name, def)
local tb = def.tiles_bottom
local function on_open_close(pos, dir, check_name, replace, replace_dir)
local meta1 = minetest.get_meta(pos)
local meta1 = minetest_get_meta(pos)
pos.y = pos.y+dir
local meta2 = minetest.get_meta(pos)
local meta2 = minetest_get_meta(pos)
-- if name of other door is not the same as check_name -> return
if not minetest.get_node(pos).name == check_name then
@ -254,7 +255,7 @@ function mcl_doors:register_door(name, def)
if not def.only_placer_can_open then
return true
end
local meta = minetest.get_meta(pos)
local meta = minetest_get_meta(pos)
local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn
end
@ -292,10 +293,15 @@ function mcl_doors:register_door(name, def)
sounds = def.sounds,
after_destruct = function(bottom, oldnode)
minetest.add_item(bottom, name)
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then
minetest.remove_node(top)
local meta_bottom = minetest_get_meta(bottom)
if meta_bottom:get_int("rotation") == 1 then
meta_bottom:set_int("rotation", 0)
else
minetest.add_item(bottom, name)
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then
minetest.remove_node(top)
end
end
end,
@ -305,13 +311,19 @@ function mcl_doors:register_door(name, def)
action_on = on_mesecons_signal_open,
}},
on_rotate = function(pos, node, user, mode, param2)
on_rotate = function(bottom, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
minetest.remove_node(pos)
node.param2 = screwdriver.rotate.facedir(pos, node, mode)
minetest.set_node(pos, node)
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
minetest.swap_node(bottom, node)
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.name = name .."_t_1"
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, node)
minetest.swap_node(top, node)
return true
end
return false
@ -353,9 +365,14 @@ function mcl_doors:register_door(name, def)
sounds = def.sounds,
after_destruct = function(top, oldnode)
local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then
minetest.dig_node(bottom)
local meta_top = minetest_get_meta(top)
if meta_top:get_int("rotation") == 1 then
meta_top:set_int("rotation", 0)
else
local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then
minetest.dig_node(bottom)
end
end
end,
@ -366,13 +383,19 @@ function mcl_doors:register_door(name, def)
rules = mesecon.rules.flat,
}},
on_rotate = function(pos, node, user, mode, param2)
on_rotate = function(top, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
minetest.remove_node(pos)
node.param2 = screwdriver.rotate.facedir(pos, node, mode)
minetest.set_node(pos, node)
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(top, node, mode)
minetest.swap_node(top, node)
local bottom = {x=top.x,y=top.y-1,z=top.z}
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.name = name .."_b_1"
minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z}, node)
minetest.swap_node(bottom, node)
return true
end
return false
@ -414,10 +437,15 @@ function mcl_doors:register_door(name, def)
sounds = def.sounds,
after_destruct = function(bottom, oldnode)
minetest.add_item(bottom, name)
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then
minetest.remove_node(top)
local meta_bottom = minetest_get_meta(bottom)
if meta_bottom:get_int("rotation") == 1 then
meta_bottom:set_int("rotation", 0)
else
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
minetest.add_item(bottom, name)
if minetest.get_node(bottom).name ~= name.."_b_1" and minetest.get_node(top).name == name.."_t_2" then
minetest.remove_node(top)
end
end
end,
@ -427,13 +455,19 @@ function mcl_doors:register_door(name, def)
action_off = on_mesecons_signal_close,
}},
on_rotate = function(pos, node, user, mode, param2)
on_rotate = function(bottom, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
minetest.remove_node(pos)
node.param2 = screwdriver.rotate.facedir(pos, node, mode)
minetest.set_node(pos, node)
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(bottom, node, mode)
minetest.swap_node(bottom, node)
local top = {x=bottom.x,y=bottom.y+1,z=bottom.z}
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.name = name .."_t_2"
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, node)
minetest.swap_node(top, node)
return true
end
return false
@ -475,9 +509,14 @@ function mcl_doors:register_door(name, def)
sounds = def.sounds,
after_destruct = function(top, oldnode)
local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then
minetest.dig_node(bottom)
local meta_top = minetest_get_meta(top)
if meta_top:get_int("rotation") == 1 then
meta_top:set_int("rotation", 0)
else
local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_1" and minetest.get_node(bottom).name == name.."_b_2" and oldnode.name == name.."_t_2" then
minetest.dig_node(bottom)
end
end
end,
@ -488,13 +527,19 @@ function mcl_doors:register_door(name, def)
rules = mesecon.rules.flat,
}},
on_rotate = function(pos, node, user, mode, param2)
on_rotate = function(top, node, user, mode, param2)
if mode == screwdriver.ROTATE_FACE then
minetest.remove_node(pos)
node.param2 = screwdriver.rotate.facedir(pos, node, mode)
minetest.set_node(pos, node)
local meta_top = minetest_get_meta(top)
meta_top:set_int("rotation", 1)
node.param2 = screwdriver.rotate.facedir(top, node, mode)
minetest.swap_node(top, node)
local bottom = {x=top.x,y=top.y-1,z=top.z}
local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1)
node.name = name .."_b_2"
minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z}, node)
minetest.swap_node(bottom, node)
return true
end
return false

View File

@ -701,6 +701,10 @@ function mcl_potions.healing_func(player, hp)
local obj = player:get_luaentity()
if player:get_hp() == 0 then
return
end
if obj and obj.harmed_by_heal then hp = -hp end
if hp > 0 then

View File

@ -175,14 +175,14 @@ minetest.register_globalstep(function(dtime)
]]--
local controls = player:get_player_control()
local control = player:get_player_control()
local name = player:get_player_name()
local meta = player:get_meta()
local parent = player:get_attach()
local wielded = player:get_wielded_item()
local player_velocity = player:get_velocity() or player:get_player_velocity()
-- controls head bone
-- control head bone
local pitch = - degrees(player:get_look_vertical())
local yaw = degrees(player:get_look_horizontal())
@ -199,11 +199,22 @@ minetest.register_globalstep(function(dtime)
minetest.log("action", "somehow player got of loaded areas")
end
controls.register_on_press(function(player, key)
if key~="jump" then return end
if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" and player_velocity.y < -6 and elytra[player] ~= true then
elytra[player] = true
end
end)
if elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then
elytra[player] = false
end
--[[
if player:get_inventory():get_stack("armor", 3):get_name() == "mcl_armor:elytra" and player_velocity.y < -6 and elytra[player] ~= true and is_sprinting(name) then
elytra[player] = true
elseif elytra[player] == true and node_stand_return ~= "air" or elytra[player] == true and player:get_inventory():get_stack("armor", 3):get_name() ~= "mcl_armor:elytra" or player:get_attach() ~= nil then
elytra[player] = false
end
end]]
if elytra[player] == true then
mcl_player.player_set_animation(player, "fly")
@ -213,9 +224,10 @@ minetest.register_globalstep(function(dtime)
end
if math.abs(player_velocity.x) + math.abs(player_velocity.z) < 20 then
local dir = minetest.yaw_to_dir(player:get_look_horizontal())
player:add_velocity({x=dir.x, y=0, z=dir.z})
local pitch = 1 * player:get_look_vertical() * -.1
player:add_velocity({x=dir.x, y=pitch, z=dir.z})
end
if controls.sneak then
if control.sneak then
if player_velocity.y > -5 then
player:add_velocity({x=0, y=-2, z=0})
end
@ -225,11 +237,11 @@ minetest.register_globalstep(function(dtime)
end
-- controls right and left arms pitch when shooting a bow
if string.find(wielded:get_name(), "mcl_bows:bow") and controls.RMB and not controls.LMB and not controls.up and not controls.down and not controls.left and not controls.right then
if string.find(wielded:get_name(), "mcl_bows:bow") and control.RMB and not control.LMB and not control.up and not control.down and not control.left and not control.right then
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35))
-- when punching
elseif controls.LMB and not parent then
elseif control.LMB and not parent then
player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch,0,0))
player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0))
-- when holding an item.
@ -246,15 +258,15 @@ minetest.register_globalstep(function(dtime)
-- 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))
-- 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 }})
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 = 0, g = 225 }})
-- control body bone when swimming
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0))
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_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, 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("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0))
elseif controls.sneak then
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))
-- sets eye height, and nametag color accordingly
@ -265,12 +277,12 @@ minetest.register_globalstep(function(dtime)
-- 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))
-- 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 }})
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 = 0, g = 225 }})
-- control body bone when swimming
player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(degrees(dir_to_pitch(player_velocity)) - 90,-player_vel_yaw + yaw + 180,0))
else
-- 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_properties({collisionbox = {-0.312,0,-0.312,0.312,1.8,0.312}, eye_height = 1.5, nametag_color = { r = 225, b = 225, a = 0, 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("Body_Control", vector.new(0,6.3,0), vector.new(0, -player_vel_yaw + yaw, 0))
@ -283,7 +295,7 @@ minetest.register_globalstep(function(dtime)
mcl_playerplus_internal[name].jump_cooldown = mcl_playerplus_internal[name].jump_cooldown - dtime
end
if controls.jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then
if control.jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then
pos = player:get_pos()