PlayerEggThrowEvent

Discussion in 'Plugin Development' started by HeadGam3z, Jun 5, 2014.

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

    HeadGam3z

    I'm trying to make it so eggs hatch every time, but I'm failing to do so.
    Main:
    Code:java
    1. package com.gmail.mcheadgam3z.egghatch;
    2.  
    3. import org.bukkit.plugin.Plugin;
    4. import org.bukkit.plugin.PluginManager;
    5. import org.bukkit.plugin.java.JavaPlugin;
    6.  
    7. public class Main extends JavaPlugin {
    8.  
    9. public static Plugin plugin;
    10.  
    11. public void onEnable() {
    12. plugin = this;
    13. PluginManager m = this.getServer().getPluginManager();
    14. m.registerEvents(new EggHatchEvent(), this);
    15. }
    16.  
    17. public void onDisable() {
    18.  
    19. }
    20. }
    21.  


    Listener
    Code:java
    1. package com.gmail.mcheadgam3z.egghatch;
    2.  
    3. import org.bukkit.event.EventHandler;
    4. import org.bukkit.event.Listener;
    5. import org.bukkit.event.player.PlayerEggThrowEvent;
    6.  
    7. public class EggHatchEvent implements Listener {
    8. @EventHandler
    9. public void throwEgg(PlayerEggThrowEvent e) {
    10. e.setHatching(true);
    11. }
    12. }
    13.  

    No errors, it's just not hatching everytime.
     
  2. Offline

    97WaterPolo

    HeadGam3z
    I would recommend listening to the ProjectileHitEvent, check if the entity is an egg, and if it is spawn a baby chicken where the egg lands.

    I hope I got the right event! :p
     
    Surfdudeboy likes this.
  3. Offline

    Surfdudeboy

    HeadGam3z Yep, Do what 97WaterPolo says. I assume that e.setHatching(true)only makes it so the egg has a chance of spawning at all, not a 100% chance.
     
    97WaterPolo likes this.
Thread Status:
Not open for further replies.

Share This Page