From decb1c384c0a05491cae65509f4d005b7f788107 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 10 Jun 2021 15:47:34 +0100 Subject: [PATCH] redo saddles and add overlay --- init.lua | 65 +++++++++++++++++-------------- readme.md | 4 ++ textures/mobs_saddle_overlay.png | Bin 0 -> 1069 bytes 3 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 textures/mobs_saddle_overlay.png diff --git a/init.lua b/init.lua index 5445192..a8bd8c2 100644 --- a/init.lua +++ b/init.lua @@ -92,22 +92,20 @@ mobs:register_mob("mob_horse:horse", { on_die = function(self, pos) - -- drop saddle when horse is killed while riding - -- also detach from horse properly + -- detach player from horse properly if self.driver then - - minetest.add_item(pos, "mobs:saddle") - mobs.detach(self.driver, {x = 1, y = 0, z = 1}) + end - self.saddle = nil + -- drop saddle if found + if self.saddle then + minetest.add_item(pos, "mobs:saddle") end -- drop any horseshoes added if self.shoed then minetest.add_item(pos, self.shoed) end - end, do_punch = function(self, hitter) @@ -149,29 +147,27 @@ mobs:register_mob("mob_horse:horse", { mobs.detach(clicker, {x = 1, y = 0, z = 1}) - -- add saddle back to inventory - if inv:room_for_item("main", "mobs:saddle") then - inv:add_item("main", "mobs:saddle") - else - minetest.add_item(clicker:get_pos(), "mobs:saddle") - end + return + end - self.saddle = nil - - -- attach player to horse - elseif (not self.driver and not self.child - and clicker:get_wielded_item():get_name() == "mobs:saddle") - or self.saddle then - - self.object:set_properties({stepheight = 1.1}) - mobs.attach(self, clicker) - - -- take saddle from inventory - if not self.saddle then - inv:remove_item("main", "mobs:saddle") - end + -- attach saddle to horse + if not self.driver + and not self.child + and clicker:get_wielded_item():get_name() == "mobs:saddle" + and not self.saddle then self.saddle = true + self.order = "stand" + self.object:set_properties({stepheight = 1.1}) + + -- take saddle from inventory + inv:remove_item("main", "mobs:saddle") + + self.texture_mods = self.texture_mods .. "^mobs_saddle_overlay.png" + + self.object:set_texture_mod(self.texture_mods) + + return end -- apply horseshoes @@ -196,6 +192,12 @@ mobs:register_mob("mob_horse:horse", { -- apply horseshoe overlay to current horse texture if overlay then self.texture_mods = "^" .. overlay + + if self.saddle then + self.texture_mods = self.texture_mods + .. "^mobs_saddle_overlay.png" + end + self.object:set_texture_mod(self.texture_mods) end @@ -215,8 +217,13 @@ mobs:register_mob("mob_horse:horse", { end -- used to capture horse with magic lasso - mobs:capture_mob(self, clicker, 0, 0, 80, false, nil) - end, + if mobs:capture_mob(self, clicker, nil, nil, 80, false, nil) then return end + + -- ride horse if saddled + if self.saddle and self.owner == player_name then + mobs.attach(self, clicker) + end + end }) mobs:spawn({ diff --git a/readme.md b/readme.md index bdb8cb2..9f7bb6d 100644 --- a/readme.md +++ b/readme.md @@ -7,6 +7,10 @@ There are three different horse textures (white, brown, black) which will spawn ### Taming Horses can be tamed with 10x wheat, apple, barley, oats of corn which then allows the player to pick up the horse using a lasso and ride by right-clicking with a saddle. +--- +### Saddle +Right clicking a horse with a saddle equips it and the horse will be ordered to stand still until you wish to ride. + --- ### Horseshoes Horseshoes can be crafted using steel, bronze, mese, diamond and crystal (4x ingots - 2 down either side with 1x block top middle) and placed on a horse by right clicking with the item. These can make horses run faster or jump higher while riding depending on tier. diff --git a/textures/mobs_saddle_overlay.png b/textures/mobs_saddle_overlay.png new file mode 100644 index 0000000000000000000000000000000000000000..ef100478f99becb0060b2c2b54ee344a86bb00c2 GIT binary patch literal 1069 zcmV+|1k(G7P);xR*hV)gWh>}dGCIC3Hn`f_ulvW?tMSspYMfKt5w7$S(aVz zlu}=QMNu#_GvkuAWMo-(JqOK&rJy~f&_yy$Gm&+Il=1@TM?#VcDvE;D)m7XiN`-ar zuoiAMo3UiC9RTTc8qH>t=|(&kV~y*&j^W|qYYPe&fWL3o&D5ERm5oid;Mgd6zwrjo z$0lthon(!9$9bW1tpHelF=0OJA422DZrj}bJH7bXYT@6;ruhrN(%Ks4KYS!!zWx1u z7Z}}0j)?&v7(l}~#@(I_4o;3;bKm~_2GVJqW<&tMz>|B}T#-ys6d}u>L1*U(0F+84 z0D!8hkR-_t0dFWc-~Hyg3c$jDQ96Vk%X0#uxwZZq>|jsO=^H_0LtYu48usoa-t}9%@-co+1XjwtxqXMDz5c;?w-wNBd_&f;M9CI*42Y4rWRYow+h6~ z0gXl@^m>-;*Y5(ET5Q>4k9$>f@!b&NxvjS^3DY}RlAH^mc#JB*+b|0l>w`g-h(bZ05LWK>_}+!}FZVCt znvwJ17W~|5D)N1*iD8Kpi$wrvI^jaih-<=WO-SXhWu1$gy7ih@@T zfk*if5_j<+w`X~QrOfe(5gMqlcaMo3hk1$7OI9biy}j)kUs_tSpX>EH1VONQFPkf3 zx2sV)RKKoO2HMt)1pu!q@Icwx+VWj*aBvWNdwX5G9d>rMi5$UL)gY+e=W;pJ>vaG? ze}6v!V0U+y%kR8qi~8T7^Uu}9Z-l&+;8st@R*XmU^Yf@yt1b{mMn*y(%Ay?3f_R0b nl;?#;5LwkC2(+Yblf3jF_uVAV(Id7V00000NkvXXu0mjf?=1;F literal 0 HcmV?d00001