Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure when the trees are placed it doesn't interfere with a protected area #26

Open
Panquesito7 opened this issue Apr 20, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Panquesito7
Copy link
Member

Description

A few years back, I remember that I was working on this feature (when the mod was still available on GitLab), but I didn't fully finish it.
It appears the issue is still present. Would be great if this could be worked on (I could help a little bit if wanted).

moretrees/node_defs.lua

Lines 445 to 450 in 393840b

-- minp, maxp to be checked, relative to sapling pos
-- minp_relative.y = 1 because sapling pos has been checked
{x = -3, y = 1, z = -3},
{x = 3, y = 6, z = 3},
-- maximum interval of interior volume check
4)

@Panquesito7 Panquesito7 added the enhancement New feature or request label Apr 20, 2023
@fluxionary
Copy link
Member

one of the items on my wish-list is a way for mods to register the dimensions of trees in an abstract way. while this request isn't for such a feature, IMO it's a step in the right direction.

@Panquesito7
Copy link
Member Author

Panquesito7 commented Jan 13, 2024

I found the correct values for three saplings back when I was working on it. I might re-work this soon using this method unless there's a better way to do so. IIRC, these should be the correct values. There could be some minor issues, though, but here you go. :)

...
-- this code should be on the `on_place` callback of the sapling registration

if treename == "beech" then
	itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
		"moretrees:" ..treename.. "_sapling",
		-- minp, maxp to be checked, relative to sapling pos
		-- minp_relative.y = 1 because sapling pos has been checked
		{x = -3, y = 1, z = -4},
		{x = 4, y = 9, z = 3},
		-- maximum interval of interior volume check
	4)
elseif treename == "apple_tree" then
	itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
		"moretrees:" ..treename.. "_sapling",
		-- minp, maxp to be checked, relative to sapling pos
		-- minp_relative.y = 1 because sapling pos has been checked
		{x = -9, y = 1, z = -9},
		{x = 9, y = 9, z = 9},
		-- maximum interval of interior volume check
	4)
elseif treename == "oak" then
	itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
		"moretrees:" ..treename.. "_sapling",
		-- minp, maxp to be checked, relative to sapling pos
		-- minp_relative.y = 1 because sapling pos has been checked
		{x = -6, y = 1, z = -6},
		{x = 8, y = 16, z = 6},
		-- maximum interval of interior volume check
	4)

@wsor4035
Copy link
Contributor

while i think this can be useful, it should be behind a setting (maybe off by default?) since checking the whole area probably will be expensive/some people might not care for it

@fluxionary
Copy link
Member

expensive

if we assume areas mod instead of minetest.is_protected, the check need not be very expensive. https://github.com/minetest-mods/areas/blob/cba647225ce68bb543b8911063b965a1527b3526/api.lua#L58. i know there's other protection mods out there, but areas is common.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants