#252 Fix review issues

This commit is contained in:
kay27 2022-03-14 02:59:21 +04:00
parent ba5474f5d4
commit 37ff5f15bd
6 changed files with 68 additions and 67 deletions

View File

@ -302,7 +302,6 @@ function mobs:spawn_setup(def)
on_spawn = on_spawn, on_spawn = on_spawn,
} }
summary_chance = summary_chance + chance summary_chance = summary_chance + chance
minetest.log("warning", minetest.serialize(spawn_dictionary))
end end
function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn) function mobs:spawn_specific(name, dimension, type_of_spawning, biomes, min_light, max_light, interval, chance, aoc, min_height, max_height, day_toggle, on_spawn)

View File

@ -55,7 +55,7 @@ mobs:register_mob("mobs_mc:silverfish", {
local selfpos = self.object:get_pos() local selfpos = self.object:get_pos()
local objects = minetest.get_objects_inside_radius(selfpos, PLAYER_SCAN_RADIUS) local objects = minetest.get_objects_inside_radius(selfpos, PLAYER_SCAN_RADIUS)
for _, obj in pairs(objects) do for _, obj in pairs(objects) do
if obj:is_player() then if obj:is_player() and not minetest.is_creative_enabled(obj:get_player_name()) then
self.attacking = obj self.attacking = obj
mobs.group_attack_initialization(self) mobs.group_attack_initialization(self)
return return

View File

@ -248,6 +248,51 @@ local function player_chest_close(player)
open_chests[name] = nil open_chests[name] = nil
end end
local function drop_item_stack(pos, stack)
if not stack or stack:is_empty() then return end
local drop_offset = vector.new(math.random() - 0.5, 0, math.random() - 0.5)
minetest.add_item(vector.add(pos, drop_offset), stack)
end
local function drop_items_chest(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.inventory then
-- process after_dig_node callback
local main = oldmetadata.inventory.main
if not main then return end
for _, stack in pairs(main) do
drop_item_stack(pos, stack)
end
else
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, inv:get_size("main") do
drop_item_stack(pos, inv:get_stack("main", i))
end
meta:from_table()
end
end
local function on_chest_blast(pos, intensity)
local node = minetest.get_node(pos)
drop_items_chest(pos, node)
minetest.remove_node(pos)
-- drop node itself with some probability depended on explosion intensity (1 for TNT):
if math.random(1, math.floor((intensity or 1) * 2)) ~= 1 then return end
local node_def = minetest.registered_nodes[node.name]
if not node_def then return end
local node_name = node_def.drop or node_def.name
drop_item_stack(pos, ItemStack(node_name))
end
local function close_forms(canonical_basename, pos)
local players = minetest.get_connected_players()
for p=1, #players do
if vector.distance(players[p]:get_pos(), pos) <= 30 then
minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z)
end
end
end
-- This is a helper function to register both chests and trapped chests. Trapped chests will make use of the additional parameters -- This is a helper function to register both chests and trapped chests. Trapped chests will make use of the additional parameters
local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, canonical_basename) local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tiles_table, hidden, mesecons, on_rightclick_addendum, on_rightclick_addendum_left, on_rightclick_addendum_right, drop, canonical_basename)
-- START OF register_chest FUNCTION BODY -- START OF register_chest FUNCTION BODY
@ -295,42 +340,6 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
end end
end end
local function drop_item_stack(pos, stack)
if not stack or stack:is_empty() then return end
local drop_offset = vector.new(math.random() - 0.5, 0, math.random() - 0.5)
minetest.add_item(vector.add(pos, drop_offset), stack)
end
local function drop_items_chest(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.inventory then
-- process after_dig_node callback
local main = oldmetadata.inventory.main
if not main then return end
for _, stack in pairs(main) do
drop_item_stack(pos, stack)
end
else
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, inv:get_size("main") do
drop_item_stack(pos, inv:get_stack("main", i))
end
meta:from_table()
end
end
local function on_chest_blast(pos, intensity)
local node = minetest.get_node(pos)
drop_items_chest(pos, node)
minetest.remove_node(pos)
-- drop node itself with some probability depended on explosion intensity (1 for TNT):
if math.random(1, math.floor((intensity or 1) * 2)) ~= 1 then return end
local node_def = minetest.registered_nodes[node.name]
if not node_def then return end
local node_name = node_def.drop or node_def.name
drop_item_stack(pos, ItemStack(node_name))
end
local function limit_put_list(stack, list) local function limit_put_list(stack, list)
for _, other in ipairs(list) do for _, other in ipairs(list) do
stack = other:add_item(stack) stack = other:add_item(stack)
@ -380,15 +389,6 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
end, end,
}) })
local function close_forms(canonical_basename, pos)
local players = minetest.get_connected_players()
for p=1, #players do
if vector.distance(players[p]:get_pos(), pos) <= 30 then
minetest.close_formspec(players[p]:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z)
end
end
end
minetest.register_node(small_name, { minetest.register_node(small_name, {
description = desc, description = desc,
_tt_help = tt_help, _tt_help = tt_help,
@ -1476,9 +1476,11 @@ minetest.register_node("mcl_chests:barrel", {
minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name"))
end, end,
after_dig_node = drop_items_chest, after_dig_node = drop_items_chest,
on_blast = on_blast, on_blast = on_chest_blast,
on_rightclick = barrel_open, on_rightclick = barrel_open,
on_destruct = close_forms, on_destruct = function(pos)
close_forms("barrel", pos)
end,
_mcl_blast_resistance = 2.5, _mcl_blast_resistance = 2.5,
_mcl_hardness = 2.5, _mcl_hardness = 2.5,
}) })
@ -1497,9 +1499,11 @@ minetest.register_node("mcl_chests:barrel_open", {
sounds = mcl_sounds.node_sound_wood_defaults(), sounds = mcl_sounds.node_sound_wood_defaults(),
groups = {handy = 1, axey = 1, container = 2, material_wood = 1, flammable = -1, deco_block = 1, not_in_creative_inventory = 1}, groups = {handy = 1, axey = 1, container = 2, material_wood = 1, flammable = -1, deco_block = 1, not_in_creative_inventory = 1},
after_dig_node = drop_items_chest, after_dig_node = drop_items_chest,
on_blast = on_blast, on_blast = on_chest_blast,
on_rightclick = barrel_open, on_rightclick = barrel_open,
on_destruct = close_forms, on_destruct = function(pos)
close_forms("barrel_open", pos)
end,
_mcl_blast_resistance = 2.5, _mcl_blast_resistance = 2.5,
_mcl_hardness = 2.5, _mcl_hardness = 2.5,
}) })

View File

@ -470,8 +470,8 @@ minetest.register_abm({
}) })
function generate_warped_tree(pos) function generate_warped_tree(pos)
breakgrow = false local breakgrow = false
breakgrow2 = false local breakgrow2 = false
-- Baumgenerator -- Baumgenerator
-- erste und zweite Etage -- erste und zweite Etage
for x = pos.x - 2,pos.x + 2 do for x = pos.x - 2,pos.x + 2 do
@ -547,8 +547,8 @@ function generate_warped_tree(pos)
end end
function generate_crimson_tree(pos) function generate_crimson_tree(pos)
breakgrow = false local breakgrow = false
breakgrow2 = false local breakgrow2 = false
-- Baumgenerator -- Baumgenerator
-- erste und zweite Etage -- erste und zweite Etage
for x = pos.x - 2,pos.x + 2 do for x = pos.x - 2,pos.x + 2 do

View File

@ -17,16 +17,14 @@ mcl_mapgen.register_mapgen_block(function(minp, maxp)
local nodes = minetest_find_nodes_in_area(minp, maxp, debris_name) local nodes = minetest_find_nodes_in_area(minp, maxp, debris_name)
if nodes then if nodes then
for _, pos in pairs(nodes) do for _, pos in pairs(nodes) do
minetest.log("warning","debris found at "..minetest.pos_to_string(pos))
local x, y, z = pos.x, pos.y, pos.z local x, y, z = pos.x, pos.y, pos.z
if minetest_get_node({x = x-1, y = y, z = z}) == air_name if minetest_get_node({x = x-1, y = y, z = z}).name == air_name
or minetest_get_node({x = x+1, y = y, z = z}) == air_name or minetest_get_node({x = x+1, y = y, z = z}).name == air_name
or minetest_get_node({x = x, y = y-1, z = z}) == air_name or minetest_get_node({x = x, y = y-1, z = z}).name == air_name
or minetest_get_node({x = x, y = y+1, z = z}) == air_name or minetest_get_node({x = x, y = y+1, z = z}).name == air_name
or minetest_get_node({x = x, y = y, z = z-1}) == air_name or minetest_get_node({x = x, y = y, z = z-1}).name == air_name
or minetest_get_node({x = x, y = y, z = z+1}) == air_name then or minetest_get_node({x = x, y = y, z = z+1}).name == air_name then
minetest_set_node(pos, netherrack_name) minetest_set_node(pos, {name = netherrack_name})
minetest.log("warning","debris at "..minetest.pos_to_string(pos) .. " replaced to netherrack")
end end
end end
end end

View File

@ -289,9 +289,9 @@ function mcl_structures.place_schematic(def)
pos = vector.new(pos), pos = vector.new(pos),
schematic = loaded_schematic, schematic = loaded_schematic,
rotation = rotation, rotation = rotation,
replacements = replacements, replacements = def.replacements,
force_placement = force_placement, force_placement = def.force_placement,
flags = flags, flags = def.flags,
size = vector.new(size), size = vector.new(size),
pr = pr, pr = pr,
on_placed = on_placed, on_placed = on_placed,