Page 1 of 1

Too many mods destroy “indescructible” nodes

PostPosted: Fri Feb 20, 2015 05:56
by Wuzzy
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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?

Re: Too many mods destroy “indescructible” nodes

PostPosted: Fri Feb 20, 2015 06:42
by HeroOfTheWinds
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.

Re: Too many mods destroy “indescructible” nodes

PostPosted: Fri Feb 20, 2015 19:55
by guideahon
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

Re: Too many mods destroy “indescructible” nodes

PostPosted: Fri Feb 20, 2015 20:28
by Wuzzy
guideahon's suggestion sounds like a good start.

Re: Too many mods destroy “indescructible” nodes

PostPosted: Sat Feb 21, 2015 01:34
by stu
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.

Re: Too many mods destroy “indescructible” nodes

PostPosted: Sat Feb 21, 2015 03:43
by false_chicken
Nice PSA Wuzzy. Noted for any future projects.

Re: Too many mods destroy “indescructible” nodes

PostPosted: Thu Apr 09, 2015 01:30
by Dopium
Great write up, i will have to take a look at your bedrock code as to how you went about "true" immortal

Re: Too many mods destroy “indescructible” nodes

PostPosted: Fri May 08, 2015 23:22
by fessmK
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.

Re: Too many mods destroy “indescructible” nodes

PostPosted: Sat May 09, 2015 13:24
by Wuzzy
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.