Use new vectors in several places

This commit is contained in:
AFCMS 2023-08-19 18:27:00 +02:00
parent 560aead57f
commit 1b5b2e4dc7
No known key found for this signature in database
GPG Key ID: 8720389A25B652E3
3 changed files with 15 additions and 22 deletions

@ -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

@ -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

@ -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)