mirror of
				https://github.com/luanti-org/minetest_game.git
				synced 2025-10-28 22:35:22 +01:00 
			
		
		
		
	Log bucket liquid placement
This commit is contained in:
		| @@ -33,6 +33,11 @@ local function check_protection(pos, name, text) | ||||
| 	return false | ||||
| end | ||||
|  | ||||
| local function log_action(pos, name, text) | ||||
| 	minetest.log("action", (name ~= "" and name or "A mod") | ||||
| 		.. " " .. text .. " at " .. minetest.pos_to_string(pos) .. " with a bucket") | ||||
| end | ||||
|  | ||||
| -- Register a new liquid | ||||
| --    source = name of the source node | ||||
| --    flowing = name of the flowing node | ||||
| @@ -101,13 +106,13 @@ function bucket.register_liquid(source, flowing, itemname, inventory_image, name | ||||
| 					end | ||||
| 				end | ||||
|  | ||||
| 				if check_protection(lpos, user | ||||
| 						and user:get_player_name() | ||||
| 						or "", "place "..source) then | ||||
| 				local pname = user and user:get_player_name() or "" | ||||
| 				if check_protection(lpos, pname, "place "..source) then | ||||
| 					return | ||||
| 				end | ||||
|  | ||||
| 				minetest.set_node(lpos, {name = source}) | ||||
| 				log_action(lpos, pname, "placed " .. source) | ||||
| 				return ItemStack("bucket:bucket_empty") | ||||
| 			end | ||||
| 		}) | ||||
| @@ -128,16 +133,16 @@ minetest.register_craftitem("bucket:bucket_empty", { | ||||
| 			return | ||||
| 		end | ||||
| 		-- Check if pointing to a liquid source | ||||
| 		local node = minetest.get_node(pointed_thing.under) | ||||
| 		local pos = pointed_thing.under | ||||
| 		local node = minetest.get_node(pos) | ||||
| 		local liquiddef = bucket.liquids[node.name] | ||||
| 		local item_count = user:get_wielded_item():get_count() | ||||
|  | ||||
| 		if liquiddef ~= nil | ||||
| 		and liquiddef.itemname ~= nil | ||||
| 		and node.name == liquiddef.source then | ||||
| 			if check_protection(pointed_thing.under, | ||||
| 					user:get_player_name(), | ||||
| 					"take ".. node.name) then | ||||
| 			local pname = user:get_player_name() | ||||
| 			if check_protection(pos, pname, "take ".. node.name) then | ||||
| 				return | ||||
| 			end | ||||
|  | ||||
| @@ -166,10 +171,13 @@ minetest.register_craftitem("bucket:bucket_empty", { | ||||
| 			local source_neighbor = false | ||||
| 			if liquiddef.force_renew then | ||||
| 				source_neighbor = | ||||
| 					minetest.find_node_near(pointed_thing.under, 1, liquiddef.source) | ||||
| 					minetest.find_node_near(pos, 1, liquiddef.source) | ||||
| 			end | ||||
| 			if not (source_neighbor and liquiddef.force_renew) then | ||||
| 				minetest.add_node(pointed_thing.under, {name = "air"}) | ||||
| 			if source_neighbor and liquiddef.force_renew then | ||||
| 				log_action(pos, pname, "picked up " .. liquiddef.source .. " (force renewed)") | ||||
| 			else | ||||
| 				minetest.add_node(pos, {name = "air"}) | ||||
| 				log_action(pos, pname, "picked up " .. liquiddef.source) | ||||
| 			end | ||||
|  | ||||
| 			return ItemStack(giving_back) | ||||
| @@ -177,7 +185,7 @@ minetest.register_craftitem("bucket:bucket_empty", { | ||||
| 			-- non-liquid nodes will have their on_punch triggered | ||||
| 			local node_def = minetest.registered_nodes[node.name] | ||||
| 			if node_def then | ||||
| 				node_def.on_punch(pointed_thing.under, node, user, pointed_thing) | ||||
| 				node_def.on_punch(pos, node, user, pointed_thing) | ||||
| 			end | ||||
| 			return user:get_wielded_item() | ||||
| 		end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user