From f3e66701aa4e57d6163704d6cd96219c639006d3 Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Mon, 27 Nov 2023 22:08:29 -0800 Subject: [PATCH] add a protected shared armor stand (#127) --- 3d_armor_stand/init.lua | 87 +++++++++++++++++- .../models/3d_armor_stand_shared.png | Bin 0 -> 1011 bytes 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 3d_armor_stand/models/3d_armor_stand_shared.png diff --git a/3d_armor_stand/init.lua b/3d_armor_stand/init.lua index 018a4a7..b2d42b0 100644 --- a/3d_armor_stand/init.lua +++ b/3d_armor_stand/init.lua @@ -299,6 +299,84 @@ minetest.register_node("3d_armor_stand:locked_armor_stand", { end, }) +minetest.register_node("3d_armor_stand:shared_armor_stand", { + description = S("Shared Armor Stand"), + drawtype = "mesh", + mesh = "3d_armor_stand.obj", + tiles = {"3d_armor_stand_shared.png"}, + use_texture_alpha = "clip", + paramtype = "light", + paramtype2 = "facedir", + walkable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.25, -0.4375, -0.25, 0.25, 1.4, 0.25}, + {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}, + }, + }, + groups = {choppy=2, oddly_breakable_by_hand=2}, + sounds = default.node_sound_wood_defaults(), + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", armor_stand_formspec) + meta:set_string("infotext", S("Shared Armor Stand")) + local inv = meta:get_inventory() + for _, element in pairs(elements) do + inv:set_size("armor_"..element, 1) + end + end, + can_dig = function(pos, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + for _, element in pairs(elements) do + if not inv:is_empty("armor_"..element) then + return false + end + end + return true + end, + after_place_node = function(pos, placer) + minetest.add_entity(pos, "3d_armor_stand:armor_entity") + local meta = minetest.get_meta(pos) + meta:set_string("infotext", S("Shared Armor Stand")) + add_hidden_node(pos, placer) + end, + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + if not minetest.is_player(player) or minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + local def = stack:get_definition() or {} + local groups = def.groups or {} + if groups[listname] then + return 1 + end + return 0 + end, + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + if not minetest.is_player(player) or minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + return stack:get_count() + end, + allow_metadata_inventory_move = function(pos) + return 0 + end, + on_metadata_inventory_put = function(pos) + update_entity(pos) + end, + on_metadata_inventory_take = function(pos) + update_entity(pos) + end, + after_destruct = function(pos) + update_entity(pos) + remove_hidden_node(pos) + end, + on_blast = function(pos) + -- Not affected by TNT + end, +}) + minetest.register_entity("3d_armor_stand:armor_entity", { initial_properties = { physical = true, @@ -328,7 +406,7 @@ minetest.register_entity("3d_armor_stand:armor_entity", { }) minetest.register_abm({ - nodenames = {"3d_armor_stand:locked_armor_stand", "3d_armor_stand:armor_stand"}, + nodenames = {"3d_armor_stand:locked_armor_stand", "3d_armor_stand:shared_armor_stand", "3d_armor_stand:armor_stand"}, interval = 15, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) @@ -354,3 +432,10 @@ minetest.register_craft({ {"3d_armor_stand:armor_stand", "default:steel_ingot"}, } }) + +minetest.register_craft({ + output = "3d_armor_stand:shared_armor_stand", + recipe = { + {"3d_armor_stand:armor_stand", "default:copper_ingot"}, + } +}) diff --git a/3d_armor_stand/models/3d_armor_stand_shared.png b/3d_armor_stand/models/3d_armor_stand_shared.png new file mode 100644 index 0000000000000000000000000000000000000000..e54b599d3c3c3929765203d361793902716ba86c GIT binary patch literal 1011 zcmV5+mJcnyNiEBNRlarN|m6w;7nVFfLc}1R{o}qq7qN1Xvfl8;R zr>v~3udlDLv9P$fxVyZ%zP`S|!N9`8!od9T$H>UZ$jZvf%goEn%FfKq&Cbio z&(F@!&(F}%(9qJ&(b3V;($mw_)Yj6`*4EYNmPP59N$HwQ>6}mLoKWhWQtF;l>Yh~U zpH=FhSL&cx>Y-TcqFU>vU+k%9?XGa{v3BmWdGNf5@Vtrfy^8U^jq$&Z@xYJqz>x95 zk@CWm^1_tz!^va_2%cK0=>nZ>M00DGTPE!Ct=GbNc z00OH?L_t(o!|jz>Q`;~Ug<~PBKoT597!u1HP`OfY(gI!0*3v+lrs?wk|4gsk=*2IN z?5ECfXDs_<#$UADbKL1vYPh%8-SY?C!G5=Q(DVJO?$i~_C+a*`aeN}B%p|MoTEPB9 zP4ZlcIL(w&a!}Q^0AJ-VbER^bWwBCmx2o%BkgJK(C56bMkX3apU^r19i{ke7_TqYW zHy#Z@N2f4*DaDxpT?^znH$7!N^bQi&+xp-4g3cOp#rEIW|M$D^ZBziO zs3icqtzM_t!5Aab2H<%u0hE#!0MBg+c;TUbD*&NrhwdWW;vAN9gwW#AanN#g^#-0V zFW~v@`|SY>O6m7sFf7+smvDRc35Kf=+rIv7{sfIMU%{|iu9wRdA^7JS)Sn+)0j5y> z9d|kQl# z?>%$3|1NxmKzMj?%-uFrDP626eR_lk@5=(y_1dl%u=Xv+`qCrOmwmKv{*yF~R>x`a zl{Cj^j??}SHw|PO${Ju=*tE1Yz?jIGs?iLzjg76FY+@NCCRpqNn