Finish ruined portals

This commit is contained in:
kay27 2022-02-24 03:59:11 +04:00
parent 8272343084
commit cfc0fda314
8 changed files with 281 additions and 42 deletions

View File

@ -0,0 +1,4 @@
* sounds/bell_stroke.ogg
* created by edsward
* modified by sorcerykid
* obtained from https://freesound.org/people/edsward/sounds/341866/

View File

@ -0,0 +1,24 @@
local S = minetest.get_translator(minetest.get_current_modname())
mcl_bells = {}
local has_mcl_wip = minetest.get_modpath("mcl_wip")
minetest.register_node("mcl_bells:bell", {
description = S("Bell"),
inventory_image = "bell.png",
drawtype = "plantlike",
tiles = {"bell.png"},
stack_max = 64,
selection_box = {
type = "fixed",
fixed = {
-4/16, -6/16, -4/16,
4/16, 7/16, 4/16,
},
},
})
if has_mcl_wip then
mcl_wip.register_wip_item("mcl_bells:bell")
end

View File

@ -0,0 +1,2 @@
# textdomain: mcl_observers
Bell=

View File

@ -0,0 +1,3 @@
name = mcl_bells
depends = mesecons
optional_depends = mcl_wip

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

View File

@ -201,4 +201,15 @@ mesecon.register_pressure_plate(
{ player = true, mob = true },
S("A stone pressure plate is a redstone component which supplies its surrounding blocks with redstone power while a player or mob stands on top of it. It is not triggered by anything else."))
mesecon.register_pressure_plate(
"mesecons_pressureplates:pressure_plate_gold",
S("Light-Weighted Pressure Plate"),
{"default_gold_block.png"},
{"default_gold_block.png"},
"default_gold_block.png",
nil,
{{"mcl_core:gold_ingot", "mcl_core:gold_ingot"}},
mcl_sounds.node_sound_metal_defaults(),
{pickaxey=1},
{ player = true, mob = true },
S("A light-weighted pressure plate is a redstone component which supplies its surrounding blocks with redstone power while a player or mob stands on top of it. It is not triggered by anything else."))

View File

@ -4,10 +4,15 @@ local modpath = minetest.get_modpath(modname)
local chance_per_chunk = 400
local noise_multiplier = 2.5
local random_offset = 9159
local scanning_ratio = 0.01
local struct_threshold = 390
local scanning_ratio = 0.001
local struct_threshold = 396
local mcl_structures_get_perlin_noise_level = mcl_structures.get_perlin_noise_level
local minetest_find_nodes_in_area = minetest.find_nodes_in_area
local minetest_swap_node = minetest.swap_node
local math_round = math.round
local math_abs = math.abs
local rotation_to_orientation = {
["0"] = 1,
@ -59,7 +64,7 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
local function set_ruined_node(pos, node)
if pr:next(1, 5) == 4 then return end
minetest.set_node(pos, node)
minetest_swap_node(pos, node)
end
local function get_random_stone_material()
@ -88,7 +93,7 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
end
local function set_frame_stone_material(pos)
minetest.swap_node(pos, get_random_stone_material())
minetest_swap_node(pos, get_random_stone_material())
end
local function set_ruined_frame_stone_material(pos)
@ -108,23 +113,23 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
-- it's about the portal frame itself, what it will consist of
local frame_nodes = 2 * (frame_height + frame_width) - 4
local obsidian_nodes = pr:next(math.round(frame_nodes * 0.5), math.round(frame_nodes * 0.73))
local crying_obsidian_nodes = pr:next(math.round(obsidian_nodes * 0.09), math.round(obsidian_nodes * 0.5))
local obsidian_nodes = pr:next(math_round(frame_nodes * 0.5), math_round(frame_nodes * 0.73))
local crying_obsidian_nodes = pr:next(math_round(obsidian_nodes * 0.09), math_round(obsidian_nodes * 0.5))
local air_nodes = frame_nodes - obsidian_nodes
local function set_frame_node(pos)
-- local node_choice = pr:next(1, air_nodes + obsidian_nodes)
local node_choice = math.round(mcl_structures_get_perlin_noise_level(pos) * (air_nodes + obsidian_nodes))
local node_choice = math_round(mcl_structures_get_perlin_noise_level(pos) * (air_nodes + obsidian_nodes))
if node_choice > obsidian_nodes and air_nodes > 0 then
air_nodes = air_nodes - 1
return
end
obsidian_nodes = obsidian_nodes - 1
if node_choice >= crying_obsidian_nodes then
minetest.swap_node(pos, {name = "mcl_core:obsidian"})
minetest_swap_node(pos, {name = "mcl_core:obsidian"})
return 1
end
minetest.swap_node(pos, {name = "mcl_core:crying_obsidian"})
minetest_swap_node(pos, {name = "mcl_core:crying_obsidian"})
crying_obsidian_nodes = crying_obsidian_nodes - 1
return 1
end
@ -136,7 +141,7 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
local is_top_hole = is_top and frame_width > 5 and ((pos2.x == x1 + slide_x * 2 and pos2.z == z1 + slide_z * 2) or (pos2.x == last_x - slide_x * 2 and pos2.z == last_z - slide_z * 2))
if is_top_hole then
if pr:next(1, 7) > 1 then
minetest.swap_node(pos2, {name = "xpanes:bar_flat", param2 = orientation})
minetest_swap_node(pos2, {name = "xpanes:bar_flat", param2 = orientation})
end
else
set_frame_stone_material(pos2)
@ -147,18 +152,18 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
local pos = def.pos_outer1
local is_decor_here = not is_top and pos.y % 3 == 2
if is_decor_here then
minetest.swap_node(pos, {name = "mcl_core:stonebrickcarved"})
minetest_swap_node(pos, {name = "mcl_core:stonebrickcarved"})
elseif is_chain then
if not is_top and not is_obsidian then
minetest.swap_node(pos, {name = "xpanes:bar"})
minetest_swap_node(pos, {name = "xpanes:bar"})
else
minetest.swap_node(pos, {name = "xpanes:bar_flat", param2 = orientation})
minetest_swap_node(pos, {name = "xpanes:bar_flat", param2 = orientation})
end
else
if pr:next(1, 5) == 3 then
minetest.swap_node(pos, {name = "mcl_core:stonebrickcracked"})
minetest_swap_node(pos, {name = "mcl_core:stonebrickcracked"})
else
minetest.swap_node(pos, {name = "mcl_core:stonebrick"})
minetest_swap_node(pos, {name = "mcl_core:stonebrick"})
end
end
end
@ -207,7 +212,7 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
end
for y = y1, last_y do
local begin_or_end = y == y1 or y == lasy_y
local begin_or_end = y == y1 or y == last_y
local is_obsidian_left = begin_or_end and is_obsidian_top_left or set_frame_node({x = x1 , y = y, z = z1 })
local is_obsidian_right = begin_or_end and is_obsidian_top_right or set_frame_node({x = last_x, y = y, z = last_z})
set_outer_frame_node({
@ -239,7 +244,7 @@ local function draw_frame(frame_pos, frame_width, frame_height, orientation, pr,
for x = x1 + slide_x, last_x - slide_x do for z = z1 + slide_z, last_z - slide_z do
set_frame_node({x = x, y = y1, z = z})
local is_obsitian_top = set_frame_node({x = x, y = last_y, z = z})
local is_obsidian_top = set_frame_node({x = x, y = last_y, z = z})
set_outer_frame_node({
pos_outer1 = {x = x, y = last_y + 1, z = z},
pos_outer2 = {x = x, y = last_y + 2, z = z},
@ -288,11 +293,11 @@ local function draw_trash(pos, width, height, lift, orientation, pr)
local opacity_layers = math.floor((y2 - y1) / 2)
local opacity_layer = -opacity_layers
for y = y1, y2 do
local inverted_opacity_0_5 = math.round(math.abs(opacity_layer) / opacity_layers * 5)
local inverted_opacity_0_5 = math_round(math_abs(opacity_layer) / opacity_layers * 5)
for x = x1 + pr:next(0, 2), x2 - pr:next(0, 2) do
for z = z1 + pr:next(0, 2), z2 - pr:next(0, 2) do
if inverted_opacity_0_5 == 0 or (x % inverted_opacity_0_5 ~= pr:next(0, 1) and z % inverted_opacity_0_5 ~= pr:next(0, 1)) then
minetest.swap_node({x = x, y = y, z = z}, {name = node_garbage[pr:next(1, #node_garbage)]})
minetest_swap_node({x = x, y = y, z = z}, {name = node_garbage[pr:next(1, #node_garbage)]})
end
end
end
@ -309,36 +314,186 @@ local stair_replacement_list = {
}
local stair_offset_from_bottom = 3
local function draw_stairs(pos, width, height, lift, orientation, pr, is_chain)
local stair_names = {
"mcl_stairs:stair_stonebrickcracked",
"mcl_stairs:stair_stonebrickmossy",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stone_rough",
"mcl_stairs:stair_stonebrick",
"mcl_stairs:stair_stonebrick",
"mcl_stairs:stair_stonebrick",
}
local stair_outer_names = {
"mcl_stairs:stair_stonebrickcracked_outer",
"mcl_stairs:stair_stonebrickmossy_outer",
"mcl_stairs:stair_stone_rough_outer",
"mcl_stairs:stair_stonebrick_outer",
}
local stair_content = {
{name = "mcl_core:lava_source"},
{name = "mcl_core:stone"},
{name = "mcl_core:stone"},
{name = "mcl_core:stone"},
{name = "mcl_core:stone"},
{name = "mcl_core:stone"},
{name = "mcl_core:stonebrick"},
{name = "mcl_nether:magma"},
{name = "mcl_nether:netherrack"},
{name = "mcl_nether:netherrack"},
}
local slabs = {
{name = "mcl_stairs:slab_stone"},
{name = "mcl_stairs:slab_stone"},
{name = "mcl_stairs:slab_stone"},
{name = "mcl_stairs:slab_stone"},
{name = "mcl_stairs:slab_stone"},
{name = "mcl_stairs:slab_stonebrick"},
{name = "mcl_stairs:slab_stonebrick"},
{name = "mcl_stairs:slab_stonebrickcracked"},
{name = "mcl_stairs:slab_stonebrickmossy"},
}
local stones = {
{name = "mcl_core:stone"},
{name = "mcl_core:stone"},
{name = "mcl_core:stone"},
{name = "mcl_core:cobble"},
{name = "mcl_core:mossycobble"},
}
local stair_selector = {
[-1] = {
[-1] = {
names = stair_outer_names,
param2 = 1,
},
[0] = {
names = stair_names,
param2 = 1,
},
[1] = {
names = stair_outer_names,
param2 = 2,
},
},
[0] = {
[-1] = {
names = stair_names,
param2 = 0,
},
[0] = {
names = stair_content,
},
[1] = {
names = stair_names,
param2 = 2,
},
},
[1] = {
[-1] = {
names = stair_outer_names,
param2 = 0,
},
[0] = {
names = stair_names,
param2 = 3,
},
[1] = {
names = stair_outer_names,
param2 = 3,
},
},
}
local function draw_stairs(pos, width, height, lift, orientation, pr, is_chain, param2)
local function set_ruined_node(pos, node)
if pr:next(1, 7) < 3 then return end
minetest_swap_node(pos, node)
return true
end
local param2 = param2
local mirror = param2 == 1 or param2 == 2
if mirror then
param2 = (param2 + 2) % 4
end
local chain_offset = is_chain and 1 or 0
local lift = lift + stair_offset_from_bottom
local slide_x = (1 - orientation)
local slide_z = orientation
local width = width + (is_chain and 2 or 0)
local x1 = pos.x - lift - (is_chain and 1 or 0) - 1
local x2 = pos.x + lift + width * slide_x + 1
local z1 = pos.z - lift - (is_chain and 1 or 0) - 1
local z2 = pos.z + lift + width * slide_z + 1
local width = width + 2
local x1 = pos.x - (chain_offset + 1 ) * slide_x - 1
local x2 = pos.x + (chain_offset + width) * slide_x + 1
local z1 = pos.z - (chain_offset + 1 ) * slide_z - 1
local z2 = pos.z + (chain_offset + width) * slide_z + 1
local y1 = pos.y - stair_offset_from_bottom
local y2 = pos.y + lift - stair_offset_from_bottom
local current_radius = lift
for y = y1, y2 do
local stair_layer = true
local y = y2
local place_slabs = true
local x_key, y_key
local need_to_place_chest = true
local chest_pos
while y >= y1 do
for x = x1, x2 do
x_key = (x == x1) and -1 or (x == x2) and 1 or 0
for z = z1, z2 do
--local stair1 = "mcl_stairs:stair_stonebrickcracked"
--local stair2 = "mcl_stairs:stair_stonebrickmossy"
--local stair3 = "mcl_stairs:stair_stone_rough"
--local stair4 = "mcl_stairs:stair_stonebrick"
local pos = {x = x, y = y, z = z}
if #minetest.find_nodes_in_area(pos, pos, stair_replacement_list, false) > 0 then
minetest.swap_node(pos, {name = "mcl_stairs:stair_stone_rough"})
if #minetest_find_nodes_in_area(pos, pos, stair_replacement_list, false) > 0 then
z_key = (z == z1) and -1 or (z == z2) and 1 or 0
local stair_coverage = (x_key ~= 0) or (z_key ~= 0)
if stair_coverage then
if stair_layer then
local stair = stair_selector[x_key][z_key]
local names = stair.names
set_ruined_node(pos, {name = names[pr:next(1, #names)], param2 = stair.param2})
elseif place_slabs then
set_ruined_node(pos, slabs[pr:next(1, #slabs)])
else
local placed = set_ruined_node(pos, stones[pr:next(1, #stones)])
if need_to_place_chest and placed then
chest_pos = {x = pos.x, y = pos.y + 1, z = pos.z}
minetest_swap_node(chest_pos, {name = "mcl_chests:chest_small"})
need_to_place_chest = false
end
end
elseif not stair_layer then
set_ruined_node(pos, stair_content[pr:next(1, #stair_content)])
end
end
end
x1 = x1 + 1
x2 = x2 - 1
z1 = z1 + 1
z2 = z2 - 1
end
x1 = x1 - 1
x2 = x2 + 1
z1 = z1 - 1
z2 = z2 + 1
if (stair_layer or place_slabs) then
y = y - 1
end
stair_layer = false
place_slabs = not place_slabs
end
return chest_pos
end
local function enchant(stack, pr)
-- 75%-100% damage
mcl_enchanting.enchant_randomly(stack, 30, true, false, false, pr)
end
local function enchant_armor(stack, pr)
-- itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr)
mcl_enchanting.enchant_randomly(stack, 30, false, false, false, pr)
end
local function place(pos, rotation, pr)
@ -352,18 +507,58 @@ local function place(pos, rotation, pr)
assert(param2)
local is_chain = pr:next(1, 3) > 1
draw_trash(pos, width, height, lift, orientation, pr)
draw_stairs(pos, width, height, lift, orientation, pr, is_chain)
local chest_pos = draw_stairs(pos, width, height, lift, orientation, pr, is_chain, param2)
draw_frame({x = pos.x, y = pos.y + lift, z = pos.z}, width + 2, height + 2, orientation, pr, is_chain, rotation)
if not chest_pos then return end
local lootitems = mcl_loot.get_loot(
{
stacks_min = 4,
stacks_max = 8,
items = {
{itemstring = "mcl_core:iron_nugget", weight = 40, amount_min = 9, amount_max = 18},
{itemstring = "mcl_core:flint", weight = 40, amount_min = 9, amount_max = 18},
{itemstring = "mcl_core:obsidian", weight = 40, amount_min = 1, amount_max = 2},
{itemstring = "mcl_fire:fire_charge", weight = 40, amount_min = 1, amount_max = 1},
{itemstring = "mcl_fire:flint_and_steel", weight = 40, amount_min = 1, amount_max = 1},
{itemstring = "mcl_core:gold_nugget", weight = 15, amount_min = 4, amount_max = 24},
{itemstring = "mcl_core:apple_gold", weight = 15},
{itemstring = "mcl_tools:axe_gold", weight = 15, func = enchant},
{itemstring = "mcl_farming:hoe_gold", weight = 15, func = enchant},
{itemstring = "mcl_tools:pick_gold", weight = 15, func = enchant},
{itemstring = "mcl_tools:shovel_gold", weight = 15, func = enchant},
{itemstring = "mcl_tools:sword_gold", weight = 15, func = enchant},
{itemstring = "mcl_armor:helmet_gold", weight = 15, func = enchant_armor},
{itemstring = "mcl_armor:chestplate_gold", weight = 15, func = enchant_armor},
{itemstring = "mcl_armor:leggings_gold", weight = 15, func = enchant_armor},
{itemstring = "mcl_armor:boots_gold", weight = 15, func = enchant_armor},
{itemstring = "mcl_potions:speckled_melon", weight = 5, amount_min = 4, amount_max = 12},
{itemstring = "mcl_farming:carrot_item_gold", weight = 5, amount_min = 4, amount_max = 12},
{itemstring = "mcl_core:gold_ingot", weight = 5, amount_min = 2, amount_max = 8},
{itemstring = "mcl_clock:clock", weight = 5},
{itemstring = "mesecons_pressureplates:pressure_plate_gold_off", weight = 5},
{itemstring = "mobs_mc:gold_horse_armor", weight = 5},
{itemstring = "mcl_core:goldblock", weight = 1, amount_min = 1, amount_max = 2},
{itemstring = "mcl_bells:bell", weight = 1},
{itemstring = "mcl_core:apple_gold_enchanted", weight = 1},
}
},
pr
)
mcl_structures.init_node_construct(chest_pos)
local meta = minetest.get_meta(chest_pos)
local inv = meta:get_inventory()
mcl_loot.fill_inventory(inv, "main", lootitems, pr)
end
local function get_place_rank(pos)
local x, y, z = pos.x, pos.y, pos.z
local p1 = {x = x , y = y, z = z }
local p2 = {x = x + 7, y = y, z = z + 7}
local air_pos_list_surface = #minetest.find_nodes_in_area(p1, p2, "air", false)
local air_pos_list_surface = #minetest_find_nodes_in_area(p1, p2, "air", false)
p1.y = p1.y - 1
p2.y = p2.y - 1
local opaque_pos_list_surface = #minetest.find_nodes_in_area(p1, p2, "group:opaque", false)
local opaque_pos_list_surface = #minetest_find_nodes_in_area(p1, p2, "group:opaque", false)
return air_pos_list_surface + 3 * opaque_pos_list_surface
end
@ -374,7 +569,7 @@ mcl_structures.register_structure({
flags = "all_floors",
fill_ratio = scanning_ratio,
height = 1,
place_on = {"mcl_core:sand", "mcl_core:dirt_with_grass", "mcl_core:water_source"},
place_on = {"mcl_core:sand", "mcl_core:dirt_with_grass", "mcl_core:water_source", "mcl_core:dirt_with_grass_snow"},
},
on_finished_chunk = function(minp, maxp, seed, vm_context, pos_list)
if maxp.y < mcl_mapgen.overworld.min then return end