From fd73c81d23e242c66035c847815f7d6d7280c546 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 11 Jun 2017 14:44:37 +0200 Subject: [PATCH] Prevent player from walking while sleeping --- mods/ITEMS/mcl_beds/functions.lua | 3 +++ mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua | 2 +- mods/PLAYER/mcl_playerplus/init.lua | 7 ++++--- mods/PLAYER/mcl_sprint/init.lua | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 589ccfe2af..5f79ba43fa 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -73,6 +73,7 @@ local function lay_down(player, pos, bed_pos, state, skip) player:set_look_horizontal(math.random(1, 180) / 100) mcl_player.player_attached[name] = false player:set_physics_override(1, 1, 1) + player:set_attribute("mcl_beds:sleeping", "false") hud_flags.wielditem = true 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) 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} + -- 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:setpos(p) mcl_player.player_attached[name] = true diff --git a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua index 5a5b9b8a60..a02b382c11 100644 --- a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua +++ b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua @@ -174,7 +174,7 @@ armor.set_player_armor = function(self, player) armor_groups.radiation = 100 - armor_radiation end 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].preview = preview self.def[name].state = state diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index e5aa899c54..4532fcb6c8 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -139,9 +139,10 @@ minetest.register_globalstep(function(dtime) end end - -- set player physics - -- TODO: Resolve conflict - player:set_physics_override(def.speed, def.jump, def.gravity) + -- Set player physics if there's no conflict + if player:get_attribute("mcl_beds:sleeping") ~= "true" then + player:set_physics_override(def.speed, def.jump, def.gravity) + end -- Is player suffocating inside node? (Only for solid full opaque cube type nodes -- without group disable_suffocation=1) diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 41ddd3a828..931f853109 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -100,8 +100,8 @@ function setSprinting(playerName, sprinting) --Sets the state of a player (0=sto local player = minetest.get_player_by_name(playerName) if players[playerName] then players[playerName]["sprinting"] = sprinting - -- Don't overwrite physics when standing on soul sand - if mcl_playerplus[playerName].node_stand ~= "mcl_nether:soul_sand" then + -- Don't overwrite physics when standing on soul sand or sleeping + if mcl_playerplus[playerName].node_stand ~= "mcl_nether:soul_sand" and player:get_attribute("mcl_beds:sleeping") ~= "true" then if sprinting == true then player:set_physics_override({speed=mcl_sprint.SPEED}) elseif sprinting == false then