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.
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.
Neutral mobs does not attack you at any point at all. Passive attacks you if you hit them. Hostile mobs always attacks you.
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.
but pigs are passive mobs don't have attack how will you do it? like zombies?On contact? hmmm...if distance < x... I see mind showing me the code afterwards? Im curious about this one
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 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); } } }
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
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.
Shit, he can code java 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 ?
i have been coding for about 4 months, ima noob at it 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.
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 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.
MrBluebear3 has logged in! Here is how I got pigs to attack in my plugin WildBoars with more mobs to come. Code:java @EventHandlerpublic void onPigAttack(EntityDamageByEntityEvent event) {if(event.getEntity().getType().toString()=="PIG") {if(event.getDamager().getType().toString()=="PLAYER") {Entity pig = event.getEntity();Player player = (Player) event.getDamager();pig.teleport(player);for(Player allPlayers : player.getWorld().getPlayers()) {allPlayers.playEffect(pig.getLocation(), Effect.POTION_BREAK, 9);}Integer height = config.getInt("Height-to-hit-players")/4;player.damage(config.getInt("Hearts-per-hit"));Vector victor = player.getVelocity();Vector newVictor = victor.add(new Vector(0,height,0));player.setVelocity(newVictor);}}} 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.
Does look interesting. I'll have a look at it. Though I'm still going to wait for XbannisherX's one, will see..
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
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.
Yeah that would be the last step to the best plugin for bukkit (after VoxelSniper xD) Greetings Virtuu ^^