mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Merge branch 'master' of https://git.minetest.land/Wuzzy/MineClone2
This commit is contained in:
commit
fbb5f7464c
7 changed files with 119 additions and 74 deletions
|
@ -789,15 +789,15 @@ local check_for_death = function(self, cause, cmi_cause)
|
||||||
local puncher = cmi_cause.puncher
|
local puncher = cmi_cause.puncher
|
||||||
if puncher then
|
if puncher then
|
||||||
wielditem = puncher:get_wielded_item()
|
wielditem = puncher:get_wielded_item()
|
||||||
|
|
||||||
if mod_experience and ((not self.child) or self.type ~= "animal") then
|
|
||||||
mcl_experience.throw_experience(self.object:get_pos(), math.random(self.xp_min, self.xp_max))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local cooked = mcl_burning.is_burning(self.object) or mcl_enchanting.has_enchantment(wielditem, "fire_aspect")
|
local cooked = mcl_burning.is_burning(self.object) or mcl_enchanting.has_enchantment(wielditem, "fire_aspect")
|
||||||
local looting = mcl_enchanting.get_enchantment(wielditem, "looting")
|
local looting = mcl_enchanting.get_enchantment(wielditem, "looting")
|
||||||
item_drop(self, cooked, looting)
|
item_drop(self, cooked, looting)
|
||||||
|
|
||||||
|
if mod_experience and ((not self.child) or self.type ~= "animal") and (minetest.get_us_time() - self.xp_timestamp <= 5000000) then
|
||||||
|
mcl_experience.throw_experience(self.object:get_pos(), math.random(self.xp_min, self.xp_max))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2921,10 +2921,16 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- is mob protected?
|
local is_player = hitter:is_player()
|
||||||
if self.protected and hitter:is_player()
|
|
||||||
and minetest.is_protected(self.object:get_pos(), hitter:get_player_name()) then
|
if is_player then
|
||||||
return
|
-- is mob protected?
|
||||||
|
if self.protected and minetest.is_protected(self.object:get_pos(), hitter:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- set/update 'drop xp' timestamp if hitted by player
|
||||||
|
self.xp_timestamp = minetest.get_us_time()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -2933,7 +2939,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
local punch_interval = 1.4
|
local punch_interval = 1.4
|
||||||
|
|
||||||
-- exhaust attacker
|
-- exhaust attacker
|
||||||
if mod_hunger and hitter:is_player() then
|
if mod_hunger and is_player then
|
||||||
mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3082,7 +3088,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
if hitter then
|
if hitter then
|
||||||
luaentity = hitter:get_luaentity()
|
luaentity = hitter:get_luaentity()
|
||||||
end
|
end
|
||||||
if hitter and hitter:is_player() then
|
if hitter and is_player then
|
||||||
local wielditem = hitter:get_wielded_item()
|
local wielditem = hitter:get_wielded_item()
|
||||||
kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback")
|
||||||
elseif luaentity and luaentity._knockback then
|
elseif luaentity and luaentity._knockback then
|
||||||
|
@ -3091,7 +3097,7 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
|
|
||||||
self.object:set_velocity({
|
self.object:set_velocity({
|
||||||
x = dir.x * kb,
|
x = dir.x * kb,
|
||||||
y = dir.y * kb + up,
|
y = dir.y * kb + up * 2,
|
||||||
z = dir.z * kb
|
z = dir.z * kb
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3719,6 +3725,7 @@ minetest.register_entity(name, {
|
||||||
hp_max = scale_difficulty(def.hp_max, 10, 1),
|
hp_max = scale_difficulty(def.hp_max, 10, 1),
|
||||||
xp_min = def.xp_min or 0,
|
xp_min = def.xp_min or 0,
|
||||||
xp_max = def.xp_max or 0,
|
xp_max = def.xp_max or 0,
|
||||||
|
xp_timestamp = 0,
|
||||||
breath_max = def.breath_max or 15,
|
breath_max = def.breath_max or 15,
|
||||||
breathes_in_water = def.breathes_in_water or false,
|
breathes_in_water = def.breathes_in_water or false,
|
||||||
physical = true,
|
physical = true,
|
||||||
|
|
|
@ -43,10 +43,10 @@ end
|
||||||
local pr = PseudoRandom(os.time()*(-334))
|
local pr = PseudoRandom(os.time()*(-334))
|
||||||
|
|
||||||
-- How freqeuntly to take and place blocks, in seconds
|
-- How freqeuntly to take and place blocks, in seconds
|
||||||
local take_frequency_min = 25
|
local take_frequency_min = 235
|
||||||
local take_frequency_max = 90
|
local take_frequency_max = 245
|
||||||
local place_frequency_min = 10
|
local place_frequency_min = 235
|
||||||
local place_frequency_max = 30
|
local place_frequency_max = 245
|
||||||
|
|
||||||
-- Create the textures table for the enderman, depending on which kind of block
|
-- Create the textures table for the enderman, depending on which kind of block
|
||||||
-- the enderman holds (if any).
|
-- the enderman holds (if any).
|
||||||
|
|
|
@ -49,7 +49,7 @@ schem_path = settlements.modpath.."/schematics/"
|
||||||
--
|
--
|
||||||
-- list of schematics
|
-- list of schematics
|
||||||
--
|
--
|
||||||
local basic_pseudobiome_villages = minetest.settings:get_bool("basic_pseudobiome_villages", false)
|
local basic_pseudobiome_villages = minetest.settings:get_bool("basic_pseudobiome_villages", true)
|
||||||
|
|
||||||
settlements.schematic_table = {
|
settlements.schematic_table = {
|
||||||
{name = "large_house", mts = schem_path.."large_house.mts", hwidth = 11, hdepth = 12, hheight = 9, hsize = 14, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
{name = "large_house", mts = schem_path.."large_house.mts", hwidth = 11, hdepth = 12, hheight = 9, hsize = 14, max_num = 0.08 , rplc = basic_pseudobiome_villages },
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
--
|
|
||||||
function settlements.convert_mts_to_lua()
|
|
||||||
local building = schem_path.."townhall.mts"
|
|
||||||
local str = minetest.serialize_schematic(building, "lua", {lua_use_comments = true, lua_num_indent_spaces = 0}).." return(schematic)"
|
|
||||||
local schematic = loadstring(str)()
|
|
||||||
local file = io.open(schem_path.."church"..".lua", "w")
|
|
||||||
file:write(dump(schematic))
|
|
||||||
file:close()
|
|
||||||
print(dump(schematic))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function settlements.mts_save()
|
|
||||||
local f = assert(io.open(schem_path.."hut.lua", "r"))
|
|
||||||
local content = f:read("*all").." return(schematic2)"
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
local schematic2 = loadstring("schematic2 = "..content)()
|
|
||||||
local seb = minetest.serialize_schematic(schematic2, "mts", {})
|
|
||||||
local filename = schem_path .. "hut2" .. ".mts"
|
|
||||||
filename = filename:gsub("\"", "\\\""):gsub("\\", "\\\\")
|
|
||||||
local file, err = io.open(filename, "wb")
|
|
||||||
if err == nil and seb then
|
|
||||||
file:write(seb)
|
|
||||||
file:flush()
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
print("Wrote: " .. filename)
|
|
||||||
end
|
|
|
@ -72,26 +72,29 @@ local function ecb_build_a_settlement(blockpos, action, calls_remaining, param)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
-- Disable natural generation in singlenode.
|
||||||
-- needed for manual and automated settlement building
|
local mg_name = minetest.get_mapgen_setting("mg_name")
|
||||||
local heightmap = minetest.get_mapgen_object("heightmap")
|
if mg_name ~= "singlenode" then
|
||||||
|
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||||
|
-- needed for manual and automated settlement building
|
||||||
|
local heightmap = minetest.get_mapgen_object("heightmap")
|
||||||
|
|
||||||
-- randomly try to build settlements
|
-- randomly try to build settlements
|
||||||
if blockseed % 77 ~= 17 then return end
|
if blockseed % 77 ~= 17 then return end
|
||||||
|
|
||||||
-- don't build settlement underground
|
-- don't build settlement underground
|
||||||
if maxp.y < 0 then return end
|
if maxp.y < 0 then return end
|
||||||
|
|
||||||
-- don't build settlements on (too) uneven terrain
|
-- don't build settlements on (too) uneven terrain
|
||||||
local height_difference = settlements.evaluate_heightmap(minp, maxp)
|
local height_difference = settlements.evaluate_heightmap(minp, maxp)
|
||||||
if height_difference > max_height_difference then return end
|
if height_difference > max_height_difference then return end
|
||||||
|
|
||||||
-- new way - slow :(((((
|
|
||||||
minetest.emerge_area(vector.subtract(minp,24), vector.add(maxp,24), ecb_build_a_settlement, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed})
|
|
||||||
-- old way - wait 3 seconds:
|
|
||||||
-- minetest.after(3, ecb_build_a_settlement, nil, 1, 0, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed})
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
-- new way - slow :(((((
|
||||||
|
minetest.emerge_area(vector.subtract(minp,24), vector.add(maxp,24), ecb_build_a_settlement, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed})
|
||||||
|
-- old way - wait 3 seconds:
|
||||||
|
-- minetest.after(3, ecb_build_a_settlement, nil, 1, 0, {minp = vector.new(minp), maxp=vector.new(maxp), blockseed=blockseed})
|
||||||
|
end)
|
||||||
|
end
|
||||||
-- manually place villages
|
-- manually place villages
|
||||||
if minetest.is_creative_enabled("") then
|
if minetest.is_creative_enabled("") then
|
||||||
minetest.register_craftitem("mcl_villages:tool", {
|
minetest.register_craftitem("mcl_villages:tool", {
|
||||||
|
|
|
@ -45,6 +45,8 @@ local start_pos = minetest.setting_get_pos("static_spawnpoint") or {x = 0, y = 8
|
||||||
-- Table of suitable biomes
|
-- Table of suitable biomes
|
||||||
local biome_ids = {}
|
local biome_ids = {}
|
||||||
|
|
||||||
|
local no_trees_area_counter = 0
|
||||||
|
|
||||||
-- Bed spawning offsets
|
-- Bed spawning offsets
|
||||||
local node_search_list =
|
local node_search_list =
|
||||||
{
|
{
|
||||||
|
@ -225,6 +227,33 @@ end
|
||||||
-- Spawn position search
|
-- Spawn position search
|
||||||
|
|
||||||
local function next_biome()
|
local function next_biome()
|
||||||
|
if #biome_ids < 1 then
|
||||||
|
for _, biome_name in pairs(biomes_white_list) do
|
||||||
|
local biome_id = minetest.get_biome_id(biome_name)
|
||||||
|
if biome_id then
|
||||||
|
table.insert(biome_ids, biome_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #biome_ids < 1 then
|
||||||
|
next_pos()
|
||||||
|
if math.abs(cp.x) > spawn_limit or math.abs(cp.z) > spawn_limit then
|
||||||
|
check = checks + 1
|
||||||
|
minetest.log("warning", "[mcl_spawn] No white-listed biomes found - search stopped by overlimit")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
check = check + 1
|
||||||
|
cp.y = minetest.get_spawn_level(cp.x, cp.z) or start_pos.y
|
||||||
|
if cp.y then
|
||||||
|
wsp = {x = cp.x, y = cp.y, z = cp.z}
|
||||||
|
minetest.log("warning", "[mcl_spawn] No white-listed biomes found - using current")
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
minetest.log("warning", "[mcl_spawn] No white-listed biomes found and spawn level is nil - please define start_pos to continue")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.log("action", "[mcl_spawn] Suitable biomes found: "..tostring(#biome_ids))
|
||||||
|
end
|
||||||
while check <= checks do
|
while check <= checks do
|
||||||
local biome_data = minetest.get_biome_data(cp)
|
local biome_data = minetest.get_biome_data(cp)
|
||||||
-- Sometimes biome_data is nil
|
-- Sometimes biome_data is nil
|
||||||
|
@ -264,16 +293,56 @@ local function ecb_search_continue(blockpos, action, calls_remaining, param)
|
||||||
local nodes = minetest.find_nodes_in_area_under_air(emerge_pos1, emerge_pos2, node_groups_white_list)
|
local nodes = minetest.find_nodes_in_area_under_air(emerge_pos1, emerge_pos2, node_groups_white_list)
|
||||||
minetest.log("verbose", "[mcl_spawn] Data emerge callback: "..minetest.pos_to_string(wsp).." - "..tostring(nodes and #nodes) .. " node(s) found under air")
|
minetest.log("verbose", "[mcl_spawn] Data emerge callback: "..minetest.pos_to_string(wsp).." - "..tostring(nodes and #nodes) .. " node(s) found under air")
|
||||||
if nodes then
|
if nodes then
|
||||||
local trees = get_trees(emerge_pos1, emerge_pos2)
|
if no_trees_area_counter >= 0 then
|
||||||
if trees then
|
local trees = get_trees(emerge_pos1, emerge_pos2)
|
||||||
|
if trees and #trees > 0 then
|
||||||
|
no_trees_area_counter = 0
|
||||||
|
if attempts_to_find_pos * 3 < #nodes then
|
||||||
|
-- random
|
||||||
|
for i=1, attempts_to_find_pos do
|
||||||
|
wsp = nodes[math.random(1,#nodes)]
|
||||||
|
if wsp then
|
||||||
|
wsp.y = wsp.y + 1
|
||||||
|
if good_for_respawn(wsp) and can_find_tree(wsp, trees) then
|
||||||
|
minetest.log("action", "[mcl_spawn] Dynamic world spawn randomly determined to be "..minetest.pos_to_string(wsp))
|
||||||
|
searched = true
|
||||||
|
success = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- in a sequence
|
||||||
|
for i=1, math.min(#nodes, attempts_to_find_pos) do
|
||||||
|
wsp = nodes[i]
|
||||||
|
if wsp then
|
||||||
|
wsp.y = wsp.y + 1
|
||||||
|
if good_for_respawn(wsp) and can_find_tree(wsp, trees) then
|
||||||
|
minetest.log("action", "[mcl_spawn] Dynamic world spawn determined to be "..minetest.pos_to_string(wsp))
|
||||||
|
searched = true
|
||||||
|
success = true
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
no_trees_area_counter = no_trees_area_counter + 1
|
||||||
|
if no_trees_area_counter > 10 then
|
||||||
|
minetest.log("verbose", "[mcl_spawn] More than 10 times no trees at all! Won't search trees next 200 calls")
|
||||||
|
no_trees_area_counter = -200
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else -- seems there are no trees but we'll check it later, after next 200 calls
|
||||||
|
no_trees_area_counter = no_trees_area_counter + 1
|
||||||
if attempts_to_find_pos * 3 < #nodes then
|
if attempts_to_find_pos * 3 < #nodes then
|
||||||
-- random
|
-- random
|
||||||
for i=1, attempts_to_find_pos do
|
for i=1, attempts_to_find_pos do
|
||||||
wsp = nodes[math.random(1,#nodes)]
|
wsp = nodes[math.random(1,#nodes)]
|
||||||
if wsp then
|
if wsp then
|
||||||
wsp.y = wsp.y + 1
|
wsp.y = wsp.y + 1
|
||||||
if good_for_respawn(wsp) and can_find_tree(wsp, trees) then
|
if good_for_respawn(wsp) then
|
||||||
minetest.log("action", "[mcl_spawn] Dynamic world spawn determined to be "..minetest.pos_to_string(wsp))
|
minetest.log("action", "[mcl_spawn] Dynamic world spawn randomly determined to be "..minetest.pos_to_string(wsp) .. " (no trees)")
|
||||||
searched = true
|
searched = true
|
||||||
success = true
|
success = true
|
||||||
return
|
return
|
||||||
|
@ -286,8 +355,8 @@ local function ecb_search_continue(blockpos, action, calls_remaining, param)
|
||||||
wsp = nodes[i]
|
wsp = nodes[i]
|
||||||
if wsp then
|
if wsp then
|
||||||
wsp.y = wsp.y + 1
|
wsp.y = wsp.y + 1
|
||||||
if good_for_respawn(wsp) and can_find_tree(wsp, trees) then
|
if good_for_respawn(wsp) then
|
||||||
minetest.log("action", "[mcl_spawn] Dynamic world spawn determined to be "..minetest.pos_to_string(wsp))
|
minetest.log("action", "[mcl_spawn] Dynamic world spawn determined to be "..minetest.pos_to_string(wsp) .. " (no trees)")
|
||||||
searched = true
|
searched = true
|
||||||
success = true
|
success = true
|
||||||
return
|
return
|
||||||
|
@ -425,11 +494,6 @@ end
|
||||||
minetest.register_on_respawnplayer(mcl_spawn.spawn)
|
minetest.register_on_respawnplayer(mcl_spawn.spawn)
|
||||||
|
|
||||||
function mcl_spawn.shadow_worker()
|
function mcl_spawn.shadow_worker()
|
||||||
if #biome_ids > 1 then
|
|
||||||
for _, biome_name in pairs(biomes_white_list) do
|
|
||||||
table.insert(biome_ids, minetest.get_biome_id(biome_name))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if not searched then
|
if not searched then
|
||||||
searched = true
|
searched = true
|
||||||
mcl_spawn.search()
|
mcl_spawn.search()
|
||||||
|
|
|
@ -130,8 +130,8 @@ mcl_superflat_classic (Classic superflat map generation) bool false
|
||||||
# game by a lot.
|
# game by a lot.
|
||||||
mcl_node_particles (Block particles detail level) enum none high,medium,low,none
|
mcl_node_particles (Block particles detail level) enum none high,medium,low,none
|
||||||
|
|
||||||
# If enabled, this will substitute a few blocks in village schematics so they blend into normal, snowy, and sandy areas. Defaults to false.
|
# If enabled, this will substitute a few blocks in village schematics so they blend into normal, snowy, and sandy areas. Defaults to true.
|
||||||
basic_pseudobiome_villages (Enables very basic, and experimental "pseudobiome-based" villages) bool false
|
basic_pseudobiome_villages (Enables very basic, and experimental "pseudobiome-based" villages) bool true
|
||||||
|
|
||||||
# If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true.
|
# If enabled, will run an LBM to fix the top 1/2 of double plants in mcimported worlds; defaults to true.
|
||||||
fix_doubleplants (Mcimport double plant fixes) bool true
|
fix_doubleplants (Mcimport double plant fixes) bool true
|
||||||
|
|
Loading…
Reference in a new issue