Compare commits

...

5 Commits

Author SHA1 Message Date
loveaabb 195b193260 remove trailing whitespace 2024-05-24 01:39:11 +00:00
loveaabb 83a651d375 change a misset global variable to local 2024-05-18 15:25:03 +00:00
loveaabb 19190d92e7 revert f50ef6b52a
revert 更新 mods/ITEMS/mcl_shields/init.lua

change commit info
2024-05-18 15:21:38 +00:00
loveaabb f50ef6b52a 更新 mods/ITEMS/mcl_shields/init.lua 2024-05-18 15:15:42 +00:00
loveaabb 50fda3e844 Several improvements to the Shield
changes:
1. removed the limitation to block while pointing a node wielding an item
2. check whether the player is pointing to a node defined with right-click Formspec (to avoid the formspec bug while blocking) and whether the player is wielding a node (to avoid continous node placing not functioning) before blocking
3. decreased the interval between right click and block
2024-05-16 15:33:32 +00:00
1 changed files with 19 additions and 5 deletions

View File

@ -251,6 +251,15 @@ local function remove_shield_entity(player, i)
end
end
local function is_node_stack(itemstack)
return itemstack:get_definition().drawtype -- only node's definition table contains element "drawtype"
end
local function is_rmb_conflicting_node(nodename)
local nodedef = minetest.registered_nodes[nodename]
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 +275,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 +286,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 is_node_stack(wielded_stack)
then
return
end
end
@ -290,7 +304,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)