Beispiel #1
0
  public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
    int dir = world.getBlockMetadata(i, j, k);

    if (dir == 0) {
      if (!world.isBlockOpaqueCube(i, j, k + 1)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 1) {
      if (!world.isBlockOpaqueCube(i - 1, j, k)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 2) {
      if (!world.isBlockOpaqueCube(i, j, k - 1)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 3) {
      if (!world.isBlockOpaqueCube(i + 1, j, k)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    }
  }
 @Override
 public void updateTick(World world, int i, int j, int k, Random rand) {
   if (!world.isRemote) {
     if (!world.isBlockOpaqueCube(i, j - 1, k)) {
       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
           && world.getBlockId(i + 1, j, k + 1) != blockID
           && world.getBlockId(i + 1, j, k - 1) != blockID
           && world.getBlockId(i - 1, j, k + 1) != blockID
           && world.getBlockId(i - 1, j, k - 1) != blockID) {
         world.setBlock(i, j, k, 0);
       }
     }
   }
 }
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   boolean check = false;
   for (int h = -1; h <= 1; h++) {
     for (int g = -1; g <= 1; g++) {
       for (int f = -1; f <= 1; f++) {
         if (world.getBlockId(i + h, j + g, k + f) == blockID
             && world.getBlockMetadata(i + h, j + g, k + f) == world.getBlockMetadata(i, j, k)) {
           check = true;
         }
       }
     }
   }
   if (!check) {
     world.setBlock(i, j, k, 0);
   }
 }
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   boolean check = false;
   for (int h = -2; h <= 2; h++) {
     for (int g = -2; g <= 2; g++) {
       for (int f = -2; f <= 2; f++) {
         if (world.getBlockId(i + h, j + g, k + f) == blockID
             && world.getBlockMetadata(i + h, j + g, k + f) == world.getBlockMetadata(i, j, k)) {
           check = true;
         }
       }
     }
   }
   if (!check) {
     world.setBlock(i, j, k, 0);
     dropBlockAsItem_do(world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
   }
 }
  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));
      }
    }
  }