Blocking Certain Mobs from spawning on certain blocks

Discussion in 'Plugin Development' started by nrs23, Nov 7, 2013.

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

    nrs23

    How would I go about blocking certain mobs from spawning on a particular block.

    i.e Zombies couldn't spawn on sand no matter the light level
     
  2. Offline

    drtshock

    Have you tried any code yet? People are much more likely to help, or should be, if you've shown you've at least given it some effort :)
     
  3. Offline

    NinjaWAffles

    Like drtshock said, you'll want to show some effort. Although, if you're lost, try looking into events first. Mostly, CreatureSpawnEvent.

    Also, seeing as how you're having problem with this shows me you don't know much about Java or the Bukkit API, I'd suggest you read this tutorial before diving into this.
     
  4. Offline

    Milkywayz

    > CreatureSpawnEvent
    > getLocation() , find block under that location
    > find the block based on that location
    > do your check if that block is allowed to have that specific mob on

    This only works for mobs that spawn on blocks. Withers, Dragons, Bats, and maybe other mobs do not spawn on a block but rather in the air so you can't really change that.
     
  5. Offline

    nrs23

    @NinjaWAffles @drtshock, i get what your saying, i've never done anything to do with creature spawning before so i don't even know where to start. Ive been making plugins for about 6 months now, but they've all been revolving around EventListeners and Schedules, i've never touched the manipulating entities side of things. So im not a noob i just don't have a wide range of knowledge.
     
  6. Offline

    maxben34

    This however is an EventListener, so you shouldn't have any trouble.

    Some tips-
    Use a CreatureSpawnEvent
    Get the relative upwards face of the block 1 down from where the mob spawns. If this block face is recognized as sand, then you can set the event as cancelled.
    You can use if statements to choose which mobs can spawn on the sand and which ones cant.

    If you have any questions just ask :)
     
  7. Offline

    nrs23

Thread Status:
Not open for further replies.

Share This Page