From b53329b45217f153d0fad4af1ee58096d233430e Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 16 Mar 2021 08:40:37 +0100 Subject: [PATCH] Several Bugfixes --- mods/CORE/mcl_util/init.lua | 41 ------------------------------- mods/DATA/mcl_loottables/mod.conf | 2 +- mods/DATA/mcl_numbers/init.lua | 4 ++- mods/DATA/mcl_predicates/init.lua | 2 +- mods/DATA/mcl_types/init.lua | 6 ++--- mods/DATA/mcl_types/mod.conf | 1 + 6 files changed, 9 insertions(+), 47 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 7b0686a50..9fa53ab17 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -446,44 +446,3 @@ function mcl_util.rand_bool(probability, pr) return mcl_util.rand(pr, 0, 32767) < probability * 32768 end end - -function mcl_util.switch_type(value, funcs, name) - local t = type(value) - local func = funcs[func] or funcs["default"] - if func then - return func(value, ...) - else - error("invalid " .. (name and name .. " " or "") .. "type: " .. t) - end -end - ---[[ -function mcl_util.assert_type(value, expected_type, allow_nil) - local actual_type = type(value) - local errmsg = value .. " is not a " .. expected_type - - if expected_type == "itemstack" then - return mcl_util.switch_type(value, { - ["nil"] = function() - assert(allow_nil, errmsg) - end, - ["string"] = ItemStack, - ["table"] = ItemStack, - ["userdata"] = function() - assert(value.get_name, errmsg) - return value - end, - }, "ItemStack") - end - - if expected_type == "vector" then - assert(actual_type == "table", errmsg) - assert(value.x, errmsg) - assert(value.y, errmsg) - assert(value.z, errmsg) - else - assert((allow_nil and value == nil) or (actual_type == expected_type), errmsg) - end - return value -end -]]-- diff --git a/mods/DATA/mcl_loottables/mod.conf b/mods/DATA/mcl_loottables/mod.conf index 7c595f865..a0b7b2773 100644 --- a/mods/DATA/mcl_loottables/mod.conf +++ b/mods/DATA/mcl_loottables/mod.conf @@ -1,4 +1,4 @@ -name = mcl_loot +name = mcl_loottables author = Fleckenstein description = Provides Minecraft-like loot table definitions depends = mcl_util, mcl_predicates, mcl_item_modifiers, mcl_groupcache diff --git a/mods/DATA/mcl_numbers/init.lua b/mods/DATA/mcl_numbers/init.lua index d9aeb3bfd..b42932e14 100644 --- a/mods/DATA/mcl_numbers/init.lua +++ b/mods/DATA/mcl_numbers/init.lua @@ -2,6 +2,8 @@ mcl_numbers = { providers = {}, } +dofile(minetest.get_modpath("mcl_numbers") .. "/api.lua") + mcl_numbers.register_provider("mcl_numbers:constant", function(provider) return provider.value end) @@ -20,4 +22,4 @@ mcl_numbers.register_provider("mcl_numbers:binomial", function(provider, data) end return num end) - + diff --git a/mods/DATA/mcl_predicates/init.lua b/mods/DATA/mcl_predicates/init.lua index addd8e8d0..46380761d 100644 --- a/mods/DATA/mcl_predicates/init.lua +++ b/mods/DATA/mcl_predicates/init.lua @@ -48,7 +48,7 @@ mcl_predicates.register_predicate("killed_by_player", function(predicate, data) end) mcl_predicates.register_predicate("location_check", function(predicate, data) - local pos = vector.add(data.pos), vector.new(predicate.offset_x or 0, predicate.offset_y or 0, predicate.offset_z or 0)) + local pos = vector.add(data.pos, vector.new(predicate.offset_x or 0, predicate.offset_y or 0, predicate.offset_z or 0)) return mcl_location(pos, data.nodemeta):match(predicate.predicate) end) diff --git a/mods/DATA/mcl_types/init.lua b/mods/DATA/mcl_types/init.lua index 2eb5441ad..12f4df83a 100644 --- a/mods/DATA/mcl_types/init.lua +++ b/mods/DATA/mcl_types/init.lua @@ -35,7 +35,7 @@ function mcl_types.match_enchantments(actual, expected) return true end -function mcl_util.match_item(actual, expected) +function mcl_types.match_item(actual, expected) actual = actual or ItemStack() if expected.item and actual:get_name() ~= expected.item then @@ -55,7 +55,7 @@ function mcl_util.match_item(actual, expected) end end -function mcl_util.match_node(actual, expected, pos, meta) +function mcl_types.match_node(actual, expected, pos, meta) if expected.node and actual.name ~= expected.node then return false elseif expected.group and minetest.get_item_group(actual.name, expected.group) == 0 then @@ -78,7 +78,7 @@ function mcl_types.match_pos(actual, expected, meta) return false elseif expected.biome and minetest.get_biome_name(minetest.get_biome_data(actual).biome) ~= expected.biome then return false - elseif expected.node and not mcl_types.match_node(minetest.get_node(actual), expected.node, actual, meta) + elseif expected.node and not mcl_types.match_node(minetest.get_node(actual), expected.node, actual, meta) then return false elseif expected.light and not mcl_types.match_bounds(minetest.get_node_light(actual), expected.light) then return false diff --git a/mods/DATA/mcl_types/mod.conf b/mods/DATA/mcl_types/mod.conf index 28e5a19d5..20da6f8bf 100644 --- a/mods/DATA/mcl_types/mod.conf +++ b/mods/DATA/mcl_types/mod.conf @@ -1,3 +1,4 @@ name = mcl_types author = Fleckenstein description = Offers compare functions for many types, used for MineClone2 datapacks +depends =