forked from Mineclonia/Mineclonia
Add command to spawn small ruined portal
This commit is contained in:
parent
180109bd30
commit
0ba832776c
|
@ -89,6 +89,8 @@ mcl_structures.call_struct = function(pos, struct_style, rotation, pr)
|
|||
return mcl_structures.generate_end_exit_portal(pos, rotation)
|
||||
elseif struct_style == "end_portal_shrine" then
|
||||
return mcl_structures.generate_end_portal_shrine(pos, rotation, pr)
|
||||
elseif struct_style == "ruined_portal_small" then
|
||||
return mcl_structures.generate_ruined_portal_small(pos, rotation, pr)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -404,6 +406,309 @@ mcl_structures.generate_end_portal_shrine = function(pos, rotation, pr)
|
|||
mcl_structures.place_schematic(newpos, path, "0", nil, true, nil, shrine_placement_callback, pr)
|
||||
end
|
||||
|
||||
local function ruined_portal_small_callback(p1, p2, size, rotation, pr)
|
||||
local biome_data = minetest.get_biome_data(p1)
|
||||
local biome_is_cold = (biome_data.heat < 15) or false
|
||||
local biome_name = minetest.get_biome_name(biome_data.biome)
|
||||
local biome_is_ocean = string.find(biome_name, "ocean") and true or false
|
||||
local nodes = minetest.find_nodes_in_area(p1, p2, {
|
||||
"mcl_core:goldblock",
|
||||
"mcl_stairs:slab_goldblock",
|
||||
"mcl_stairs:slab_goldblock_double",
|
||||
"mcl_stairs:slab_goldblock_top",
|
||||
"mcl_stairs:stair_goldblock",
|
||||
"mcl_stairs:stair_goldblock_inner",
|
||||
"mcl_stairs:stair_goldblock_outer",
|
||||
"mcl_core:obsidian",
|
||||
"mcl_nether:netherrack",
|
||||
"mcl_core:lava_source",
|
||||
"mcl_core:stonebrick",
|
||||
"mcl_core:stonebrickcarved",
|
||||
"mcl_stairs:slab_stonebrick",
|
||||
"mcl_stairs:slab_stonebrick_top",
|
||||
"mcl_stairs:slab_stonebrick_double",
|
||||
"mcl_stairs:slab_stone",
|
||||
"mcl_stairs:slab_stone_top",
|
||||
"mcl_stairs:slab_stone_double",
|
||||
"mcl_stairs:stair_stonebrick",
|
||||
"mcl_stairs:stair_stonebrick_outer",
|
||||
"mcl_stairs:stair_stonebrick_inner",
|
||||
"mcl_walls:stonebrick",
|
||||
"mcl_walls:stonebrick_0",
|
||||
"mcl_walls:stonebrick_1",
|
||||
"mcl_walls:stonebrick_10",
|
||||
"mcl_walls:stonebrick_11",
|
||||
"mcl_walls:stonebrick_12",
|
||||
"mcl_walls:stonebrick_13",
|
||||
"mcl_walls:stonebrick_14",
|
||||
"mcl_walls:stonebrick_15",
|
||||
"mcl_walls:stonebrick_16",
|
||||
"mcl_walls:stonebrick_2",
|
||||
"mcl_walls:stonebrick_21",
|
||||
"mcl_walls:stonebrick_3",
|
||||
"mcl_walls:stonebrick_4",
|
||||
"mcl_walls:stonebrick_5",
|
||||
"mcl_walls:stonebrick_6",
|
||||
"mcl_walls:stonebrick_7",
|
||||
"mcl_walls:stonebrick_8",
|
||||
"mcl_walls:stonebrick_9"
|
||||
})
|
||||
for n=1, #nodes do
|
||||
local node = minetest.get_node(nodes[n])
|
||||
-- Rotate walls (needs to be done first)
|
||||
if rotation == "90" or rotation == "270" then
|
||||
if "mcl_walls:stonebrick_5" == node.name then
|
||||
node.name = "mcl_walls:stonebrick_10"
|
||||
elseif "mcl_walls:stonebrick_10" == node.name then
|
||||
node.name = "mcl_walls:stonebrick_5"
|
||||
end
|
||||
if "mcl_walls:stonebrick_16" == node.name then
|
||||
node.name = "mcl_walls:stonebrick_21"
|
||||
elseif "mcl_walls:stonebrick_21" == node.name then
|
||||
node.name = "mcl_walls:stonebrick_16"
|
||||
end
|
||||
end
|
||||
if (p1.y > mcl_vars.mg_overworld_min) and (p1.y < mcl_vars.mg_overworld_max) then
|
||||
local r_bricktype = pr:next(1, 100)
|
||||
-- Replace stone brick with mossy variants (30%)
|
||||
if r_bricktype <= 30 then -- 30%
|
||||
if "mcl_core:stonebrick" == node.name then
|
||||
node.name = "mcl_core:stonebrickmossy"
|
||||
elseif "mcl_stairs:slab_stonebrick" == node.name then
|
||||
node.name = "mcl_stairs:slab_stonebrickmossy"
|
||||
elseif "mcl_stairs:slab_stonebrick_top" == node.name then
|
||||
node.name = "mcl_stairs:slab_stonebrickmossy_top"
|
||||
elseif "mcl_stairs:slab_stonebrick_double" == node.name then
|
||||
node.name = "mcl_stairs:slab_stonebrickmossy_double"
|
||||
elseif "mcl_stairs:stair_stonebrick" == node.name then
|
||||
node.name = "mcl_stairs:stair_stonebrickmossy"
|
||||
elseif "mcl_stairs:stair_stonebrick_outer" == node.name then
|
||||
node.name = "mcl_stairs:stair_stonebrickmossy_outer"
|
||||
elseif "mcl_stairs:stair_stonebrick_inner" == node.name then
|
||||
node.name = "mcl_stairs:stair_stonebrickmossy_inner"
|
||||
elseif "mcl_walls:stonebrick" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy"
|
||||
elseif "mcl_walls:stonebrick_0" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_0"
|
||||
elseif "mcl_walls:stonebrick_1" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_1"
|
||||
elseif "mcl_walls:stonebrick_10" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_10"
|
||||
elseif "mcl_walls:stonebrick_11" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_11"
|
||||
elseif "mcl_walls:stonebrick_12" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_12"
|
||||
elseif "mcl_walls:stonebrick_13" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_13"
|
||||
elseif "mcl_walls:stonebrick_14" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_14"
|
||||
elseif "mcl_walls:stonebrick_15" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_15"
|
||||
elseif "mcl_walls:stonebrick_16" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_16"
|
||||
elseif "mcl_walls:stonebrick_2" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_2"
|
||||
elseif "mcl_walls:stonebrick_21" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_21"
|
||||
elseif "mcl_walls:stonebrick_3" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_3"
|
||||
elseif "mcl_walls:stonebrick_4" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_4"
|
||||
elseif "mcl_walls:stonebrick_5" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_5"
|
||||
elseif "mcl_walls:stonebrick_6" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_6"
|
||||
elseif "mcl_walls:stonebrick_7" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_7"
|
||||
elseif "mcl_walls:stonebrick_8" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_8"
|
||||
elseif "mcl_walls:stonebrick_9" == node.name then
|
||||
node.name = "mcl_walls:stonebrickmossy_9"
|
||||
end
|
||||
-- Replace stone brick with cracked variants (20%)
|
||||
elseif r_bricktype <= 50 then -- 20%
|
||||
if "mcl_core:stonebrick" == node.name then
|
||||
node.name = "mcl_core:stonebrickcracked"
|
||||
elseif "mcl_stairs:slab_stonebrick" == node.name then
|
||||
node.name = "mcl_stairs:slab_stonebrickcracked"
|
||||
elseif "mcl_stairs:slab_stonebrick_top" == node.name then
|
||||
node.name = "mcl_stairs:slab_stonebrickcracked_top"
|
||||
elseif "mcl_stairs:slab_stonebrick_double" == node.name then
|
||||
node.name = "mcl_stairs:slab_stonebrickcracked_double"
|
||||
elseif "mcl_stairs:stair_stonebrick" == node.name then
|
||||
node.name = "mcl_stairs:stair_stonebrickcracked"
|
||||
elseif "mcl_stairs:stair_stonebrick_outer" == node.name then
|
||||
node.name = "mcl_stairs:stair_stonebrickcracked_outer"
|
||||
elseif "mcl_stairs:stair_stonebrick_inner" == node.name then
|
||||
node.name = "mcl_stairs:stair_stonebrickcracked_inner"
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Replace gold with air (30%)
|
||||
if (
|
||||
"mcl_core:goldblock" == node.name or
|
||||
"mcl_stairs:slab_goldblock" == node.name or
|
||||
"mcl_stairs:slab_goldblock_double" == node.name or
|
||||
"mcl_stairs:slab_goldblock_top" == node.name or
|
||||
"mcl_stairs:stair_goldblock" == node.name or
|
||||
"mcl_stairs:stair_goldblock_inner" == node.name or
|
||||
"mcl_stairs:stair_goldblock_outer" == node.name
|
||||
) then
|
||||
local r_air = pr:next(1,100)
|
||||
if r_air <= 30 then
|
||||
node.name = "air"
|
||||
end
|
||||
-- Replace obsidian with crying obsidian (20%)
|
||||
elseif "mcl_core:obsidian" == node.name then
|
||||
local r_crying = pr:next(1,100)
|
||||
if r_crying <= 30 then
|
||||
node.name = "mcl_nether:crying_obsidian"
|
||||
end
|
||||
-- Replace Nether rack with magma (7% if not cold)
|
||||
elseif "mcl_nether:netherrack" == node.name then
|
||||
if not biome_is_cold then
|
||||
local r_magma = pr:next(1,100)
|
||||
if r_magma <= 7 then
|
||||
node.name = "mcl_nether:magma"
|
||||
end
|
||||
end
|
||||
-- Replace lava (underwater: 100% magma / cold: 100% Nether rack / else: 20% magma)
|
||||
elseif "mcl_core:lava_source" == node.name then
|
||||
if biome_is_ocean and nodes[n].y < 0 then -- do not replace at surface
|
||||
node.name = "mcl_nether:magma"
|
||||
elseif biome_is_cold then
|
||||
node.name = "mcl_nether:netherrack"
|
||||
else
|
||||
local r_magma = pr:next(1,100)
|
||||
if r_magma <= 20 then
|
||||
node.name = "mcl_nether:magma"
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Replace stone brick variants with (red) Nether brick in the Nether
|
||||
-- TODO: Replace stone brick variants with blackstone when we have it
|
||||
if (p1.y > mcl_vars.mg_nether_min) and (p1.y < mcl_vars.mg_nether_max) then
|
||||
if "mcl_core:stonebrick" == node.name then
|
||||
node.name = "mcl_nether:nether_brick"
|
||||
elseif "mcl_core:stonebrickcarved" == node.name then
|
||||
node.name = "mcl_nether:nether_brick_carved"
|
||||
elseif "mcl_stairs:slab_stonebrick" == node.name then
|
||||
node.name = "mcl_stairs:slab_nether_brick"
|
||||
elseif "mcl_stairs:slab_stonebrick_top" == node.name then
|
||||
node.name = "mcl_stairs:slab_nether_brick_top"
|
||||
elseif "mcl_stairs:slab_stonebrick_double" == node.name then
|
||||
node.name = "mcl_stairs:slab_nether_brick_double"
|
||||
elseif "mcl_stairs:slab_stone" == node.name then
|
||||
node.name = "mcl_stairs:slab_red_nether_brick"
|
||||
elseif "mcl_stairs:slab_stone_top" == node.name then
|
||||
node.name = "mcl_stairs:slab_red_nether_brick_top"
|
||||
elseif "mcl_stairs:slab_stone_double" == node.name then
|
||||
node.name = "mcl_stairs:slab_red_nether_brick_double"
|
||||
elseif "mcl_stairs:stair_stonebrick" == node.name then
|
||||
node.name = "mcl_stairs:stair_nether_brick"
|
||||
elseif "mcl_stairs:stair_stonebrick_outer" == node.name then
|
||||
node.name = "mcl_stairs:stair_nether_brick_outer"
|
||||
elseif "mcl_stairs:stair_stonebrick_inner" == node.name then
|
||||
node.name = "mcl_stairs:stair_nether_brick_inner"
|
||||
elseif "mcl_walls:stonebrick" == node.name then
|
||||
node.name = "mcl_walls:netherbrick"
|
||||
elseif "mcl_walls:stonebrick_0" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_0"
|
||||
elseif "mcl_walls:stonebrick_1" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_1"
|
||||
elseif "mcl_walls:stonebrick_10" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_10"
|
||||
elseif "mcl_walls:stonebrick_11" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_11"
|
||||
elseif "mcl_walls:stonebrick_12" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_12"
|
||||
elseif "mcl_walls:stonebrick_13" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_13"
|
||||
elseif "mcl_walls:stonebrick_14" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_14"
|
||||
elseif "mcl_walls:stonebrick_15" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_15"
|
||||
elseif "mcl_walls:stonebrick_16" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_16"
|
||||
elseif "mcl_walls:stonebrick_2" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_2"
|
||||
elseif "mcl_walls:stonebrick_21" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_21"
|
||||
elseif "mcl_walls:stonebrick_3" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_3"
|
||||
elseif "mcl_walls:stonebrick_4" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_4"
|
||||
elseif "mcl_walls:stonebrick_5" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_5"
|
||||
elseif "mcl_walls:stonebrick_6" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_6"
|
||||
elseif "mcl_walls:stonebrick_7" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_7"
|
||||
elseif "mcl_walls:stonebrick_8" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_8"
|
||||
elseif "mcl_walls:stonebrick_9" == node.name then
|
||||
node.name = "mcl_walls:netherbrick_9"
|
||||
-- Replace lava with Nether lava
|
||||
elseif "mcl_core:lava_source" == node.name then
|
||||
node.name = "mcl_nether:nether_lava_source"
|
||||
end
|
||||
end
|
||||
minetest.set_node(nodes[n], node)
|
||||
end
|
||||
-- Add loot into chests.
|
||||
local chests = minetest.find_nodes_in_area(p1, p2, "mcl_chests:chest_small")
|
||||
for c=1, #chests do
|
||||
local lootitems = mcl_loot.get_multi_loot({
|
||||
{
|
||||
stacks_min = 4,
|
||||
stacks_max = 8,
|
||||
items = {
|
||||
{ itemstring = "mcl_core:iron_nugget", weight = 46, amount_min = 9, amount_max = 18 },
|
||||
{ itemstring = "mcl_core:flint", weight = 46, amount_min = 1, amount_max = 4 },
|
||||
{ itemstring = "mcl_core:obsidian", weight = 46, amount_min = 1, amount_max = 2 },
|
||||
{ itemstring = "mcl_fire:fire_charge", weight = 46, },
|
||||
{ itemstring = "mcl_fire:flint_and_steel", weight = 46, },
|
||||
{ itemstring = "mcl_core:gold_nugget", weight = 21, amount_min = 4, amount_max = 24 },
|
||||
{ itemstring = "mcl_core:apple_gold", weight = 21 },
|
||||
-- TODO: enchanted golden axe / hoe / pickaxe / shovel / sword / helmet / chestplate / leggings / boots
|
||||
{ itemstring = "mcl_potions:speckled_melon", weight = 7, amount_min = 4, amount_max = 12 },
|
||||
{ itemstring = "mcl_farming:carrot_item_gold", weight = 7, amount_min = 4, amount_max = 12 },
|
||||
{ itemstring = "mcl_core:gold_ingot", weight = 7, amount_min = 2, amount_max = 6 },
|
||||
{ itemstring = "mcl_clock:clock", weight = 7, },
|
||||
{ itemstring = "mobs_mc:gold_horse_armor", weight = 7, },
|
||||
{ itemstring = "mcl_core:goldblock", weight = 2, amount_min = 1, amount_max = 2 },
|
||||
{ itemstring = "mcl_core:apple_gold_enchanted", weight = 2, },
|
||||
}
|
||||
}
|
||||
}, pr)
|
||||
|
||||
local meta = minetest.get_meta(chests[c])
|
||||
init_node_construct(chests[c])
|
||||
local meta = minetest.get_meta(chests[c])
|
||||
local inv = meta:get_inventory()
|
||||
mcl_loot.fill_inventory(inv, "main", lootitems, pr)
|
||||
end
|
||||
end
|
||||
|
||||
mcl_structures.generate_ruined_portal_small = function(pos, orientation, pr)
|
||||
-- Generates one out of 5 possible small ruined nether portals
|
||||
local newpos = {
|
||||
x = pos.x,
|
||||
y = pos.y - 4,
|
||||
z = pos.z
|
||||
}
|
||||
local portals = {
|
||||
"mcl_structures_ruined_portal_small_1.mts",
|
||||
"mcl_structures_ruined_portal_small_2.mts",
|
||||
"mcl_structures_ruined_portal_small_3.mts",
|
||||
"mcl_structures_ruined_portal_small_4.mts",
|
||||
"mcl_structures_ruined_portal_small_5.mts"
|
||||
}
|
||||
local r = pr:next(1, #portals)
|
||||
local path = minetest.get_modpath("mcl_structures") .. "/schematics/" .. portals[r]
|
||||
return mcl_structures.place_schematic(newpos, path, orientation, nil, true, nil, ruined_portal_small_callback, pr)
|
||||
end
|
||||
|
||||
local function temple_placement_callback(p1, p2, size, rotation, pr)
|
||||
|
||||
-- Delete cacti leftovers:
|
||||
|
@ -534,7 +839,7 @@ end
|
|||
|
||||
-- Debug command
|
||||
minetest.register_chatcommand("spawnstruct", {
|
||||
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_portal_shrine",
|
||||
params = "desert_temple | desert_well | igloo | witch_hut | boulder | ice_spike_small | ice_spike_large | fossil | end_exit_portal | end_portal_shrine | ruined_portal_small",
|
||||
description = S("Generate a pre-defined structure near your position."),
|
||||
privs = {debug = true},
|
||||
func = function(name, param)
|
||||
|
@ -568,6 +873,8 @@ minetest.register_chatcommand("spawnstruct", {
|
|||
mcl_structures.generate_end_exit_portal(pos, rot, pr)
|
||||
elseif param == "end_portal_shrine" then
|
||||
mcl_structures.generate_end_portal_shrine(pos, rot, pr)
|
||||
elseif param == "ruined_portal_small" then
|
||||
mcl_structures.generate_ruined_portal_small(pos, rot, pr)
|
||||
elseif param == "" then
|
||||
message = S("Error: No structure type given. Please use “/spawnstruct <type>”.")
|
||||
errord = true
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
name = mcl_structures
|
||||
depends = mcl_loot
|
||||
depends = mcl_init, mcl_loot
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue