More code problems

Discussion in 'Plugin Development' started by Felixbakkum, Jan 30, 2015.

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

    Felixbakkum

    Hey,

    One question:

    How do I add a specific Monster Spawner to one's inventory. What I mean by "specific" is; a blaze type for example...
     
  2. Offline

    caderape

    You cannot, by default it's a pig.
    But you can check the event block place and if the block is your spawner, you cast the block as a spawner and you can change the type of mob.
     
  3. Offline

    guitargun

    @Felixbakkum while it is still a itemstack you can add some lore to define the type of spawner when placed. then listen to a block place event and get the item lore of it to then cast the type as mentioned above
     
    WinX64 likes this.
  4. Offline

    DoggyCode™

    @guitargun Thanks, but can I do it by Displayname? or do I have to do it by Lore?
     
  5. Offline

    WinX64

    Whatever you can use to distinguish your custom item from normal ones later on.
     
  6. Offline

    sirrus86

    What I did was give the Monster Spawner item a data value equal to what mob you wanted to spawn (for example, give it the data value of 54 if you want it to spawn zombies). Then when the spawner is placed, check the data value then set the spawner to spawn the entity type associated with that data value.

    This can avoid the "if (item.getDisplayName().equals("Zombie Spawner")) ..." conditionals.
     
Thread Status:
Not open for further replies.

Share This Page