If Spawner = Zombie

Discussion in 'Spigot Plugin Development' started by XKnucklesX, Apr 13, 2017.

  1. Hello,

    I want to write a plugin that opens a specific GUI if a spawner is right clicked. The GUI will differ from spawner to spawner and was wondering is there anyway to check what the spawner is spawning (mobs)?

  2. You should be able on right click in player interact event

    First check if the block clicked was instance of CreatureSpawner. If so do something like.

    CreatureSpawner spawner = (CreatureSpawner) event.getClickedBlock().getState();

    Then spawner.getSpawnedType() to see which EntityType it is, so just look for EntityType.ZOMBIE

    Sent from my iPhone using Tapatalk
    #2 dNiym, Apr 13, 2017
    Last edited: Apr 13, 2017
  3. CreatureSpawner spawner = (CreatureSpawner) event.getClickedBlock().getState();
  4. Whoops you're right will edit my post!

    Sent from my iPhone using Tapatalk
  5. So would I look for EntityType.Zombie?
  6. Yep, once you've got it cast to a CreatureSpawner

    If spawner.getSpawnedType() == EntityType.ZOMBIE

    Sent from my iPhone using Tapatalk