Make one specific node unbreakable inside a world [solved]

Post Reply
minetestcr
Member
Posts: 58
Joined: Fri Feb 13, 2015 21:31

Make one specific node unbreakable inside a world [solved]

by minetestcr » Post

Hello!

Is there a way to make one type of nodes unbreakable inside a world?
Wool nodes must be unbreakable, other nodes must keep their original attributes.

What file in the world folder must I change to specify this?

thanks a lot?
Last edited by minetestcr on Thu Mar 05, 2015 16:25, edited 1 time in total.

User avatar
rubenwardy
Moderator
Posts: 6094
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Make one specific node unbreakable inside a world

by rubenwardy » Post

You need to edit a mod or make your own mod. Use the immortal group. (groups={immortal=1})

You can install mods in worlds/worldname/worldmods/

I can't write a mod for you ATM, but it'll be like this:

Code: Select all

minetest.override_item("wool:red", {
        groups={immortal=1}
})

minetestcr
Member
Posts: 58
Joined: Fri Feb 13, 2015 21:31

Re: Make one specific node unbreakable inside a world

by minetestcr » Post

thanks a lot rubenwardy, I'm gonna try that. I'll let you know how it goes...

minetestcr
Member
Posts: 58
Joined: Fri Feb 13, 2015 21:31

Re: Make one specific node unbreakable inside a world

by minetestcr » Post

Hello rubenwardy!

I made the mod and it's working fine for me. Thank you very much for your help, your answer gave me all the information I neded.

I was trying to upload the mod to the mods forum but I don't have the option to create a new topic for Mod Releases!!!! so, I'm attaching the file to this post.

This would be officially my first mod!!!!!!!!!!!!! = )
Attachments
wool_unbreakable.zip
mod to make the wool nodes unbreakable inside a world.
(1.15 KiB) Downloaded 35 times

User avatar
rubenwardy
Moderator
Posts: 6094
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: United Kingdom
Contact:

Re: Make one specific node unbreakable inside a world [solve

by rubenwardy » Post

You need to post in WIP Mods. See Minetest Modding Book > Releasing a mod

You may want to consider creating your own wool so that people can still place breakable wool.

minetestcr
Member
Posts: 58
Joined: Fri Feb 13, 2015 21:31

Re: Make one specific node unbreakable inside a world [solve

by minetestcr » Post

rubenwardy wrote:You need to post in WIP Mods. See Minetest Modding Book > Releasing a mod

You may want to consider creating your own wool so that people can still place breakable wool.

I'm going to look into that, thanks!

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

Re: Make one specific node unbreakable inside a world [solve

by Wuzzy » Post

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):

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):

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=11272
viewtopic.php?f=9&t=11271

EDIT:
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.
Last edited by Wuzzy on Sun Jun 21, 2015 11:42, edited 1 time in total.

minetestcr
Member
Posts: 58
Joined: Fri Feb 13, 2015 21:31

Re: Make one specific node unbreakable inside a world [solve

by minetestcr » Post

Hello Wuzzy!


Very interesting all the information you gave with this answer. I guess my [solved] label isn't entirely true hahaha!

I was trying to make wool unbreakable for an specific world that will be played by my students in school, and so far it has worked well vecause they don't have access to tnt in this world. But I find your answer very helpful because I think I will need it for future projects.

I will try some mods with the things you mention here and I'll get back to you when I do. Thanks a lot.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests