Prevent player from walking while sleeping

This commit is contained in:
Wuzzy 2017-06-11 14:44:37 +02:00
parent 3121ab7c2d
commit fd73c81d23
4 changed files with 10 additions and 6 deletions

View file

@ -73,6 +73,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
player:set_look_horizontal(math.random(1, 180) / 100) player:set_look_horizontal(math.random(1, 180) / 100)
mcl_player.player_attached[name] = false mcl_player.player_attached[name] = false
player:set_physics_override(1, 1, 1) player:set_physics_override(1, 1, 1)
player:set_attribute("mcl_beds:sleeping", "false")
hud_flags.wielditem = true hud_flags.wielditem = true
mcl_player.player_set_animation(player, "stand" , 30) mcl_player.player_set_animation(player, "stand" , 30)
@ -88,6 +89,8 @@ local function lay_down(player, pos, bed_pos, state, skip)
player:set_look_horizontal(yaw) player:set_look_horizontal(yaw)
local dir = minetest.facedir_to_dir(param2) local dir = minetest.facedir_to_dir(param2)
local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2} local p = {x = bed_pos.x + dir.x / 2, y = bed_pos.y, z = bed_pos.z + dir.z / 2}
-- Set player attribute so other mods know they should not touch set_physics_override
player:set_attribute("mcl_beds:sleeping", "true")
player:set_physics_override(0, 0, 0) player:set_physics_override(0, 0, 0)
player:setpos(p) player:setpos(p)
mcl_player.player_attached[name] = true mcl_player.player_attached[name] = true

View file

@ -174,7 +174,7 @@ armor.set_player_armor = function(self, player)
armor_groups.radiation = 100 - armor_radiation armor_groups.radiation = 100 - armor_radiation
end end
player:set_armor_groups(armor_groups) player:set_armor_groups(armor_groups)
player:set_physics_override(physics_o) -- Physics override intentionally removed because of possible conflicts
self.textures[name].armor = armor_texture self.textures[name].armor = armor_texture
self.textures[name].preview = preview self.textures[name].preview = preview
self.def[name].state = state self.def[name].state = state

View file

@ -139,9 +139,10 @@ minetest.register_globalstep(function(dtime)
end end
end end
-- set player physics -- Set player physics if there's no conflict
-- TODO: Resolve conflict if player:get_attribute("mcl_beds:sleeping") ~= "true" then
player:set_physics_override(def.speed, def.jump, def.gravity) player:set_physics_override(def.speed, def.jump, def.gravity)
end
-- Is player suffocating inside node? (Only for solid full opaque cube type nodes -- Is player suffocating inside node? (Only for solid full opaque cube type nodes
-- without group disable_suffocation=1) -- without group disable_suffocation=1)

View file

@ -100,8 +100,8 @@ function setSprinting(playerName, sprinting) --Sets the state of a player (0=sto
local player = minetest.get_player_by_name(playerName) local player = minetest.get_player_by_name(playerName)
if players[playerName] then if players[playerName] then
players[playerName]["sprinting"] = sprinting players[playerName]["sprinting"] = sprinting
-- Don't overwrite physics when standing on soul sand -- Don't overwrite physics when standing on soul sand or sleeping
if mcl_playerplus[playerName].node_stand ~= "mcl_nether:soul_sand" then if mcl_playerplus[playerName].node_stand ~= "mcl_nether:soul_sand" and player:get_attribute("mcl_beds:sleeping") ~= "true" then
if sprinting == true then if sprinting == true then
player:set_physics_override({speed=mcl_sprint.SPEED}) player:set_physics_override({speed=mcl_sprint.SPEED})
elseif sprinting == false then elseif sprinting == false then