Item type

Discussion in 'Plugin Development' started by deregudegu, Oct 20, 2012.

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

    deregudegu

    Hello,
    I'm developing a showcase plugin and I'm having a problem with item that have many types like wood, wool, etc.
    How can I differentiate them?
    PHP:
        public static void makeACase(Integer itemBlock bWorld wMaterialData data) {
            if (
    showcases.containsKey(b)) { delCase(b); }
     
            
    Location targetloc b.getLocation();
            
    targetloc.setY(targetloc.getY() + 1.0D);
            
    targetloc.setX(targetloc.getX() + 0.5D);
            
    targetloc.setZ(targetloc.getZ() + 0.5D);
            
    Block target w.getBlockAt(targetloc);
            
            if (
    target.getTypeId() != 0){ target.setTypeId(0); }
     
            
    ItemStack i = new ItemStack(item.intValue());
            
    i.setData(data);
            
    Entity drop w.dropItem(targetloci);
            
    drop.setVelocity(new Vector(000));
     
            
    showcases.put(bdrop);
        }
        
        public 
    void makeCase(Player pBlock b) {     
           
    Integer item Integer.valueOf(p.getItemInHand().getTypeId()); if (item.intValue() < 1item Integer.valueOf(332);
           
    ItemStack i = new ItemStack(item.intValue());
           
    MaterialData data i.getData();
           
    makeCase(pbitemidata);
        }
        
        public 
    void makeCase(Player pBlock bInteger itemItemStack iMaterialData data) {
            
    World w p.getWorld();
            
    Boolean rep Boolean.valueOf(false);
            if (
    showcases.containsKey(b)) {
                
    delCase(b);
                
    rep Boolean.valueOf(true);
            }
            
            
    Location targetloc b.getLocation();
            
    targetloc.setY(targetloc.getY() + 1.0D);
            
    targetloc.setX(targetloc.getX() + 0.5D);
            
    targetloc.setZ(targetloc.getZ() + 0.5D);
            
    Block target w.getBlockAt(targetloc);
     
            if (
    target.getTypeId() != 0) { target.setTypeId(0); }
           
            
    i.setData(data);
            
    Entity drop w.dropItem(targetloci);
            
    drop.setVelocity(new Vector(000));
            
            
    showcases.put(bdrop);
     
            
    Location bLoc b.getLocation();
            
    Object[] pvars = { Integer.valueOf(bLoc.getBlockX()), Integer.valueOf(bLoc.getBlockY()), Integer.valueOf(bLoc.getBlockZ()), b.getWorld().getName(), itemdata};
            
    backup.put(b.toString(), pvars);
            
    saveMap(backupPlayerListener.mainDirectory File.separator "showcases.bin");
     
            if (!
    rep.booleanValue()) p.sendMessage("Showcase created!"); else p.sendMessage("Showcase replaced!"); 
        }
    Thanks.
     
  2. Offline

    Timr

    When you're dealing with different types of a certain material, you need to familiarize yourself with the data values for that item. Here is a list of all materials in Minecraft, with their respective data values.

    Now you need to implement the data values, so let's make an ItemStack containing red wool:

    Code:java
    1. ItemStack redWool = new ItemStack(Material.WOOL, 5, (short) 0, (byte) 14);


    The (byte) 14 at the end of the constructor is the data value.
     
    deregudegu likes this.
  3. Offline

    deregudegu

    Thanks.
    But how I can get the material id form object?
     
Thread Status:
Not open for further replies.

Share This Page