Compare commits

..

8 Commits

Author SHA1 Message Date
epCode 647a53c354 Merge pull request 'Fix player speed on soul sand, MineClone2/MineClone2#1356' (#1363) from ArTee3/MineClone2:fix-player-speed-on-soulsand into master
Reviewed-on: MineClone2/MineClone2#1363
2021-03-22 21:53:47 +00:00
ArTee3 910c9083e5 Fix player speed on soul sand, MineClone2/MineClone2#1356 2021-03-22 21:55:57 +01:00
kay27 66a64439c6 [mcl_weather] Fix crash on saving uninitialized data, MineClone2/MineClone2#1361 2021-03-22 17:31:24 +04:00
kay27 7fe3217cd0 [mcl_portals] Remove debug messages 2021-03-22 11:32:28 +04:00
epCode 01df02667b Make setting for swim on lava 2021-03-21 17:53:57 -07:00
kay27 03feb36558 Improve Nether Portals (#1315) (as a squash)
Remove Nether portal caches, MineClone2/MineClone2#1210

Store all exits from Nether portals in quick-access table

Implement proper Nether portal search, using the table, MineClone2/MineClone2#1055

Store Nether portal exits table in mod storage

Remove exits from table on Nether portal destruction

Align destination area to [map chunks 5x5x5](https://git.minetest.land/MineClone2/MineClone2/wiki/World-structure%3A-positions%2C-boundaries%2C-blocks%2C-chunks%2C-dimensions%2C-barriers-and-the-void) to avoid lots of ```emerge_area()``` calls

Support Nether roof, MineClone2/MineClone2#1267

Implement better suitable place search, MineClone2/MineClone2#1126

Implement object queue not to trigger the same search again

Avoid lava lakes, MineClone2/MineClone2#1126

Add ```/spawnstruct nether_portal``` chat command
Co-Authored-By: kay27 <kay27@noreply.git.minetest.land>
Co-Committed-By: kay27 <kay27@noreply.git.minetest.land>
2021-03-21 23:14:33 +00:00
kay27 1f925b6c84 Merge pull request 'Give xp if items are moved between furnace slots, unlock smelting achievements if furnace is inactive' (#1360) from ArTee3/MineClone2:furnace-fixes into master
Reviewed-on: MineClone2/MineClone2#1360
2021-03-21 22:53:59 +00:00
ArTee3 1fa2bd3477 Give xp if items are moved between furnace slots, unlock smelting achievements if furnace is inactive 2021-03-21 17:01:28 +01:00
5 changed files with 27 additions and 111 deletions

View File

@ -2856,6 +2856,18 @@ local falling = function(self, pos)
self.object:set_acceleration({x = 0, y = 0, z = 0})
end
if minetest.registered_nodes[node_ok(pos).name].groups.lava then
if self.floats_on_lava == 1 then
self.object:set_acceleration({
x = 0,
y = -self.fall_speed / (max(1, v.y) ^ 2),
z = 0
})
end
end
-- in water then float up
if minetest.registered_nodes[node_ok(pos).name].groups.water then
@ -3773,6 +3785,7 @@ minetest.register_entity(name, {
knock_back = def.knock_back ~= false,
shoot_offset = def.shoot_offset or 0,
floats = def.floats or 1, -- floats in water by default
floats_on_lava = def.floats_on_lava or 0,
replace_rate = def.replace_rate,
replace_what = def.replace_what,
replace_with = def.replace_with,

View File

@ -38,6 +38,7 @@ mcl_weather.reg_weathers["none"] = {
local storage = minetest.get_mod_storage()
-- Save weather into mod storage, so it can be loaded after restarting the server
local save_weather = function()
if not mcl_weather.end_time then return end
storage:set_string("mcl_weather_state", mcl_weather.state)
storage:set_int("mcl_weather_end_time", mcl_weather.end_time)
minetest.log("verbose", "[mcl_weather] Weather data saved: state="..mcl_weather.state.." end_time="..mcl_weather.end_time)

View File

@ -161,6 +161,12 @@ local function on_metadata_inventory_take(pos, listname, index, stack, player)
end
end
local function on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
if from_list == "dst" then
give_xp(pos, player)
end
end
local function spawn_flames(pos, param2)
local minrelpos, maxrelpos
local dir = minetest.facedir_to_dir(param2)
@ -477,10 +483,12 @@ minetest.register_node("mcl_furnaces:furnace", {
give_xp(pos)
end,
on_metadata_inventory_move = function(pos)
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-- Reset accumulated game time when player works with furnace:
furnace_reset_delta_time(pos)
minetest.get_node_timer(pos):start(1.0)
on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
end,
on_metadata_inventory_put = function(pos)
-- Reset accumulated game time when player works with furnace:
@ -494,9 +502,7 @@ minetest.register_node("mcl_furnaces:furnace", {
-- start timer function, it will helpful if player clears dst slot
minetest.get_node_timer(pos):start(1.0)
if listname == "dst" then
give_xp(pos, player)
end
on_metadata_inventory_take(pos, listname, index, stack, player)
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
@ -552,6 +558,7 @@ minetest.register_node("mcl_furnaces:furnace_active", {
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_metadata_inventory_move = on_metadata_inventory_move,
on_metadata_inventory_take = on_metadata_inventory_take,
on_receive_fields = receive_fields,
_mcl_blast_resistance = 3.5,

View File

@ -324,10 +324,8 @@ function build_nether_portal(pos, width, height, orientation, name)
local pp_1 = {x = x, y = pos.y - 2, z = z}
local nn = get_node(pp).name
local nn_1 = get_node(pp_1).name
log("warning", "[mcl_portals] pos=" .. pos_to_string(pp) .. " nn=" .. nn .. " name=" .. name .. " width=" .. tostring(width) .. " height=" .. tostring(height).." orientation=" ..tostring(orientation).." gc="..tostring(registered_nodes[nn].is_ground_content) .." for obsidian platform:")
if ((nn=="air" and nn_1 == "air") or not registered_nodes[nn].is_ground_content) and not is_protected(pp, name) then
set_node(pp, {name = OBSIDIAN})
minetest.log("warning", "set!")
end
end
end
@ -432,96 +430,12 @@ local function get_lava_level(pos, pos1, pos2)
return max(min(mcl_vars.mg_lava_nether_max, pos2.y-1), pos1.y+1)
end
local function ecb_scan_area(blockpos, action, calls_remaining, param)
if calls_remaining and calls_remaining > 0 then return end
local pos, pos1, pos2, name, obj = param.pos, param.pos1, param.pos2, param.name or "", param.obj
local lava = get_lava_level(pos, pos1, pos2)
local ttt1 = minetest.get_us_time() -- !!debug
-- loop in a spiral around pos
local cs, x, z, dx, dz, p0x, p0z, p1x, p1y, p1z, p2x, p2y, p2z = mcl_vars.chunk_size_in_nodes, 0, 0, 0, -1, pos.x, pos.z, pos1.x, pos1.y, pos1.z, pos2.x, pos2.y, pos2.z
local i_max = (cs*2-1) * (cs*2-1)
log("action", "[mcl_portals] Area for destination Nether portal emerged! We about to iterate " .. tostring(i_max) .. " positions of spiral around "..pos_to_string(pos))
local backup_pos, bnc = nil, 0 -- 'better than nothing'
local p1 = {x=0, y=p1y, z=0}
local p2 = {x=0, y=p2y, z=0}
for i = 1, i_max do
local px, pz = p0x + x, p0z + z
if ((i%100) == 1) then
log("action", "[mcl_portals] i=" ..tostring(i) .." px=" .. tostring(px) .." pz=" .. tostring(pz) .. " x:"..tostring(p1x) .."-"..tostring(p2x) .. " z:"..tostring(p1z) .."-"..tostring(p2z))
end
if px >= p1x and pz >= p1z and px <= p2x and pz <= p2z then
p1.x, p2.x, p1.z, p2.z = px, px, pz, pz
local nodes = find_nodes_in_area_under_air(p1, p2, {"group:building_block"})
log("action", "[mcl_portals] check " .. pos_to_string(p1) .. "-" .. pos_to_string(p2) .. ": " .. tostring(nodes and #nodes))
if nodes and #nodes > 0 then
for j = 1, #nodes do
local node = nodes[j]
if not is_protected(node, name) then
node.y = node.y + 2
local node2 = {x = node.x, y = node.y + 2, z = node.z}
if not is_protected(node2, name) then
local nodes_j = find_nodes_in_area(node, node2, {"air"})
local nc = #nodes_j
if nc >= 3 then
node2.x = node2.x + 2
node2.z = node2.z + 2
nodes_j = find_nodes_in_area(node, node2, {"air"})
if #nodes_j == 36 then
local msg1 = "DEBUG message: space found using algorithm 1, elapsed time: " .. tostring(minetest.get_us_time()-ttt1) .." us" -- !!debug
log("warning", "[mcl_portals] " .. msg1) -- !!debug
minetest.chat_send_all(msg1) -- !!debug
log("action", "[mcl_portals] found space at pos "..pos_to_string(node).." - creating a portal")
create_portal_2({x=node.x, y=node.y+1, z=node.z}, name, obj)
return
end
elseif nc > bnc or ((nc > max(bnc-2,0)) and backup_pos.y<lava and node.y > lava) then
bnc = nc
backup_pos = {x = node2.x, y = node2.y, z = node2.z}
log("action", "[mcl_portals] set backup pos "..pos_to_string(backup_pos).." with "..tostring(nc).." air node(s)")
end
end
end
end
end
end
if x == z or (x < 0 and x == -z) or (x > 0 and x == 1-z) then
dx, dz = -dz, dx
end
x, z = x+dx, z+dz
px, pz = p0x + x, p0z + z
end
if backup_pos then -- several nodes of air might be better than lava lake, right?
local msg1 = "DEBUG message: space partially found using algorithm 1, elapsed time: " .. tostring(minetest.get_us_time()-ttt1) .." us" -- !!debug
log("warning", "[mcl_portals] " .. msg1) -- !!debug
minetest.chat_send_all(msg1) -- !!debug
log("action", "[mcl_portals] using backup pos "..pos_to_string(backup_pos).." to create a portal")
create_portal_2(backup_pos, name, obj)
return
end
local msg1 = "DEBUG message: space not found using algorithm 1, elapsed time: " .. tostring(minetest.get_us_time()-ttt1) .." us" -- !!debug
log("warning", "[mcl_portals] " .. msg1) -- !!debug
minetest.chat_send_all(msg1) -- !!debug
log("action", "[mcl_portals] found no space, reverting to target pos "..pos_to_string(pos).." - creating a portal")
if pos.y < lava then
pos.y = lava + 1
else
pos.y = pos.y + 1
end
create_portal_2(pos, name, obj)
end
local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
if calls_remaining and calls_remaining > 0 then return end
local pos, pos1, pos2, name, obj = param.pos, param.pos1, param.pos2, param.name or "", param.obj
local pos0, distance
local lava = get_lava_level(pos, pos1, pos2)
local ttt2 = minetest.get_us_time() -- !!debug
local nodes = find_nodes_in_area_under_air(pos1, pos2, {"group:building_block"})
if nodes then
local nc = #nodes
@ -538,9 +452,6 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
if nc2 == 27 and not is_area_protected(node, node2, name) then
local distance0 = dist(pos, node)
if distance0 < 2 then
local msg1 = "DEBUG message: space found using algorithm 2, elapsed time: " .. tostring(minetest.get_us_time()-ttt2) .." us" -- !!debug
log("warning", "[mcl_portals] " .. msg1) -- !!debug
minetest.chat_send_all(msg1) -- !!debug
log("action", "[mcl_portals] found space at pos "..pos_to_string(node).." - creating a portal")
create_portal_2(node1, name, obj)
return
@ -556,16 +467,10 @@ local function ecb_scan_area_2(blockpos, action, calls_remaining, param)
end
end
if distance then -- several nodes of air might be better than lava lake, right?
local msg1 = "DEBUG message: space partially found using algorithm 2, elapsed time: " .. tostring(minetest.get_us_time()-ttt2) .." us" -- !!debug
log("warning", "[mcl_portals] " .. msg1) -- !!debug
minetest.chat_send_all(msg1) -- !!debug
log("action", "[mcl_portals] using backup pos "..pos_to_string(pos0).." to create a portal")
create_portal_2(pos0, name, obj)
return
end
local msg1 = "DEBUG message: space not found using algorithm 2, elapsed time: " .. tostring(minetest.get_us_time()-ttt2) .." us" -- !!debug
log("warning", "[mcl_portals] " .. msg1) -- !!debug
minetest.chat_send_all(msg1) -- !!debug
log("action", "[mcl_portals] found no space, reverting to target pos "..pos_to_string(pos).." - creating a portal")
if pos.y < lava then
pos.y = lava + 1
@ -598,11 +503,7 @@ local function create_portal(pos, limit1, limit2, name, obj)
pos2 = {x = min(max(limit2.x, pos.x), pos2.x), y = min(max(limit2.y, pos.y), pos2.y), z = min(max(limit2.z, pos.z), pos2.z)}
end
if random(1,2) == 2 then
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = vector.new(pos), pos1 = pos1, pos2 = pos2, name=name, obj=obj})
else
minetest.emerge_area(pos1, pos2, ecb_scan_area, {pos = vector.new(pos), pos1 = pos1, pos2 = pos2, name=name, obj=obj})
end
minetest.emerge_area(pos1, pos2, ecb_scan_area_2, {pos = vector.new(pos), pos1 = pos1, pos2 = pos2, name=name, obj=obj})
end
local function available_for_nether_portal(p)

View File

@ -252,13 +252,7 @@ minetest.register_globalstep(function(dtime)
playerphysics.add_physics_factor(player, "speed", "mcl_playerplus:surface", 0.4)
end
end
else
-- Reset speed decrease
playerphysics.remove_physics_factor(player, "speed", "mcl_playerplus:surface")
end
-- Swimming? Check if boots are enchanted with depth strider
if get_item_group(node_feet, "liquid") ~= 0 and mcl_enchanting.get_enchantment(player:get_inventory():get_stack("armor", 5), "depth_strider") then
elseif get_item_group(node_feet, "liquid") ~= 0 and mcl_enchanting.get_enchantment(player:get_inventory():get_stack("armor", 5), "depth_strider") then
local boots = player:get_inventory():get_stack("armor", 5)
local depth_strider = mcl_enchanting.get_enchantment(boots, "depth_strider")