Armored Zombies Help

Discussion in 'Plugin Development' started by TheTennessee, Aug 5, 2011.

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


    Okay, so I am trying my hand at learning to make plugins for bukkit. I figured as a good first simple plugin, I'd make zombies that spawn with armor on. I'd seen it on the wiki that it was possible for them to wear it, so I have been wracking my brain trying to figure out how I would do it. Since I'm from C++, and this is my first time in java, I am -really- confused by inheritance when it comes to these abstract interfaces...

    Here's what I thought to do. Since it seems that zombies don't have the ability to change inventory items for some reason, and they can't be type casted to a HumanEntity to do that... I thought I'd create a new class (Or abstract interface as I found out I had to use)... I called it ArmoredZombie:

    public abstract interface ArmoredZombie extends org.bukkit.entity.Zombie, org.bukkit.entity.HumanEntity{}
    It wouldn't let me add anything new, like functions, but I figured I could still do it. Now, I am trying to make zombies spawn with armor, and I can't get it to work no matter what I do. It gives me type casting errors every time.

    ArmoredZombie zombie = (ArmoredZombie) e.getLocation().getWorld().spawnCreature(e.getLocation(), CreatureType.ZOMBIE);
    zombie.getInventory().setHelmet(new ItemStack(306));
    zombie.getInventory().setChestplate(new ItemStack(307));
    zombie.getInventory().setLeggings(new ItemStack(308));
    zombie.getInventory().setBoots(new ItemStack(309));
    That's what I am trying to do, and no dice. So, I'm wondering, is it even possible to do what I am trying to do? Is it possible in Minecraft but just not in bukkit? I feel like I am so close and missing something vital.
  2. Offline


    I don't think zombies have an inventory as they do not extend HumanEntity.
    You might be able to force armour to appear on a zombie by sending network packets directly.
    By the way, an interface means that an actual class must implement all the functions defined in it. For example, the actual implementation of Zombie is in org.bukkit.craftbukkit.entity.CraftZombie.
  3. Offline


    @zhuowei That's why I was making a new type that extended both of them. It made sense to me, I just don't know if it can work because they are abstract interfaces... But essentially, I wanted to make a new entity with the functionality of both...

    [edit] Or maybe in order to make that entity function, I have to find some way to create it, and to somehow send it to the bukkit entity manager, or whatever it would be called in bukkit.

    So if I figure out how to do that (which I have no idea how to), I might be able to get it to work? I just need more or less to code out a CraftArmoredZombie class to go with it, right? How the heck do I link it together?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 18, 2016
  4. Offline


    Creating a new entity is more complicated than just creating a class and implementing the correct interfaces. The main issue you'll run into is the game client won't know what that entity is, so it won't be able to render it. It may seem like it, but this is not a "good simple plugin" for a beginning plugin developer.
  5. Offline


    Yeah, I figured that out. So... even if I create a new one, the client will not recognize it? There's no way to make the client view it as a zombie?
  6. Offline


    The only way is to let the zomie appear as player with zombie skin and amor.
  7. Offline


    Hm alright, well, I've scrapped this idea for now, and I'll be working on a different mod. So far, I've made giants spawn and work in normal worlds, nether worlds, and skylands. Interesting learning experience about the skylands. Diamond for the person who guesses what happened.
Thread Status:
Not open for further replies.

Share This Page