Пример #1
0
  @Override
  public void d(ItemStack itemstack, World world, EntityHuman entityhuman) {
    if (itemstack.hasTag() && itemstack.getTag().getBoolean("map_is_scaling")) {
      WorldMap worldmap = Items.MAP.getSavedMap(itemstack, world);

      world =
          world.getServer().getServer().worlds.get(0); // CraftBukkit - use primary world for maps

      itemstack.setData(world.b("map"));
      WorldMap worldmap1 = new WorldMap("map_" + itemstack.getData());

      worldmap1.scale = (byte) (worldmap.scale + 1);
      if (worldmap1.scale > 4) {
        worldmap1.scale = 4;
      }

      worldmap1.centerX = worldmap.centerX;
      worldmap1.centerZ = worldmap.centerZ;
      worldmap1.map = worldmap.map;
      worldmap1.c();
      world.a("map_" + itemstack.getData(), worldmap1);

      // CraftBukkit start
      MapInitializeEvent event = new MapInitializeEvent(worldmap1.mapView);
      Bukkit.getServer().getPluginManager().callEvent(event);
      // CraftBukkit end
    }
  }
Пример #2
0
  public WorldMap getSavedMap(ItemStack itemstack, World world) {
    World worldMain =
        world
            .getServer()
            .getServer()
            .worlds
            .get(0); // CraftBukkit - store reference to primary world
    String s = "map_" + itemstack.getData();
    WorldMap worldmap =
        (WorldMap) worldMain.a(WorldMap.class, s); // CraftBukkit - use primary world for maps

    if (worldmap == null && !world.isStatic) {
      itemstack.setData(worldMain.b("map")); // CraftBukkit - use primary world for maps
      s = "map_" + itemstack.getData();
      worldmap = new WorldMap(s);
      worldmap.scale = 3;
      int i = 128 * (1 << worldmap.scale);

      worldmap.centerX = Math.round((float) world.getWorldData().c() / (float) i) * i;
      worldmap.centerZ = Math.round(world.getWorldData().e() / i) * i;
      worldmap.map =
          (byte) ((WorldServer) world).dimension; // CraftBukkit - fixes Bukkit multiworld maps
      worldmap.c();
      worldMain.a(s, worldmap); // CraftBukkit - use primary world for maps

      // CraftBukkit start
      MapInitializeEvent event = new MapInitializeEvent(worldmap.mapView);
      Bukkit.getServer().getPluginManager().callEvent(event);
      // CraftBukkit end
    }

    return worldmap;
  }
Пример #3
0
 public float checkTemps(IInventory inv) {
   float temp = 0;
   float[] temp1 = new float[inv.getSizeInventory()];
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     ItemStack is = inv.getStackInSlot(i);
     if (is != null
         && is.hasTagCompound()
         && !is.getItem().getUnlocalizedName(is).contains("Clay")) {
       if (is.getTagCompound().hasKey("temperature")) {
         temp1[i] = is.getTagCompound().getFloat("temperature");
         if (temp1[i] < TFC_ItemHeat.getMeltingPoint(is)) {
           return (float) -1;
         }
       } else {
         return (float) -1;
       }
     } else if (is == null) {
       temp1[i] = -1;
     }
   }
   int temp2 = 0;
   for (int i = 0; i < inv.getSizeInventory(); i++) {
     if (temp1[i] >= 0) {
       temp += temp1[i];
       temp2++;
     }
   }
   if (temp2 > 0) {
     temp /= temp2;
   }
   return temp;
 }
Пример #4
0
  public static Map b(int i, ItemStack itemstack) {
    Item item = itemstack.getItem();
    HashMap hashmap = null;
    boolean flag = itemstack.getItem() == Items.BOOK;
    Enchantment[] aenchantment = Enchantment.byId;
    int j = aenchantment.length;

    for (int k = 0; k < j; ++k) {
      Enchantment enchantment = aenchantment[k];

      if (enchantment != null && (enchantment.slot.canEnchant(item) || flag)) {
        for (int l = enchantment.getStartLevel(); l <= enchantment.getMaxLevel(); ++l) {
          if (i >= enchantment.a(l) && i <= enchantment.b(l)) {
            if (hashmap == null) {
              hashmap = new HashMap();
            }

            hashmap.put(Integer.valueOf(enchantment.id), new EnchantmentInstance(enchantment, l));
          }
        }
      }
    }

    return hashmap;
  }
Пример #5
0
  private static ItemStack tryMoveInItem(IInventory iinventory, ItemStack itemstack, int i, int j) {
    ItemStack itemstack1 = iinventory.getItem(i);

    if (canPlaceItemInInventory(iinventory, itemstack, i, j)) {
      boolean flag = false;

      if (itemstack1 == null) {
        iinventory.setItem(i, itemstack);
        itemstack = null;
        flag = true;
      } else if (canMergeItems(itemstack1, itemstack)) {
        int k = itemstack.getMaxStackSize() - itemstack1.count;
        int l = Math.min(itemstack.count, k);

        itemstack.count -= l;
        itemstack1.count += l;
        flag = l > 0;
      }

      if (flag) {
        if (iinventory instanceof TileEntityHopper) {
          ((TileEntityHopper) iinventory)
              .c(((TileEntityHopper) iinventory).world.spigotConfig.hopperTransfer); // Spigot
          iinventory.update();
        }

        iinventory.update();
      }
    }

    return itemstack;
  }
Пример #6
0
  public EnumInteractionResult a(
      EntityHuman entityhuman,
      World world,
      BlockPosition blockposition,
      EnumHand enumhand,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    IBlockData iblockdata = world.getType(blockposition);

    if (iblockdata.getBlock() == Blocks.JUKEBOX
        && !((Boolean) iblockdata.get(BlockJukeBox.HAS_RECORD)).booleanValue()) {
      if (!world.isClientSide) {
        if (true) return EnumInteractionResult.SUCCESS; // CraftBukkit - handled in ItemStack
        ItemStack itemstack = entityhuman.b(enumhand);

        ((BlockJukeBox) Blocks.JUKEBOX).a(world, blockposition, iblockdata, itemstack);
        world.a((EntityHuman) null, 1010, blockposition, Item.getId(this));
        itemstack.subtract(1);
        entityhuman.b(StatisticList.Z);
      }

      return EnumInteractionResult.SUCCESS;
    } else {
      return EnumInteractionResult.PASS;
    }
  }
Пример #7
0
  public static void a(Map map, ItemStack itemstack) {
    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = map.keySet().iterator();

    while (iterator.hasNext()) {
      int i = ((Integer) iterator.next()).intValue();
      NBTTagCompound nbttagcompound = new NBTTagCompound();

      nbttagcompound.setShort("id", (short) i);
      nbttagcompound.setShort("lvl", (short) ((Integer) map.get(Integer.valueOf(i))).intValue());
      nbttaglist.add(nbttagcompound);
      if (itemstack.getItem() == Items.ENCHANTED_BOOK) {
        Items.ENCHANTED_BOOK.a(
            itemstack,
            new EnchantmentInstance(i, ((Integer) map.get(Integer.valueOf(i))).intValue()));
      }
    }

    if (nbttaglist.size() > 0) {
      if (itemstack.getItem() != Items.ENCHANTED_BOOK) {
        itemstack.a("ench", (NBTBase) nbttaglist);
      }
    } else if (itemstack.hasTag()) {
      itemstack.getTag().remove("ench");
    }
  }
Пример #8
0
  @Override
  public void detectAndSendChanges() {
    for (int var1 = 0; var1 < this.inventorySlots.size(); ++var1) {
      ItemStack var2 = ((Slot) this.inventorySlots.get(var1)).getStack();
      ItemStack var3 = (ItemStack) this.inventoryItemStacks.get(var1);

      if (!ItemStack.areItemStacksEqual(var3, var2)) {
        var3 = var2 == null ? null : var2.copy();
        this.inventoryItemStacks.set(var1, var3);

        for (int var4 = 0; var4 < this.crafters.size(); ++var4) {
          ((ICrafting) this.crafters.get(var4)).sendSlotContents(this, var1, var3);
        }
      }
    }
    for (int var1 = 0; var1 < this.crafters.size(); ++var1) {
      ICrafting var2 = (ICrafting) this.crafters.get(var1);
      if (this.soilamt != this.sluice.soilAmount) {
        var2.sendProgressBarUpdate(this, 0, this.sluice.soilAmount);
      }
      if (this.progress != this.sluice.processTimeRemaining) {
        var2.sendProgressBarUpdate(this, 1, this.sluice.processTimeRemaining);
      }
    }

    soilamt = this.sluice.soilAmount;
    progress = this.sluice.processTimeRemaining;
  }
Пример #9
0
  public void remove(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!world.isStatic) {
      // CraftBukkit start - Drop item in code above, not here
      // if (!((Boolean) iblockdata.get(BlockSkull.NODROP)).booleanValue()) {
      if (false) {
        // CraftBukkit end
        TileEntity tileentity = world.getTileEntity(blockposition);

        if (tileentity instanceof TileEntitySkull) {
          TileEntitySkull tileentityskull = (TileEntitySkull) tileentity;
          ItemStack itemstack =
              new ItemStack(Items.SKULL, 1, this.getDropData(world, blockposition));

          if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
            itemstack.setTag(new NBTTagCompound());
            NBTTagCompound nbttagcompound = new NBTTagCompound();

            GameProfileSerializer.serialize(nbttagcompound, tileentityskull.getGameProfile());
            itemstack.getTag().set("SkullOwner", nbttagcompound);
          }

          a(world, blockposition, itemstack);
        }
      }

      super.remove(world, blockposition, iblockdata);
    }
  }
Пример #10
0
 @Override
 public Material getPlaying() {
   ItemStack record = jukebox.getRecord();
   if (record == null) {
     return Material.AIR;
   }
   return CraftMagicNumbers.getMaterial(record.getItem());
 }
Пример #11
0
  public void b(ICommandListener icommandlistener, String[] astring) {
    if (astring.length < 2) {
      throw new ExceptionUsage("commands.enchant.usage", new Object[0]);
    } else {
      EntityPlayer entityplayer = d(icommandlistener, astring[0]);
      int i = a(icommandlistener, astring[1], 0, Enchantment.byId.length - 1);
      int j = 1;
      ItemStack itemstack = entityplayer.bx();

      if (itemstack == null) {
        throw new CommandException("commands.enchant.noItem", new Object[0]);
      } else {
        Enchantment enchantment = Enchantment.byId[i];

        if (enchantment == null) {
          throw new ExceptionInvalidNumber(
              "commands.enchant.notFound", new Object[] {Integer.valueOf(i)});
        } else if (!enchantment.canEnchant(itemstack)) {
          throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
        } else {
          if (astring.length >= 3) {
            j =
                a(
                    icommandlistener,
                    astring[2],
                    enchantment.getStartLevel(),
                    enchantment.getMaxLevel());
          }

          if (itemstack.hasTag()) {
            NBTTagList nbttaglist = itemstack.getEnchantments();

            if (nbttaglist != null) {
              for (int k = 0; k < nbttaglist.size(); ++k) {
                short short1 = ((NBTTagCompound) nbttaglist.get(k)).getShort("id");

                if (Enchantment.byId[short1] != null) {
                  Enchantment enchantment1 = Enchantment.byId[short1];

                  if (!enchantment1.a(enchantment)) {
                    throw new CommandException(
                        "commands.enchant.cantCombine",
                        new Object[] {
                          enchantment.c(j),
                          enchantment1.c(((NBTTagCompound) nbttaglist.get(k)).getShort("lvl"))
                        });
                  }
                }
              }
            }
          }

          itemstack.addEnchantment(enchantment, j);
          a(icommandlistener, "commands.enchant.success", new Object[0]);
        }
      }
    }
  }
 /* (non-Javadoc)
  * @see net.minecraft.server.Item#addCreativeItems(java.util.ArrayList)
  */
 public void addCreativeItems(ArrayList arraylist) {
   ItemStack itemstack = new ItemStack(this, 1);
   itemstack.setData((int) getElectricityCapacity());
   arraylist.add(itemstack);
   ItemStack itemstack1 = new ItemStack(this, 1);
   setElectricityStored(
       itemstack1, ((ItemElectric) itemstack1.getItem()).getElectricityCapacity());
   arraylist.add(itemstack1);
 }
  /**
   * Sets the electricity stored.
   *
   * @param itemstack the itemstack
   * @param f the f
   */
  protected void setElectricityStored(ItemStack itemstack, float f) {
    if (itemstack.tag == null) {
      itemstack.setTag(new NBTTagCompound());
    }

    float f1 = Math.max(Math.min(f, getElectricityCapacity()), 0.0F);
    itemstack.tag.setFloat("electricity", f1);
    itemstack.setData((int) (getElectricityCapacity() - f1));
  }
Пример #14
0
  public ItemStack cloneItemStack() {
    ItemStack itemstack = new ItemStack(this.id, this.count, this.damage);

    if (this.tag != null) {
      itemstack.tag = (NBTTagCompound) this.tag.clone();
    }

    return itemstack;
  }
Пример #15
0
  private static boolean tryTakeInItemFromSlot(
      IHopper ihopper, IInventory iinventory, int i, int j) {
    ItemStack itemstack = iinventory.getItem(i);

    if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
      ItemStack itemstack1 = itemstack.cloneItemStack();
      // CraftBukkit start - Call event on collection of items from inventories into the hopper
      CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));

      Inventory sourceInventory;
      // Have to special case large chests as they work oddly
      if (iinventory instanceof InventoryLargeChest) {
        sourceInventory =
            new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(
                (InventoryLargeChest) iinventory);
      } else if (isIronChest) {
        sourceInventory = null;
      } else {
        sourceInventory = iinventory.getOwner().getInventory();
      }

      InventoryMoveItemEvent event =
          new InventoryMoveItemEvent(
              sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);

      ihopper.getWorld().getServer().getPluginManager().callEvent(event);
      if (event.isCancelled()) {
        iinventory.setItem(i, itemstack1);

        if (ihopper instanceof TileEntityHopper) {
          ((TileEntityHopper) ihopper).c(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
        } else if (ihopper instanceof EntityMinecartHopper) {
          ((EntityMinecartHopper) ihopper)
              .l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
        }

        return false;
      }
      ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1);

      if (itemstack2 == null || itemstack2.count == 0) {
        if (event.getItem().equals(oitemstack)) {
          iinventory.update();
        } else {
          iinventory.setItem(i, itemstack1);
        }
        // CraftBukkit end

        return true;
      }

      iinventory.setItem(i, itemstack1);
    }

    return false;
  }
Пример #16
0
 // CraftBukkit start
 public org.bukkit.inventory.ShapedRecipe toBukkitRecipe() {
   CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
   CraftShapedRecipe recipe = new CraftShapedRecipe(result, this);
   switch (this.height) {
     case 1:
       switch (this.width) {
         case 1:
           recipe.shape("a");
           break;
         case 2:
           recipe.shape("ab");
           break;
         case 3:
           recipe.shape("abc");
           break;
       }
       break;
     case 2:
       switch (this.width) {
         case 1:
           recipe.shape("a", "b");
           break;
         case 2:
           recipe.shape("ab", "cd");
           break;
         case 3:
           recipe.shape("abc", "def");
           break;
       }
       break;
     case 3:
       switch (this.width) {
         case 1:
           recipe.shape("a", "b", "c");
           break;
         case 2:
           recipe.shape("ab", "cd", "ef");
           break;
         case 3:
           recipe.shape("abc", "def", "ghi");
           break;
       }
       break;
   }
   char c = 'a';
   for (ItemStack stack : this.items) {
     if (stack != null) {
       recipe.setIngredient(
           c,
           org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(stack.getItem()),
           stack.getData());
     }
     c++;
   }
   return recipe;
 }
 public void postPlace(
     World var1, BlockPosition var2, IBlockData var3, EntityLiving var4, ItemStack var5) {
   super.postPlace(var1, var2, var3, var4, var5);
   if (var5.hasDisplayName()) {
     TileEntity var6 = var1.getTileEntity(var2);
     if (var6 instanceof TileEntityEnchantTable) {
       ((TileEntityEnchantTable) var6).a(var5.getDisplayName());
     }
   }
 }
Пример #18
0
  public ItemStack a(int i) {
    ItemStack itemstack = new ItemStack(this.id, i, this.damage);

    if (this.tag != null) {
      itemstack.tag = (NBTTagCompound) this.tag.clone();
    }

    this.count -= i;
    return itemstack;
  }
Пример #19
0
  public static ItemStack a(ItemStack var0, class_acd var1) {
    MinecraftKey var2 = (MinecraftKey) class_acd.a.getKey(var1);
    if (var2 != null) {
      NBTTagCompound var3 = var0.hasTag() ? var0.getTag() : new NBTTagCompound();
      var3.put("Potion", var2.toString());
      var0.setTag(var3);
    }

    return var0;
  }
Пример #20
0
 public boolean contentsMatch(int index, ItemStack is) {
   if (storage[index] != null
       && storage[index].getItem() == is.getItem()
       && storage[index].getItemDamage() == is.getItemDamage()
       && storage[index].stackSize < storage[index].getMaxStackSize()) {
     return true;
   } else {
     return false;
   }
 }
Пример #21
0
  /** Called whenever the block is removed. */
  @Override
  public void remove(World par1World, int par2, int par3, int par4) {
    if (!c) {
      TileEntityIronFurnace tileentityfurnace =
          (TileEntityIronFurnace) par1World.getTileEntity(par2, par3, par4);

      if (tileentityfurnace != null) {
        label0:
        for (int i = 0; i < tileentityfurnace.getSize(); i++) {
          ItemStack itemstack = tileentityfurnace.getItem(i);

          if (itemstack == null) {
            continue;
          }

          float f = a.nextFloat() * 0.8F + 0.1F;
          float f1 = a.nextFloat() * 0.8F + 0.1F;
          float f2 = a.nextFloat() * 0.8F + 0.1F;

          do {
            if (itemstack.count <= 0) {
              continue label0;
            }

            int j = a.nextInt(21) + 10;

            if (j > itemstack.count) {
              j = itemstack.count;
            }

            itemstack.count -= j;
            EntityItem entityitem =
                new EntityItem(
                    par1World,
                    par2 + f,
                    par3 + f1,
                    par4 + f2,
                    new ItemStack(itemstack.id, j, itemstack.getData()));

            if (itemstack.hasTag()) {
              entityitem.itemStack.setTag((NBTTagCompound) itemstack.getTag().clone());
            }

            float f3 = 0.05F;
            entityitem.motX = (float) a.nextGaussian() * f3;
            entityitem.motY = (float) a.nextGaussian() * f3 + 0.2F;
            entityitem.motZ = (float) a.nextGaussian() * f3;
            par1World.addEntity(entityitem);
          } while (true);
        }
      }
    }

    super.remove(par1World, par2, par3, par4);
  }
  public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
    EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
    double d0 = isourceblock.getX() + (double) enumfacing.c();
    double d1 = (double) ((float) isourceblock.getBlockY() + 0.2F);
    double d2 = isourceblock.getZ() + (double) enumfacing.e();

    // CraftBukkit start
    World world = isourceblock.k();
    ItemStack itemstack1 = itemstack.a(1);
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(
                isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
    CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);

    BlockDispenseEvent event =
        new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d0, d1, d2));
    if (!BlockDispenser.eventFired) {
      world.getServer().getPluginManager().callEvent(event);
    }

    if (event.isCancelled()) {
      itemstack.count++;
      return itemstack;
    }

    if (!event.getItem().equals(craftItem)) {
      itemstack.count++;
      // Chain to handler for new item
      ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
      IDispenseBehavior idispensebehavior =
          (IDispenseBehavior) BlockDispenser.a.a(eventStack.getItem());
      if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
        idispensebehavior.a(isourceblock, eventStack);
        return itemstack;
      }
    }

    itemstack1 = CraftItemStack.asNMSCopy(event.getItem());
    EntityFireworks entityfireworks =
        new EntityFireworks(
            isourceblock.k(),
            event.getVelocity().getX(),
            event.getVelocity().getY(),
            event.getVelocity().getZ(),
            itemstack1);

    isourceblock.k().addEntity(entityfireworks);
    // itemstack.a(1); // Handled during event processing
    // CraftBukkit end

    return itemstack;
  }
  public void a(DamageSource var1) {
    this.die();
    if (this.world.getGameRules().getBoolean("doEntityDrops")) {
      ItemStack var2 = new ItemStack(Items.MINECART, 1);
      if (this.b != null) {
        var2.c(this.b);
      }

      this.a(var2, 0.0F);
    }
  }
Пример #24
0
  @Override
  public int getAttackStrength(Entity par1Entity) {
    ItemStack var2 = this.getHeldItem();
    int var3 = TFC_MobDamage.PigZombieDamage;

    if (var2 != null) {
      var3 += var2.getDamageVsEntity(this);
    }

    return var3;
  }
Пример #25
0
  public ItemStack[] b(class_yg var1) {
    ItemStack[] var2 = new ItemStack[var1.getSize()];

    for (int var3 = 0; var3 < var2.length; ++var3) {
      ItemStack var4 = var1.getItem(var3);
      if (var4 != null && var4.getItem().r()) {
        var2[var3] = new ItemStack(var4.getItem().q());
      }
    }

    return var2;
  }
Пример #26
0
  public void e(Entity entity) {
    if (!entity.b(this)) {
      ItemStack itemstack = this.U();

      if (itemstack != null && entity instanceof EntityLiving) {
        itemstack.a((EntityLiving) entity);
        if (itemstack.count <= 0) {
          itemstack.a(this);
          this.V();
        }
      }
    }
  }
Пример #27
0
  public ItemStack[] b(InventoryCrafting inventorycrafting) {
    ItemStack[] aitemstack = new ItemStack[inventorycrafting.getSize()];

    for (int i = 0; i < aitemstack.length; ++i) {
      ItemStack itemstack = inventorycrafting.getItem(i);

      if (itemstack != null && itemstack.getItem().r()) {
        aitemstack[i] = new ItemStack(itemstack.getItem().q());
      }
    }

    return aitemstack;
  }
  public PacketPlayOutNamedEntitySpawn(EntityHuman entityhuman) {
    a = entityhuman.getId();
    b = entityhuman.getProfile();
    c = MathHelper.floor(entityhuman.locX * 32.0D);
    d = MathHelper.floor(entityhuman.locY * 32.0D);
    e = MathHelper.floor(entityhuman.locZ * 32.0D);
    f = (byte) (int) (entityhuman.yaw * 256.0F / 360.0F);
    g = (byte) (int) (entityhuman.pitch * 256.0F / 360.0F);
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    h = itemstack == null ? 0 : Item.getId(itemstack.getItem());
    i = entityhuman.getDataWatcher();
  }
Пример #29
0
  public ItemStack craft(InventoryCrafting inventorycrafting, World world) {
    int i = 0;
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;

    int j;

    for (j = 0; j < inventorycrafting.getSize(); ++j) {
      ItemStack itemstack2 = inventorycrafting.getItem(j);

      if (itemstack2 != null) {
        if (i == 0) {
          itemstack = itemstack2;
        }

        if (i == 1) {
          itemstack1 = itemstack2;
        }

        ++i;
      }
    }

    if (i == 2
        && itemstack.id == itemstack1.id
        && itemstack.count == 1
        && itemstack1.count == 1
        && Item.byId[itemstack.id].usesDurability()) {
      Item item = Item.byId[itemstack.id];
      int k = item.getMaxDurability() - itemstack.j();
      int l = item.getMaxDurability() - itemstack1.j();
      int i1 = k + l + item.getMaxDurability() * 5 / 100;
      int j1 = item.getMaxDurability() - i1;

      if (j1 < 0) {
        j1 = 0;
      }

      return new ItemStack(itemstack.id, 1, j1);
    } else {
      for (j = 0; j < this.recipes.size(); ++j) {
        IRecipe irecipe = (IRecipe) this.recipes.get(j);

        if (irecipe.a(inventorycrafting, world)) {
          return irecipe.a(inventorycrafting);
        }
      }

      return null;
    }
  }
Пример #30
0
  public ItemStack b(int i) {
    ItemStack itemstack = null;
    Slot slot = (Slot) this.b.get(i);

    if (slot != null && slot.d()) {
      ItemStack itemstack1 = slot.getItem();

      itemstack = itemstack1.cloneItemStack();
      if (i == 2) {
        if (!this.a(itemstack1, 3, 39, true)) {
          return null;
        }

        slot.a(itemstack1, itemstack);
      } else if (i != 1 && i != 0) {
        if (RecipesFurnace.getInstance().getResult(itemstack1.getItem().id) != null) {
          if (!this.a(itemstack1, 0, 1, false)) {
            return null;
          }
        } else if (TileEntityFurnace.isFuel(itemstack1)) {
          if (!this.a(itemstack1, 1, 2, false)) {
            return null;
          }
        } else if (i >= 3 && i < 30) {
          if (!this.a(itemstack1, 30, 39, false)) {
            return null;
          }
        } else if (i >= 30 && i < 39 && !this.a(itemstack1, 3, 30, false)) {
          return null;
        }
      } else if (!this.a(itemstack1, 3, 39, false)) {
        return null;
      }

      if (itemstack1.count == 0) {
        slot.set((ItemStack) null);
      } else {
        slot.e();
      }

      if (itemstack1.count == itemstack.count) {
        return null;
      }

      slot.b(itemstack1);
    }

    return itemstack;
  }