This commit is contained in:
Elias Fleckenstein 2021-01-27 16:01:04 +01:00
parent 5ede42bbe7
commit 248272a128
2 changed files with 8 additions and 4 deletions

@ -161,7 +161,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
local objects = minetest.get_objects_inside_radius(pos, 1)
for _,obj in ipairs(objects) do
if obj:is_player() then
if not minetest.is_creative_enabled(obj:get_player_name()) then
if self._collectable and not minetest.is_creative_enabled(obj:get_player_name()) then
if obj:get_inventory():room_for_item("main", "mcl_bows:arrow") then
obj:get_inventory():add_item("main", "mcl_bows:arrow")
minetest.sound_play("item_drop_pickup", {

@ -33,7 +33,7 @@ local bow_load = {}
-- Another player table, this one stores the wield index of the bow being charged
local bow_index = {}
mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack)
mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable)
local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity")
if power == nil then
power = BOW_MAX_SPEED --19
@ -60,6 +60,7 @@ mcl_bows.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter, power, damag
le._is_critical = is_critical
le._startpos = pos
le._knockback = knockback
le._collectable = collectable
minetest.sound_play("mcl_bows_bow_shoot", {pos=pos, max_hear_distance=16}, true)
if shooter ~= nil and shooter:is_player() then
if obj:get_luaentity().player == "" then
@ -88,6 +89,7 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
local arrow_stack, arrow_stack_id = get_arrow(player)
local arrow_itemstring
local has_infinity_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "infinity")
local infinity_used = false
if minetest.is_creative_enabled(player:get_player_name()) then
if arrow_stack then
@ -100,7 +102,9 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
return false
end
arrow_itemstring = arrow_stack:get_name()
if not has_infinity_enchantment or minetest.get_item_group(arrow_itemstring, "ammo_bow_regular") == 0 then
if has_infinity_enchantment and minetest.get_item_group(arrow_itemstring, "ammo_bow_regular") > 0 then
infinity_used = true
else
arrow_stack:take_item()
end
local inv = player:get_inventory()
@ -113,7 +117,7 @@ local player_shoot_arrow = function(itemstack, player, power, damage, is_critica
local dir = player:get_look_dir()
local yaw = player:get_look_horizontal()
mcl_bows.shoot_arrow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item())
mcl_bows.shoot_arrow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), not infinity_used)
return true
end