NeutralMobs

Discussion in 'Archived: Plugin Requests' started by Superboop, Aug 24, 2012.

  1. Offline

    Superboop

    Plugin category: MECH

    Suggested name: NeutralMobs

    What I want: I'd like to see all passive mobs become neutral, such as Wolves or Zombie Pigman. Similar to Zelda chickens.. When you attack any currently passive mob, they will attempt to attack you.

    Ideas for commands: No commands needed for this plugin.

    Ideas for permissions: No permissions needed for this plugin either.

    When I'd like it by: ASAP.
     
  2. Offline

    adde

    So you want passive mobs won't hurt you back when you hit them?
     
  3. Offline

    Woobie

    I think he wants passive mobs to attack you if you hit them.
     
  4. Offline

    adde

    Dude, they already do -.-
     
  5. Offline

    Woobie

    Well thats new, i always thought that HOSTILE mobs were the ones who attack you.
    From wiki: Pages for passive mobs, which do not attack even when provoked and spawn regardless of difficulty setting.
     
  6. Offline

    adde

    Neutral mobs does not attack you at any point at all. Passive attacks you if you hit them. Hostile mobs always attacks you.
     
    Woobie likes this.
  7. Offline

    Woobie

    ohh.. i messed up the neutral and passive:D
     
  8. Offline

    Superboop

    Nonono. If you look at the Minecraft Wiki..

    Passive
    Passive mobs will never attack the player.
    All passive mobs except squids require land to spawn on. Squids need water to spawn in.

    Chicken, Cow, Mooshroom, Ocelot, Pig, Sheep, Squid, Villager

    Neutral
    Neutral mobs will not attack the player unless provoked. The act of provoking neutral mobs varies between mobs.
    Enderman, Wolf, Zombie Pigman

    So Woobie was right. I do want Pigs, Chickens, Cows, etc. that attack you if you hit them.
     
  9. Offline

    Superboop

    I don't know why my bumps were deleted..
    Anybody look at this request?
     
  10. Offline

    arcade_droid

  11. Offline

    Superboop

    Wow, so nobody at all?
     
  12. Offline

    XbannisherX

    im working on this :p
    im almost done making pigs evil :D
     
  13. Offline

    Superboop

    Hurrah, my prayers have been answered.
    Now to just wait..
     
  14. Offline

    Vandrake

    but pigs are passive mobs :confused: don't have attack how will you do it? like zombies?On contact? hmmm...if distance < x... I see :confused: mind showing me the code afterwards? :D Im curious about this one
     
  15. Offline

    XbannisherX

    Sure, i can show you it now, but the pig isnt listening to setTarget, atleast, he listens to setTarget for 1 sec, after that he just runs away, im stuck on that :p
    Please dont steal my code D:

    Code:
    @EventHandler
    public void setTarget(EntityDamageByEntityEvent event){
    Entity en = event.getEntity();
    Entity damager = event.getDamager();
    EntityType type = event.getDamager().getType();
    if(type == EntityType.PLAYER && en.getClass() == Pig.class){
    final Player p = (Player) damager;
    final Pig pig = (Pig) en;
    Location locd = p.getLocation();
    Location locp = pig.getLocation();
    double lengte = locd.distance(locp);
    this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
     
          public void run() {
     
              pig.setTarget((LivingEntity)p);
          }
        }, 20L, 20L);
    if(lengte < 2){
    p.playEffect(EntityEffect.DEATH);
    p.setHealth(p.getHealth()-1);
    }
    }
    }
     
  16. Offline

    Vandrake

    XbannisherX
    I never steal anything lol xD even the smallest thing.. Which is what does NOT describe this code o.o its reallly good but. Pigs are hard to make attack someone exactly because of that lol :3 but wow you got some serious code there o.o sweet xD I won't steal it but i cant say the same about others xD and say it's theirs xDD so ill copy paste to a txt file and check it and learn something :3 thank you
     
  17. Offline

    Superboop

    Any ETA?
     
  18. Offline

    XbannisherX

    well if you need some explenation behind the text i can do that :p
     
  19. Offline

    Vandrake

    Calm down man xD
    XbannisherX is working his ass off xD Trust me what he is doing is no level 1 coding so give him a little time o.o

    Sorry for double post xD
    How about repeating the task banisher?On the settarget matter. or did you solve it already? (if distance < x repeat set target) xD YOu know what i mean with this rough text

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  20. Offline

    Virtualium


    Shit, he can code java :confused: can you eventualy explain to me what the code does in its smalles instances ? because i want a plugin wich let you change the behavior of the mobs in specific zones :O

    (btw i want to learn java but i actualy just watched some tutorials, never wrote something by my own :I)

    Greetins Virtuu

    PS: How long do you code Java ?
     
  21. Offline

    XbannisherX

    i have been coding for about 4 months, ima noob at it :p atleast, this code is basic lvl code

    Code:
    @EventHandler
    public void setTarget(EntityDamageByEntityEvent event){//EntityDamageByEntityEvent means whenever a person(or zombie) hits other entity's
    Entity en = event.getEntity();//so i get the Entity by using a variable which makes it much shorter coding( a variable is a ''shortcut'' for code, so i can do this if(en == EntityType.ZOMBIE) orrr i can do this if(event.getEntityType()== EntityType.ZOMBIE).
    //much shorter right? in this case, this entity is the victim, or the pig you can say
    Entity damager = event.getDamager();//now i get the damager, this is not relative, becaus nobody attacks pigs exept players? correct me if im wrong
    EntityType type = event.getDamager().getType();//so another useless thing, im getting the attacker ''type'' so, basicly what im doing here is EntityType type = event.getDamager().getType(); which means : So minecraft, what is the attacker? a human?
    if(type == EntityType.PLAYER && en.getClass() == Pig.class){ //Soooo if(the attacker is a player AND the victim is a pig){ do this }
    final Player p = (Player) damager;// im ''transforming them into a thing i can work with'' a player for instance, here is another variable, here i transform the attack into a player
    final Pig pig = (Pig) en;// the same thing, and now i do it with a pig...ALSO, a variable consists of a couple things: Player* p** = event.getPlayer();***     
    // * The object, in this case its a Entity
    // ** Your name for it, i can make it Player dickhead = event.getPlayer(); or Player Turd = event.getPlayer(); and if i did this, i only need to write Turd.(options)
    // *** where you get it from, im getting the player from a event here, it can be anything for example: Block b = event.getBlock();
    //if i do Player p = event.getBlock();, thats obvious not gonna work right? indeed, that is not gonna work
    Location locd = p.getLocation();// here i do some complicated stuff, i get the Location of the player for later uses
    Location locp = pig.getLocation();// same thing here, but here i get the Location of the pig
    double lengte = locd.distance(locp);// here i use them together to form a formula, becaus i need to know if the pig is close to player, If thats true, than i hurt the player.
    //but if he is far away i dont hurt the player, becaus that looks weird
    this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {// this is a Repeating task, it means that this code will continue to repeat itself, forever until you stop it
        //im not going to stop it becaus it stops itself when the pig dies(remember i only activate this code when the player hits the pig)
    //you can copy this whole thing from me, i dont mind(the repeater i mean :>)
          public void run() {
     
              pig.setTarget((LivingEntity)p);//here goes your actual code, this code will repeat itself
              //here i set the target for the pig, he will not attack it becaus he cant, he will just go towards him
          }
        }, 20L, 20L);// the 1st 20L means the time it takes to activate the task, 20L means 1 sec, 20 ticks means 1 sec, so this task starts to repeat itself after 1 sec the pig got hit by the player
    // the second 20 L means the time between every repeat which is 1 sec
    if(lengte < 2){// here i use the locations, IF the lenght between the pig and the attacker < (is smaller) than 2 blocks, than i hurt the player
    p.playEffect(EntityEffect.DEATH);//i give a little effect, a hurting sound, makes it more realistic
    p.setHealth(p.getHealth()-1);//here the i get the health the player got, and give him new health. the new health is his old health -1 ( a half a hart )
    //and there ya go, i hope this helped a bit, if you need any further explenation from me or some help just pm, im open to questions and more
    }
    }
    }
    the text after the // are the explenation

    Code:
    @EventHandler
    public void setTarget(EntityDamageByEntityEvent event){//EntityDamageByEntityEvent means whenever a person(or zombie) hits other entity's
    Entity en = event.getEntity();//so i get the Entity by using a variable which makes it much shorter coding( a variable is a ''shortcut'' for code, so i can do this if(en == EntityType.ZOMBIE) orrr i can do this if(event.getEntityType()== EntityType.ZOMBIE).
    //much shorter right? in this case, this entity is the victim, or the pig you can say
    Entity damager = event.getDamager();//now i get the damager, this is not relative, becaus nobody attacks pigs exept players? correct me if im wrong
    EntityType type = event.getDamager().getType();//so another useless thing, im getting the attacker ''type'' so, basicly what im doing here is EntityType type = event.getDamager().getType(); which means : So minecraft, what is the attacker? a human?
    if(type == EntityType.PLAYER && en.getClass() == Pig.class){ //Soooo if(the attacker is a player AND the victim is a pig){ do this }
    final Player p = (Player) damager;// im ''transforming them into a thing i can work with'' a player for instance, here is another variable, here i transform the attack into a player
    final Pig pig = (Pig) en;// the same thing, and now i do it with a pig...ALSO, a variable consists of a couple things: Player* p** = event.getPlayer();***     
    // * The object, in this case its a Entity
    // ** Your name for it, i can make it Player dickhead = event.getPlayer(); or Player Turd = event.getPlayer(); and if i did this, i only need to write Turd.(options)
    // *** where you get it from, im getting the player from a event here, it can be anything for example: Block b = event.getBlock();
    //if i do Player p = event.getBlock();, thats obvious not gonna work right? indeed, that is not gonna work
    Location locd = p.getLocation();// here i do some complicated stuff, i get the Location of the player for later uses
    Location locp = pig.getLocation();// same thing here, but here i get the Location of the pig
    double lengte = locd.distance(locp);// here i use them together to form a formula, becaus i need to know if the pig is close to player, If thats true, than i hurt the player.
    //but if he is far away i dont hurt the player, becaus that looks weird
    this.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {// this is a Repeating task, it means that this code will continue to repeat itself, forever until you stop it
        //im not going to stop it becaus it stops itself when the pig dies(remember i only activate this code when the player hits the pig)
    //you can copy this whole thing from me, i dont mind(the repeater i mean :>)
          public void run() {
     
              pig.setTarget((LivingEntity)p);//here goes your actual code, this code will repeat itself
              //here i set the target for the pig, he will not attack it becaus he cant, he will just go towards him
          }
        }, 20L, 20L);// the 1st 20L means the time it takes to activate the task, 20L means 1 sec, 20 ticks means 1 sec, so this task starts to repeat itself after 1 sec the pig got hit by the player
    // the second 20 L means the time between every repeat which is 1 sec
    if(lengte < 2){// here i use the locations, IF the lenght between the pig and the attacker < (is smaller) than 2 blocks, than i hurt the player
    p.playEffect(EntityEffect.DEATH);//i give a little effect, a hurting sound, makes it more realistic
    p.setHealth(p.getHealth()-1);//here the i get the health the player got, and give him new health. the new health is his old health -1 ( a half a hart )
    //and there ya go, i hope this helped a bit, if you need any further explenation from me or some help just pm, im open to questions and more
    }
    }
    }
    the text after the // are the explenation

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  22. Offline

    Vandrake

    Holy smokes xDD
    Haha give me some time to read this xD I'll be right back

    Annnd I'm back xD That was actually really precise and really really explicit! You sure know how to explain something :confused: and I do believe that from what I read from the code that this will work xD. I haven't tested it yet honestly xD You sure know what you're doing :3 Keep it up,

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  23. Offline

    Hoolean

    MrBluebear3 has logged in!
    Here is how I got pigs to attack in my plugin WildBoars with more mobs to come.
    Code:java
    1. @EventHandler
    2. public void onPigAttack(EntityDamageByEntityEvent event) {
    3. if(event.getEntity().getType().toString()=="PIG") {
    4. if(event.getDamager().getType().toString()=="PLAYER") {
    5. Entity pig = event.getEntity();
    6. Player player = (Player) event.getDamager();
    7. pig.teleport(player);
    8. for(Player allPlayers : player.getWorld().getPlayers()) {
    9. allPlayers.playEffect(pig.getLocation(), Effect.POTION_BREAK, 9);
    10. }
    11. Integer height = config.getInt("Height-to-hit-players")/4;
    12. player.damage(config.getInt("Hearts-per-hit"));
    13. Vector victor = player.getVelocity();
    14. Vector newVictor = victor.add(new Vector(0,height,0));
    15. player.setVelocity(newVictor);
    16. }
    17. }
    18. }


    If this helped in any way, please give me a teeensy-weensy bit of credit in your plugin. EDIT: Nearly all passive mobs coming in next update, configurable!

    My plugin WildBoars now has all passive mobs become neutral, with custom amounts of damage, toggling individuals mobs and random aggression! Is this what you were looking for?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  24. Offline

    Superboop

    Does look interesting. I'll have a look at it.
    Though I'm still going to wait for XbannisherX's one, will see..
     
  25. Offline

    XbannisherX

    awh! you did it D:
     
  26. Offline

    Virtualium

    Your plugin is AWESOME ! But they dont keep attacking you, do they ? That would be the only thing that i would love to see :)

    Greetings Virtuu
     
  27. Offline

    Hoolean

    Sorry dude... I made mine for another post actually! Still feel free to use the code I posted to make yours!

    Why thank you! I may make the option to let them attack again!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  28. Offline

    Virtualium

    Yeah that would be the last step to the best plugin for bukkit (after VoxelSniper xD)

    Greetings Virtuu ^^
     
  29. Offline

    Hoolean

    Version 1.3.2_4 is waiting for approval! It includes the OPTION to have this feature!
     
  30. Offline

    XbannisherX

    aha.. so you teleport them to your target? setTarget still doesnt work? D:
     
    Virtualium likes this.

Share This Page