From e56fa0d8098aaef6b5e325aafe8cf9248f50986a Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sun, 23 Oct 2022 00:38:56 +0200 Subject: [PATCH] Lightning Rod Fixes - give node a proper nodebox - add better texture compatible with MC texture packs - set use_texture_alpha = "opaque" - fix invalid translator - disable node placement prediction - simplificate placement code --- mods/ITEMS/mcl_lightning_rods/init.lua | 51 +++++++++--------- .../textures/mcl_lightning_rods_rod.png | Bin 236 -> 144 bytes 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/mcl_lightning_rods/init.lua b/mods/ITEMS/mcl_lightning_rods/init.lua index 41d9adfbd..593a3119b 100644 --- a/mods/ITEMS/mcl_lightning_rods/init.lua +++ b/mods/ITEMS/mcl_lightning_rods/init.lua @@ -1,34 +1,39 @@ -local S = minetest.get_translator("mobs_mc") +local S = minetest.get_translator("mcl_lightning_rods") +---@type nodebox local cbox = { type = "fixed", fixed = { - { 0/16, -8/16, 0/16, 2/16, 4/16, 2/16 }, - { 0/16, 4/16, 0/16, 3/16, 8/16, 3/16 }, - } + { -0.0625, -0.5, -0.0625, 0.0625, 0.25, 0.0625 }, + { -0.125, 0.25, -0.125, 0.125, 0.5, 0.125 }, + }, } +local text_top = "[combine:16x16:6,6=mcl_lightning_rods_rod.png" +local text_side = "[combine:16x16:7,0=mcl_lightning_rods_rod.png:-6,0=mcl_lightning_rods_rod.png\\^[transformR270" + minetest.register_node("mcl_lightning_rods:rod", { description = S("Lightning Rod"), _doc_items_longdesc = S("A block that attracts lightning"), - --inventory_image = "mcl_lightning_rods_rod_inv.png", tiles = { - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", - "mcl_lightning_rods_rod.png", + text_top, + text_top, + text_side, + text_side, + text_side, + text_side, }, drawtype = "nodebox", is_ground_content = false, paramtype = "light", paramtype2 = "facedir", - groups = {pickaxey=2,attracts_lightning=1}, + use_texture_alpha = "opaque", + groups = { pickaxey = 2, attracts_lightning = 1 }, sounds = mcl_sounds.node_sound_metal_defaults(), node_box = cbox, selection_box = cbox, collision_box = cbox, + node_placement_prediction = "", on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack @@ -40,12 +45,7 @@ minetest.register_node("mcl_lightning_rods:rod", { local placer_pos = placer:get_pos() if placer_pos then - local dir = { - x = p1.x - placer_pos.x, - y = p1.y - placer_pos.y, - z = p1.z - placer_pos.z - } - param2 = minetest.dir_to_facedir(dir) + param2 = minetest.dir_to_facedir(vector.subtract(p1, placer_pos)) end if p0.y - 1 == p1.y then @@ -63,20 +63,19 @@ minetest.register_node("mcl_lightning_rods:rod", { return minetest.item_place(itemstack, placer, pointed_thing, param2) end, - sounds = mcl_sounds.node_sound_glass_defaults(), _mcl_blast_resistance = 0, }) -lightning.register_on_strike(function(pos,pos2,objects) - local lr = minetest.find_node_near(pos,128,{"group:attracts_lightning"},true) - return lr,nil +lightning.register_on_strike(function(pos, pos2, objects) + local lr = minetest.find_node_near(pos, 128, { "group:attracts_lightning" }, true) + return lr, nil end) minetest.register_craft({ output = "mcl_lightning_rods:rod", recipe = { - {"", "mcl_copper:copper_ingot",""}, - {"", "mcl_copper:copper_ingot",""}, - {"", "mcl_copper:copper_ingot",""}, - } + { "", "mcl_copper:copper_ingot", "" }, + { "", "mcl_copper:copper_ingot", "" }, + { "", "mcl_copper:copper_ingot", "" }, + }, }) diff --git a/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png b/mods/ITEMS/mcl_lightning_rods/textures/mcl_lightning_rods_rod.png index 71a0817029b40ca0c3638407651824cd5b1c315e..227ff1ceb5189aa13b1aa278a4bc182ad908b5ed 100644 GIT binary patch literal 144 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7!aZFaLo9leEyR<5%eR!X z&1}wO3u5%RTvPt{zp%`f6UGcF#va9+w@Td*P1)I?q~DOU-XK^hR+*<^j@<_~5vh}t v^BFXFG>jUO!~fq}u()z4*}Q$iB}1=1zXxl4Npk4p=SdCc<~~ zz}OB{6t8JqO9k7R)(!vK;kGPvwJ_Dd-={lM-8r_#8i~J-Gl#}dRWbtyIQAVu@^M>G zfT^rR1OR#(dPw-33s1eHTLgP10Ba3YL}<+bFj2HOnh?g(c|#0000