Spawner spawning custom entities

Discussion in 'Plugin Development' started by MrGazdag, Dec 19, 2017.

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

    MrGazdag

    I've been searching on the Internet, to find a solution to my problem, but didn't find anything, so i'll ask it here: How can you set a spawner block's entity's data? For example, lets say i have an armor stand with a stone on it's head. How could i modify a spawner in such a way, to set the armor stand's head item to be a stone?
     
  2. Offline

    PikaThieme

    1. ((CreatureSpawner) <your block>.getState()).setSpawnedType(<some entity type>);

      So far as I know you can't do anything more
     
  3. Offline

    AdamDev

    @MrGazdag
    If your wishing to do custom entities you are going to need to do the following:
    1. Make a custom entity
    2. Make an instance of the custom entity such as "CustomEntityClass en = new CustomEntityClass(stuff);
    3. Under that make a Entity variable such as "Entity bukkiten = en.getBukkitEntity();" This here returns the entity that the CustomEntity is.
    4. After that you'll set the spawner's data such as what @PikaThieme had said. "((CreatureSpawner)<your block>.getState()).setSpawnedType(bukkiten))
    If @PikaThieme 's method doesn't work just search up on how to set a spawner type.
    If the problem persists, please reply with your recent code.

    Hope this helps!
    ~ AdamDev
     
  4. Offline

    MrGazdag

    @AdamDev Sadly, CreatureSpawner.setSpawnedType() only accepts the enum EntityType, not entities itself i think :(
     
  5. Offline

    AdamDev

    @MrGazdag
    Well, for me I don't know much else unless you can try doing bukkiten.getType()? It would make sense but currently I can't test or see if it's true.
     
Thread Status:
Not open for further replies.

Share This Page