mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-26 19:27:31 +01:00
Merge branch 'master' of https://git.minetest.land/MineClone2/MineClone2 into commands-refactoring-1
This commit is contained in:
commit
71353ac934
@ -33,3 +33,8 @@ mgvalleys_spflags = noaltitude_chill,noaltitude_dry,nohumid_rivers,vary_river_de
|
|||||||
keepInventory = false
|
keepInventory = false
|
||||||
|
|
||||||
dedicated_server_step = 0.001
|
dedicated_server_step = 0.001
|
||||||
|
|
||||||
|
# Clientmodding to support official client
|
||||||
|
enable_client_modding = true
|
||||||
|
csm_restriction_flags = 0
|
||||||
|
enable_mod_channels = true
|
||||||
|
@ -405,3 +405,17 @@ function mcl_util.get_object_center(obj)
|
|||||||
pos.y = pos.y + (ymax - ymin) / 2.0
|
pos.y = pos.y + (ymax - ymin) / 2.0
|
||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_util.get_color(colorstr)
|
||||||
|
local mc_color = mcl_colors[colorstr:upper()]
|
||||||
|
if mc_color then
|
||||||
|
return mc_color
|
||||||
|
end
|
||||||
|
if #colorstr ~= 7 or colorstr:sub(1, 1) ~= "#"then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local hex = tonumber(colorstr:sub(2, 7), 16)
|
||||||
|
if hex then
|
||||||
|
return colorstr, hex
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -31,9 +31,11 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
sprinting = false,
|
sprinting = false,
|
||||||
timeOut = 0,
|
timeOut = 0,
|
||||||
shouldSprint = false,
|
shouldSprint = false,
|
||||||
|
clientSprint = false,
|
||||||
lastPos = player:get_pos(),
|
lastPos = player:get_pos(),
|
||||||
sprintDistance = 0,
|
sprintDistance = 0,
|
||||||
fov = 1.0
|
fov = 1.0,
|
||||||
|
channel = minetest.mod_channel_join("mcl_sprint:" .. playerName),
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
@ -41,6 +43,11 @@ minetest.register_on_leaveplayer(function(player)
|
|||||||
players[playerName] = nil
|
players[playerName] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local function cancelClientSprinting(name)
|
||||||
|
players[name].channel:send_all("")
|
||||||
|
players[name].clientSprint = false
|
||||||
|
end
|
||||||
|
|
||||||
local function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
|
local function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
|
||||||
local player = minetest.get_player_by_name(playerName)
|
local player = minetest.get_player_by_name(playerName)
|
||||||
if players[playerName] then
|
if players[playerName] then
|
||||||
@ -97,6 +104,16 @@ local function get_top_node_tile(param2, paramtype2)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_on_modchannel_message(function(channel_name, sender, message)
|
||||||
|
if channel_name == "mcl_sprint:" .. sender then
|
||||||
|
players[sender].clientSprint = minetest.is_yes(message)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_respawnplayer(function(player)
|
||||||
|
cancelClientSprinting(player:get_player_name())
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
--Get the gametime
|
--Get the gametime
|
||||||
local gameTime = minetest.get_gametime()
|
local gameTime = minetest.get_gametime()
|
||||||
@ -107,7 +124,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
if player ~= nil then
|
if player ~= nil then
|
||||||
local ctrl = player:get_player_control()
|
local ctrl = player:get_player_control()
|
||||||
--Check if the player should be sprinting
|
--Check if the player should be sprinting
|
||||||
if ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
if players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then
|
||||||
players[playerName]["shouldSprint"] = true
|
players[playerName]["shouldSprint"] = true
|
||||||
else
|
else
|
||||||
players[playerName]["shouldSprint"] = false
|
players[playerName]["shouldSprint"] = false
|
||||||
@ -160,6 +177,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
-- Prevent sprinting if hungry or sleeping
|
-- Prevent sprinting if hungry or sleeping
|
||||||
if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then
|
if (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) or (player:get_meta():get_string("mcl_beds:sleeping") == "true") then
|
||||||
sprinting = false
|
sprinting = false
|
||||||
|
cancelClientSprinting(playerName)
|
||||||
else
|
else
|
||||||
sprinting = true
|
sprinting = true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user