From 1b5b2e4dc7fc2660f6858f2df92543ed9fa00367 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 19 Aug 2023 18:27:00 +0200 Subject: [PATCH] Use new vectors in several places --- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 13 ++++++------- mods/ITEMS/REDSTONE/mcl_droppers/init.lua | 17 ++++++++--------- mods/ITEMS/mcl_blast_furnace/init.lua | 7 +------ 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index fa8ecc779..ae419a512 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -101,8 +101,7 @@ local dispenserdef = { for i = 1, inv:get_size("main") do local stack = inv:get_stack("main", i) if not stack:is_empty() then - local p = { x = pos.x + math.random(0, 10) / 10 - 0.5, y = pos.y, z = pos.z + math.random(0, 10) / 10 - 0.5 } - minetest.add_item(p, stack) + minetest.add_item(vector.offset(pos, math.random(0, 10) / 10 - 0.5, 0, math.random(0, 10) / 10 - 0.5), stack) end end meta:from_table(meta2) @@ -120,11 +119,11 @@ local dispenserdef = { dropdir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) droppos = vector.add(pos, dropdir) elseif node.name == "mcl_dispensers:dispenser_up" then - dropdir = { x = 0, y = 1, z = 0 } - droppos = { x = pos.x, y = pos.y + 1, z = pos.z } + dropdir = vector.new(0, 1, 0) + droppos = vector.offset(pos, 0, 1, 0) elseif node.name == "mcl_dispensers:dispenser_down" then - dropdir = { x = 0, y = -1, z = 0 } - droppos = { x = pos.x, y = pos.y - 1, z = pos.z } + dropdir = vector.new(0, -1, 0) + droppos = vector.offset(pos, 0, -1, 0) end local dropnode = minetest.get_node(droppos) local dropnodedef = minetest.registered_nodes[dropnode.name] @@ -156,7 +155,7 @@ local dispenserdef = { -- Armor, mob heads and pumpkins if igroups.armor then - local droppos_below = { x = droppos.x, y = droppos.y - 1, z = droppos.z } + local droppos_below = vector.offset(droppos, 0, -1, 0) for _, objs in ipairs({ minetest.get_objects_inside_radius(droppos, 1), minetest.get_objects_inside_radius(droppos_below, 1) }) do diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index 78a9a773b..09e221a4d 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -74,8 +74,7 @@ local dropperdef = { for i = 1, inv:get_size("main") do local stack = inv:get_stack("main", i) if not stack:is_empty() then - local p = { x = pos.x + math.random(0, 10) / 10 - 0.5, y = pos.y, z = pos.z + math.random(0, 10) / 10 - 0.5 } - minetest.add_item(p, stack) + minetest.add_item(vector.offset(pos, math.random(0, 10) / 10 - 0.5, 0, math.random(0, 10) / 10 - 0.5), stack) end end meta:from_table(meta2) @@ -119,9 +118,9 @@ local dropperdef = { if node.name == "mcl_droppers:dropper" then droppos = vector.subtract(pos, minetest.facedir_to_dir(node.param2)) elseif node.name == "mcl_droppers:dropper_up" then - droppos = { x = pos.x, y = pos.y + 1, z = pos.z } + droppos = vector.offset(pos, 0, 1, 0) elseif node.name == "mcl_droppers:dropper_down" then - droppos = { x = pos.x, y = pos.y - 1, z = pos.z } + droppos = vector.offset(pos, 0, -1, 0) end local dropnode = minetest.get_node(droppos) -- Do not drop into solid nodes, unless they are containers @@ -149,11 +148,11 @@ local dropperdef = { if not dropped and not dropnodedef.groups.container then -- Drop item normally local pos_variation = 100 - droppos = { - x = droppos.x + math.random(-pos_variation, pos_variation) / 1000, - y = droppos.y + math.random(-pos_variation, pos_variation) / 1000, - z = droppos.z + math.random(-pos_variation, pos_variation) / 1000, - } + droppos = vector.offset(droppos, + math.random(-pos_variation, pos_variation) / 1000, + math.random(-pos_variation, pos_variation) / 1000, + math.random(-pos_variation, pos_variation) / 1000 + ) local item_entity = minetest.add_item(droppos, dropitem) local drop_vel = vector.subtract(droppos, pos) local speed = 3 diff --git a/mods/ITEMS/mcl_blast_furnace/init.lua b/mods/ITEMS/mcl_blast_furnace/init.lua index 108411083..51a8f193a 100644 --- a/mods/ITEMS/mcl_blast_furnace/init.lua +++ b/mods/ITEMS/mcl_blast_furnace/init.lua @@ -466,12 +466,7 @@ minetest.register_node("mcl_blast_furnace:blast_furnace", { for _, listname in ipairs({ "src", "dst", "fuel" }) do local stack = inv:get_stack(listname, 1) if not stack:is_empty() then - local p = { - x = pos.x + math.random(0, 10) / 10 - 0.5, - y = pos.y, - z = pos.z + math.random(0, 10) / 10 - 0.5 - } - minetest.add_item(p, stack) + minetest.add_item(vector.offset(pos, math.random(0, 10) / 10 - 0.5, 0, math.random(0, 10) / 10 - 0.5), stack) end end meta:from_table(meta2)