Actually, it is not quite as easy to make a node truly unbreakable.
It is not done by just adding your node to the group “immortal=1”.
This will only protect the node from being mined by ordinary mining tools.
There will still be many ways to break your node:
- TNT from the default game
- Similar TNT or explosive mods
- Replacer Tool (does not actually break the node, but you can replace it and thus remove it from the world indirectly)
- Shooting it with a mining laser from Technic mod
- Possibly even the cave generator may remove it
You can “harden” your node by adding this code to the node definition (I added some comments, feel free to remove them afterwards):
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
diggable = false, --[[ protects against normal digging ]]
can_dig = function() return false end, --[[ some mods use this function to check for digging instead ]]
on_blast = function() end, -- [[this function is intended to be called by explosion mods such as TNT. It should handle a blast manually. Since we want to keep our node, we simply do nothing, thus keep our node.]]
is_ground_content = false, --[[ protects against cave generator ]]
drop = "", --[[ I don't know if this is really needed, but since your node is supposed to be unbreakable, drops are not needed anyways]]
groups = {immortal=1}, --[[ don't forget to add other groups you may want!]]
Sadly, most TNT mods (including TNT from minetest_game) ignore on_blast and call minetest.remove_node directly. There is no good way for a mod to defend itself against minetest.remove_node, so I consider this a problem in the TNT mod itself, because there is not anything you can do against it so far.
IMO mods should never call minetest.remove_node directly if its not for debugging or testing reasons, because this weakens “unbreakable” blocks.
Above code has been taken directly from my bedrock2 mod, where I have tried to ensure that bedrock is
truly unbreakable (still haven't achieved this goal, thanks to TNT). I still have added on_blast because I hope that on_blast support will be added to the TNT mods in the future.
Additionally, it will still be possible to push and pull the node by pistons from the Mesecons mod. This is not the same as breaking the node, but in case you also want to prevent this, you first have to optionally depend on mesecons_mvps and then add this code into your mod (and don't forget to add your node name):
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
-- NOTE: replace node_name with the name of your node
if minetest.get_modpath("mesecons_mvps") ~= nil then
mesecon:register_mvps_stopper(node_name)
end
Further reading:
viewtopic.php?f=47&t=11272viewtopic.php?f=9&t=11271EDIT:
Minetest Game (development version) finally respects on_blast now. So it is now possible to create a block which can not be destroyed by Minetest Game's TNT.