mirror of
https://codeberg.org/tenplus1/farming.git
synced 2025-07-17 15:50:26 +02:00
hoebomb uses moveresult
This commit is contained in:
@ -2,7 +2,6 @@
|
|||||||
-- All textures by (C) Auke Kok <sofar@foo-projects.org> CC-BY-SA-3.0
|
-- All textures by (C) Auke Kok <sofar@foo-projects.org> CC-BY-SA-3.0
|
||||||
|
|
||||||
local S = core.get_translator("farming")
|
local S = core.get_translator("farming")
|
||||||
local a = farming.recipe_items
|
|
||||||
|
|
||||||
-- place beans helper
|
-- place beans helper
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
local S = core.get_translator("farming")
|
local S = core.get_translator("farming")
|
||||||
local a = farming.recipe_items
|
|
||||||
|
|
||||||
-- item/seed
|
-- item/seed
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
-- https://forum.core.net/viewtopic.php?id=4990
|
-- https://forum.core.net/viewtopic.php?id=4990
|
||||||
|
|
||||||
local S = core.get_translator("farming")
|
local S = core.get_translator("farming")
|
||||||
local a = farming.recipe_items
|
|
||||||
|
|
||||||
-- item/seed
|
-- item/seed
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
local S = core.get_translator("farming")
|
local S = core.get_translator("farming")
|
||||||
local a = farming.recipe_items
|
|
||||||
|
|
||||||
-- item/seed
|
-- item/seed
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ if core.registered_nodes["default:junglegrass"] then
|
|||||||
})
|
})
|
||||||
end
|
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
|
if farming.mcl then
|
||||||
|
|
||||||
|
45
hoes.lua
45
hoes.lua
@ -241,7 +241,7 @@ local function hoe_area(pos, player)
|
|||||||
-- remove flora (grass, flowers etc.)
|
-- remove flora (grass, flowers etc.)
|
||||||
local res = core.find_nodes_in_area(
|
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 - 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"})
|
{"group:flora", "group:grass", "group:dry_grass", "default:dry_shrub"})
|
||||||
|
|
||||||
for n = 1, #res do
|
for n = 1, #res do
|
||||||
@ -268,46 +268,27 @@ core.register_entity("farming:hoebomb_entity", {
|
|||||||
visual = "sprite",
|
visual = "sprite",
|
||||||
visual_size = {x = 1.0, y = 1.0},
|
visual_size = {x = 1.0, y = 1.0},
|
||||||
textures = {"farming_hoe_bomb.png"},
|
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 = {},
|
lastpos = {},
|
||||||
player = "",
|
player = "",
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime, moveresult)
|
||||||
|
|
||||||
if not self.player then
|
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()
|
self.object:remove()
|
||||||
|
|
||||||
return
|
|
||||||
end
|
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
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -342,7 +323,7 @@ core.register_craftitem("farming:hoe_bomb", {
|
|||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
hoe_area(pointed_thing.above, user)
|
hoe_area(pointed_thing.under, user)
|
||||||
else
|
else
|
||||||
throw_potion(itemstack, user)
|
throw_potion(itemstack, user)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user