Killed Player's Inventory to Mob Inventory

Discussion in 'Plugin Development' started by Liutenantpickle, Aug 31, 2012.

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

    Liutenantpickle

    Can someone help me out? Im trying to make a plugin that when a Player Kills another Player, this spawns a Mob, the killed player's inventory transfers to the Mob, and when a Player kills the Mob, this drops the inventory. Just need the code :) Thanks!
     
  2. Offline

    skore87

    Normally an entity wouldn't have an inventory (unless a player) so you will have to create one for it and store it.
    Code:
    Inventory inventory = Bukkit.getServer().createInventory(player,36,entity.getEntityId());
    The entity.getEntityId() bit is the name of the inventory, 36 is the size, and player is the inventory holder. You will then want to hook the event for when entities are killed and then drop each item in the inventory. You should be able to figure the rest out on your own =)
     
  3. Offline

    Liutenantpickle

    Thanks dude :) But im having troubles with the entitiy event code, can you help me out?
     
  4. Offline

    skore87

    What part? Spawning it?
     
    Liutenantpickle likes this.
  5. Offline

    Liutenantpickle

    When the Mob dies lol
     
  6. Offline

    skore87

    Code:
        @EventHandler
        public void onEntityDeathEvent(EntityDeathEvent e){
                // e.getEntity().getEntityId();
        }
    If that ID is the same as the one you stored earlier, then cycle through the itemstacks in the inventory and drop it. Oh... and on second thought, it might be best that you save the ItemStack[] of the player's inventory instead of creating a new one.
     
    Liutenantpickle likes this.
  7. Offline

    Liutenantpickle

    How do I make the entity to a Zombie?
     
  8. Offline

    skore87

    For the entity death event, you wouldn't need to. Though you could check to see if it were an instanceof Zombie if you so desired.
     
    Liutenantpickle likes this.
  9. Offline

    Liutenantpickle

    Okay, Thanks for your help! :)

    Having trouble with getEntityId()); Help

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

    frozenpoptartmc

  11. Offline

    amitlin14

    so? its a good idea! they arnt copyrighted, they dont own the game, for all i know someone could make an exact copy with the exact code and they cant do anything.

    good ideas should be shared
     
    Liutenantpickle likes this.
  12. Offline

    Liutenantpickle

    Damn right, and I won't use this plugin just for MineZ this plugin can be useful, so someone help me please lol
     
Thread Status:
Not open for further replies.

Share This Page