@Override
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
    ChunkCoordinates coord =
        getBase(par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
    if (par1World.getBlock(coord.posX, coord.posY, coord.posZ) != NailedBlocks.portalCrystal) {
      this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
      par1World.setBlockToAir(par2, par3, par4);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, block);
  }
 private int getMaxCurrentStrength(World world, int i, int j, int k, int l) {
   if (world.getBlockId(i, j, k) != blockID) {
     return l;
   }
   int i1 = world.getBlockMetadata(i, j, k);
   if (i1 > l) {
     return i1;
   } else {
     return l;
   }
 }
 private static void depolarize(World world, int i, int j, int k, List<ChunkCoordinates> blocks) {
   Block block = world.getBlock(i, j, k);
   if (isValidLinkPortalBlock(block) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) == 0) {
     return;
   }
   world.setBlockMetadataWithNotify(i, j, k, 0, 0);
   if ((block == NailedBlocks.portal) && (!BlockPortal.isValidPortal(world, i, j, k))) {
     world.setBlock(i, j, k, Blocks.air, 0, 2);
   }
   blocks.add(new ChunkCoordinates(i, j, k));
 }
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (world.multiplayerWorld) {
     return;
   }
   int i1 = world.getBlockMetadata(i, j, k);
   boolean flag = canPlaceBlockAt(world, i, j, k);
   if (!flag) {
     dropBlockAsItem(world, i, j, k, i1);
     world.setBlockWithNotify(i, j, k, 0);
   } else {
     updateAndPropagateCurrentStrength(world, i, j, k);
   }
   super.onNeighborBlockChange(world, i, j, k, l);
 }
  @Override
  public AxisAlignedBB getSelectedBoundingBoxFromPool(
      World par1World, int par2, int par3, int par4) {
    int i = par1World.getBlockMetadata(par2, par3, par4);
    float f = 0.375F;

    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    if (i == 0) {
      setBlockBounds(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 1) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    }

    if (i == 2) {
      setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
    }

    if (i == 3) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
    }

    if (i == 4) {
      setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 5) {
      setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
    }
    AxisAlignedBB box =
        AxisAlignedBB.getAABBPool()
            .getAABB(
                par2 + this.minX,
                par3 + this.minY,
                par4 + this.minZ,
                par2 + this.maxX,
                par3 + this.maxY,
                par4 + this.maxZ);
    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.375F);
    return box;
  }
 private static void directPortal(
     World world,
     int i,
     int j,
     int k,
     int meta,
     List<ChunkCoordinates> blocks,
     List<ChunkCoordinates> portals) {
   if (isValidLinkPortalBlock(world.getBlock(i, j, k)) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) != 0) {
     return;
   }
   world.setBlockMetadataWithNotify(i, j, k, meta, 0);
   if (world.getBlock(i, j, k) == NailedBlocks.portal) {
     portals.add(new ChunkCoordinates(i, j, k));
   } else {
     blocks.add(new ChunkCoordinates(i, j, k));
   }
 }
 public void randomDisplayTick(World world, int i, int j, int k, Random random) {
   int l = world.getBlockMetadata(i, j, k);
   if (l > 0) {
     double d = (double) i + 0.5D + ((double) random.nextFloat() - 0.5D) * 0.20000000000000001D;
     double d1 = (float) j + 0.0625F;
     double d2 = (double) k + 0.5D + ((double) random.nextFloat() - 0.5D) * 0.20000000000000001D;
     float f = (float) l / 15F;
     float f1 = f * 0.6F + 0.4F;
     if (l == 0) {
       f1 = 0.0F;
     }
     float f2 = f * f * 0.7F - 0.5F;
     float f3 = f * f * 0.6F - 0.7F;
     if (f2 < 0.0F) {
       f2 = 0.0F;
     }
     if (f3 < 0.0F) {
       f3 = 0.0F;
     }
     world.spawnParticle("reddust", d, d1, d2, f1, f2, f3);
   }
 }
  private void updateTileEntityOrientation(World world, int i, int j, int k) {
    TileEntityPortalController controller =
        (TileEntityPortalController) world.getTileEntity(i, j, k);
    int metadata = world.getBlockMetadata(i, j, k);

    if (metadata == 1) {
      controller.pitch = -90;
      controller.yaw = -90;
      /*}else if(metadata == 1){
      controller.pitch = 90;
      controller.yaw = -90;*/
    } else if (metadata == 2) {
      controller.yaw = 270;
    } else if (metadata == 3) {
      controller.yaw = 90;
    } else if (metadata == 4) {
      controller.yaw = 0;
    } else if (metadata == 5) {
      controller.yaw = 180;
    }

    controller.markDirty();
  }
 private static void redirectPortal(
     World world,
     TileEntity tileentity,
     int i,
     int j,
     int k,
     int meta,
     List<ChunkCoordinates> blocks) {
   if (isValidLinkPortalBlock(world.getBlock(i, j, k)) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) == meta) {
     for (int m = 1; m < 7; m++) {
       if (m != meta) {
         world.setBlockMetadataWithNotify(i, j, k, m, 2);
         TileEntity local = getTileEntity(world, i, j, k);
         if ((local == tileentity) || ((local != null) && (tileentity == null))) {
           return;
         }
       }
     }
     world.setBlockMetadataWithNotify(i, j, k, 0, 2);
   }
 }
 public static void fire(World world, int i, int j, int k) {
   ChunkCoordinates coord = getBase(i, j, k, world.getBlockMetadata(i, j, k));
   onpulse(world, coord.posX, coord.posY, coord.posZ);
   pathto(world, i, j, k);
 }
  public void setPowerStateMetadata(World world, int i, int j, int k, int powerState) {
    int savePositionId = world.getBlockMetadata(i, j, k) & directionMask;

    world.setBlockMetadataWithNotify(i, j, k, savePositionId + powerState);
  }
 public int getPositionMetadata(World world, int i, int j, int k) {
   return world.getBlockMetadata(i, j, k) & directionMask;
 }
  public void setPositionMetadata(World world, int i, int j, int k, int positionValue) {
    int saveBlockId = world.getBlockMetadata(i, j, k) & 8;

    world.setBlockMetadataWithNotify(i, j, k, positionValue + saveBlockId);
  }
 public int getPowerStateMetadata(World world, int i, int j, int k) {
   return world.getBlockMetadata(i, j, k) & stateMask;
 }
  private void func_21030_a(World world, int i, int j, int k, int l, int i1, int j1) {
    int k1 = world.getBlockMetadata(i, j, k);
    int l1 = 0;
    wiresProvidePower = false;
    boolean flag = world.isBlockIndirectlyGettingPowered(i, j, k);
    wiresProvidePower = true;
    if (flag) {
      l1 = 15;
    } else {
      for (int i2 = 0; i2 < 4; i2++) {
        int k2 = i;
        int i3 = k;
        if (i2 == 0) {
          k2--;
        }
        if (i2 == 1) {
          k2++;
        }
        if (i2 == 2) {
          i3--;
        }
        if (i2 == 3) {
          i3++;
        }
        if (k2 != l || j != i1 || i3 != j1) {
          l1 = getMaxCurrentStrength(world, k2, j, i3, l1);
        }
        if (world.isBlockOpaqueCube(k2, j, i3) && !world.isBlockOpaqueCube(i, j + 1, k)) {
          if (k2 != l || j + 1 != i1 || i3 != j1) {
            l1 = getMaxCurrentStrength(world, k2, j + 1, i3, l1);
          }
          continue;
        }
        if (!world.isBlockOpaqueCube(k2, j, i3) && (k2 != l || j - 1 != i1 || i3 != j1)) {
          l1 = getMaxCurrentStrength(world, k2, j - 1, i3, l1);
        }
      }

      if (l1 > 0) {
        l1--;
      } else {
        l1 = 0;
      }
    }
    if (k1 != l1) {
      world.field_1043_h = true;
      world.setBlockMetadataWithNotify(i, j, k, l1);
      world.markBlocksDirty(i, j, k, i, j, k);
      world.field_1043_h = false;
      for (int j2 = 0; j2 < 4; j2++) {
        int l2 = i;
        int j3 = k;
        int k3 = j - 1;
        if (j2 == 0) {
          l2--;
        }
        if (j2 == 1) {
          l2++;
        }
        if (j2 == 2) {
          j3--;
        }
        if (j2 == 3) {
          j3++;
        }
        if (world.isBlockOpaqueCube(l2, j, j3)) {
          k3 += 2;
        }
        int l3 = 0;
        l3 = getMaxCurrentStrength(world, l2, j, j3, -1);
        l1 = world.getBlockMetadata(i, j, k);
        if (l1 > 0) {
          l1--;
        }
        if (l3 >= 0 && l3 != l1) {
          func_21030_a(world, l2, j, j3, i, j, k);
        }
        l3 = getMaxCurrentStrength(world, l2, k3, j3, -1);
        l1 = world.getBlockMetadata(i, j, k);
        if (l1 > 0) {
          l1--;
        }
        if (l3 >= 0 && l3 != l1) {
          func_21030_a(world, l2, k3, j3, i, j, k);
        }
      }

      if (k1 == 0 || l1 == 0) {
        field_21031_b.add(new ChunkPosition(i, j, k));
        field_21031_b.add(new ChunkPosition(i - 1, j, k));
        field_21031_b.add(new ChunkPosition(i + 1, j, k));
        field_21031_b.add(new ChunkPosition(i, j - 1, k));
        field_21031_b.add(new ChunkPosition(i, j + 1, k));
        field_21031_b.add(new ChunkPosition(i, j, k - 1));
        field_21031_b.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }