Merge branch 'master' into objects

This commit is contained in:
Lizzy Fleckenstein 2021-03-17 11:09:18 +01:00
commit 99357d467c
39 changed files with 185 additions and 89 deletions

View File

@ -34,7 +34,7 @@ function mcl_burning.is_burning(obj)
end end
function mcl_burning.is_affected_by_rain(obj) function mcl_burning.is_affected_by_rain(obj)
return mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos()) return mcl_weather and mcl_weather.get_weather() == "rain" and mcl_weather.is_outdoor(obj:get_pos())
end end
function mcl_burning.get_collisionbox(obj, smaller) function mcl_burning.get_collisionbox(obj, smaller)
@ -267,7 +267,7 @@ function mcl_burning.fire_entity_step(self, dtime)
if not parent or not mcl_burning.is_burning(parent) then if not parent or not mcl_burning.is_burning(parent) then
do_remove = true do_remove = true
else else
for _, other in ipairs(minetest.get_objects_inside_radius(obj:get_pos(), 0)) do for _, other in pairs(minetest.get_objects_inside_radius(obj:get_pos(), 0)) do
local luaentity = obj:get_luaentity() local luaentity = obj:get_luaentity()
if luaentity and luaentity.name == "mcl_burning:fire" and not luaentity.doing_step and not luaentity.removed then if luaentity and luaentity.name == "mcl_burning:fire" and not luaentity.doing_step and not luaentity.removed then
do_remove = true do_remove = true

View File

@ -22,7 +22,7 @@ minetest.register_entity("mcl_burning:fire", {
}) })
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
mcl_burning.tick(player, dtime) mcl_burning.tick(player, dtime)
end end
end) end)

View File

@ -1,4 +1,10 @@
-- register extra flavours of a base nodedef -- register extra flavours of a base nodedef
local get_connected_players = minetest.get_connected_players
local get_node = minetest.get_node
local vector_add = vector.add
local ceil = math.ceil
walkover = {} walkover = {}
walkover.registered_globals = {} walkover.registered_globals = {}
@ -6,25 +12,38 @@ function walkover.register_global(func)
table.insert(walkover.registered_globals, func) table.insert(walkover.registered_globals, func)
end end
local on_walk = {}
local registered_globals = {}
minetest.register_on_mods_loaded(function()
for name,def in pairs(minetest.registered_nodes) do
if def.on_walk_over then
on_walk[name] = def.on_walk_over
end
end
for _,func in ipairs(walkover.registered_globals) do --cache registered globals
table.insert(registered_globals, func)
end
end)
local timer = 0 local timer = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
timer = timer + dtime; timer = timer + dtime;
if timer >= 0.3 then if timer >= 0.3 then
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(get_connected_players()) do
local pp = player:get_pos() local pp = player:get_pos()
pp.y = math.ceil(pp.y) pp.y = ceil(pp.y)
local loc = vector.add(pp, {x=0,y=-1,z=0}) local loc = vector_add(pp, {x=0,y=-1,z=0})
if loc ~= nil then if loc ~= nil then
local nodeiamon = minetest.get_node(loc) local nodeiamon = get_node(loc)
if nodeiamon ~= nil then if nodeiamon ~= nil then
local def = minetest.registered_nodes[nodeiamon.name] if on_walk[nodeiamon.name] then
if def ~= nil and def.on_walk_over ~= nil then on_walk[nodeiamon.name](loc, nodeiamon, player)
def.on_walk_over(loc, nodeiamon, player)
end end
for _, func in ipairs(walkover.registered_globals) do for i = 1, #registered_globals do
func(loc, nodeiamon, player) registered_globals[i](loc, nodeiamon, player)
end end
end end
end end

View File

@ -223,7 +223,7 @@ function boat.on_step(self, dtime, moveresult)
self._regen_timer = regen_timer self._regen_timer = regen_timer
if moveresult and moveresult.collides then if moveresult and moveresult.collides then
for _, collision in ipairs(moveresult.collisions) do for _, collision in pairs(moveresult.collisions) do
local pos = collision.node_pos local pos = collision.node_pos
if collision.type == "node" and minetest.get_item_group(minetest.get_node(pos).name, "dig_by_boat") > 0 then if collision.type == "node" and minetest.get_item_group(minetest.get_node(pos).name, "dig_by_boat") > 0 then
minetest.dig_node(pos) minetest.dig_node(pos)
@ -305,7 +305,7 @@ function boat.on_step(self, dtime, moveresult)
self._animation = 0 self._animation = 0
end end
for _, obj in ipairs(minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)) do for _, obj in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 1.3)) do
local entity = obj:get_luaentity() local entity = obj:get_luaentity()
if entity and entity._cmi_is_mob then if entity and entity._cmi_is_mob then
attach_object(self, obj) attach_object(self, obj)

View File

@ -54,14 +54,14 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement
end end
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _,player in ipairs(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()
local inv = player:get_inventory() local inv = player:get_inventory()
local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z} local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z}
--magnet and collection --magnet and collection
for _,object in ipairs(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 object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
local collected = false local collected = false
@ -785,7 +785,7 @@ minetest.register_entity(":__builtin:item", {
if self.physical_state then if self.physical_state then
local own_stack = ItemStack(self.object:get_luaentity().itemstring) local own_stack = ItemStack(self.object:get_luaentity().itemstring)
-- Merge with close entities of the same item -- Merge with close entities of the same item
for _, object in ipairs(minetest.get_objects_inside_radius(p, 0.8)) do for _, object in pairs(minetest.get_objects_inside_radius(p, 0.8)) do
local obj = object:get_luaentity() local obj = object:get_luaentity()
if obj and obj.name == "__builtin:item" if obj and obj.name == "__builtin:item"
and obj.physical_state == false then and obj.physical_state == false then

View File

@ -226,7 +226,7 @@ local collision = function(self)
local z = 0 local z = 0
local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5 local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5
for _,object in ipairs(minetest.get_objects_inside_radius(pos, width)) do for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
if object:is_player() if object:is_player()
or (object:get_luaentity()._cmi_is_mob == true and object ~= self.object) then or (object:get_luaentity()._cmi_is_mob == true and object ~= self.object) then
@ -1047,8 +1047,13 @@ local do_env_damage = function(self)
end end
end end
-- Use get_node_light for Minetest version 5.3 where get_natural_light
-- does not exist yet.
local get_light = minetest.get_natural_light or minetest.get_node_light
local sunlight = get_light(pos, self.time_of_day)
-- bright light harms mob -- bright light harms mob
if self.light_damage ~= 0 and (minetest.get_node_light(pos) or 0) > 12 then if self.light_damage ~= 0 and (sunlight or 0) > 12 then
if deal_light_damage(self, pos, self.light_damage) then if deal_light_damage(self, pos, self.light_damage) then
return true return true
end end
@ -1057,7 +1062,7 @@ local do_env_damage = function(self)
if mod_worlds then if mod_worlds then
_, dim = mcl_worlds.y_to_layer(pos.y) _, dim = mcl_worlds.y_to_layer(pos.y)
end end
if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (minetest.get_node_light(pos) or 0) >= minetest.LIGHT_MAX and dim == "overworld" then if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then
if self.ignited_by_sunlight then if self.ignited_by_sunlight then
mcl_burning.set_on_fire(self.object, 10) mcl_burning.set_on_fire(self.object, 10)
else else
@ -4576,9 +4581,9 @@ local timer = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
timer = timer + dtime timer = timer + dtime
if timer < 1 then return end if timer < 1 then return end
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local pos = player:get_pos() local pos = player:get_pos()
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 47)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 47)) do
local lua = obj:get_luaentity() local lua = obj:get_luaentity()
if lua and lua._cmi_is_mob then if lua and lua._cmi_is_mob then
lua.lifetimer = math.max(20, lua.lifetimer) lua.lifetimer = math.max(20, lua.lifetimer)

View File

@ -122,7 +122,7 @@ local arrows = {
} }
local throwing_shoot_arrow = function(itemstack, player) local throwing_shoot_arrow = function(itemstack, player)
for _,arrow in ipairs(arrows) do for _,arrow in pairs(arrows) do
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
if not minetest.is_creative_enabled(player:get_player_name()) then if not minetest.is_creative_enabled(player:get_player_name()) then
player:get_inventory():remove_item("main", arrow[1]) player:get_inventory():remove_item("main", arrow[1])

View File

@ -27,7 +27,7 @@ minetest.register_globalstep(function(dtime)
if timer < 0.7 then return end if timer < 0.7 then return end
timer = 0 timer = 0
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
if not mcl_worlds.has_dust(player:get_pos()) then if not mcl_worlds.has_dust(player:get_pos()) then
return false return false
end end

View File

@ -1,6 +1,8 @@
local PARTICLES_COUNT_RAIN = 30 local PARTICLES_COUNT_RAIN = 30
local PARTICLES_COUNT_THUNDER = 45 local PARTICLES_COUNT_THUNDER = 45
local get_connected_players = minetest.get_connected_players
mcl_weather.rain = { mcl_weather.rain = {
-- max rain particles created at time -- max rain particles created at time
particles_count = PARTICLES_COUNT_RAIN, particles_count = PARTICLES_COUNT_RAIN,
@ -36,7 +38,7 @@ mcl_weather.rain.set_sky_box = function()
{r=85, g=86, b=98}, {r=85, g=86, b=98},
{r=0, g=0, b=0}}) {r=0, g=0, b=0}})
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
player:set_clouds({color="#5D5D5FE8"}) player:set_clouds({color="#5D5D5FE8"})
end end
end end
@ -154,7 +156,7 @@ mcl_weather.rain.clear = function()
mcl_weather.rain.init_done = false mcl_weather.rain.init_done = false
mcl_weather.rain.set_particles_mode("rain") mcl_weather.rain.set_particles_mode("rain")
mcl_weather.skycolor.remove_layer("weather-pack-rain-sky") mcl_weather.skycolor.remove_layer("weather-pack-rain-sky")
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
mcl_weather.rain.remove_sound(player) mcl_weather.rain.remove_sound(player)
mcl_weather.rain.remove_player(player) mcl_weather.rain.remove_player(player)
end end
@ -176,7 +178,7 @@ mcl_weather.rain.make_weather = function()
mcl_weather.rain.init_done = true mcl_weather.rain.init_done = true
end end
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then
mcl_weather.rain.remove_sound(player) mcl_weather.rain.remove_sound(player)
return false return false

View File

@ -43,7 +43,7 @@ mcl_weather.skycolor = {
-- Remove layer from colors table -- Remove layer from colors table
remove_layer = function(layer_name) remove_layer = function(layer_name)
for k, name in ipairs(mcl_weather.skycolor.layer_names) do for k, name in pairs(mcl_weather.skycolor.layer_names) do
if name == layer_name then if name == layer_name then
table.remove(mcl_weather.skycolor.layer_names, k) table.remove(mcl_weather.skycolor.layer_names, k)
mcl_weather.skycolor.force_update = true mcl_weather.skycolor.force_update = true

View File

@ -1,3 +1,5 @@
local get_connected_players = minetest.get_connected_players
mcl_weather.snow = {} mcl_weather.snow = {}
mcl_weather.snow.particles_count = 15 mcl_weather.snow.particles_count = 15
@ -37,7 +39,7 @@ mcl_weather.snow.set_sky_box = function()
{r=85, g=86, b=86}, {r=85, g=86, b=86},
{r=0, g=0, b=0}}) {r=0, g=0, b=0}})
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
player:set_clouds({color="#ADADADE8"}) player:set_clouds({color="#ADADADE8"})
end end
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
@ -71,7 +73,7 @@ minetest.register_globalstep(function(dtime)
mcl_weather.snow.init_done = true mcl_weather.snow.init_done = true
end end
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then if (mcl_weather.is_underwater(player) or not mcl_worlds.has_weather(player:get_pos())) then
return false return false
end end

View File

@ -1,3 +1,5 @@
local get_connected_players = minetest.get_connected_players
-- turn off lightning mod 'auto mode' -- turn off lightning mod 'auto mode'
lightning.auto = false lightning.auto = false
@ -25,7 +27,7 @@ minetest.register_globalstep(function(dtime)
{r=40, g=40, b=40}, {r=40, g=40, b=40},
{r=0, g=0, b=0}}) {r=0, g=0, b=0}})
mcl_weather.skycolor.active = true mcl_weather.skycolor.active = true
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(get_connected_players()) do
player:set_clouds({color="#3D3D3FE8"}) player:set_clouds({color="#3D3D3FE8"})
end end
mcl_weather.thunder.init_done = true mcl_weather.thunder.init_done = true

View File

@ -118,7 +118,7 @@ minetest.register_globalstep(function(dtime)
if main_timer > mcl_hbarmor.tick or timer > 4 then if main_timer > mcl_hbarmor.tick or timer > 4 then
if minetest.settings:get_bool("enable_damage") then if minetest.settings:get_bool("enable_damage") then
if main_timer > mcl_hbarmor.tick then main_timer = 0 end if main_timer > mcl_hbarmor.tick then main_timer = 0 end
for _,player in ipairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
if mcl_hbarmor.player_active[name] == true then if mcl_hbarmor.player_active[name] == true then
local ret = mcl_hbarmor.get_armor(player) local ret = mcl_hbarmor.get_armor(player)

View File

@ -22,7 +22,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
local toremove = nil local toremove = nil
-- Otherwise, add the action to the queue -- Otherwise, add the action to the queue
if overwritecheck then -- check if old action has to be overwritten / removed: if overwritecheck then -- check if old action has to be overwritten / removed:
for i, ac in ipairs(mesecon.queue.actions) do for i, ac in pairs(mesecon.queue.actions) do
if(vector.equals(pos, ac.pos) if(vector.equals(pos, ac.pos)
and mesecon.cmpAny(overwritecheck, ac.owcheck)) then and mesecon.cmpAny(overwritecheck, ac.owcheck)) then
toremove = i toremove = i

View File

@ -75,10 +75,10 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
rules = rules or mesecon.rules.default rules = rules or mesecon.rules.default
-- Call turnon on all linking positions -- Call turnon on all linking positions
for _, rule in ipairs(mesecon.flattenrules(rules)) do for _, rule in pairs(mesecon.flattenrules(rules)) do
local np = vector.add(pos, rule) local np = vector.add(pos, rule)
local rulenames = mesecon.rules_link_rule_all(pos, rule) local rulenames = mesecon.rules_link_rule_all(pos, rule)
for _, rulename in ipairs(rulenames) do for _, rulename in pairs(rulenames) do
mesecon.turnon(np, rulename) mesecon.turnon(np, rulename)
end end
end end

View File

@ -149,8 +149,8 @@ armor.set_player_armor = function(self, player)
if level then if level then
local texture = def.texture or item:gsub("%:", "_") local texture = def.texture or item:gsub("%:", "_")
local enchanted_addition = (mcl_enchanting.is_enchanted(item) and mcl_enchanting.overlay or "") local enchanted_addition = (mcl_enchanting.is_enchanted(item) and mcl_enchanting.overlay or "")
table.insert(textures, "("..texture..".png"..enchanted_addition..")") table.insert(textures, texture..".png"..enchanted_addition)
preview = "(player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..")"..(preview and "^"..preview or "") preview = "player.png^[opacity:0^"..texture.."_preview.png"..enchanted_addition..""..(preview and "^"..preview or "")
armor_level = armor_level + level armor_level = armor_level + level
items = items + 1 items = items + 1
mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0) mcl_armor_points = mcl_armor_points + (def.groups["mcl_armor_points"] or 0)

View File

@ -36,7 +36,7 @@ local function check_in_beds(players)
players = minetest.get_connected_players() players = minetest.get_connected_players()
end end
for n, player in ipairs(players) do for n, player in pairs(players) do
local name = player:get_player_name() local name = player:get_player_name()
if not in_bed[name] then if not in_bed[name] then
return false return false
@ -102,8 +102,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
-- No sleeping if monsters nearby. -- No sleeping if monsters nearby.
-- The exceptions above apply. -- The exceptions above apply.
-- Zombie pigmen only prevent sleep while they are hostle. -- Zombie pigmen only prevent sleep while they are hostle.
local objs = minetest.get_objects_inside_radius(bed_pos, 8) for _, obj in pairs(minetest.get_objects_inside_radius(bed_pos, 8)) do
for _, obj in ipairs(objs) do
if obj ~= nil and not obj:is_player() then if obj ~= nil and not obj:is_player() then
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
local mobname = ent.name local mobname = ent.name

View File

@ -15,6 +15,26 @@ local dir_to_pitch = function(dir)
return -math.atan2(-dir.y, xz) return -math.atan2(-dir.y, xz)
end end
local random_arrow_positions = function(positions, placement)
local min = 0
local max = 0
if positions == 'x' then
min = -4
max = 4
elseif positions == 'y' then
min = 0
max = 10
end
if placement == 'front' and positions == 'z' then
min = 3
max = 3
elseif placement == 'back' and positions == 'z' then
min = -3
max = -3
end
return math.random(max, min)
end
local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
local mod_button = minetest.get_modpath("mesecons_button") local mod_button = minetest.get_modpath("mesecons_button")
@ -101,6 +121,14 @@ ARROW_ENTITY.on_step = function(self, dtime)
dpos = vector.round(dpos) dpos = vector.round(dpos)
local node = minetest.get_node(dpos) local node = minetest.get_node(dpos)
if self.object:get_attach() ~= nil and self.object:get_attach(parent):get_hp() < 1 then
self.object:remove()
end
if self.object:get_attach() and not self.object:get_attach(parent) then
self.object:remove()
end
if self._stuck then if self._stuck then
self._stucktimer = self._stucktimer + dtime self._stucktimer = self._stucktimer + dtime
self._stuckrechecktimer = self._stuckrechecktimer + dtime self._stuckrechecktimer = self._stuckrechecktimer + dtime
@ -146,7 +174,7 @@ ARROW_ENTITY.on_step = function(self, dtime)
-- Check for object "collision". Done every tick (hopefully this is not too stressing) -- Check for object "collision". Done every tick (hopefully this is not too stressing)
else else
if self._damage >= 9 then if self._damage >= 9 and self._in_player == false then
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = 1, amount = 1,
time = .001, time = .001,
@ -230,19 +258,60 @@ ARROW_ENTITY.on_step = function(self, dtime)
if obj:is_player() and rawget(_G, "armor") and armor.last_damage_types then if obj:is_player() and rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[obj:get_player_name()] = "projectile" armor.last_damage_types[obj:get_player_name()] = "projectile"
end end
damage_particles(self.object:get_pos(), self._is_critical) if self._in_player == false then
damage_particles(self.object:get_pos(), self._is_critical)
end
if mcl_burning.is_burning(self.object) then if mcl_burning.is_burning(self.object) then
mcl_burning.set_on_fire(obj, 5) mcl_burning.set_on_fire(obj, 5)
end end
obj:punch(self.object, 1.0, { if self._in_player == false then
full_punch_interval=1.0, obj:punch(self.object, 1.0, {
damage_groups={fleshy=self._damage}, full_punch_interval=1.0,
}, self.object:get_velocity()) damage_groups={fleshy=self._damage},
}, self.object:get_velocity())
if obj:is_player() then
local placement = ''
self._placement = math.random(1, 2)
if self._placement == 1 then
placement = 'front'
else
placement = 'back'
end
self._in_player = true
if self._placement == 2 then
self._rotation_station = 90
else
self._rotation_station = -90
end
self._y_position = random_arrow_positions('y', placement)
self._x_position = random_arrow_positions('x', placement)
if self._y_position > 6 and self._x_position < 2 and self._x_position > -2 then
self._attach_parent = 'Head'
self._y_position = self._y_position - 6
elseif self._x_position > 2 then
self._attach_parent = 'Arm_Right'
self._y_position = self._y_position - 3
self._x_position = self._x_position - 2
elseif self._x_position < -2 then
self._attach_parent = 'Arm_Left'
self._y_position = self._y_position - 3
self._x_position = self._x_position + 2
else
self._attach_parent = 'Body'
end
self._z_rotation = math.random(30, -30)
self._y_rotation = math.random(30, -30)
self.object:set_attach(obj, self._attach_parent, {x=self._x_position,y=self._y_position,z=random_arrow_positions('z', placement)}, {x=0,y=self._rotation_station + self._y_rotation,z=self._z_rotation})
minetest.after(150, function()
self.object:remove()
end)
end
end
end end
if is_player then if is_player then
if self._shooter and self._shooter:is_player() then if self._shooter and self._shooter:is_player() and self._in_player == false then
-- “Ding” sound for hitting another player -- “Ding” sound for hitting another player
minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter:get_player_name()}, true) minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter:get_player_name()}, true)
end end
@ -259,10 +328,14 @@ ARROW_ENTITY.on_step = function(self, dtime)
end end
end end
end end
minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true) if self._in_player == false then
minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true)
end
end end
mcl_burning.extinguish(self.object) mcl_burning.extinguish(self.object)
self.object:remove() if not obj:is_player() then
self.object:remove()
end
return return
end end
end end
@ -389,6 +462,7 @@ ARROW_ENTITY.get_staticdata = function(self)
end end
ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s) ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s)
self._in_player = false
local data = minetest.deserialize(staticdata) local data = minetest.deserialize(staticdata)
if data then if data then
self._stuck = data.stuck self._stuck = data.stuck

View File

@ -341,7 +341,7 @@ controls.register_on_hold(function(player, key, time)
end) end)
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local wielditem = player:get_wielded_item() local wielditem = player:get_wielded_item()
local wieldindex = player:get_wield_index() local wieldindex = player:get_wield_index()

View File

@ -65,7 +65,7 @@ function mcl_buckets.register_liquid(def)
_doc_items_usagehelp = def.usagehelp, _doc_items_usagehelp = def.usagehelp,
_tt_help = def.tt_help, _tt_help = def.tt_help,
inventory_image = def.inventory_image, inventory_image = def.inventory_image,
stack_max = 16, stack_max = 1,
groups = def.groups, groups = def.groups,
on_place = function(itemstack, user, pointed_thing) on_place = function(itemstack, user, pointed_thing)
-- Must be pointing to node -- Must be pointing to node

View File

@ -131,7 +131,7 @@ minetest.register_abm({
interval = 0.5, interval = 0.5,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 0.4)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.4)) do
if mcl_burning.is_burning(obj) then if mcl_burning.is_burning(obj) then
mcl_burning.extinguish(obj) mcl_burning.extinguish(obj)
local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1 local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1

View File

@ -11,10 +11,8 @@ local entity_animations = {
}, },
chest = { chest = {
speed = 25, speed = 25,
open = {x = 0, y = 10}, open = {x = 0, y = 7},
open_partly = {x = 0, y = 7}, close = {x = 13, y = 20},
close = {x = 10, y = 20},
close_partly = {x = 13, y = 20},
} }
} }
@ -34,15 +32,14 @@ minetest.register_entity("mcl_chests:chest", {
self.object:set_animation(anim, anim_table.speed, 0, false) self.object:set_animation(anim, anim_table.speed, 0, false)
end, end,
open = function(self, playername, partly) open = function(self, playername)
self.players[playername] = true self.players[playername] = true
if not self.is_open then if not self.is_open then
self:set_animation(partly and "open_partly" or "open") self:set_animation("open")
minetest.sound_play(self.sound_prefix .. "_open", { minetest.sound_play(self.sound_prefix .. "_open", {
pos = self.node_pos, pos = self.node_pos,
}) })
self.is_open = true self.is_open = true
self.opened_partly = partly
end end
end, end,
@ -53,12 +50,11 @@ minetest.register_entity("mcl_chests:chest", {
for _ in pairs(playerlist) do for _ in pairs(playerlist) do
return return
end end
self:set_animation(self.opened_partly and "close_partly" or "close") self:set_animation("close")
minetest.sound_play(self.sound_prefix .. "_close", { minetest.sound_play(self.sound_prefix .. "_close", {
pos = self.node_pos, pos = self.node_pos,
}) })
self.is_open = false self.is_open = false
self.opened_partly = false
end end
end, end,
@ -118,7 +114,7 @@ local function get_entity_pos(pos, dir, double)
end end
local function find_entity(pos) local function find_entity(pos)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 0)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0)) do
local luaentity = obj:get_luaentity() local luaentity = obj:get_luaentity()
if luaentity and luaentity.name == "mcl_chests:chest" then if luaentity and luaentity.name == "mcl_chests:chest" then
return luaentity return luaentity
@ -179,8 +175,7 @@ local player_chest_open = function(player, pos, node_name, textures, param2, dou
open_chests[name] = {pos = pos, node_name = node_name, textures = textures, param2 = param2, double = double, sound = sound, mesh = mesh, shulker = shulker} open_chests[name] = {pos = pos, node_name = node_name, textures = textures, param2 = param2, double = double, sound = sound, mesh = mesh, shulker = shulker}
if animate_chests then if animate_chests then
local dir = minetest.facedir_to_dir(param2) local dir = minetest.facedir_to_dir(param2)
local blocked = not shulker and (back_is_blocked(pos, dir) or double and back_is_blocked(mcl_util.get_double_container_neighbor_pos(pos, param2, node_name:sub(-4)), dir)) find_or_create_entity(pos, node_name, textures, param2, double, sound, mesh, shulker and "shulker" or "chest", dir):open(name)
find_or_create_entity(pos, node_name, textures, param2, double, sound, mesh, shulker and "shulker" or "chest", dir):open(name, blocked)
end end
end end

View File

@ -94,9 +94,8 @@ minetest.register_globalstep(function(dtime)
watch.old_time = now watch.old_time = now
local players = minetest.get_connected_players() for p, player in pairs(minetest.get_connected_players()) do
for p, player in ipairs(players) do for s, stack in pairs(player:get_inventory():get_list("main")) do
for s, stack in ipairs(player:get_inventory():get_list("main")) do
local dim = mcl_worlds.pos_to_dimension(player:get_pos()) local dim = mcl_worlds.pos_to_dimension(player:get_pos())
local frame local frame
-- Clocks do not work in certain zones -- Clocks do not work in certain zones

View File

@ -14,15 +14,14 @@ local random_frame = math.random(0, compass_frames-1)
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
random_timer = random_timer + dtime random_timer = random_timer + dtime
local players = minetest.get_connected_players()
if random_timer >= random_timer_trigger then if random_timer >= random_timer_trigger then
random_frame = (random_frame + math.random(-1, 1)) % compass_frames random_frame = (random_frame + math.random(-1, 1)) % compass_frames
random_timer = 0 random_timer = 0
end end
for i,player in ipairs(players) do for i,player in pairs(minetest.get_connected_players()) do
local function has_compass(player) local function has_compass(player)
for _,stack in ipairs(player:get_inventory():get_list("main")) do for _,stack in pairs(player:get_inventory():get_list("main")) do
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then
return true return true
end end
@ -53,7 +52,7 @@ minetest.register_globalstep(function(dtime)
compass_image = math.floor((angle_relative/11.25) + 0.5) % compass_frames compass_image = math.floor((angle_relative/11.25) + 0.5) % compass_frames
end end
for j,stack in ipairs(player:get_inventory():get_list("main")) do for j,stack in pairs(player:get_inventory():get_list("main")) do
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and if minetest.get_item_group(stack:get_name(), "compass") ~= 0 and
minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then minetest.get_item_group(stack:get_name(), "compass")-1 ~= compass_image then
local itemname = "mcl_compass:"..compass_image local itemname = "mcl_compass:"..compass_image

View File

@ -1378,7 +1378,7 @@ minetest.register_abm({
if not do_preserve then if not do_preserve then
-- Drop stuff other than the node itself -- Drop stuff other than the node itself
local itemstacks = minetest.get_node_drops(n0.name) local itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do for _, itemname in pairs(itemstacks) do
local p_drop = { local p_drop = {
x = p0.x - 0.5 + math.random(), x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(), y = p0.y - 0.5 + math.random(),

View File

@ -4,7 +4,7 @@ local S = minetest.get_translator("mcl_doors")
local function on_place_node(place_to, newnode, local function on_place_node(place_to, newnode,
placer, oldnode, itemstack, pointed_thing) placer, oldnode, itemstack, pointed_thing)
-- Run script hook -- Run script hook
for _, callback in ipairs(minetest.registered_on_placenodes) do for _, callback in pairs(minetest.registered_on_placenodes) do
-- Deep-copy pos, node and pointed_thing because callback can modify them -- Deep-copy pos, node and pointed_thing because callback can modify them
local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z} local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z}
local newnode_copy = local newnode_copy =

View File

@ -191,7 +191,7 @@ minetest.register_entity("mcl_enchanting:book", {
local old_player_near = self._player_near local old_player_near = self._player_near
local player_near = false local player_near = false
local player local player
for _, obj in ipairs(minetest.get_objects_inside_radius(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset), 2.5)) do for _, obj in pairs(minetest.get_objects_inside_radius(vector.subtract(self.object:get_pos(), mcl_enchanting.book_offset), 2.5)) do
if obj:is_player() then if obj:is_player() then
player_near = true player_near = true
player = obj player = obj
@ -308,7 +308,7 @@ minetest.register_abm({
nodenames = "mcl_enchanting:table", nodenames = "mcl_enchanting:table",
action = function(pos) action = function(pos)
local playernames = {} local playernames = {}
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 15)) do
if obj:is_player() then if obj:is_player() then
table.insert(playernames, obj:get_player_name()) table.insert(playernames, obj:get_player_name())
end end

View File

@ -419,7 +419,7 @@ mcl_end.grow_chorus_plant_step = function(pos, node)
end end
end end
for _, f in ipairs(new_flowers) do for _, f in pairs(new_flowers) do
if age >= MAX_FLOWER_AGE then if age >= MAX_FLOWER_AGE then
local nn = minetest.get_node(f).name local nn = minetest.get_node(f).name
if nn ~= "mcl_end:chorus_flower" and nn ~= "mcl_end:chorus_flower_dead" then if nn ~= "mcl_end:chorus_flower" and nn ~= "mcl_end:chorus_flower_dead" then

View File

@ -349,7 +349,7 @@ minetest.register_abm({
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do for _,object in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
-- Item must get sucked in when the item just TOUCHES the block above the hopper -- Item must get sucked in when the item just TOUCHES the block above the hopper

View File

@ -17,7 +17,7 @@ local function get_mob_textures(mob)
end end
local function find_doll(pos) local function find_doll(pos)
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do for _,obj in pairs(minetest.get_objects_inside_radius(pos, 0.5)) do
if not obj:is_player() then if not obj:is_player() then
if obj ~= nil and obj:get_luaentity().name == "mcl_mobspawners:doll" then if obj ~= nil and obj:get_luaentity().name == "mcl_mobspawners:doll" then
return obj return obj

View File

@ -224,7 +224,7 @@ function mcl_portals.end_teleport(obj, pos)
end end
function mcl_portals.end_portal_teleport(pos, node) function mcl_portals.end_portal_teleport(pos, node)
for _,obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do for _,obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do
local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel
if obj:is_player() or lua_entity then if obj:is_player() or lua_entity then
local objpos = obj:get_pos() local objpos = obj:get_pos()

View File

@ -798,7 +798,7 @@ minetest.register_abm({
end end
end end
distance = vector.subtract(pos, distance) distance = vector.subtract(pos, distance)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 15)) do
if obj:is_player() then if obj:is_player() then
minetest.add_particlespawner({ minetest.add_particlespawner({
amount = node_particles_allowed_level + 1, amount = node_particles_allowed_level + 1,
@ -818,7 +818,7 @@ minetest.register_abm({
}) })
end end
end end
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do --maikerumine added for objects to travel for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do --maikerumine added for objects to travel
local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel local lua_entity = obj:get_luaentity() --maikerumine added for objects to travel
if (obj:is_player() or lua_entity) and prevent_portal_chatter(obj) then if (obj:is_player() or lua_entity) and prevent_portal_chatter(obj) then
teleport(obj, pos) teleport(obj, pos)

View File

@ -539,7 +539,7 @@ end)
minetest.register_on_shutdown(function() minetest.register_on_shutdown(function()
-- save player effects on server shutdown -- save player effects on server shutdown
for _,player in ipairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
mcl_potions._save_player_effects(player) mcl_potions._save_player_effects(player)
end end

View File

@ -393,7 +393,7 @@ local function RecheckCartHack(params)
local pos = params[1] local pos = params[1]
local cart_id = params[2] local cart_id = params[2]
-- Find cart -- Find cart
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 1)) do for _, obj in pairs(minetest.get_objects_inside_radius(pos, 1)) do
if obj ~= nil and obj:get_luaentity().name == cart_id then if obj ~= nil and obj:get_luaentity().name == cart_id then
-- Cart found! We can now safely call the callback func. -- Cart found! We can now safely call the callback func.
-- (calling it earlier has the danger of failing) -- (calling it earlier has the danger of failing)

View File

@ -142,7 +142,7 @@ minetest.register_globalstep(function(dtime)
timer = timer + dtime timer = timer + dtime
if main_timer > mcl_hunger.HUD_TICK or timer > 0.5 then if main_timer > mcl_hunger.HUD_TICK or timer > 0.5 then
if main_timer > mcl_hunger.HUD_TICK then main_timer = 0 end if main_timer > mcl_hunger.HUD_TICK then main_timer = 0 end
for _,player in ipairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local h = tonumber(mcl_hunger.get_hunger(player)) local h = tonumber(mcl_hunger.get_hunger(player))

View File

@ -148,7 +148,7 @@ local player_attached = mcl_player.player_attached
-- Check each player and apply animations -- Check each player and apply animations
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _, player in ipairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do
local name = player:get_player_name() local name = player:get_player_name()
local model_name = player_model[name] local model_name = player_model[name]
local model = model_name and models[model_name] local model = model_name and models[model_name]

View File

@ -52,7 +52,7 @@ minetest.register_globalstep(function(dtime)
time = 0 time = 0
-- check players -- check players
for _,player in ipairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
-- who am I? -- who am I?
local name = player:get_player_name() local name = player:get_player_name()

View File

@ -41,7 +41,7 @@ minetest.register_globalstep(function(dtime)
-- Update jump status immediately since we need this info in real time. -- Update jump status immediately since we need this info in real time.
-- WARNING: This section is HACKY as hell since it is all just based on heuristics. -- WARNING: This section is HACKY as hell since it is all just based on heuristics.
for _,player in ipairs(get_connected_players()) do for _,player in pairs(get_connected_players()) do
local controls = player:get_player_control() local controls = player:get_player_control()
name = player:get_player_name() name = player:get_player_name()
@ -173,7 +173,7 @@ minetest.register_globalstep(function(dtime)
time = 0 time = 0
-- check players -- check players
for _,player in ipairs(get_connected_players()) do for _,player in pairs(get_connected_players()) do
-- who am I? -- who am I?
local name = player:get_player_name() local name = player:get_player_name()

View File

@ -78,7 +78,7 @@ minetest.register_on_joinplayer(function(player)
end) end)
minetest.register_globalstep(function() minetest.register_globalstep(function()
for _,player in ipairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do
wieldview:update_wielded_item(player) wieldview:update_wielded_item(player)
end end
end) end)