Last active
January 18, 2024 01:21
-
-
Save corarona/16b4d87916a6c39f4b8b949b924afe0a to your computer and use it in GitHub Desktop.
mcl_obscores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--turns ores adjacent to air to the stone/deepslate/netherrack/blackstone counterparts | |
--in one in `chance` of the cases | |
--does not appear to *always* work i.e. with chance = 1 you'll still rarely see some exposed ores | |
local chance = 5 | |
local c_stone = minetest.get_content_id("mcl_core:stone") | |
local c_deepslate = minetest.get_content_id("mcl_deepslate:deepslate") | |
local c_netherrack = minetest.get_content_id("mcl_nether:netherrack") | |
local c_blackstone = minetest.get_content_id("mcl_blackstone:blackstone") | |
local c_air = minetest.get_content_id("air") | |
local c_ores = { | |
[minetest.get_content_id("mcl_core:stone_with_redstone")] = c_stone, | |
[minetest.get_content_id("mcl_core:stone_with_lapis")] = c_stone, | |
[minetest.get_content_id("mcl_core:stone_with_gold")] = c_stone, | |
[minetest.get_content_id("mcl_core:stone_with_iron")] = c_stone, | |
[minetest.get_content_id("mcl_core:stone_with_emerald")] = c_stone, | |
[minetest.get_content_id("mcl_core:stone_with_diamond")] = c_stone, | |
[minetest.get_content_id("mcl_core:stone_with_coal")] = c_stone, | |
[minetest.get_content_id("mcl_copper:stone_with_copper")] = c_stone, | |
[minetest.get_content_id("mcl_blackstone:nether_gold")] = c_netherrack, | |
[minetest.get_content_id("mcl_blackstone:blackstone_gilded")] = c_blackstone, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_copper")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_lapis")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_gold")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_iron")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_emerald")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_diamond")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_coal")] = c_deepslate, | |
[minetest.get_content_id("mcl_deepslate:deepslate_with_redstone")] = c_deepslate, | |
} | |
minetest.register_on_generated(function(minp, maxp, blockseed) | |
local t1=os.clock() | |
local pr = PseudoRandom(blockseed) | |
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip") | |
local a = VoxelArea:new{ | |
MinEdge={x=emin.x, y=emin.y, z=emin.z}, | |
MaxEdge={x=emax.x, y=emax.y, z=emax.z}, | |
} | |
local data = vm:get_data() | |
for z = minp.z, maxp.z do | |
for y = minp.y, maxp.y do | |
for x = minp.x, maxp.x do | |
local vi = a:index(x, y, z) | |
if c_ores[data[vi]] and pr:next(1, chance) == 1 and | |
(data[a:index(x + 1, y, z)] == c_air or | |
data[a:index(x - 1, y, z)] == c_air or | |
data[a:index(x, y + 1, z)] == c_air or | |
data[a:index(x, y - 1, z)] == c_air or | |
data[a:index(x, y, z + 1)] == c_air or | |
data[a:index(x, y, z - 1)] == c_air) then | |
data[vi] = c_ores[data[vi]] | |
end | |
end | |
end | |
end | |
vm:set_data(data) | |
vm:write_to_map(data) | |
print(string.format("elapsed time: %.2fms", (os.clock() - t1) * 1000)) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment