Too many mods destroy “indescructible” nodes

Post Reply
User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Too many mods destroy “indescructible” nodes

by Wuzzy » Post

Well, it turns out it is not quite easy to create a truly indestructible block.

Sure, when using minetest.remove_node, you can destroy everything. What I am talking about is creating a block which should be indestructible in normal gameplay.

A good start might be to add this code into the node definition:

Code: Select all

groups = { immortal = 1 },
Now you are certain the node cannot be destroyed by mining.

However, the real problem comes when your node has to interact with other mods. I noticed that many mods are way too trigger happy when it comes to destroying nodes. As soon they destroy nodes, they completely ignore even the most basic properties.

All TNT and similar mods I know mercilessly destroy any node the TNT can reach. Including the TNT mod from minetest_game. The mods do not check if the node is part of the immortal group, so they destroy “indestructible” nodes.
This is not a problem unique to TNT mods, it affects all mods which blindly call minetest.remove_node or minetest.set_node on unknown nodes.

More mod makers need to be aware of this.


So here is my suggestion to mod makers:
Please be very cautios when calling minetest.remove_node / minetest.set_node on unknown nodes. You always have the risk of destroying a node which is not supposed to be destroyed.
First check if the node is in the immortal group. Only then proceed with deleting or replacing.


There is one exception to this rule: When you're debugging and testing. There is a mod which adds an admin stick, which removes EVERYTHING it touches. This is legitimate, as it is specifically designed to get rid of otherwise indestructible nodes and it is not designed for normal gameplay.


So, my fellow modders, what do you think? Do you agree with me? Would you change your modding style accordingly? Or do you have a different opinion?

User avatar
HeroOfTheWinds
Member
Posts: 470
Joined: Wed Apr 23, 2014 23:16
GitHub: HeroOfTheWinds
IRC: WindHero
Location: Hawaii

Re: Too many mods destroy “indescructible” nodes

by HeroOfTheWinds » Post

I agree that more attention should be payed to keeping indestructible nodes indestructible. However, there are in fact extra measures that can be taken on the defensive side: Implement the on_destruct and after_destruct functions to put the block back in place after it is destroyed. Not perfect, especially if you had metadata in the node, but certainly takes out some 50% of offending mods.
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P

guideahon
Member
Posts: 37
Joined: Mon Jan 26, 2015 12:49
In-game: guideahon

Re: Too many mods destroy “indescructible” nodes

by guideahon » Post

Maybe another property can be made by the devs "minetest.check&remove_node" to be use by modders instead of minetest.remove_node? or viceversa, edit minetest.remove_node to check and make a new one minetest.remove_node_nocheck for admin privileges mods

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Too many mods destroy “indescructible” nodes

by Wuzzy » Post

guideahon's suggestion sounds like a good start.

User avatar
stu
Member
Posts: 923
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11
Location: United Kingdom

Re: Too many mods destroy “indescructible” nodes

by stu » Post

Wuzzy wrote: All TNT and similar mods I know mercilessly destroy any node the TNT can reach. Including the TNT mod from minetest_game. The mods do not check if the node is part of the immortal group, so they destroy “indestructible” nodes.
This is not a problem unique to TNT mods, it affects all mods which blindly call minetest.remove_node or minetest.set_node on unknown nodes.
To be fair, there aren't any indestructable nodes in minetest_game afaik, but then I do see your point.
I think the biggest issue with blasting is that checking every node will cause a considerable slow down,
I also think that it should be up to server ops and game makers to decide what is more important.

User avatar
false_chicken
Member
Posts: 53
Joined: Wed Feb 04, 2015 23:41
GitHub: falsechicken
In-game: false_chicken
Location: Florida, USA

Re: Too many mods destroy “indescructible” nodes

by false_chicken » Post

Nice PSA Wuzzy. Noted for any future projects.
DISCLAIMER: I am probably wrong.

User avatar
Dopium
Member
Posts: 233
Joined: Sat Jun 09, 2012 15:43
Location: Australia

Re: Too many mods destroy “indescructible” nodes

by Dopium » Post

Great write up, i will have to take a look at your bedrock code as to how you went about "true" immortal

fessmK
Member
Posts: 49
Joined: Wed Sep 25, 2013 15:56

Re: Too many mods destroy “indescructible” nodes

by fessmK » Post

I have a disruptor in quest test, I may make it to conform. However, making a node's selection box = nil helps a lot, except against tnt.(I used this in the dimensional separator) If tnt respected a node's on_blast() function, this could be used to make a node indestructible to tnt.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Too many mods destroy “indescructible” nodes

by Wuzzy » Post

I don't know if it is a good idea to set the selection box to nil; this looks more like a hack and you are using this parameter in a way which is probably not intended by the programmers; so maybe this weirdness may change in future.
To make a node non-pointable, set pointable = false.

Oh, and about TNT, there is a pull request over there:
https://github.com/minetest/minetest_game/pull/450

:-)

There is nothing you, as a modder, can defend against Minetest Game's TNT right now (unless you directly hack Minetest Game), and this is really a fault in Minetest Game, so the fix has to be applied there.

pl608
New member
Posts: 7
Joined: Wed Mar 10, 2021 18:01
GitHub: pl608
IRC: pl608
In-game: pl608

Re: Too many mods destroy “indescructible” nodes

by pl608 » Post

Is there a way to tell if a node is indestructible from a remote mod? :get_definition() didn't work for me.

Code: Select all

init.lua:38: attempt to call global 'get_definition' (a nil value)

Code: Select all

function check_immortal(item)
    --local it = ItemStack(item)

    if item:get_definition()--[[get group info]] >= 1 then
        return true
    else
        return false
    end
end

...

local node = minetest.get_node(pos)
if check_immortal(node) ~= false then
	minetest.set_node(p, {name="air"})
end

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Too many mods destroy “indescructible” nodes

by Blockhead » Post

pl608 wrote:
Sat Nov 26, 2022 23:46
Is there a way to tell if a node is indestructible from a remote mod? :get_definition() didn't work for me.
Technically there's no established standard for making things indestructible, but if you want to use the immortal group that Wuzzy suggests (because immortal is an armour group for entities that has a similar effect), then try something like this:

Code: Select all

function is_indestructible(pos)
	local node = minetest.get_node(pos)
	local def = minetest.registered_nodes[node.name]
	if not (def and def.groups) then return end
	return def.groups.immortal >= 1
end
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

pl608
New member
Posts: 7
Joined: Wed Mar 10, 2021 18:01
GitHub: pl608
IRC: pl608
In-game: pl608

Re: Too many mods destroy “indescructible” nodes

by pl608 » Post

Ok, thanks for the code!

User avatar
FreeLikeGNU
Member
Posts: 280
Joined: Tue Oct 28, 2014 02:50
GitHub: FreeLikeGNU
IRC: freelikegnu
In-game: FreeLikeGNU

Re: Too many mods destroy “indescructible” nodes

by FreeLikeGNU » Post

Why not:

Code: Select all

groups = { indescructible = 1 }

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Too many mods destroy “indescructible” nodes

by Blockhead » Post

FreeLikeGNU wrote:
Sat Dec 03, 2022 04:37
Why not:

Code: Select all

groups = { indescructible = 1 }
There's no engine features you get by using one name or another, they are just conventions. The argument in favour of using immortal is that entities already use that group. The argument in favour of indestructible is that it would probably be more semantically correct. Immortal is easier to type correctly too..
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Corax
Member
Posts: 18
Joined: Tue Jan 05, 2021 17:59

Re: Too many mods destroy “indescructible” nodes

by Corax » Post

Blockhead wrote:
Sat Dec 03, 2022 20:53
FreeLikeGNU wrote:
Sat Dec 03, 2022 04:37
Why not:

Code: Select all

groups = { indescructible = 1 }
There's no engine features you get by using one name or another, they are just conventions. The argument in favour of using immortal is that entities already use that group. The argument in favour of indestructible is that it would probably be more semantically correct. Immortal is easier to type correctly too..
Depending on your tool chain, immoral is not necessarily easier to type correctly and might not even get flagged, whereas indescructible should get caught by even the most primitive spell checking tools.
Obviously even that assumption does not hold in the face of reality.

User avatar
snoopy
Member
Posts: 263
Joined: Thu Oct 20, 2016 16:49
Location: DE, European Union

Re: Too many mods destroy “indescructible” nodes

by snoopy » Post

What about "sturdy" ?

Code: Select all

groups = { sturdy = 1 } 
sturdy - strong enough to withstand rough work or treatment

Would be easier to type and lower the chance of putting it wrong. Furthermore, the term would acknowledge the introductory statement from Wuzzy that it is not quite easy to create a truly indestructible block.
Corax wrote:
Sat Dec 10, 2022 15:10
Depending on your tool chain, immoral is not necessarily easier to type correctly and might not even get flagged, whereas indescructible should get caught by even the most primitive spell checking tools.
Obviously even that assumption does not hold in the face of reality.
@Corax - Good point. ;)

I very much enjoy your non-destructive way of scrupulously comparing the term immoral with immortal by an almost inscrutable attitude of incredibility ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests