1
0
Fork 0

Merge remote-tracking branch 'origin/master' into mineclone5

This commit is contained in:
kay27 2021-04-03 14:05:47 +04:00
commit 70f1434da6
2 changed files with 54 additions and 56 deletions

View File

@ -1,5 +1,8 @@
# This is a game specific minetest.conf file, do not edit # This is a game specific minetest.conf file, do not edit
# If any of these settings are set in your minetest.conf file in ~/.minetest (Linux) or in the root directory of the game (Run in place/Windows)
# They will override these settings
# Basic game rules # Basic game rules
time_speed = 72 time_speed = 72
@ -33,7 +36,7 @@ mgvalleys_spflags = noaltitude_chill,noaltitude_dry,nohumid_rivers,vary_river_de
keepInventory = false keepInventory = false
# Performance settings # Performance settings
# dedicated_server_step = 0.001 dedicated_server_step = 0.05 #tick rate
# abm_interval = 0.25 # abm_interval = 0.25
# max_objects_per_block = 4096 # max_objects_per_block = 4096
# max_packets_per_iteration = 10096 # max_packets_per_iteration = 10096

View File

@ -4,11 +4,12 @@ local mcl_item_entity = {}
--basic settings --basic settings
local item_drop_settings = {} --settings table local item_drop_settings = {} --settings table
item_drop_settings.dug_buffer = 0.65 -- the warm up period before a dug item can be collected
item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting
item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect!
item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect!
item_drop_settings.radius_collect = 0.2 --radius of collection item_drop_settings.radius_collect = 0.2 --radius of collection
item_drop_settings.player_collect_height = 1.0 --added to their pos y value item_drop_settings.player_collect_height = 0.8 --added to their pos y value
item_drop_settings.collection_safety = false --do this to prevent items from flying away on laggy servers item_drop_settings.collection_safety = false --do this to prevent items from flying away on laggy servers
item_drop_settings.random_item_velocity = true --this sets random item velocity if velocity is 0 item_drop_settings.random_item_velocity = true --this sets random item velocity if velocity is 0
item_drop_settings.drop_single_item = false --if true, the drop control drops 1 item instead of the entire stack, and sneak+drop drops the stack item_drop_settings.drop_single_item = false --if true, the drop control drops 1 item instead of the entire stack, and sneak+drop drops the stack
@ -74,14 +75,8 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement
end end
end end
--this is a 0.2 second tick globally across all players
local item_check_ticker = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
item_check_ticker = item_check_ticker + dtime
if item_check_ticker >= 0.2 then
item_check_ticker = 0
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
local pos = player:get_pos() local pos = player:get_pos()
@ -91,8 +86,7 @@ minetest.register_globalstep(function(dtime)
--magnet and collection --magnet and collection
for _,object in pairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do for _,object in pairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do
if not object:is_player() and vector.distance(checkpos, object:get_pos()) < item_drop_settings.radius_magnet and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then if not object:is_player() and vector.distance(checkpos, object:get_pos()) < item_drop_settings.radius_magnet and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
local collected = false
if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then if object:get_luaentity()._magnet_timer >= 0 and object:get_luaentity()._magnet_timer < item_drop_settings.magnet_time and inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
-- Collection -- Collection
@ -107,24 +101,23 @@ minetest.register_globalstep(function(dtime)
}, true) }, true)
check_pickup_achievements(object, player) check_pickup_achievements(object, player)
object:move_to(checkpos, false)
-- Destroy entity -- Destroy entity
-- This just prevents this section to be run again because object:remove() doesn't remove the item immediately. -- This just prevents this section to be run again because object:remove() doesn't remove the item immediately.
object:get_luaentity().target = checkpos
object:get_luaentity()._removed = true object:get_luaentity()._removed = true
collected = true object:set_velocity({x=0,y=0,z=0})
end object:set_acceleration({x=0,y=0,z=0})
end
end
if not collected then object:move_to(checkpos)
if object:get_luaentity()._magnet_timer > 1 then
object:get_luaentity()._magnet_timer = -item_drop_settings.magnet_time minetest.after(0.25, function()
object:get_luaentity()._magnet_active = false --safety check
elseif object:get_luaentity()._magnet_timer < 0 then if object and object:get_luaentity() then
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime object:remove()
end
end)
end
end end
end end
@ -138,7 +131,6 @@ minetest.register_globalstep(function(dtime)
end end
end end
end
end) end)
-- Stupid workaround to get drops from a drop table: -- Stupid workaround to get drops from a drop table:
@ -291,6 +283,10 @@ function minetest.handle_node_drops(pos, drops, digger)
z = -z z = -z
end end
obj:set_velocity({x=1/x, y=obj:get_velocity().y, z=1/z}) obj:set_velocity({x=1/x, y=obj:get_velocity().y, z=1/z})
obj:get_luaentity().age = item_drop_settings.dug_buffer
obj:get_luaentity()._insta_collect = false
end end
end end
end end
@ -525,12 +521,11 @@ minetest.register_entity(":__builtin:item", {
on_step = function(self, dtime) on_step = function(self, dtime)
if self._removed then if self._removed then
self.object:set_acceleration({x=0,y=0,z=0}) self.object:set_properties({
physical = false
})
self.object:set_velocity({x=0,y=0,z=0}) self.object:set_velocity({x=0,y=0,z=0})
self.collection_age = self.collection_age + dtime self.object:set_acceleration({x=0,y=0,z=0})
if self.collection_age > 0.15 then
self.object:remove()
end
return return
end end
self.age = self.age + dtime self.age = self.age + dtime