Fix cable plate placing on several-blocks nodes (#358)

Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com>
This commit is contained in:
Athozus 2024-04-14 03:13:19 +02:00 committed by GitHub
parent e699d32f47
commit ad2c11ed9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,13 +96,20 @@ function technic.register_cable_plate(nodename, data)
def.node_box["connect_"..notconnects[i]] = nil
if i == 1 then
def.on_place = function(itemstack, placer, pointed_thing)
local pointed_thing_diff = vector.subtract(pointed_thing.above, pointed_thing.under)
local count = 0
for axis in pairs(xyz) do
count = count + (pointed_thing.under[axis] == pointed_thing.above[axis] and 0 or 1)
if count > 1 then
return itemstack
end
end
local pointed_thing_diff = vector.direction(pointed_thing.under, pointed_thing.above)
local index = pointed_thing_diff.x + (pointed_thing_diff.y*2) + (pointed_thing_diff.z*3)
local num = index < 0 and -index + 3 or index
local crtl = placer:get_player_control()
if (crtl.aux1 or crtl.sneak) and not (crtl.aux1 and crtl.sneak) and index ~= 0 then
local fine_pointed = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
fine_pointed = vector.subtract(fine_pointed, pointed_thing.above)
fine_pointed = vector.direction(pointed_thing.above,fine_pointed)
fine_pointed[xyz[index < 0 and -index or index]] = nil
local key_a, a = next(fine_pointed)
local key_b, b = next(fine_pointed, key_a)