forked from MineClone5/MineClone5
Merge testing into compatibility
This commit is contained in:
commit
230e3b0bc3
|
@ -302,7 +302,6 @@ function mobs:spawn_setup(def)
|
|||
on_spawn = on_spawn,
|
||||
}
|
||||
summary_chance = summary_chance + chance
|
||||
minetest.log("warning", minetest.serialize(spawn_dictionary))
|
||||
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)
|
||||
|
|
|
@ -55,7 +55,7 @@ mobs:register_mob("mobs_mc:silverfish", {
|
|||
local selfpos = self.object:get_pos()
|
||||
local objects = minetest.get_objects_inside_radius(selfpos, PLAYER_SCAN_RADIUS)
|
||||
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
|
||||
mobs.group_attack_initialization(self)
|
||||
return
|
||||
|
|
|
@ -248,6 +248,51 @@ local function player_chest_close(player)
|
|||
open_chests[name] = nil
|
||||
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
|
||||
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
|
||||
|
@ -295,42 +340,6 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
|
|||
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)
|
||||
for _, other in ipairs(list) do
|
||||
stack = other:add_item(stack)
|
||||
|
@ -380,15 +389,6 @@ local function register_chest(basename, desc, longdesc, usagehelp, tt_help, tile
|
|||
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, {
|
||||
description = desc,
|
||||
_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"))
|
||||
end,
|
||||
after_dig_node = drop_items_chest,
|
||||
on_blast = on_blast,
|
||||
on_blast = on_chest_blast,
|
||||
on_rightclick = barrel_open,
|
||||
on_destruct = close_forms,
|
||||
on_destruct = function(pos)
|
||||
close_forms("barrel", pos)
|
||||
end,
|
||||
_mcl_blast_resistance = 2.5,
|
||||
_mcl_hardness = 2.5,
|
||||
})
|
||||
|
@ -1497,9 +1499,11 @@ minetest.register_node("mcl_chests:barrel_open", {
|
|||
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},
|
||||
after_dig_node = drop_items_chest,
|
||||
on_blast = on_blast,
|
||||
on_blast = on_chest_blast,
|
||||
on_rightclick = barrel_open,
|
||||
on_destruct = close_forms,
|
||||
on_destruct = function(pos)
|
||||
close_forms("barrel_open", pos)
|
||||
end,
|
||||
_mcl_blast_resistance = 2.5,
|
||||
_mcl_hardness = 2.5,
|
||||
})
|
||||
|
|
|
@ -470,8 +470,8 @@ minetest.register_abm({
|
|||
})
|
||||
|
||||
function generate_warped_tree(pos)
|
||||
breakgrow = false
|
||||
breakgrow2 = false
|
||||
local breakgrow = false
|
||||
local breakgrow2 = false
|
||||
-- Baumgenerator
|
||||
-- erste und zweite Etage
|
||||
for x = pos.x - 2,pos.x + 2 do
|
||||
|
@ -547,8 +547,8 @@ function generate_warped_tree(pos)
|
|||
end
|
||||
|
||||
function generate_crimson_tree(pos)
|
||||
breakgrow = false
|
||||
breakgrow2 = false
|
||||
local breakgrow = false
|
||||
local breakgrow2 = false
|
||||
-- Baumgenerator
|
||||
-- erste und zweite Etage
|
||||
for x = pos.x - 2,pos.x + 2 do
|
||||
|
|
|
@ -17,16 +17,14 @@ mcl_mapgen.register_mapgen_block(function(minp, maxp)
|
|||
local nodes = minetest_find_nodes_in_area(minp, maxp, debris_name)
|
||||
if nodes then
|
||||
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
|
||||
if minetest_get_node({x = x-1, y = y, z = z}) == air_name
|
||||
or minetest_get_node({x = x+1, y = y, z = z}) == 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}) == 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}) == air_name then
|
||||
minetest_set_node(pos, netherrack_name)
|
||||
minetest.log("warning","debris at "..minetest.pos_to_string(pos) .. " replaced to netherrack")
|
||||
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}).name == 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}).name == 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}).name == air_name then
|
||||
minetest_set_node(pos, {name = netherrack_name})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -291,9 +291,9 @@ function mcl_structures.place_schematic(def)
|
|||
pos = vector.new(pos),
|
||||
schematic = loaded_schematic,
|
||||
rotation = rotation,
|
||||
replacements = replacements,
|
||||
force_placement = force_placement,
|
||||
flags = flags,
|
||||
replacements = def.replacements,
|
||||
force_placement = def.force_placement,
|
||||
flags = def.flags,
|
||||
size = vector.new(size),
|
||||
pr = pr,
|
||||
on_placed = on_placed,
|
||||
|
|
Loading…
Reference in New Issue