Exemple #1
0
 @Override
 public ItemStack getCraftingResult(InventoryCrafting crafting) {
   ItemStack armor = null;
   IDyeableItem dyeable = null;
   List<ItemStack> dyes = new ArrayList<ItemStack>();
   for (int i = 0; i < crafting.getSizeInventory(); i++) {
     ItemStack stack = crafting.getStackInSlot(i);
     if (stack == null) continue;
     dyeable = ((stack.getItem() instanceof IDyeableItem) ? (IDyeableItem) stack.getItem() : null);
     if ((dyeable != null) && dyeable.canDye(stack)) {
       if (armor != null) return null;
       armor = stack.copy();
     } else if (DyeUtils.isDye(stack)) dyes.add(stack);
     else return null;
   }
   if (dyes.isEmpty()) return null;
   int oldColor = StackUtils.get(armor, -1, "display", "color");
   int newColor = DyeUtils.getColorFromDyes(oldColor, dyes);
   StackUtils.set(armor, newColor, "display", "color");
   return armor;
 }
 @Override
 @SideOnly(Side.CLIENT)
 public int getColorFromItemStack(ItemStack stack, int renderPass) {
   return StackUtils.get(stack, 0x705030, "display", "color");
 }