Solved CreatureSpawnEvent and Eggs -- Getting the ItemStack

Discussion in 'Spigot Plugin Development' started by Penguinchao, May 16, 2016.

  1. I am trying to create a Stable plugin that will store horses in spawn eggs. Players who possess the eggs will be able to spawn that specified horse. The problem I am having is that I do not know how to retrieve the Lore from the held Horse Egg. Does anyone know how I can do this? Any help is appreciated!
  2. player interact event
    check if item isn't null, and item has lore
    read and diagnose lore
    run certain code based on diagnosis
  3. Thank you guys :)
    So you think I should go the route of listening for PlayerInteractEvent instead of CreatureSpawnEvent to get the ItemStack (then cancel the Spawn event)?
  4. CreatureSpawnEvent is for detecting when a creature spawns. you will need a interact event to detect a right click and get the item in the hand of the player.If the hand contains the horse,then add what you like.
  5. This part is working like a charm! Thank you guys!
  6. No problem, glad to help!