1
0
Fork 0

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
effects_rewrite
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.
function mcl_autogroup.get_wear(toolname, diggroup)
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
return math.ceil(65535 / uses)
end

View File

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

View File

@ -91,7 +91,7 @@ local skeleton = {
},
on_spawn = function(self)
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
return true
end,

View File

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

View File

@ -278,6 +278,10 @@ end
local old_add_item = minetest.add_item
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)
if get_item_group(stack:get_name(), "filled_map") > 0 then
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)
local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "shovely")
itemstack:add_wear(wear)
if wear then
itemstack:add_wear(wear)
end
end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true)
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)
local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "shearsy")
itemstack:add_wear(wear)
if wear then
itemstack:add_wear(wear)
end
end
minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true)
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)
local toolname = itemstack:get_name()
local wear = mcl_autogroup.get_wear(toolname, "axey")
itemstack:add_wear(wear)
if wear then
itemstack:add_wear(wear)
end
end
end
return itemstack