From bb9d6cf03726039764bb7af919720be9a6c07616 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 24 Feb 2017 06:24:16 +0100 Subject: [PATCH] Show barrier positions when wielding barrier --- mods/ITEMS/mcl_core/nodes.lua | 12 ++++++++++++ mods/PLAYER/playerplus/init.lua | 30 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/mods/ITEMS/mcl_core/nodes.lua b/mods/ITEMS/mcl_core/nodes.lua index 0c1a8cdffa..98069f7b11 100644 --- a/mods/ITEMS/mcl_core/nodes.lua +++ b/mods/ITEMS/mcl_core/nodes.lua @@ -21,6 +21,18 @@ minetest.register_node("mcl_core:barrier", { on_blast = function() end, drop = "", _mcl_blast_resistance = 18000003, + after_place_node = function (pos, placer, itemstack, pointed_thing) + if placer == nil then + return + end + minetest.add_particle({ + pos = pos, + expirationtime = 1, + size = 8, + texture = "default_barrier.png", + playername = placer:get_player_name() + }) + end, }) -- The void below the bedrock. Void damage is handled in playerplus. diff --git a/mods/PLAYER/playerplus/init.lua b/mods/PLAYER/playerplus/init.lua index 1f3f308fd9..be0312bece 100644 --- a/mods/PLAYER/playerplus/init.lua +++ b/mods/PLAYER/playerplus/init.lua @@ -137,6 +137,36 @@ minetest.register_globalstep(function(dtime) end end + -- Show positions of barriers when player is wielding a barrier + if player:get_wielded_item():get_name() == "mcl_core:barrier" then + local pos = vector.round(player:getpos()) + local r = 8 + local vm = minetest.get_voxel_manip() + local emin, emax = vm:read_from_map({x=pos.x-r, y=pos.y-r, z=pos.z-r}, {x=pos.x+r, y=pos.y+r, z=pos.z+r}) + local area = VoxelArea:new{ + MinEdge = emin, + MaxEdge = emax, + } + local data = vm:get_data() + for x=pos.x-r, pos.x+r do + for y=pos.y-r, pos.y+r do + for z=pos.z-r, pos.z+r do + local vi = area:indexp(pos) + local node = minetest.get_name_from_content_id(data[vi]) + if minetest.get_node({x=x,y=y,z=z}).name == "mcl_core:barrier" then + minetest.add_particle({ + pos = {x=x, y=y, z=z}, + expirationtime = 1, + size = 8, + texture = "default_barrier.png", + playername = player:get_player_name() + }) + end + end + end + end + end + end end)