Update Fork #9

Merged
chmodsayshello merged 403 commits from MineClone5/MineClone5:master into master 2022-08-02 15:50:37 +02:00
9 changed files with 146 additions and 49 deletions
Showing only changes of commit 69b66c2e3c - Show all commits

View File

@ -70,7 +70,11 @@ an explanation.
## Installation ## Installation
This game requires latest stable [Minetest](http://minetest.net) to run, please install This game requires latest stable [Minetest](http://minetest.net) to run, please install
it first. Only stable versions of Minetest are officially supported. it first. Only latest stable version of Minetest is officially supported.
There are lots of questions about Ubuntu, which has minetest-5.1.1 still.
Please, first of all, visit this page, it should fix the problem: https://launchpad.net/~minetestdevs/+archive/ubuntu/stable
Also, here is endless issue #123: https://git.minetest.land/MineClone5/MineClone5/issues/123 - really less preferable way.
There is no support for running MineClone 5 in development versions of Minetest. There is no support for running MineClone 5 in development versions of Minetest.
To install MineClone 5 (if you haven't already), move this directory into the To install MineClone 5 (if you haven't already), move this directory into the

View File

@ -148,16 +148,48 @@ local chunk_scan_range = {
[ CS_NODES] = {LAST_BLOCK+1, LAST_BLOCK+1}, [ CS_NODES] = {LAST_BLOCK+1, LAST_BLOCK+1},
} }
local EDGE_MIN = mcl_mapgen.EDGE_MIN
local EDGE_MAX = mcl_mapgen.EDGE_MAX
local function is_chunk_finished(minp) local function is_chunk_finished(minp)
local center = vector.add(minp, HALF_CS_NODES) local center_x = minp.x + HALF_CS_NODES
for check_x = center.x - CS_NODES, center.x + CS_NODES, CS_NODES do local center_y = minp.y + HALF_CS_NODES
for check_y = center.y - CS_NODES, center.y + CS_NODES, CS_NODES do local center_z = minp.z + HALF_CS_NODES
for check_z = center.z - CS_NODES, center.z + CS_NODES, CS_NODES do local from_x = center_x - CS_NODES
local pos = vector.new(check_x, check_y, check_z) local from_y = center_y - CS_NODES
if pos ~= center then local from_z = center_z - CS_NODES
minetest_get_voxel_manip():read_from_map(pos, pos) local to_x = center_x + CS_NODES
local node = minetest_get_node(pos) local to_y = center_y + CS_NODES
local to_z = center_z + CS_NODES
if from_x < EDGE_MIN then from_x = center_x end
if from_y < EDGE_MIN then from_y = center_y end
if from_z < EDGE_MIN then from_z = center_z end
if to_x > EDGE_MAX then to_x = center_x end
if to_y > EDGE_MAX then to_y = center_y end
if to_z > EDGE_MAX then to_z = center_z end
for check_x = from_x, to_x, CS_NODES do
local are_we_in_central_chunk = check_x == center_x
for check_y = from_y, to_y, CS_NODES do
are_we_in_central_chunk = are_we_in_central_chunk and (check_y == center_y)
for check_z = from_z, to_z, CS_NODES do
are_we_in_central_chunk = are_we_in_central_chunk and (check_z == center_z)
if not are_we_in_central_chunk then
local check_pos = {x = check_x, y = check_y, z = check_z}
minetest_get_voxel_manip():read_from_map(check_pos, check_pos)
local node = minetest_get_node(check_pos)
if node.name == "ignore" then if node.name == "ignore" then
-- return nil, means false, means, there is something to generate still,
-- (because one of adjacent chunks is unfinished - "ignore" means that),
-- means this chunk will be changed, at least one of its sides or corners
-- means it's unsafe to place anything there right now, it might disappar,
-- better to wait, see the diagram of conflict/ok areas per a single axis:
-- conflict| ok |conflict|conflict| ok |conflict|conflict| ok |conflict
-- (_________Chunk1_________)|(_________Chunk2_________)|(_________Chunk3_________)
-- [Block1]|[MidBlk]|[BlockN]|[Block1]|[MidBlk]|[BlockN]|[Block1]|[MidBlk]|[BlockN]
-- \_____________Chunk2-with-shell____________/
-- ...______Chunk1-with-shell________/ \________Chunk3-with-shell______...
-- Generation of chunk 1 AFFECTS 2 ^^^ ^^^ Generation of chunk 3 affects 2
-- ^^^^^^^^Chunk 2 gen. affects 1 and 3^^^^^^^^
return return
end end
end end

View File

@ -611,11 +611,14 @@ do
io.close(file) io.close(file)
if string then if string then
local savetable = minetest.deserialize(string) local savetable = minetest.deserialize(string)
for name, players_stored_data in pairs(savetable.players_stored_data) do local savetable_players_stored_data = savetable and savetable.players_stored_data
doc.data.players[name] = {} if savetable_players_stored_data then
doc.data.players[name].stored_data = players_stored_data for name, players_stored_data in pairs(savetable_players_stored_data) do
doc.data.players[name] = {}
doc.data.players[name].stored_data = players_stored_data
end
minetest.log("action", "[doc] doc.mt successfully read.")
end end
minetest.log("action", "[doc] doc.mt successfully read.")
end end
end end
end end

View File

@ -63,40 +63,42 @@ local function add_wear(placer, itemstack)
end end
local function anti_oxidation(itemstack, placer, pointed_thing) local function anti_oxidation(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then return end local pointed_thing = pointed_thing
if pointed_thing.type ~= "node" then return end
local node = minetest.get_node(pointed_thing.under) local pointed_thing_under = pointed_thing.under
local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] local node = minetest.get_node(pointed_thing_under)
local node_def = minetest.registered_nodes[node.name]
if not node_def then return end
if not placer:get_player_control().sneak and noddef.on_rightclick then if not placer:get_player_control().sneak and node_def.on_rightclick then
return minetest.item_place(itemstack, placer, pointed_thing) return minetest.item_place(itemstack, placer, pointed_thing)
end end
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then local placer_name = placer:get_player_name()
minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) if minetest.is_protected(pointed_thing_under, placer_name) then
return itemstack minetest.record_protection_violation(pointed_thing_under, placer_name)
end return itemstack
end
if noddef._mcl_stripped_variant == nil then if not node_def._mcl_stripped_variant then
for _, c in pairs(stairs) do for _, c in pairs(stairs) do
if noddef.name == "mcl_stairs:"..c[1].."_copper_"..c[2].."_cut"..c[3] then if node_def.name == "mcl_stairs:"..c[1].."_copper_"..c[2].."_cut"..c[3] then
minetest.swap_node(pointed_thing.under, {name="mcl_stairs:"..c[1].."_copper_"..c[4], param2=node.param2}) minetest.swap_node(pointed_thing_under, {name="mcl_stairs:"..c[1].."_copper_"..c[4], param2=node.param2})
anti_oxidation_particles(pointed_thing) anti_oxidation_particles(pointed_thing)
add_wear(placer, itemstack) add_wear(placer, itemstack)
end end
end end
if noddef._mcl_anti_oxidation_variant ~= nil then if node_def._mcl_anti_oxidation_variant then
minetest.swap_node(pointed_thing.under, {name=noddef._mcl_anti_oxidation_variant, param2=node.param2}) minetest.swap_node(pointed_thing_under, {name=node_def._mcl_anti_oxidation_variant, param2=node.param2})
anti_oxidation_particles(pointed_thing) anti_oxidation_particles(pointed_thing)
add_wear(placer, itemstack) add_wear(placer, itemstack)
end end
elseif noddef._mcl_stripped_variant ~= nil then elseif node_def._mcl_stripped_variant then
minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_variant, param2=node.param2}) minetest.swap_node(pointed_thing_under, {name=node_def._mcl_stripped_variant, param2=node.param2})
add_wear(placer, itemstack) add_wear(placer, itemstack)
else
return itemstack
end end
return itemstack return itemstack
end end
local function register_axe_override(axe_name) local function register_axe_override(axe_name)

View File

@ -4,6 +4,11 @@
local modpath = minetest.get_modpath(minetest.get_current_modname()) local modpath = minetest.get_modpath(minetest.get_current_modname())
local minetest_get_item_group = minetest.get_item_group
local minetest_get_node = minetest.get_node
local math_random = math.random
local minetest_after = minetest.after
local mg_name = mcl_mapgen.name local mg_name = mcl_mapgen.name
local v6 = mcl_mapgen.v6 local v6 = mcl_mapgen.v6
@ -148,6 +153,30 @@ function mcl_core.lava_spark_add(pos)
luaentity._life_timer = 0.4 + math.random() luaentity._life_timer = 0.4 + math.random()
end end
if lava_spark_limit > 0 then
mcl_core.lava_spark_set_chance()
minetest.register_abm({
label = "Lava produce sparks",
nodenames = {"group:lava"},
neighbors = {"air"},
interval = LAVA_SPARK_ABM_INTERVAL,
chance = 18,
action = function(pos, node)
local above = minetest_get_node({x = pos.x, y = pos.y + 1, z = pos.z})
if above.name ~= "air" then return end
lava_spark_abm_census = lava_spark_abm_census + 1
if lava_spark_census >= lava_spark_limit then return end
if math_random() > lava_spark_chance then return end
lava_spark_census = lava_spark_census + 1
minetest_after(math_random() * LAVA_SPARK_ABM_INTERVAL, lava_spark_add, pos)
end
})
end
minetest.register_entity("mcl_core:lava_spark", { minetest.register_entity("mcl_core:lava_spark", {
physical = true, physical = true,
visual = "sprite", visual = "sprite",

View File

@ -14,6 +14,7 @@ mcl_shields = {
enchantments = {"mending", "unbreaking"}, enchantments = {"mending", "unbreaking"},
players = {}, players = {},
} }
local players = mcl_shields.players
local interact_priv = minetest.registered_privileges.interact local interact_priv = minetest.registered_privileges.interact
interact_priv.give_to_singleplayer = false interact_priv.give_to_singleplayer = false
@ -110,7 +111,7 @@ end
function mcl_shields.is_blocking(obj) function mcl_shields.is_blocking(obj)
if not mcl_util or not mcl_util.is_player(obj) then return end if not mcl_util or not mcl_util.is_player(obj) then return end
local blocking = mcl_shields.players[obj].blocking local blocking = players[obj].blocking
if blocking > 0 then if blocking > 0 then
local shieldstack = obj:get_wielded_item() local shieldstack = obj:get_wielded_item()
if blocking == 1 then if blocking == 1 then
@ -155,7 +156,7 @@ local function modify_shield(player, vpos, vrot, i)
if i == 1 then if i == 1 then
arm = "Left" arm = "Left"
end end
local player_data = mcl_shields.players[player] local player_data = players[player]
if not player_data then return end if not player_data then return end
local shields = player_data.shields local shields = player_data.shields
if not shields then return end if not shields then return end
@ -178,7 +179,10 @@ local function set_shield(player, block, i)
modify_shield(player, vector.new(3, -5, 0), vector.new(0, 0, 0), i) modify_shield(player, vector.new(3, -5, 0), vector.new(0, 0, 0), i)
end end
end end
local shield = mcl_shields.players[player].shields[i] local player_data = players[player]
if not player_data then return end
local player_shields = player_data.shields
local shield = player_shields[i]
if not shield then return end if not shield then return end
local luaentity = shield:get_luaentity() local luaentity = shield:get_luaentity()
if not luaentity then return end if not luaentity then return end
@ -219,12 +223,12 @@ end
local function add_shield_entity(player, i) local function add_shield_entity(player, i)
local shield = minetest.add_entity(player:get_pos(), "mcl_shields:shield_entity") local shield = minetest.add_entity(player:get_pos(), "mcl_shields:shield_entity")
shield:get_luaentity()._shield_number = i shield:get_luaentity()._shield_number = i
mcl_shields.players[player].shields[i] = shield players[player].shields[i] = shield
set_shield(player, false, i) set_shield(player, false, i)
end end
local function remove_shield_entity(player, i) local function remove_shield_entity(player, i)
local shields = mcl_shields.players[player].shields local shields = players[player].shields
if shields[i] then if shields[i] then
shields[i]:remove() shields[i]:remove()
shields[i] = nil shields[i] = nil
@ -232,7 +236,7 @@ local function remove_shield_entity(player, i)
end end
local function handle_blocking(player) local function handle_blocking(player)
local player_shield = mcl_shields.players[player] local player_shield = players[player]
local rmb = player:get_player_control().RMB local rmb = player:get_player_control().RMB
if rmb then if rmb then
local shield_in_offhand = mcl_shields.wielding_shield(player, 1) local shield_in_offhand = mcl_shields.wielding_shield(player, 1)
@ -274,7 +278,7 @@ local function handle_blocking(player)
end end
local function update_shield_entity(player, blocking, i) local function update_shield_entity(player, blocking, i)
local shield = mcl_shields.players[player].shields[i] local shield = players[player].shields[i]
if mcl_shields.wielding_shield(player, i) then if mcl_shields.wielding_shield(player, i) then
if not shield then if not shield then
add_shield_entity(player, i) add_shield_entity(player, i)
@ -378,7 +382,7 @@ end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
shield_hud[player] = nil shield_hud[player] = nil
mcl_shields.players[player] = nil players[player] = nil
end) end)
minetest.register_craft({ minetest.register_craft({
@ -468,7 +472,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
end) end)
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
mcl_shields.players[player] = { players[player] = {
shields = {}, shields = {},
blocking = 0, blocking = 0,
} }

View File

@ -62,7 +62,6 @@ local spawn_trident = function(player)
durability = durability * (unbreaking + 1) durability = durability * (unbreaking + 1)
end end
wielditem:add_wear(65535/durability) wielditem:add_wear(65535/durability)
minetest.chat_send_all(wielditem:get_wear())
obj:set_velocity(vector.multiply(player:get_look_dir(), 20)) obj:set_velocity(vector.multiply(player:get_look_dir(), 20))
obj:set_acceleration({x=0, y=-GRAVITY, z=0}) obj:set_acceleration({x=0, y=-GRAVITY, z=0})
obj:set_yaw(yaw) obj:set_yaw(yaw)
@ -78,10 +77,10 @@ minetest.register_tool("mcl_tridents:trident", {
stack_max = 1, stack_max = 1,
groups = {weapon=1,weapon_ranged=1,trident=1,enchantability=1}, groups = {weapon=1,weapon_ranged=1,trident=1,enchantability=1},
_mcl_uses = TRIDENT_DURABILITY, _mcl_uses = TRIDENT_DURABILITY,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
spawn_trident(placer) spawn_trident(placer)
end, end,
on_secondary_use = function(itemstack, user, pointed_thing) on_secondary_use = function(itemstack, user, pointed_thing)
spawn_trident(user) spawn_trident(user)
end end
}) })

View File

@ -1,3 +1,6 @@
local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath .. "/ratelimit.lua")
local enable_anticheat = true local enable_anticheat = true
local kick_cheaters = false local kick_cheaters = false
local kick_threshold = 10 local kick_threshold = 10

View File

@ -0,0 +1,21 @@
-- by LoneWolfHT
-- https://github.com/minetest/minetest/issues/12220#issuecomment-1108789409
local ratelimit = {}
local after = minetest.after
local LIMIT = 2
local function remove_entry(ip)
ratelimit[ip] = nil
end
minetest.register_on_mods_loaded(function()
table.insert(core.registered_on_prejoinplayers, 1, function(player, ip)
if ratelimit[ip] then
return "You are joining too fast, please try again"
else
ratelimit[ip] = true
after(LIMIT, remove_entry, ip)
end
end)
end)