From 47e91b9b6b95233f0f6ec7bafad662e71445a48f Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 12 Jan 2024 10:44:39 +0000 Subject: [PATCH] add pint sized rune to shrink tamed animals --- lucky_block.lua | 90 ++++++++++++++++++++++++++++++ textures/mobs_pint_sized_rune.png | Bin 0 -> 160 bytes 2 files changed, 90 insertions(+) create mode 100644 textures/mobs_pint_sized_rune.png diff --git a/lucky_block.lua b/lucky_block.lua index dafab3c..cd249ad 100644 --- a/lucky_block.lua +++ b/lucky_block.lua @@ -1,4 +1,7 @@ +local S = minetest.get_translator("mobs") + + lucky_block:add_blocks({ {"dro", {"mobs:meat_raw"}, 5}, {"dro", {"mobs:meat"}, 5}, @@ -13,3 +16,90 @@ lucky_block:add_blocks({ {"dro", {"mobs:fence_top"}, 12}, {"lig"} }) + + +-- pint sized rune + +minetest.register_craftitem(":mobs:pint_sized_rune", { + description = S("Pint Sized Rune"), + inventory_image = "mobs_pint_sized_rune.png", + groups = {flammable = 2}, + + on_use = function(itemstack, user, pointed_thing) + + if pointed_thing.type ~= "object" then + return + end + + local name = user and user:get_player_name() or "" + local tool = user and user:get_wielded_item() + local tool_name = tool:get_name() + + if tool_name ~= "mobs:pint_sized_rune" then + return + end + + local self = pointed_thing.ref:get_luaentity() + + if not self._cmi_is_mob then + minetest.chat_send_player(name, S("Not a Mobs Redo mob!")) + return + end + + if not self.tamed then + minetest.chat_send_player(name, S("Not tamed!")) + return + end + + if self.pint_size_potion then + minetest.chat_send_player(name, S("Potion already applied!")) + return + end + + if not mobs.is_creative(user:get_player_name()) then + tool:take_item() -- take 1 rune + user:set_wielded_item(tool) + end + + local pos = self.object:get_pos() + local prop = self.object:get_properties() + + vis_size = {x = self.base_size.x * .5, y = self.base_size.y * .5} + + self.base_size = vis_size + + colbox = { + self.base_colbox[1] * .5, self.base_colbox[2] * .5, + self.base_colbox[3] * .5, self.base_colbox[4] * .5, + self.base_colbox[5] * .5, self.base_colbox[6] * .5} + + self.base_colbox = colbox + + selbox = { + self.base_selbox[1] * .5, self.base_selbox[2] * .5, + self.base_selbox[3] * .5, self.base_selbox[4] * .5, + self.base_selbox[5] * .5, self.base_selbox[6] * .5} + + self.base_selbox = selbox + + self.object:set_properties({ + visual_size = vis_size, + collisionbox = colbox, + selectionbox = selbox + }) + + self.pint_size_potion = true + + pos.y = pos.y + prop.collisionbox[5] + + mobs:effect(pos, 25, "mobs_protect_particle.png", 0.5, 4, 2, 15) + + self:mob_sound("mobs_spell") + end +}) + +minetest.register_craft({ + output = "lucky_block:pint_sized_rune", + recipe = {{ "lucky_block:pint_sized_potion", "mobs:protector" }} +}) + diff --git a/textures/mobs_pint_sized_rune.png b/textures/mobs_pint_sized_rune.png new file mode 100644 index 0000000000000000000000000000000000000000..75ace1ca6fe01ca0673e06485df39c1a4af47e7b GIT binary patch literal 160 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPHV5AX?b1=0pa`e6~FYuzulH#Hu; zQCJBSVk`;r3ubV5b|VeQvG;Uw4B@z*oZ!G9CeFz5cF7Wsw2c~?lA4Dkyc87GS)3)$ zFr0LdJmoM=$>m6dr{FR-!BFujjRuhc0Raprc^Mv`;;Iv^c*hDfiow&>&t;ucLK6U| CkSwPF literal 0 HcmV?d00001