Do not feed horny animals
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Thu, 12 Jul 2018 13:34:52 +0000 (15:34 +0200)
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>
Thu, 12 Jul 2018 13:34:52 +0000 (15:34 +0200)
init.lua

index f9ec252..a99b757 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -186,11 +186,14 @@ minetest.register_abm({
         end
         local objs = minetest.get_objects_inside_radius(pos, radius)
         for _,obj in ipairs(objs) do
-           if not obj:is_player() and obj:get_armor_groups().fleshy and obj:get_armor_groups().fleshy > 0 and is_mob(obj) then
-              --              obj:on_rightclick(fake_player)
-              if obj:get_luaentity().on_rightclick then
-                 obj:get_luaentity():on_rightclick(fake_player)
-              end
+            ent = obj:get_luaentity()
+            if not obj:is_player() and obj:get_armor_groups().fleshy and obj:get_armor_groups().fleshy > 0 and is_mob(obj) then
+               if ent.on_rightclick then
+                   if ent.horny and node.name == "feedlot:feedlot" then
+                       return
+                   end
+                   obj:get_luaentity():on_rightclick(fake_player)
+               end
 --            minetest.chat_send_all("animal fed")
            end
         end