How to stop certain mobs from spawning

Discussion in 'Plugin Development' started by dragon53170, Sep 7, 2014.

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

    dragon53170

    I am making a plugin in which horses can't spawn. I have been trying to figure out how to stop them from spawning but I just can't. So far I've gotten this far.
    Code:java
    1. public void CreatureSpawnEvent(Entity spawnee, CreatureType type, Location loc, SpawnReason spawnReason) {
    2.  
    3. int eID = spawnee.getEntityId();
    4. if (eID == 100) {
    5.  
    6. //???????????????
    7.  
    8. }
    9. }

    I am really bad at this. :(

    Thanks for any help!
     
  2. Offline

    masons123456

  3. Offline

    Tecno_Wizard

    dragon53170, wouldn't this be an EventHandler? Right now, that method would not even run.
     
  4. Offline

    Fhbgsdhkfbl

  5. Offline

    Luke_Lax

    • Listen for the CreatureSpawnEvent
    • Check the mob type
    • if the mob type is equal to one of the mobs you wish to deny spawning then cancel the event
    • Profit???
     
  6. Offline

    Tecno_Wizard

    Fhbgsdhkfbl, his post was not on my screen when i typed that
     
  7. Offline

    DusRonald

    This should be work. If not, change anything in the code.
    Code:java
    1. @EventHandler
    2. public void onCreatureSpawn(CreatureSpawnEvent e){
    3. if(e.getCreatureType() == CreatureType.HORSE){
    4. e.setCanceld(true);
    5. }
    6. }
     
  8. Offline

    dragon53170

    It says horse is not a thing
     
  9. Offline

    Tecno_Wizard

    dragon53170, what do you mean by that? Is it a runtime error or an error thrown by eclipse? (assuming you use eclipse)
     
  10. Offline

    dragon53170

    Thrown by eclipse it wants me to replace it with another creature
     
  11. Offline

    DusRonald

    Maybe you can replace
    Code:java
    1. CreatureType.HORSE
    with
    Code:java
    1. EntityType.HORSE


    I recommence to see the Javadoc. Click here.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  12. DusRonald Please don't spoonfeed

    dragon53170 If you haven't yet learned Java, please do so from the oracle tutorials or a java book. If you already know or once you have learned Java, please read the plugin tutorial on the bukkit wiki :)
     
  13. Offline

    DusRonald

    You give a good suggestion to dragon53170, but don't say what i must to (not) do..
     
  14. DusRonald I'm not telling you want not to do, I'm merely politely asking you to help rather than spoonfeed.
     
  15. Offline

    DusRonald

    Spoonfeed does work, and it can help to learn from it. Not always ofcourse.
     
  16. Offline

    DusRonald

    AdamQpzm I know the problem of spoonfeeding, but i don't do that always. Only at the time, he has fast required.
    Bytheway: My english is not very good, but you can maybe understand it.
     
  17. DusRonald He clearly doesn't know the Bukkit API yet to giving him a solution is just covering the real problem, rather than solving anything.
     
  18. Offline

    DusRonald

    I give not always spoonfeed for anything.

    And stop it, because I'm too stubborn to admit ..
    It's a waste of time.
     
  19. Offline

    dragon53170

    You're right I don't really know anything, I know Java sort of but I am very new.
    And just to clarify is this the correct API?
     
  20. Offline

    DusRonald

    Yes it is, but a older version of Bukkit, I advise you to take the Development Build, which is 1.7.10.

    This is for the development to a plugin:
    Here is the download for the API: Click here.

    This is for information over the API.
    Here is the Javadoc from the API: Click here.
     
  21. Offline

    dragon53170

    When I click the download link it says it can't be found
     
  22. Offline

    Cerberus XII

Thread Status:
Not open for further replies.

Share This Page