Snippets for 1.4

Discussion in 'Resources' started by stirante, Oct 29, 2012.

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

    stirante

    If you want to use int type something like that 0x00FF00
     
  2. Offline

    Uniclaw

    Hm, how i can add a code snippet in the getSkin method, that if the head is just a normal head fro msteve, and not from a player, its return "Steve" ? Because if i surround with try-catch and catch the npe, its not works

    And how i can get the "SkullOwner" of a placed skull?
     
  3. Offline

    Me4502

    You can access protected constructors using Reflection.
     
  4. Offline

    Uniclaw

    Hm, anyone has a Idea why the Armor setting does not works?

    My Code:

    Code:
     
    protected boolean isMob(Entity ent){
    boolean im;
    if(ent instanceof Monster){
    im = true;
    }else
    im = false;
    return im;
    }
     
     
    @EventHandler
    public void equip(PlayerInteractEntityEvent e){
    Player p = e.getPlayer();
    Entity ent = e.getRightClicked();
    if(isMob(ent)){
    ItemStack is = p.getItemInHand();
    p.sendMessage("yeah");
    EntityEquipment.setHelmet((LivingEntity) ent, is);
     
    }
    }
    The Message is sent, and in my hand is a DiamondHelmet - so why it don't works :( ?
     
  5. Offline

    DCuno

    Hello.
    What is/where is the following?
    importorg.bukkit.craftbukkit.inventory.CraftItemStack;
     
  6. Offline

    chaseoes

  7. Offline

    stirante

    It can be only applied to zombie and skeleton I think. Only mistake that I could do is typing wrong slots. Could you try do EntityEquipment.setEquipment((LivingEntity) ent, is, 4);

    EDIT:It's my mistake. Helmet is on 4th slot, not 1st

    EDIT2:Code in first post updated
     
  8. Offline

    uvbeenzaned

    Dye colors don't seem to be working. All I get is black armor.
     
  9. Offline

    stirante

    Method with DyeColor was created for wolf's collar. I'll create ENUM for armor. For now you can use this from NMS:
    Code:
        public static final String[] a = new String[] { "black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"};
        public static final int[] b = new int[] { 1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 2651799, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320};
    
     
  10. Offline

    uvbeenzaned

    Ok thanks a bunch! :)
     
  11. Offline

    stirante

    Btw. I created enum for dyeColors,but I saw that bukkit already have this enum and I DELETED IT
     
  12. Offline

    uvbeenzaned

    Oh ok. Great code. Very much appreciated for my plugin!
     
  13. Offline

    stirante

    Armor class updated, ArmorColor enum added :)
     
    uvbeenzaned likes this.
  14. Offline

    uvbeenzaned

    Ok. I will just switch to that then.

    OH WOW! Thanks for all the comments and the formatted tabbed class! Awesome. ME GUSTA. 1 like for you.

    stirante
    What's this about?
    From: pl.getInventory().setChestplate(Armor.setColor(new ItemStack(Material.LEATHER_CHESTPLATE), ArmorColor.CYAN));
    Code:
    Multiple markers at this line
        - Unhandled exception type
        Exception
    Please help.

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

    stirante

    Just remove all throws. I'll delete them but too tired... Tomorrow I'll update all code. Btw I created lib which have all this features. It's in resources called PrettyScaryLib.
     
  16. Offline

    uvbeenzaned

    Ok I got it thnx again.
     
  17. Offline

    phondeux

    I'm trying to get mob items to drop. The following code ...

    Code:
    List<ItemStack> theDrops = event.getDrops();
    if (getWeapon(theEnt).getAmount() > 0) {
        theDrops.add(getWeapon(theEnt));
        killer.getServer().broadcastMessage("found weapon");
    }
    event.getDrops().clear();
    // Iterate through list of items, drop them damaged
    for (ItemStack theItem : theDrops) {
        theMob.getWorld().dropItemNaturally(theMob.getLocation(), theItem);
    }
    ... doesn't work. I get a message, "found weapon", but nothing drops. Did I miss something here? I'm killing skeletons whom all have bows, I assume bows would drop.
     
  18. Offline

    stirante

    You cleared drops and then you're trying to iterate through them.

    Try this:
    Code:
            if (getWeapon(theEnt).getAmount() > 0) {
                event.getDrops().add(getWeapon(theEnt));
                killer.getServer().broadcastMessage("found weapon");
            }
            for (ItemStack theItem : event.getDrops()) {
                theMob.getWorld().dropItemNaturally(theMob.getLocation(), theItem);
            }
    
     
  19. Offline

    phondeux

    Now Skeletons and Zombies drop two of everything. Maybe a round of checking to see if the item is already on the drop list?
     
  20. Offline

    stirante

    add event.getDrops().clear() on the end.
     
  21. Offline

    phondeux

    That works if they didn't pick up anything you dropped; if you drop something and they pick you get two of it.
     
  22. Offline

    Swordslam46

    Hello, I'm trying to make a plugin to let someone get a skull. This is my code so far:

    Code:
    if(label.equalsIgnoreCase("skull"))
    {
    ItemStack item = new ItemStack(397, 1);
    ItemStack itemskull = Skull.setSkin(item, "Player Name");
    p.getInventory().addItem(itemskull);
     
    return true;
    }
    And for some reason it doesn't work. Could someone please point me in the right direction?
     
  23. Offline

    stirante

    Try this :
    new ItemStack(397, 1, 3);
     
  24. Offline

    AmoebaMan

    Just curious, do you mind if I include some of this code inside a plugin I'm developing? I've javadoc'd you as the author, and I have no intention of stealing credit, but I think it's easier this way so that users don't have to go find another library dependency plugin.
     
  25. Offline

    stirante

    Use it any way you want, thats why I put source on github and included it in jar file. If you are using Namer or EntityEquipment better use those from github.
     
Thread Status:
Not open for further replies.

Share This Page