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;
 }
Example #2
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;
  }
 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;
   }
 }
  @Override
  public int getAttackStrength(Entity par1Entity) {
    ItemStack var2 = this.getHeldItem();
    int var3 = TFC_MobDamage.PigZombieDamage;

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

    return var3;
  }
 @Override
 public void setInventorySlotContents(int i, ItemStack itemstack) {
   metalItemStacks[i] = itemstack;
   if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) {
     itemstack.stackSize = getInventoryStackLimit();
   }
 }
 public void readFromNBT(NBTTagCompound nbttagcompound) {
   super.readFromNBT(nbttagcompound);
   woodType = nbttagcompound.getByte("woodType");
   NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
   storage = new ItemStack[getSizeInventory()];
   for (int i = 0; i < nbttaglist.tagCount(); i++) {
     NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
     byte byte0 = nbttagcompound1.getByte("Slot");
     if (byte0 >= 0 && byte0 < storage.length) {
       storage[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
     }
   }
 }
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    // timeleft = nbttagcompound.getInteger("timeleft");

    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    metalItemStacks = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      byte byte0 = nbttagcompound1.getByte("Slot");
      if (byte0 >= 0 && byte0 < metalItemStacks.length) {
        metalItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
  }
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure the player has the correct tool out
    boolean isAxeorSaw = false;
    boolean isHammer = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (!world.isRemote) {
      if (equip != null) {
        for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Axes[cnt]) {
            isAxeorSaw = true;
            if (cnt < 4) isStone = true;
          }
        }
        //				for(int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++)
        //				{
        //					if(equip.getItem() == Recipes.Saws[cnt])
        //					{
        //						isAxeorSaw = true;
        //					}
        //				}
        for (int cnt = 0; cnt < Recipes.Hammers.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Hammers[cnt]) {
            isHammer = true;
          }
        }
      }
      if (isAxeorSaw) {
        damage = -1;
        ProcessTree(world, i, j, k, l, equip);

        if (damage + equip.getItemDamage() > equip.getMaxDamage()) {
          int ind = entityplayer.inventory.currentItem;
          entityplayer.inventory.setInventorySlotContents(ind, null);
          world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
        } else {
          equip.damageItem(damage, entityplayer);
        }
      } else if (isHammer) {
        EntityItem item =
            new EntityItem(
                world,
                i + 0.5,
                j + 0.5,
                k + 0.5,
                new ItemStack(Item.stick, 1 + world.rand.nextInt(3)));
        world.spawnEntityInWorld(item);
      } else {
        world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
      }
    }
  }
  private void scanLogs(
      World world,
      int i,
      int j,
      int k,
      int l,
      boolean[][][] checkArray,
      int x,
      int y,
      int z,
      ItemStack stack) {
    if (y >= 0) {
      checkArray[x][y][z] = true;
      int offsetX = 0;
      int offsetY = 0;
      int offsetZ = 0;

      for (offsetY = 0; offsetY <= 1; offsetY++) {
        for (offsetX = -2; offsetX <= 2; offsetX++) {
          for (offsetZ = -2; offsetZ <= 2; offsetZ++) {
            if (x + offsetX < 11
                && x + offsetX >= 0
                && z + offsetZ < 11
                && z + offsetZ >= 0
                && y + offsetY < 50
                && y + offsetY >= 0) {
              if (checkOut(world, i + offsetX, j + offsetY, k + offsetZ, l)
                  && !checkArray[x + offsetX][y + offsetY][z + offsetZ]) {
                scanLogs(
                    world,
                    i + offsetX,
                    j + offsetY,
                    k + offsetZ,
                    l,
                    checkArray,
                    x + offsetX,
                    y + offsetY,
                    z + offsetZ,
                    stack);
              }
            }
          }
        }
      }

      damage++;
      if (stack != null) {
        if (damage + stack.getItemDamage() <= stack.getMaxDamage()) {
          world.setBlock(i, j, k, 0);
          world.markBlockForUpdate(i, j, k);
          if ((isStone && world.rand.nextInt(10) != 0) || !isStone)
            dropBlockAsItem_do(
                world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
        }
      } else {
        world.setBlock(i, j, k, 0);
        world.markBlockForUpdate(i, j, k);
        dropBlockAsItem_do(
            world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
      }
    }
  }
Example #10
0
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure teh palyer has the correct tool out
    boolean isAxeorSaw = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (equip != null) {
      for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
        if (equip.getItem() == Recipes.Axes[cnt]) {
          isAxeorSaw = true;
        }
      }
      for (int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++) {
        if (equip.getItem() == Recipes.Saws[cnt]) {
          isAxeorSaw = true;
        }
      }
    }
    if (isAxeorSaw) {
      int x = i;
      int y = 0;
      int z = k;
      int count = 0;

      if (world.getBlockId(i, j + 1, k) == blockID || world.getBlockId(i, j - 1, k) == blockID) {
        // super.harvestBlock(world, entityplayer, i, j, k, l);
        boolean checkArray[][][] = new boolean[11][50][11];

        if (TFC_Core.isGrass(world.getBlockId(i, j + y - 1, k))
            || TFC_Core.isDirt(world.getBlockId(i, j + y - 1, k))) {
          boolean reachedTop = false;
          while (!reachedTop) {
            if (l != 9 && l != 15 && world.getBlockId(x, j + y + 1, z) == 0) {
              reachedTop = true;
            } else if ((l == 9 || l == 15)
                && world.getBlockId(x, j + y + 1, z) == 0
                && world.getBlockId(x + 1, j + y + 1, z) != blockID
                && world.getBlockId(x - 1, j + y + 1, z) != blockID
                && world.getBlockId(x, j + y + 1, z + 1) != blockID
                && world.getBlockId(x, j + y + 1, z - 1) != blockID
                && world.getBlockId(x - 1, j + y + 1, z - 1) != blockID
                && world.getBlockId(x - 1, j + y + 1, z + 1) != blockID
                && world.getBlockId(x + 1, j + y + 1, z + 1) != blockID
                && world.getBlockId(x + 1, j + y + 1, z - 1) != blockID) {
              reachedTop = true;
            }

            scanLogs(world, i, j + y, k, l, checkArray, 6, y, 6);

            y++;
          }
        }
      } else if (world.getBlockId(i + 1, j, k) == blockID
          || world.getBlockId(i - 1, j, k) == blockID
          || world.getBlockId(i, j, k + 1) == blockID
          || world.getBlockId(i, j, k - 1) == blockID) {
        Random R = new Random();
        if (R.nextInt(100) > 50 && isAxeorSaw) {
          dropBlockAsItem_do(world, i, j, k, new ItemStack(TFCItems.FruitTreeSapling1, 1, l));
        }
      }
    } else {
      world.setBlockAndMetadata(i, j, k, blockID, l);
    }
  }