1
0
Fork 0

Compare commits

...

7 Commits

3 changed files with 46 additions and 30 deletions

View File

@ -257,10 +257,10 @@ function ARROW_ENTITY.on_step(self, dtime)
mcl_burning.set_on_fire(obj, 5)
end
if not self._in_player and not self._blocked then
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self._damage},
}, self.object:get_velocity())
mcl_util.deal_damage(obj, self._damage, {type = "arrow", source = self._shooter, direct = self.object})
if self._extra_hit_func then
self._extra_hit_func(obj)
end
if obj:is_player() then
if not mcl_shields.is_blocking(obj) then
local placement

View File

@ -211,16 +211,37 @@ local function set_interact(player, interact)
return
end
local meta = player:get_meta()
if meta:get_int("mcl_privs:interact_revoked") ~= 1 then
privs.interact = interact
minetest.set_player_privs(player_name, privs)
meta:set_int("mcl_privs:interact_revoked",0)
if interact and meta:get_int("mcl_shields:interact_revoked") ~= 0 then
meta:set_int("mcl_shields:interact_revoked", 0)
privs.interact = true
elseif not interact then
meta:set_int("mcl_shields:interact_revoked", privs.interact and 1 or 0)
privs.interact = nil
end
minetest.set_player_privs(player_name, privs)
end
-- Prevent player from being able to circumvent interact privilage removal by
-- using shield.
minetest.register_on_priv_revoke(function(name, revoker, priv)
if priv == "interact" and revoker then
local player = minetest.get_player_by_name(name)
if not player then
return
end
local meta = player:get_meta()
meta:set_int("mcl_shields:interact_revoked", 0)
end
end)
local shield_hud = {}
local function remove_shield_hud(player)
set_interact(player, true)
playerphysics.remove_physics_factor(player, "speed", "shield_speed")
if not shield_hud[player] then return end --this function takes a long time. only run it when necessary
player:hud_remove(shield_hud[player])
shield_hud[player] = nil
@ -231,9 +252,6 @@ local function remove_shield_hud(player)
if not hf.wielditem then
player:hud_set_flags({wielditem = true})
end
playerphysics.remove_physics_factor(player, "speed", "shield_speed")
set_interact(player, true)
end
local function add_shield_entity(player, i)
@ -251,6 +269,11 @@ local function remove_shield_entity(player, i)
end
end
local function is_rmb_conflicting_node(nodename)
nodedef = minetest.registered_nodes[nodename] or {}
return nodedef.on_rightclick
end
local function handle_blocking(player)
local player_shield = mcl_shields.players[player]
local rmb = player:get_player_control().RMB
@ -266,7 +289,7 @@ local function handle_blocking(player)
local pos = player:get_pos()
if shield_in_hand then
if not_blocking then
minetest.after(0.25, function()
minetest.after(0.05, function()
if (not_blocking or not shield_in_offhand) and shield_in_hand and rmb then
player_shield.blocking = 2
set_shield(player, true, 2)
@ -277,11 +300,16 @@ local function handle_blocking(player)
end
elseif shield_in_offhand then
local pointed_thing = mcl_util.get_pointed_thing(player, true)
local offhand_can_block = (wielded_item(player) == "" or not pointed_thing)
and (minetest.get_item_group(wielded_item(player), "bow") ~= 1 and minetest.get_item_group(wielded_item(player), "crossbow") ~= 1)
local wielded_stack = player:get_wielded_item()
local offhand_can_block = (minetest.get_item_group(wielded_item(player), "bow") ~= 1
and minetest.get_item_group(wielded_item(player), "crossbow") ~= 1)
if pointed_thing and pointed_thing.type == "node" then
if minetest.get_item_group(minetest.get_node(pointed_thing.under).name, "container") > 1 then
local pointed_node = minetest.get_node(pointed_thing.under)
if minetest.get_item_group(pointed_node.name, "container") > 1
or is_rmb_conflicting_node(pointed_node.name)
or wielded_stack:get_definition().type == "node"
then
return
end
end
@ -290,7 +318,7 @@ local function handle_blocking(player)
return
end
if not_blocking then
minetest.after(0.25, function()
minetest.after(0.05, function()
if (not_blocking or not shield_in_hand) and shield_in_offhand and rmb and offhand_can_block then
player_shield.blocking = 1
set_shield(player, true, 1)
@ -344,7 +372,7 @@ local function add_shield_hud(shieldstack, player, blocking)
z_index = -200,
})
playerphysics.add_physics_factor(player, "speed", "shield_speed", 0.5)
set_interact(player, nil)
set_interact(player, false)
end
local function update_shield_hud(player, blocking, shieldstack)

View File

@ -30,17 +30,5 @@ for _, action in pairs({"grant", "revoke"}) do
if priv == "fly" then
meta:set_int("mcl_privs:fly_changed", 1)
end
--[[
so e.g. hackers who have been revoked of the interact privilege
will not automatically get the interact privilege through the mcl shields code back
]]
if priv == "interact" then
if action == "revoke" then
meta:set_int("mcl_privs:interact_revoked", 1)
else
meta:set_int("mcl_privs:interact_revoked", 0)
end
end
end)
end
end