Hi Guys I Got a Very small Problem About ItemMeta Or MetaData In ProjectileHitEvent ... The Thing is When you Throw An Egg With The Name Of "Death Egg" With a certain Color Its Spawns Some Monsters .. The Code i Made Code:java @EventHandler public void FearDeathEggAbility(ProjectileHitEvent e){ Entity entity = e.getEntity(); if(entity instanceof Egg) { Egg egg = (Egg) entity; Entity shooter = egg.getShooter(); if(shooter instanceof Player) { Player p = (Player) shooter; Location loc = egg.getLocation(); double x = loc.getX(); double y = loc.getY(); double z = loc.getZ(); Location spawn = new Location(null, x, y, z); if(egg.hasMetadata(ChatColor.DARK_RED + "Death Egg")) { p.getLocation().getWorld().spawnEntity(spawn, EntityType.CREEPER); p.getLocation().getWorld().spawnEntity(spawn, EntityType.ZOMBIE); p.getLocation().getWorld().spawnEntity(spawn, EntityType.SPIDER); } } } } But this is Not Working Even in The Normal Egg .. And I was Thinking Too at A Thing Which is SIMILAR To it How Can I Get A Name Of A Bow Which Shot A Certain Arrow ? WithTheMeaningOf When The Bow Shoots An Arrow With The Name Of "Poison" It Checks The Bows Name And If The Bow Name Was "Poisoner" It Gives Out a Splash Of Poison ... Wish I Gave It Good .. I Made This Code Too Code:java @EventHandler public void FearFreakBowAbility(ProjectileHitEvent event) { Entity entity = event.getEntity(); if(entity instanceof Arrow) { Arrow arrow = (Arrow) entity; Entity shooter = arrow.getShooter(); if(shooter instanceof Player) { Player player = (Player) shooter; PlayerInventory inv = player.getInventory(); Location loc = arrow.getLocation(); double x = loc.getX(); double y = loc.getY(); double z = loc.getZ(); Location spawn = new Location(null, x, y, z); if(arrow.hasMetadata(ChatColor.GREEN + "Poisened Arrow") && inv.getItemInHand() == FreakCraft.FreakBow && FreakCraft.FreakBow.hasItemMeta()) { Potion potion = new Potion(PotionType.POISON, 1); potion.setSplash(true); ItemStack iStack = new ItemStack(Material.POTION); potion.apply(iStack); ThrownPotion thrownPotion = (ThrownPotion) player.getWorld().spawnEntity(spawn, EntityType.SPLASH_POTION); thrownPotion.setItem(iStack); } } } } But The Same .. Its Not Working And What Makes Me Feel Bad is Its Not Giving Out ANY Single Error ... Any One Could Help Me So Please Do At Any Success Help .. I'll Be Thankful ThezKiller
This code is NOT tested and I do NOT quarantee that it works but it should give you a hint into the right direction Code:java if(egg.getItemMeta() != null && egg.getItemMeta().getDisplayName().equals("Death Egg")) {// spawn it}
When i Just Saw It .. I'll Say To You .. I Searched First For ItemMeta But Theres No Option For It On Egg Just MetaData ThezKiller I Dont Know Anything About MetaData .. But If We Say The MEaning .. Its The Nearest To ItemMeta ... ThezKiller EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Wazup93 Ohmigod. Please Stahp Typeing Like This. It hurts my eyes, and you can type faster if you didn't do it... You can't check itemmeta on a thrown entity......
Ok Sorry .. I dont want to check on the thrown item after its throw .. maybe i check on it before ? ThezKiller
Wazup93 Try storing the arrow's UUID and check if the UUID of the arrow is contained in on ProjectileHitEvent, then do your stuff
Just to make you notice .. i dont know what is UUID or how to store it .. + Maybe when i'm storing i store something else than the correct arrow .. what do you mean ?? xD ThezKiller
Wazup93 When an arrow is launched and it has the correct itemmeta, store it in an ArrayList<UUID> by using arrow.getUniqueId() and on ProjectileHitEvent, check if the ArrayList contains arrow.getUniqueId()
Didnt Work ... Maybe i've done it wrong but this is it .. first i got the entity as en then i checked if en is an arrow .. then when i'm trying to get its itemmeta it just gives out one choice which is metadata .. Notice i've done this on projectile launch event Any other ideas ... ThezKiller
Wazup93 Try getting the itemmeta of throw, IMO you should put the itemmeta on the item which the player shoots the arrow from, not the arrow itself
Your not getting it i want it to be like 1 bow and 3 arrows 1 arrow poison and any other too .. when i shoot the first arrow which is poison something happen but a deal to be the bow name a certain name .. Wish you got it ThezKiller
Okay, you want the effects of an arrow to correspond with the name of the arrow. ie: Lightning Arrow => "Strikes lightning at the target!" Undead Arrow => "Raises the undead to the overworld!" So on and so on... Am I correct?
Wazup93 xTrollxDudex perfectly gets it. Wouldn't the bow just shoot the 3 arrows then the poison arrow and AHH wacky stuff happens cause you have different arrows and I don't if you can make a bow shoot a specified arrow (Unless you throw the rest on the ground). I also wondered about this.... But in the end i decided to have different bows (Come on, a Lightning Hawk Bow is cool a name).
Yes ... But the bow name must be a certain name ThezKiller Ok this didnt help o.o + When i throw a certain named arrow from a certained named bow something happens .. not from any normal bow ... ThezKiller EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Wazup93 This is off topic, however i just wanted to let you know that you can put ThezKiller in a signature instead of having to type it after every post. maxben34(hehe)