From edaf7d0a15804f5b03a35aeef51df1d40e42c4c7 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 17 Jul 2025 13:06:57 +0100 Subject: [PATCH] hoebomb uses moveresult --- crops/beans.lua | 1 - crops/beetroot.lua | 1 - crops/carrot.lua | 1 - crops/chili.lua | 1 - grass.lua | 2 +- hoes.lua | 45 +++++++++++++-------------------------------- 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/crops/beans.lua b/crops/beans.lua index 82afb45..1d18e75 100644 --- a/crops/beans.lua +++ b/crops/beans.lua @@ -2,7 +2,6 @@ -- All textures by (C) Auke Kok CC-BY-SA-3.0 local S = core.get_translator("farming") -local a = farming.recipe_items -- place beans helper diff --git a/crops/beetroot.lua b/crops/beetroot.lua index 424c996..deb8a44 100644 --- a/crops/beetroot.lua +++ b/crops/beetroot.lua @@ -1,6 +1,5 @@ local S = core.get_translator("farming") -local a = farming.recipe_items -- item/seed diff --git a/crops/carrot.lua b/crops/carrot.lua index 856c820..26bff5f 100644 --- a/crops/carrot.lua +++ b/crops/carrot.lua @@ -3,7 +3,6 @@ -- https://forum.core.net/viewtopic.php?id=4990 local S = core.get_translator("farming") -local a = farming.recipe_items -- item/seed diff --git a/crops/chili.lua b/crops/chili.lua index 0ed331f..9e7722e 100644 --- a/crops/chili.lua +++ b/crops/chili.lua @@ -1,6 +1,5 @@ local S = core.get_translator("farming") -local a = farming.recipe_items -- item/seed diff --git a/grass.lua b/grass.lua index ae7c1bc..7d1ab7d 100644 --- a/grass.lua +++ b/grass.lua @@ -55,7 +55,7 @@ if core.registered_nodes["default:junglegrass"] then }) end --- override mineclone tallgrass to drop all sof the above seeds +-- override mineclone tallgrass to drop all of the above seeds if farming.mcl then diff --git a/hoes.lua b/hoes.lua index e8c7a3b..1d60b8b 100644 --- a/hoes.lua +++ b/hoes.lua @@ -241,7 +241,7 @@ local function hoe_area(pos, player) -- remove flora (grass, flowers etc.) local res = core.find_nodes_in_area( {x = pos.x - r, y = pos.y - 1, z = pos.z - r}, - {x = pos.x + r, y = pos.y + 2, z = pos.z + r}, + {x = pos.x + r, y = pos.y + 1, z = pos.z + r}, {"group:flora", "group:grass", "group:dry_grass", "default:dry_shrub"}) for n = 1, #res do @@ -268,46 +268,27 @@ core.register_entity("farming:hoebomb_entity", { visual = "sprite", 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} + collisionbox = {-0.2,-0.2,-0.2,0.2,0.2,0.2} }, lastpos = {}, player = "", - on_step = function(self, dtime) + on_step = function(self, dtime, moveresult) if not self.player then + self.object:remove() ; return + end + + if moveresult.collides then + + local pos = vector.round(self.object:get_pos()) + local def = moveresult.collisions and moveresult.collisions[1] or {} + + pos.y = pos.y - 1 ; hoe_area(pos, self.player) self.object:remove() - - return end - - local pos = self.object:get_pos() - - if self.lastpos.x ~= nil then - - local vel = self.object:get_velocity() - - -- only when potion hits something physical - if vel.x == 0 or vel.y == 0 or vel.z == 0 then - - if self.player ~= "" then - - -- round up coords to fix glitching through doors - self.lastpos = vector.round(self.lastpos) - - hoe_area(self.lastpos, self.player) - end - - self.object:remove() - - return - - end - end - - self.lastpos = pos end }) @@ -342,7 +323,7 @@ core.register_craftitem("farming:hoe_bomb", { on_use = function(itemstack, user, pointed_thing) if pointed_thing.type == "node" then - hoe_area(pointed_thing.above, user) + hoe_area(pointed_thing.under, user) else throw_potion(itemstack, user)