From 5bf8ecbbf131eece5f08698f1147ac016c8d84cf Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Fri, 27 Mar 2020 10:21:08 +0000 Subject: [PATCH] apply horseshoe overlay to horse when shoes applied --- init.lua | 31 ++++++++++++++++++++------- textures/mobs_horseshoe_bronzeo.png | Bin 0 -> 106 bytes textures/mobs_horseshoe_diamondo.png | Bin 0 -> 106 bytes textures/mobs_horseshoe_meseo.png | Bin 0 -> 106 bytes textures/mobs_horseshoe_steelo.png | Bin 0 -> 106 bytes 5 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 textures/mobs_horseshoe_bronzeo.png create mode 100644 textures/mobs_horseshoe_diamondo.png create mode 100644 textures/mobs_horseshoe_meseo.png create mode 100644 textures/mobs_horseshoe_steelo.png diff --git a/init.lua b/init.lua index 711e40b..370ba53 100644 --- a/init.lua +++ b/init.lua @@ -81,9 +81,12 @@ mobs:register_mob("mob_horse:horse", { -- drop saddle when horse is killed while riding -- also detach from horse properly if self.driver then + minetest.add_item(pos, "mobs:saddle") + mobs.detach(self.driver, {x = 1, y = 0, z = 1}) -self.saddle = nil + + self.saddle = nil end -- drop any horseshoes added @@ -127,7 +130,7 @@ self.saddle = nil minetest.add_item(clicker:get_pos(), "mobs:saddle") end -self.saddle = nil + self.saddle = nil -- attach player to horse elseif (not self.driver and not self.child @@ -142,7 +145,7 @@ self.saddle = nil inv:remove_item("main", "mobs:saddle") end -self.saddle = true + self.saddle = true end end @@ -166,7 +169,8 @@ mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1) -- horseshoe helper function -local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, reverse) +local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, + reverse, overlay) if obj.type ~= "object" then return end @@ -185,6 +189,17 @@ local apply_shoes = function(name, itemstack, obj, shoes, speed, jump, reverse) ent.accel = speed ent.shoed = shoes + -- apply horseshoe overlay to current horse texture + if overlay then + + local ov = ent.base_texture + + ov[1] = ov[1] .. "^" .. overlay + + mob:set_properties({textures = ov}) + end + + -- show horse speed and jump stats with shoes fitted minetest.chat_send_player(name, S("Horse shoes fitted -") .. S(" speed: ") .. speed .. S(" , jump height: ") .. jump @@ -203,7 +218,7 @@ minetest.register_craftitem(":mobs:horseshoe_steel", { inventory_image = "mobs_horseshoe_steel.png", on_use = function(itemstack, user, pointed_thing) return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_steel", 7, 4, 2) + "mobs:horseshoe_steel", 7, 4, 2, "mobs_horseshoe_steelo.png") end, }) @@ -222,7 +237,7 @@ minetest.register_craftitem(":mobs:horseshoe_bronze", { inventory_image = "mobs_horseshoe_bronze.png", on_use = function(itemstack, user, pointed_thing) return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_bronze", 7, 4, 4) + "mobs:horseshoe_bronze", 7, 4, 4, "mobs_horseshoe_bronzeo.png") end, }) @@ -241,7 +256,7 @@ minetest.register_craftitem(":mobs:horseshoe_mese", { inventory_image = "mobs_horseshoe_mese.png", on_use = function(itemstack, user, pointed_thing) return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_mese", 9, 5, 8) + "mobs:horseshoe_mese", 9, 5, 8, "mobs_horseshoe_meseo.png") end, }) @@ -260,7 +275,7 @@ minetest.register_craftitem(":mobs:horseshoe_diamond", { inventory_image = "mobs_horseshoe_diamond.png", on_use = function(itemstack, user, pointed_thing) return apply_shoes(user:get_player_name(), itemstack, pointed_thing, - "mobs:horseshoe_diamond", 10, 6, 6) + "mobs:horseshoe_diamond", 10, 6, 6, "mobs_horseshoe_diamondo.png") end, }) diff --git a/textures/mobs_horseshoe_bronzeo.png b/textures/mobs_horseshoe_bronzeo.png new file mode 100644 index 0000000000000000000000000000000000000000..7285e25cd80d0e2e63bcaab6c9a692b3a62a4eff GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR>YvLqAOMH~OyN0Tf{@ z3GxeOaCmkj4agDlba4!kxSX7@KyJeS`i8_Ej0{~JjQ6+PiZ}$6W$<+Mb6Mw<&;$TK Ci5@2a literal 0 HcmV?d00001 diff --git a/textures/mobs_horseshoe_diamondo.png b/textures/mobs_horseshoe_diamondo.png new file mode 100644 index 0000000000000000000000000000000000000000..166f704f1f199f11e5a1a567e999078398a2e704 GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR=>{hZbJApe+y+4isT5 z3GxeOaCmkj4agDlba4!kxSX7@KyJeS`i8_Ej0{~JjQ6+PiZ}$6W$<+Mb6Mw<&;$TL CsU9N$ literal 0 HcmV?d00001 diff --git a/textures/mobs_horseshoe_meseo.png b/textures/mobs_horseshoe_meseo.png new file mode 100644 index 0000000000000000000000000000000000000000..507e8ceeb3f74ff4bf4849e6afef8ee2542e9118 GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR?Qg4BfNMxL`x{R-g!D zNswPKgTu2MX+VyUr;B5V#O36K1#%Pq*Eb~YU}Wg(V7$NOR>UEoEQ6=3pUXO@geCx$ C${&sZ literal 0 HcmV?d00001 diff --git a/textures/mobs_horseshoe_steelo.png b/textures/mobs_horseshoe_steelo.png new file mode 100644 index 0000000000000000000000000000000000000000..7a48396890ff5bf639f65016c1252b3ca57b6afe GIT binary patch literal 106 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH$P6TB1iv{Bq}T#{LR@tcLoZ&um|-&I3s8iy zB*-tA!Qt7BG$2RF)5S4F;&O7r0=WtQ>l+exFfw#?Fy7yCE8-APmci52&t;ucLK6Uc CL?1K& literal 0 HcmV?d00001