Пример #1
0
  private void dropBlocks(World world, int x, int y, int z) {
    Block drop = world.getBlock(x, y, z);
    if (drop == Blocks.air) return;
    int dropmeta = world.getBlockMetadata(x, y, z);
    ItemStack sapling = tree.getSapling();
    Block logID = tree.getTreeType().getLogID();

    Collection<ItemStack> drops = this.getDrops(world, x, y, z, drop, dropmeta);
    if (drop == logID && logID != null) {
      if (rand.nextInt(3) == 0) {
        drops.add(
            ReikaItemHelper.getSizedItemStack(ItemStacks.sawdust.copy(), 1 + rand.nextInt(4)));
      }
    }

    for (ItemStack todrop : drops) {
      if (ReikaItemHelper.matchStacks(todrop, sapling)) {
        if (inv[0] != null && inv[0].stackSize >= inv[0].getMaxStackSize()) {
          if (!this.chestCheck(todrop))
            ReikaItemHelper.dropItem(world, dropx, yCoord - 0.25, dropz, todrop);
        } else ReikaInventoryHelper.addOrSetStack(todrop, inv, 0);
      } else {
        if (!this.chestCheck(todrop))
          ReikaItemHelper.dropItem(world, dropx, yCoord - 0.25, dropz, todrop);
      }
    }
  }
Пример #2
0
 public ItemStack getPlantedSapling() {
   if (!this.shouldPlantSapling()) return null;
   if (treeCopy.isDyeTree())
     return new ItemStack(TreeGetter.getSaplingID(), 1, treeCopy.getDyeTreeMeta());
   else if (treeCopy.getTreeType() != null) return treeCopy.getSapling();
   else return null;
 }
Пример #3
0
 private void checkAndMatchInventory() {
   ItemStack sapling = null;
   if (tree.isDyeTree()) {
     sapling = new ItemStack(TreeGetter.getSaplingID(), 1, tree.getDyeTreeMeta());
   } else if (tree.getTreeType() != null) {
     sapling = tree.getSapling();
   }
   if (!ReikaItemHelper.matchStacks(inv[0], sapling)) {
     this.dumpInventory();
   }
 }
Пример #4
0
 private boolean shouldPlantSapling() {
   if (this.hasEnchantment(Enchantment.infinity)) return true;
   if (treeCopy.isDyeTree()) {
     return inv[0] != null
         && inv[0].stackSize > 0
         && Block.getBlockFromItem(inv[0].getItem()) == TreeGetter.getSaplingID();
   } else if (treeCopy.getTreeType() != null) {
     return inv[0] != null
         && inv[0].stackSize > 0
         && ReikaItemHelper.matchStacks(inv[0], treeCopy.getSapling());
   } else return false;
 }