Merge pull request 'Fixing multiple crashes on the German server.' (#3587) from crashes_on_german_server into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3587
This commit is contained in:
ancientmarinerdev 2023-03-25 02:04:40 +00:00
commit 46eb4d11dc
6 changed files with 24 additions and 5 deletions

View file

@ -300,6 +300,10 @@ end
-- loading order. -- loading order.
function mcl_autogroup.get_wear(toolname, diggroup) function mcl_autogroup.get_wear(toolname, diggroup)
local tdef = minetest.registered_tools[toolname] local tdef = minetest.registered_tools[toolname]
if not tdef then
minetest.log("warning", "Adding wear for tool: " .. tostring(toolname) .. " failed with diggroup: " .. tostring(diggroup))
return nil
end
local uses = tdef._mcl_diggroups[diggroup].uses local uses = tdef._mcl_diggroups[diggroup].uses
return math.ceil(65535 / uses) return math.ceil(65535 / uses)
end end

View file

@ -62,8 +62,11 @@ function mob_class:update_tag() --update nametag and/or the debug box
end end
function mob_class:jock_to(mob, reletive_pos, rot) function mob_class:jock_to(mob, reletive_pos, rot)
local pos = self.object:get_pos()
if not pos then return end
self.jockey = mob self.jockey = mob
local jock = minetest.add_entity(self.object:get_pos(), mob) local jock = minetest.add_entity(pos, mob)
if not jock then return end if not jock then return end
jock:get_luaentity().docile_by_day = false jock:get_luaentity().docile_by_day = false
jock:get_luaentity().riden_by_jock = true jock:get_luaentity().riden_by_jock = true

View file

@ -91,7 +91,7 @@ local skeleton = {
}, },
on_spawn = function(self) on_spawn = function(self)
if math.random(100) == 1 then if math.random(100) == 1 then
self:jock_to("mobs_mc:spider", vector.new(0,0,0), vector.new(0,0,0)) self:jock_to("mobs_mc:spider", vector.zero(), vector.zero())
end end
return true return true
end, end,

View file

@ -99,6 +99,7 @@ local dropperdef = {
mesecons = {effector = { mesecons = {effector = {
-- Drop random item when triggered -- Drop random item when triggered
action_on = function(pos, node) action_on = function(pos, node)
if not pos then return end
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local droppos local droppos

View file

@ -278,6 +278,10 @@ end
local old_add_item = minetest.add_item local old_add_item = minetest.add_item
function minetest.add_item(pos, stack) function minetest.add_item(pos, stack)
if not pos then
minetest.log("warning", "Trying to add item with missing pos: " .. tostring(stack))
return
end
stack = ItemStack(stack) stack = ItemStack(stack)
if get_item_group(stack:get_name(), "filled_map") > 0 then if get_item_group(stack:get_name(), "filled_map") > 0 then
stack:set_name("mcl_maps:filled_map") stack:set_name("mcl_maps:filled_map")

View file

@ -183,7 +183,9 @@ local make_grass_path = function(itemstack, placer, pointed_thing)
-- Add wear (as if digging a shovely node) -- Add wear (as if digging a shovely node)
local toolname = itemstack:get_name() local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "shovely") local wear = mcl_autogroup.get_wear(toolname, "shovely")
itemstack:add_wear(wear) if wear then
itemstack:add_wear(wear)
end
end end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true) minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true)
minetest.swap_node(pointed_thing.under, {name="mcl_core:grass_path"}) minetest.swap_node(pointed_thing.under, {name="mcl_core:grass_path"})
@ -212,7 +214,10 @@ if minetest.get_modpath("mcl_farming") then
-- Add wear (as if digging a shearsy node) -- Add wear (as if digging a shearsy node)
local toolname = itemstack:get_name() local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "shearsy") local wear = mcl_autogroup.get_wear(toolname, "shearsy")
itemstack:add_wear(wear) if wear then
itemstack:add_wear(wear)
end
end end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true)
local dir = vector.subtract(pointed_thing.under, pointed_thing.above) local dir = vector.subtract(pointed_thing.under, pointed_thing.above)
@ -379,7 +384,9 @@ local function make_stripped_trunk(itemstack, placer, pointed_thing)
-- Add wear (as if digging a axey node) -- Add wear (as if digging a axey node)
local toolname = itemstack:get_name() local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "axey") local wear = mcl_autogroup.get_wear(toolname, "axey")
itemstack:add_wear(wear) if wear then
itemstack:add_wear(wear)
end
end end
end end
return itemstack return itemstack