From 6154a04c00d7650664b78e2bca37631ae3778411 Mon Sep 17 00:00:00 2001
From: David Leal <halfpacho@gmail.com>
Date: Wed, 24 Jun 2020 21:14:04 +0200
Subject: [PATCH] Remove node_ownership support, cleanup (#560)

---
 technic/machines/other/constructor.lua |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/technic/machines/other/constructor.lua b/technic/machines/other/constructor.lua
index 3396ac7..e7b1f67 100644
--- a/technic/machines/other/constructor.lua
+++ b/technic/machines/other/constructor.lua
@@ -2,6 +2,7 @@
 local S = technic.getter
 
 local function deploy_node(inv, slot_name, pos, node, machine_node)
+	if node.param2 > 3 then return end
 	if node.name ~= "air" then
 		if node.name == "ignore" or
 		   node.name == "default:lava_source" or
@@ -21,7 +22,7 @@
 		end
 		if remove_to then
 			for i = 1, remove_to do
-				inv:remove_item(drops[i])
+				inv:remove_item(slot_name, drops[i])
 			end
 		else
 			minetest.remove_node(pos)
@@ -98,7 +99,7 @@
 
 		if node.name == "technic:constructor_mk"..mark.."_off" then
 			technic.swap_node(pos, "technic:constructor_mk"..mark.."_on")
-			nodeupdate(pos)
+			minetest.check_for_falling(pos)
 			for i = 1, length do
 				place_pos = vector.add(place_pos, dir)
 				local place_node = minetest.get_node(place_pos)
@@ -112,11 +113,17 @@
 	return function(pos, node)
 		if node.name == "technic:constructor_mk"..mark.."_on" then
 			technic.swap_node(pos,"technic:constructor_mk"..mark.."_off")
-			nodeupdate(pos)
+			minetest.check_for_falling(pos)
 		end
 	end
 end
 
+local function allow_inventory_put(pos, listname, index, stack, player)
+	if stack and minetest.get_item_group(stack:get_name(), "technic_constructor") == 1 then
+		return 0
+	end
+	return technic.machine_inventory_put(pos, listname, index, stack, player)
+end
 
 local function make_constructor(mark, length)
 	minetest.register_node("technic:constructor_mk"..mark.."_off", {
@@ -128,7 +135,8 @@
 			"technic_constructor_back.png",
 			"technic_constructor_front_off.png"},
 		paramtype2 = "facedir",
-		groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon = 2},
+		groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+			mesecon = 2, technic_constructor = 1},
 		mesecons = {effector = {action_on = make_on(mark, length)}},
 		sounds = default.node_sound_stone_defaults(),
 		on_construct = function(pos)
@@ -159,9 +167,10 @@
 			end
 			return true
 		end,
-		allow_metadata_inventory_put = technic.machine_inventory_put,
+		allow_metadata_inventory_put = allow_inventory_put,
 		allow_metadata_inventory_take = technic.machine_inventory_take,
 		allow_metadata_inventory_move = technic.machine_inventory_move,
+		on_rotate = screwdriver.rotate_simple
 	})
 
 	minetest.register_node("technic:constructor_mk"..mark.."_on", {
@@ -174,12 +183,13 @@
 		paramtype2 = "facedir",
 		drop = "technic:constructor_mk"..mark.."_off",
 		groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
-			mesecon=2, not_in_creative_inventory=1},
+			mesecon=2, not_in_creative_inventory=1, technic_constructor=1},
 		mesecons= {effector = {action_off = make_off(mark)}},
 		sounds = default.node_sound_stone_defaults(),
-		allow_metadata_inventory_put = technic.machine_inventory_put,
+		allow_metadata_inventory_put = allow_inventory_put,
 		allow_metadata_inventory_take = technic.machine_inventory_take,
 		allow_metadata_inventory_move = technic.machine_inventory_move,
+		on_rotate = false
 	})
 end
 

--
Gitblit v1.8.0