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 item, Block b, World w, MaterialData 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(targetloc, i); drop.setVelocity(new Vector(0, 0, 0)); showcases.put(b, drop); } public void makeCase(Player p, Block b) { Integer item = Integer.valueOf(p.getItemInHand().getTypeId()); if (item.intValue() < 1) item = Integer.valueOf(332); ItemStack i = new ItemStack(item.intValue()); MaterialData data = i.getData(); makeCase(p, b, item, i, data); } public void makeCase(Player p, Block b, Integer item, ItemStack i, MaterialData 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(targetloc, i); drop.setVelocity(new Vector(0, 0, 0)); showcases.put(b, drop); Location bLoc = b.getLocation(); Object[] pvars = { Integer.valueOf(bLoc.getBlockX()), Integer.valueOf(bLoc.getBlockY()), Integer.valueOf(bLoc.getBlockZ()), b.getWorld().getName(), item, data}; backup.put(b.toString(), pvars); saveMap(backup, PlayerListener.mainDirectory + File.separator + "showcases.bin"); if (!rep.booleanValue()) p.sendMessage("Showcase created!"); else p.sendMessage("Showcase replaced!"); } Thanks.
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 ItemStack redWool = new ItemStack(Material.WOOL, 5, (short) 0, (byte) 14); The (byte) 14 at the end of the constructor is the data value.