CatsAttack

Discussion in 'Plugin Requests' started by Smurfamel, Dec 29, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    Smurfamel

    Minecraft version: 1.8

    Plugin category: Mobs

    Suggested name: CatAttack

    What i want: So when you hit any living entity the cat attacks it just like a wolf I also want the cats be auto tamed to whoever spawns the cat.

    Ideas for commands: none

    Ideas for permissions: none

    When I'd like it by: whenever
     
    Gh0stKitty likes this.
  2. Offline

    Smurfamel

  3. Offline

    travja

    I've got a few other projects to work on and I need to take a look at the NMS needed to make this happen, but I could potentially do this. I'll let you know when I get an opportunity to start.
     
  4. Offline

    Smurfamel

    Ok also I forgot to add that when you get hit by a mob or player the cat will also attack then and also if the cat gets hit it also attacks then.
     
    Last edited: Jan 18, 2020
  5. Offline

    Smurfamel

  6. Offline

    Smurfamel

  7. Offline

    Xp10d3

    @Smurfamel Uh idk if this is possible since it requires modeling and stuff. Do you want animation or just plain attacking?
     
  8. Offline

    Smurfamel

    just attacking i know cats have attack animation as i saw them attack chickens before
     
    Xp10d3 likes this.
  9. Offline

    Xp10d3

    Alright then. I don't know if any devs are experts in this, but it'll be a while till someone is able to do this. Sorry; just be patient :)
     
  10. Offline

    travja

    I may have some time to work on this. But it won't be top priority and it might take some time. If any other devs are around that would want to take it on, I'll provide a little bit of resources. Ocelots by default only have a targetSelector goal to target chickens, and only when they aren't tamed. https://hastebin.com/iyajazagoz.java

    On the contrast, wolves have a targetSelector goal to target anything that damages them, or their owner, or if their owner attacks it. https://hastebin.com/awesaveqec.java

    So the solution would be relatively simple in concept. Assign the cat target selection to target the same things that the wolf does, and you're golden!
     
    Xp10d3 likes this.
  11. Offline

    Xp10d3

    Reminds me of my modding days. Glad I don't do that kind of stuff; way too difficult.
    EDIT: Same with travja I might be able to tackle this but I don't have that kind of time. So travja please let me know when you're going to do this. I'll let you know as well when I'll do this and if I will :D
     
    travja likes this.
  12. Offline

    Xp10d3

    Okay, I tried a bit of this. I don't think I'm skilled enough to complete this but I did figure out a few things. I believe you have to mess around with PathfinderGoalNearestAttackableGoal. This is kinda as far as I got.
    Code:
    package cats.attack.xp10d3;
    
    import org.bukkit.event.Listener;
    
    public class PlayerListeners implements Listener {
        /*
        @EventHandler
        public void tameing(EntityTameEvent event) {
            EntityType entity = event.getEntityType();
            if (entity == EntityType.OCELOT) {
                PathfinderGoalNearestAttackableTarget<EntityOcelot> finder = new PathfinderGoalNearestAttackableTarget<EntityOcelot>(entityinsentient, oclass, flag)
            }
        }
    
        @Override
        public AttributeInstance getAttribute(Attribute arg0) {
          
            return null;
        }
        */
    }
    
    Here are some helpful links:
    https://github.com/Bukkit/mc-
    dev/blob/master/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java#start-of-content

    https://bukkit.org/threads/getting-a-players-tamed-wolf.196751/
    https://siiam.es/plugins/QuickWebPr...ate-speed-and-the-target-of-an-entity.190421/
    https://siiam.es/plugins/QuickWebPr...w.spigotmc.org/resources/attributedemo.18793/

    EDIT: If anyone else wants to give it a shot go ahead.
     
  13. Offline

    travja

    Here you go!
    https://github.com/Travja/CatAttack/raw/master/CatAttackv1.0.jar

    For those wondering how it's done, it's pretty simple. Check out the source: https://github.com/Travja/CatAttack

    The only caveat is that it is not easily transferred to different versions of MC (Currently only 1.8). Because I'm modifying the PathFinderGoals of the Ocelot, I would either need to go to a bunch of work to use Reflection, or you'd need to manually update the jar for each different version of MC you wish to support.

    EDIT: Upon further testing, it works great, until the server turns off. Then all the entities get removed upon starting the server again. I'll work on a fix for that.

    EDIT PT2: It's fixed! They stay over restarts. Keep in mind that if the plugin doesn't load or is removed from the plugins folder, all ocelots (tamed and wild) will be removed from the world when you start the server. Of course, they'll naturally spawn back in, but they won't have the custom pathfinding.
     
    Last edited: Feb 27, 2020
    Xp10d3 likes this.
  14. Offline

    Smurfamel

    The attacking works great! But they don't auto tame to the player when spawned in with a egg :/ i want it to say Playername's Cat and dies when player dies. Also this doesn't matter that much but if you could make it where the babies do the same as adults.
     
    Last edited: Mar 5, 2020
  15. Offline

    travja

    @Smurfamel Sorry it has taken so long. I just added the auto-tame with spawn eggs. I'm not sure what you mean about the death stuff though.
     
  16. Offline

    Smurfamel

    Like whoever is the owner of the cat(s) and they die the cat(s) dies with them
     
Thread Status:
Not open for further replies.

Share This Page