mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Rename: playerplus→mcl_playerplus, drop compat.
This commit is contained in:
parent
632ebd6389
commit
b8cc752e79
10 changed files with 58 additions and 57 deletions
|
@ -39,7 +39,7 @@ minetest.register_node("mcl_core:barrier", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- The void below the bedrock. Void damage is handled in playerplus.
|
-- The void below the bedrock. Void damage is handled in mcl_playerplus.
|
||||||
-- The void does not exist as a block in Minecraft but we register it as a
|
-- The void does not exist as a block in Minecraft but we register it as a
|
||||||
-- block here to make things easier for us.
|
-- block here to make things easier for us.
|
||||||
minetest.register_node("mcl_core:void", {
|
minetest.register_node("mcl_core:void", {
|
||||||
|
|
|
@ -78,7 +78,7 @@ minetest.register_node("mcl_nether:soul_sand", {
|
||||||
sounds = mcl_sounds.node_sound_sand_defaults(),
|
sounds = mcl_sounds.node_sound_sand_defaults(),
|
||||||
_mcl_blast_resistance = 2.5,
|
_mcl_blast_resistance = 2.5,
|
||||||
_mcl_hardness = 0.5,
|
_mcl_hardness = 0.5,
|
||||||
-- Movement handling is done in playerplus mod
|
-- Movement handling is done in mcl_playerplus mod
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mcl_nether:nether_brick", {
|
minetest.register_node("mcl_nether:nether_brick", {
|
||||||
|
|
|
@ -4,21 +4,24 @@
|
||||||
|
|
||||||
- Hurt players touching cacti (0.5 hearts / 0.5s)
|
- Hurt players touching cacti (0.5 hearts / 0.5s)
|
||||||
- Suffocation: Hurt players who have their head inside a solid block (0.5 hearts / 0.5s)
|
- Suffocation: Hurt players who have their head inside a solid block (0.5 hearts / 0.5s)
|
||||||
|
- Exhaustion for swimming and jumping
|
||||||
|
- Particle effects
|
||||||
|
|
||||||
Suffocation *not* dealt to player with the `noclip` privilege.
|
Suffocation *not* dealt to player with the `noclip` privilege.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
This mod is based on PlayerPlus [`playerplus`] by TenPlus1. It behaves a bit
|
This mod is based on PlayerPlus [`playerplus`] by TenPlus1. It is now
|
||||||
differently than the original, but the API is fully compatible.
|
very different than the original, no compability is intended.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
Every half second the mod checks which node the player is standing on, which
|
Every half second the mod checks which node the player is standing on, which
|
||||||
node is at foot and head level and stores inside a global table to be used by mods:
|
node is at foot and head level and stores inside a global table to be used by mods:
|
||||||
|
|
||||||
- `playerplus[name].nod_stand`
|
- `mcl_playerplus[name].node_stand`
|
||||||
- `playerplus[name].nod_foot`
|
- `mcl_playerplus[name].node_stand_below`
|
||||||
- `playerplus[name].nod_head`
|
- `mcl_playerplus[name].node_foot`
|
||||||
|
- `mcl_playerplus[name].node_head`
|
||||||
|
|
||||||
Setting the group `disable_suffocation=1` disables suffocation for nodes which
|
Setting the group `disable_suffocation=1` disables suffocation for nodes which
|
||||||
would otherwise deal suffocation damage.
|
would otherwise deal suffocation damage.
|
|
@ -1,12 +1,8 @@
|
||||||
--[[
|
|
||||||
PlayerPlus by TenPlus1
|
|
||||||
]]
|
|
||||||
|
|
||||||
-- Player state for public API
|
-- Player state for public API
|
||||||
playerplus = {}
|
mcl_playerplus = {}
|
||||||
|
|
||||||
-- Internal player state
|
-- Internal player state
|
||||||
local playerplus_internal = {}
|
local mcl_playerplus_internal = {}
|
||||||
|
|
||||||
-- get node but use fallback for nil or unknown
|
-- get node but use fallback for nil or unknown
|
||||||
local function node_ok(pos, fallback)
|
local function node_ok(pos, fallback)
|
||||||
|
@ -35,16 +31,16 @@ local get_player_nodes = function(player_pos)
|
||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
work_pos.y = work_pos.y - 0.1 -- standing on
|
work_pos.y = work_pos.y - 0.1 -- standing on
|
||||||
local nod_stand = node_ok(work_pos)
|
local node_stand = node_ok(work_pos)
|
||||||
local nod_stand_below = node_ok({x=work_pos.x, y=work_pos.y-1, z=work_pos.z})
|
local node_stand_below = node_ok({x=work_pos.x, y=work_pos.y-1, z=work_pos.z})
|
||||||
|
|
||||||
work_pos.y = work_pos.y + 1.5 -- head level
|
work_pos.y = work_pos.y + 1.5 -- head level
|
||||||
local nod_head = node_ok(work_pos)
|
local node_head = node_ok(work_pos)
|
||||||
|
|
||||||
work_pos.y = work_pos.y - 1.2 -- feet level
|
work_pos.y = work_pos.y - 1.2 -- feet level
|
||||||
local nod_feet = node_ok(work_pos)
|
local node_feet = node_ok(work_pos)
|
||||||
|
|
||||||
return nod_stand, nod_stand_below, nod_head, nod_feet
|
return node_stand, node_stand_below, node_head, node_feet
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
@ -55,14 +51,14 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- WARNING: This section is HACKY as hell since it is all just based on heuristics.
|
-- WARNING: This section is HACKY as hell since it is all just based on heuristics.
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if playerplus_internal[name].jump_cooldown > 0 then
|
if mcl_playerplus_internal[name].jump_cooldown > 0 then
|
||||||
playerplus_internal[name].jump_cooldown = playerplus_internal[name].jump_cooldown - dtime
|
mcl_playerplus_internal[name].jump_cooldown = mcl_playerplus_internal[name].jump_cooldown - dtime
|
||||||
end
|
end
|
||||||
if player:get_player_control().jump and playerplus_internal[name].jump_cooldown <= 0 then
|
if player:get_player_control().jump and mcl_playerplus_internal[name].jump_cooldown <= 0 then
|
||||||
|
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
|
|
||||||
local nod_stand, nod_stand_below, nod_head, nod_feet = get_player_nodes(pos)
|
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
||||||
|
|
||||||
-- Cause buggy exhaustion for jumping
|
-- Cause buggy exhaustion for jumping
|
||||||
|
|
||||||
|
@ -77,18 +73,18 @@ minetest.register_globalstep(function(dtime)
|
||||||
as of 0.4.15.
|
as of 0.4.15.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
if minetest.get_item_group(nod_feet, "liquid") == 0 and
|
if minetest.get_item_group(node_feet, "liquid") == 0 and
|
||||||
minetest.get_item_group(nod_stand, "liquid") == 0 and
|
minetest.get_item_group(node_stand, "liquid") == 0 and
|
||||||
not minetest.registered_nodes[nod_feet].climbable and
|
not minetest.registered_nodes[node_feet].climbable and
|
||||||
not minetest.registered_nodes[nod_stand].climbable and
|
not minetest.registered_nodes[node_stand].climbable and
|
||||||
(minetest.registered_nodes[nod_stand].walkable or minetest.registered_nodes[nod_stand_below].walkable)
|
(minetest.registered_nodes[node_stand].walkable or minetest.registered_nodes[node_stand_below].walkable)
|
||||||
and minetest.get_item_group(nod_stand, "disable_jump") == 0
|
and minetest.get_item_group(node_stand, "disable_jump") == 0
|
||||||
and minetest.get_item_group(nod_stand_below, "disable_jump") == 0 then
|
and minetest.get_item_group(node_stand_below, "disable_jump") == 0 then
|
||||||
-- Cause exhaustion for jumping
|
-- Cause exhaustion for jumping
|
||||||
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_JUMP)
|
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_JUMP)
|
||||||
|
|
||||||
-- Reset cooldown timer
|
-- Reset cooldown timer
|
||||||
playerplus_internal[name].jump_cooldown = 0.45
|
mcl_playerplus_internal[name].jump_cooldown = 0.45
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -111,11 +107,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
local nod_stand, nod_stand_below, nod_head, nod_feet = get_player_nodes(pos)
|
local node_stand, node_stand_below, node_head, node_feet = get_player_nodes(pos)
|
||||||
playerplus[name].nod_stand = nod_stand
|
mcl_playerplus[name].node_stand = node_stand
|
||||||
playerplus[name].nod_stand_below = nod_stand_below
|
mcl_playerplus[name].node_stand_below = node_stand_below
|
||||||
playerplus[name].nod_head = nod_head
|
mcl_playerplus[name].node_head = node_head
|
||||||
playerplus[name].nod_feet = nod_feet
|
mcl_playerplus[name].node_feet = node_feet
|
||||||
|
|
||||||
-- set defaults
|
-- set defaults
|
||||||
def.speed = 1
|
def.speed = 1
|
||||||
|
@ -131,11 +127,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- standing on soul sand? if so walk slower
|
-- standing on soul sand? if so walk slower
|
||||||
if playerplus[name].nod_stand == "mcl_nether:soul_sand" then
|
if mcl_playerplus[name].node_stand == "mcl_nether:soul_sand" then
|
||||||
-- TODO: Tweak walk speed
|
-- TODO: Tweak walk speed
|
||||||
-- TODO: Also slow down mobs
|
-- TODO: Also slow down mobs
|
||||||
-- FIXME: This whole speed thing is a giant hack. We need a proper framefork for cleanly handling player speeds
|
-- FIXME: This whole speed thing is a giant hack. We need a proper framefork for cleanly handling player speeds
|
||||||
local below = playerplus[name].nod_stand_below
|
local below = mcl_playerplus[name].node_stand_below
|
||||||
if below == "mcl_core:ice" or below == "mcl_core:packed_ice" or below == "mcl_core:slimeblock" then
|
if below == "mcl_core:ice" or below == "mcl_core:packed_ice" or below == "mcl_core:slimeblock" then
|
||||||
def.speed = def.speed - 0.9
|
def.speed = def.speed - 0.9
|
||||||
else
|
else
|
||||||
|
@ -149,7 +145,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
-- 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)
|
||||||
local ndef = minetest.registered_nodes[playerplus[name].nod_head]
|
local ndef = minetest.registered_nodes[mcl_playerplus[name].node_head]
|
||||||
|
|
||||||
if (ndef.walkable == nil or ndef.walkable == true)
|
if (ndef.walkable == nil or ndef.walkable == true)
|
||||||
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
and (ndef.collision_box == nil or ndef.collision_box.type == "regular")
|
||||||
|
@ -198,23 +194,23 @@ minetest.register_globalstep(function(dtime)
|
||||||
--[[ Swimming: Cause exhaustion.
|
--[[ Swimming: Cause exhaustion.
|
||||||
NOTE: As of 0.4.15, it only counts as swimming when you are with the feet inside the liquid!
|
NOTE: As of 0.4.15, it only counts as swimming when you are with the feet inside the liquid!
|
||||||
Head alone does not count. We respect that for now. ]]
|
Head alone does not count. We respect that for now. ]]
|
||||||
if minetest.get_item_group(playerplus[name].nod_feet, "liquid") ~= 0 or
|
if minetest.get_item_group(mcl_playerplus[name].node_feet, "liquid") ~= 0 or
|
||||||
minetest.get_item_group(playerplus[name].nod_stand, "liquid") ~= 0 then
|
minetest.get_item_group(mcl_playerplus[name].node_stand, "liquid") ~= 0 then
|
||||||
local lastPos = playerplus_internal[name].lastPos
|
local lastPos = mcl_playerplus_internal[name].lastPos
|
||||||
if lastPos then
|
if lastPos then
|
||||||
local dist = vector.distance(lastPos, pos)
|
local dist = vector.distance(lastPos, pos)
|
||||||
playerplus_internal[name].swimDistance = playerplus_internal[name].swimDistance + dist
|
mcl_playerplus_internal[name].swimDistance = mcl_playerplus_internal[name].swimDistance + dist
|
||||||
if playerplus_internal[name].swimDistance >= 1 then
|
if mcl_playerplus_internal[name].swimDistance >= 1 then
|
||||||
local superficial = math.floor(playerplus_internal[name].swimDistance)
|
local superficial = math.floor(mcl_playerplus_internal[name].swimDistance)
|
||||||
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_SWIM * superficial)
|
mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_SWIM * superficial)
|
||||||
playerplus_internal[name].swimDistance = playerplus_internal[name].swimDistance - superficial
|
mcl_playerplus_internal[name].swimDistance = mcl_playerplus_internal[name].swimDistance - superficial
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Underwater: Spawn bubble particles
|
-- Underwater: Spawn bubble particles
|
||||||
if minetest.get_item_group(playerplus[name].nod_head, "water") ~= 0 then
|
if minetest.get_item_group(mcl_playerplus[name].node_head, "water") ~= 0 then
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 10,
|
amount = 10,
|
||||||
|
@ -265,7 +261,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update internal values
|
-- Update internal values
|
||||||
playerplus_internal[name].lastPos = pos
|
mcl_playerplus_internal[name].lastPos = pos
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -275,13 +271,14 @@ end)
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
playerplus[name] = {
|
mcl_playerplus[name] = {
|
||||||
nod_head = "",
|
node_head = "",
|
||||||
nod_feet = "",
|
node_feet = "",
|
||||||
nod_stand = "",
|
node_stand = "",
|
||||||
|
node_stand_below = "",
|
||||||
}
|
}
|
||||||
|
|
||||||
playerplus_internal[name] = {
|
mcl_playerplus_internal[name] = {
|
||||||
lastPos = nil,
|
lastPos = nil,
|
||||||
swimDistance = 0,
|
swimDistance = 0,
|
||||||
jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly
|
jump_cooldown = -1, -- Cooldown timer for jumping, we need this to prevent the jump exhaustion to increase rapidly
|
||||||
|
@ -292,6 +289,6 @@ end)
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
||||||
playerplus[name] = nil
|
mcl_playerplus[name] = nil
|
||||||
playerplus_internal[name] = nil
|
mcl_playerplus_internal[name] = nil
|
||||||
end)
|
end)
|
1
mods/PLAYER/mcl_playerplus/mod.conf
Normal file
1
mods/PLAYER/mcl_playerplus/mod.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
name = mcl_playerplus
|
|
@ -1,2 +1,2 @@
|
||||||
playerplus
|
mcl_playerplus
|
||||||
mcl_hunger
|
mcl_hunger
|
||||||
|
|
|
@ -82,7 +82,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
if players[playerName]["shouldSprint"] == true then --Stopped
|
if players[playerName]["shouldSprint"] == true then --Stopped
|
||||||
local sprinting
|
local sprinting
|
||||||
-- Prevent sprinting if standing on soul sand or hungry
|
-- Prevent sprinting if standing on soul sand or hungry
|
||||||
if playerplus[playerName].nod_stand == "mcl_nether:soul_sand" or (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) then
|
if mcl_playerplus[playerName].node_stand == "mcl_nether:soul_sand" or (mcl_hunger.active and mcl_hunger.get_hunger(player) <= 6) then
|
||||||
sprinting = false
|
sprinting = false
|
||||||
else
|
else
|
||||||
sprinting = true
|
sprinting = true
|
||||||
|
@ -101,7 +101,7 @@ function setSprinting(playerName, sprinting) --Sets the state of a player (0=sto
|
||||||
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
|
||||||
if playerplus[playerName].nod_stand ~= "mcl_nether:soul_sand" then
|
if mcl_playerplus[playerName].node_stand ~= "mcl_nether:soul_sand" 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
|
||||||
|
|
Loading…
Reference in a new issue