Changing specific mob spawn rates..

Discussion in 'Spigot Plugin Development' started by digdiggydigger, Apr 24, 2017.

  1. It's all in the title to be honest aha.. I'm just not too sure how to do it? Anyone got any ideas or help? And before anyone says it I can't just change game rules to speed it up because that's global - I need specific
  2. *This is a really messy solution, its not recommended but it probably works*
    You can use CreatureSpawnEvent to know when a certain mob spawns, you can apply spawn rate math in there
    (ex, saving the entitytype and the time when the type last spawned and then checking if another instance of that entity can spawn).
    If you need more entities spawned you can just pick a random location close to the other mob and spawn another instance of the mob there.

    EDIT: Formatting
  3. Hmm, might be able to do this with NMS.
  4. hmmm yeah ill give that a go, I was thinking about something along those lines of spawning another entity in the surrounding area when one spawns.. alright thanks, ill post my progress soon
  5. It probably is, you can overwrite all existing mobs with different spawn rates, but it costs more time to do. The method I suggested seems easier.
    I do admit that its not an optimal solution (as stated in my post), but it'll work.
  6. Well, why not listen for CreatureSpawnEvent and check if the mob spawned is the Type you need. if not, cancel the event and spawn the mob you need instead (World#spawnEntity)
  7. Irrelevant.
    • Agree Agree x 1
  8. Hmm yeah could do but tbh i would just want to check that if, for example,a zombie is spawned then spawn another zombie next to it or at its location.. idk

    Its not irrelevant, it is different to what i asked lol but its useful xD
  9. Well, instead doing this, when an a skeleton spawn, spawn at the same location a zombie instead, so you don't need to boost anything up (Maybe you wasn't searching this, sorry if i had offtopic)
  10. But what if i want skeletons to spawn.. I didn't say anything about cancelling other mob spawns but only increasing others..
  11. Ok, my bad then. Sorry for my misunderstanding :p
  12. Its cool bud thanks anyways :eek::p:p
  13. Careful calling world.spawnEntity inside onEntitySpawn, if you're not super careful you'll end up with an endless loop of spawning extra mobs. One skeleton triggers a second, the second triggers the third, the third spawns a fourth etc.

    If you want to spawn multiple mobs at the same location based on the spawn of a natural mob you're going to have to do some checks to make sure this doesent happen.

    Like when a bonus mob should be spawned it should probably be delayed so that the spawn event has time to finish before spawning another creature. Or keep track of the locations to ensure that you don't have 500 skeletons spawn in the same general area.

    Sent from my iPhone using Tapatalk
  14. Or just give the spawned mob a metadata and check if the mob does not have the metadata
  15. If you spawn another mob before the event is finished, adding metadata or not you will still end up with an endless loop, entitySpawnEvent has to finish before a mob exists to add metadata to.

    If you spawn a mob inside the spawn event the event will fire again before your meta is added.

    Sent from my iPhone using Tapatalk
  16. Oh, okay. Good to know
  17. That's why I said to use some math before spawning. Good point though.