increase mithril scythe to 350 uses, tidy hoe code

This commit is contained in:
tenplus1 2023-10-02 07:39:06 +01:00
parent 98f0581c17
commit 421cde33a4
1 changed files with 21 additions and 28 deletions

View File

@ -110,7 +110,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
-- turn the node into soil, wear out item and play sound -- turn the node into soil, wear out item and play sound
minetest.set_node(pt.under, {name = ndef.soil.dry}) minetest.set_node(pt.under, {name = ndef.soil.dry})
minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5}) minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5}, true)
local wdef = itemstack:get_definition() local wdef = itemstack:get_definition()
local wear = 65535 / (uses - 1) local wear = 65535 / (uses - 1)
@ -130,8 +130,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
end end
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
minetest.sound_play(wdef.sound.breaks, {pos = pt.above, minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5}, true)
gain = 0.5}, true)
end end
return itemstack return itemstack
@ -252,11 +251,15 @@ end
-- throwable hoe bomb -- throwable hoe bomb
minetest.register_entity("farming:hoebomb_entity", { minetest.register_entity("farming:hoebomb_entity", {
physical = true,
visual = "sprite", initial_properties = {
visual_size = {x = 1.0, y = 1.0}, physical = true,
textures = {"farming_hoe_bomb.png"}, visual = "sprite",
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}, visual_size = {x = 1.0, y = 1.0},
textures = {"farming_hoe_bomb.png"},
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1}
},
lastpos = {}, lastpos = {},
player = "", player = "",
@ -273,7 +276,7 @@ minetest.register_entity("farming:hoebomb_entity", {
if self.lastpos.x ~= nil then if self.lastpos.x ~= nil then
local vel = self.object:getvelocity() local vel = self.object:get_velocity()
-- only when potion hits something physical -- only when potion hits something physical
if vel.x == 0 if vel.x == 0
@ -311,20 +314,14 @@ local function throw_potion(itemstack, player)
z = playerpos.z z = playerpos.z
}, "farming:hoebomb_entity") }, "farming:hoebomb_entity")
if not obj then return end
local dir = player:get_look_dir() local dir = player:get_look_dir()
local velocity = 20 local velocity = 20
obj:set_velocity({ obj:set_velocity({x = dir.x * velocity, y = dir.y * velocity, z = dir.z * velocity})
x = dir.x * velocity,
y = dir.y * velocity,
z = dir.z * velocity
})
obj:set_acceleration({ obj:set_acceleration({x = dir.x * -3, y = -9.5, z = dir.z * -3})
x = dir.x * -3,
y = -9.5,
z = dir.z * -3
})
obj:get_luaentity().player = player obj:get_luaentity().player = player
end end
@ -386,18 +383,13 @@ minetest.register_tool("farming:scythe_mithril", {
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
if not def if not def or not def.drop or not def.groups or not def.groups.plant then
or not def.drop
or not def.groups
or not def.groups.plant then
return return
end end
local drops = minetest.get_node_drops(node.name, "") local drops = minetest.get_node_drops(node.name, "")
if not drops if not drops or #drops == 0 or (#drops == 1 and drops[1] == "") then
or #drops == 0
or (#drops == 1 and drops[1] == "") then
return return
end end
@ -405,6 +397,7 @@ minetest.register_tool("farming:scythe_mithril", {
local mname = node.name:split(":")[1] local mname = node.name:split(":")[1]
local pname = node.name:split(":")[2] local pname = node.name:split(":")[2]
local sname = tonumber(pname:split("_")[2]) local sname = tonumber(pname:split("_")[2])
pname = pname:split("_")[1] pname = pname:split("_")[1]
if not sname then if not sname then
@ -443,7 +436,7 @@ minetest.register_tool("farming:scythe_mithril", {
end end
-- play sound -- play sound
minetest.sound_play("default_grass_footstep", {pos = pos, gain = 1.0}) minetest.sound_play("default_grass_footstep", {pos = pos, gain = 1.0}, true)
local replace = mname .. ":" .. pname .. "_1" local replace = mname .. ":" .. pname .. "_1"
@ -458,7 +451,7 @@ minetest.register_tool("farming:scythe_mithril", {
if not farming.is_creative(name) then if not farming.is_creative(name) then
itemstack:add_wear(65535 / 150) -- 150 uses itemstack:add_wear(65535 / 350) -- 350 uses
return itemstack return itemstack
end end