Element wrote:the unuke(tnt) mod can destroy bedrock...
This is both a bug in unuke and bedrock.
Element wrote:is there a way you can make it so it cant
Yes, by fixing the bugs. I fixed one of them. :-)
Now to the bugs:
unuke bug: A nuke destroys ANY node, no matter what it is, completely ignoring the properties of the node. This is a bit rude. This is also true for the TNT mod, for the same reasons.
bedrock bug: It does not use on_blast. By the way, bedrock’s code is kinda dated, I am surprised that you made the mod work at all.
On_blast is a neat little function defined in the modding API as a node callback if an explosion is close to a node. The engine does not use this function yet, but it is intended to be called by mods that cause explosions for every node that is affected by the explosion.
on_blast syntax: on_blast(pos, intensity)
pos = position
intensity = intensity of explosion. The intensity of a regular TNT is defined to be 1.
The trick is, on_blast will only be called if it’s not nil. If it’s nil, a standard behaviour will be done to the mod (removing it, for example). Well, at least that’s the idea how the mods handle on_blast. Mods still may screw this up.
Also there were no groups back in the days where this olden mod had been created. For nodes like bedrocks, there is now the group “immortal”. :-) Now you can dig forever on a bedrock and it will
never break. It may be still possible to remove bedrock with special tools like the admin pickaxe, or stuff like that.
Here is a fresh version of Bedrock:
init.lua:
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
local bedrock = {}
bedrock.layer = -30912 -- determined as appropriate by experiment
bedrock.node = {name = "bedrock:bedrock"}
minetest.register_on_generated(function(minp, maxp)
if maxp.y >= bedrock.layer and minp.y <= bedrock.layer then
local p = {y = bedrock.layer}
local n = bedrock.node
for x = minp.x,maxp.x do
for z = minp.z,maxp.z do
p.x=x; p.z=z
minetest.env:set_node(p, n)
end
end
end
end)
minetest.register_node("bedrock:bedrock", {
description = "Bedrock",
tiles = {"bedrock.png"},
groups = {immortal=1, stone=1, not_in_creative_inventory=1},
on_blast = function() end,
})
(the other files keep unchanged)
Above code was tested with 0.4.7. It’s usable again. :-)
I call this version of bedrock “20130924”.
Funnily, the lowest possible Y coordinate has changed over the years.
See the trick? On_blast here is defined as a function which does literally nothing, not caring about the position and the explosion intensity. Because that’s exactly what we want: No matter how big the explosion, bedrock shall stay bedrock forever.
Note that the unuke mod and the TNT mod both do not respect on_blast yet. So these mods have to be changed, too, so that bedrock does not get destroyed by explosions. I should start complaining in their respective threads soon. ;-)
For the future I would like the bedrock mod to:
- have sounds for bedrock (preferably not the default sounds! ;-))
- use LuaVoxelManip instead of set_node for better performance (I do not understand LuaVoxelManip yet :-(. )
My changes fall under the WTFPL, of course.