Creating Custom Wither Skeleton Entity

Discussion in 'Spigot Plugin Development' started by Sensonic, May 3, 2017.

  1. Hello! I am creating some custom entities.
    I would like to create a custom version of a wither skeleton class. But i don't think there is one?
    It isn't EntityWitherSkull is it?

    How would i do this, thanks!
     
  2. I feel like the one you're looking for would be EntitySkeletonWither in case you want to modify the skeleton, not a wither skull.

    EDIT: While the thread @SirGregg posted may work, it's also somewhat outdated - I made (Not trying to advertise, I feel terrible already) a post about a class that does the registration fuss easy and uses no reflection whatsoever for these cases.
     
  3. If you work with Bukkit API, then yes, but neither EntitySkeleton nor EntitySkeletonAbstract contain that setType method, and even if they did, EntitySkeletonWither is its own class (and thus would need to be re-instantiated to change the type).

    Well I mean, you can use Bukkit to spawn the entity and then set its pathfinder goals n stuff with some casting here and there, but I wouldn't really recommend that :l
     
  4. Choco

    Moderator

    To clarify, Wither Skeleton was separated to become it's own entity in 1.10 (or 1.11... I don't remember). Before then it was actually just a variant of Skeleton stored in NBT. In version 1.8 of Spigot, the EntityWitherSkeleton class does not exist, and in the EntitySkeleton class there is the method #r() (which I presume is a damage method) which checks if the skeleton type is of value 1, then applies Wither.
    Code (Java):
        @Override
        public boolean r(final Entity entity) {
            if (super.r(entity)) {
                if (this.getSkeletonType() == 1 && entity instanceof EntityLiving) { // NOTE THIS LINE
                    ((EntityLiving)entity).addEffect(new MobEffect(MobEffectList.WITHER.id, 200));
                }
                return true;
            }
            return false;
        }
    In future versions such as 1.11.2, EntitySkeletonWither does exist and everything is managed separately now that it has its own entity id ;)
     
    • Agree Agree x 1
    • Winner Winner x 1
    • Informative Informative x 1
  5. Ah, thanks for clarifying :)
    Well it seems I'm so tired my answers aren't helping anyone but instead are rather misleading, hopefully someone else can help OP further if needed.
     
  6. Hey thanks (i'm coding on 1.8 so this helps clarify)! But I'm making my own classes like CustomEntityWitherSkeleton.java, how would I implement this? Do I just write this in my class?
     
  7. I got it! It worked, thanks guys!
     
    • Like Like x 1