forked from Mineclonia/Mineclonia
Prevent player from walking while sleeping
This commit is contained in:
parent
3121ab7c2d
commit
fd73c81d23
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue