Esempio n. 1
0
 @Override
 public void onBlockRemoval(World world, int i, int j, int k) {
   int l = world.getBlockMetadata(i, j, k);
   if (l > 0) {
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
   }
   super.onBlockRemoval(world, i, j, k);
 }
  public static void notifyNeighbors(World world, int i, int j, int k) {

    for (int l = 0; l < 6; l++) {
      world.notifyBlocksOfNeighborChange(i, j, k, l);
      world.notifyBlocksOfNeighborChange(i - 1, j, k, l);
      world.notifyBlocksOfNeighborChange(i + 1, j, k, l);
      world.notifyBlocksOfNeighborChange(i, j - 1, k, l);
      world.notifyBlocksOfNeighborChange(i, j + 1, k, l);
      world.notifyBlocksOfNeighborChange(i, j, k - 1, l);
      world.notifyBlocksOfNeighborChange(i, j, k + 1, l);
    }
  }
Esempio n. 3
0
 @Override
 public boolean onItemUseFirst(
     ItemStack stack, EntityPlayer player, World world, int X, int Y, int Z, int side) {
   TileEntity te = world.getBlockTileEntity(X, Y, Z);
   if (te != null && te instanceof TileEntityIronChest) {
     TileEntityIronChest ironchest = (TileEntityIronChest) te;
     TileEntityIronChest newchest = ironchest.applyUpgradeItem(this);
     if (newchest == null) {
       return false;
     }
     world.setBlockTileEntity(X, Y, Z, newchest);
     world.setBlockMetadataWithNotify(X, Y, Z, newchest.getType().ordinal());
     world.notifyBlocksOfNeighborChange(X, Y, Z, world.getBlockId(X, Y, Z));
     world.markBlockNeedsUpdate(X, Y, Z);
     stack.stackSize = 0;
     return true;
   } else {
     return false;
   }
 }
  @Override
  public boolean onBlockActivated(
      World world,
      int i,
      int j,
      int k,
      EntityPlayer entityplayer,
      int something1,
      float something2,
      float something3,
      float something4) {
    if (world.isRemote) {
      return true;
    }

    TileEntityCamoFull entity = (TileEntityCamoFull) world.getBlockTileEntity(i, j, k);
    System.out.println("ACTIVATED: " + entity.getCopyID());

    int l = world.getBlockMetadata(i, j, k);
    int i1 = l & 7;
    int j1 = 8 - (l & 8);
    world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    world.markBlocksDirty(i, j, k, i, j, k);
    world.playSoundEffect(
        (double) i + 0.5D,
        (double) j + 0.5D,
        (double) k + 0.5D,
        "random.click",
        0.3F,
        j1 <= 0 ? 0.5F : 0.6F);
    world.notifyBlocksOfNeighborChange(i, j, k, blockID);
    world.markBlockNeedsUpdate(i, j, k);

    if (i1 == 1) {
      world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
    } else if (i1 == 2) {
      world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
    } else if (i1 == 3) {
      world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
    } else if (i1 == 4) {
      world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
    } else {
      world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
    }

    return true;
  }
  @Override
  public void breakBlock(World world, int i, int j, int k, int something, int metadata) {

    if ((metadata & 8) > 0) {
      world.notifyBlocksOfNeighborChange(i, j, k, blockID);
      int i1 = metadata & 7;

      if (i1 == 1) {
        world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
      } else if (i1 == 2) {
        world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
      } else if (i1 == 3) {
        world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
      } else if (i1 == 4) {
        world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
      } else {
        world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
      }
    }

    super.breakBlock(world, i, j, k, something, metadata);
  }
  /** Ticks the block if it's been scheduled */
  @Override
  public void updateTick(
      final World par1World,
      final int par2,
      final int par3,
      final int par4,
      final Random par5Random) {
    int var6 = this.getFlowDecay(par1World, par2, par3, par4);
    byte var7 = 1;

    if ((this.blockMaterial == Material.lava) && !par1World.provider.isHellWorld) {
      var7 = 2;
    }

    boolean var8 = true;
    int var10;

    if (var6 > 0) {
      final byte var9 = -100;
      this.numAdjacentSources = 0;
      int var12 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var9);
      var12 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var12);
      var10 = var12 + var7;

      if ((var10 >= 8) || (var12 < 0)) {
        var10 = -1;
      }

      if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) {
        final int var11 = this.getFlowDecay(par1World, par2, par3 + 1, par4);

        if (var11 >= 8) {
          var10 = var11;
        } else {
          var10 = var11 + 8;
        }
      }

      if ((this.numAdjacentSources >= 2) && (this.blockMaterial == Material.water)) {
        if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) {
          var10 = 0;
        } else if ((par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial)
            && (par1World.getBlockMetadata(par2, par3, par4) == 0)) {
          var10 = 0;
        }
      }

      if ((this.blockMaterial == Material.lava)
          && (var6 < 8)
          && (var10 < 8)
          && (var10 > var6)
          && (par5Random.nextInt(4) != 0)) {
        var10 = var6;
        var8 = false;
      }

      if (var10 == var6) {
        if (var8) {
          this.updateFlow(par1World, par2, par3, par4);
        }
      } else {
        var6 = var10;

        if (var10 < 0) {
          par1World.setBlockWithNotify(par2, par3, par4, 0);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
          par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
        }
      }
    } else {
      this.updateFlow(par1World, par2, par3, par4);
    }

    if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) {
      if ((this.blockMaterial == Material.lava)
          && (par1World.getBlockMaterial(par2, par3 - 1, par4) == Material.water)) {
        par1World.setBlockWithNotify(par2, par3 - 1, par4, Block.stone.blockID);
        this.triggerLavaMixEffects(par1World, par2, par3 - 1, par4);
        return;
      }

      if (var6 >= 8) {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6);
      } else {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6 + 8);
      }
    } else if ((var6 >= 0)
        && ((var6 == 0) || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) {
      final boolean[] var13 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var10 = var6 + var7;

      if (var6 >= 8) {
        var10 = 1;
      }

      if (var10 >= 8) {
        return;
      }

      if (var13[0]) {
        this.flowIntoBlock(par1World, par2 - 1, par3, par4, var10);
      }

      if (var13[1]) {
        this.flowIntoBlock(par1World, par2 + 1, par3, par4, var10);
      }

      if (var13[2]) {
        this.flowIntoBlock(par1World, par2, par3, par4 - 1, var10);
      }

      if (var13[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var10);
      }
    }
  }