/**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 @Override
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (!par1World.isBlockNormalCube(par2, par3 - 1, par4)
       && !canNeighborBurn(par1World, par2, par3, par4)) {
     par1World.setBlockWithNotify(par2, par3, par4, 0);
     return;
   } else {
     return;
   }
 }
Ejemplo n.º 2
0
  /** ejects contained items into the world, and notifies neighbours of an update, as appropriate */
  public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
    super.breakBlock(par1World, par2, par3, par4, par5, par6);

    if (!par1World.isRemote) {
      par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID);
      this.updateAndPropagateCurrentStrength(par1World, par2, par3, par4);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3, par4);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3, par4);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 - 1);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 + 1);

      if (par1World.isBlockNormalCube(par2 - 1, par3, par4)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 + 1, par4);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 - 1, par4);
      }

      if (par1World.isBlockNormalCube(par2 + 1, par3, par4)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 + 1, par4);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 - 1, par4);
      }

      if (par1World.isBlockNormalCube(par2, par3, par4 - 1)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 - 1);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 - 1);
      }

      if (par1World.isBlockNormalCube(par2, par3, par4 + 1)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 + 1);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 + 1);
      }
    }
  }
Ejemplo n.º 3
0
 public static boolean isWestSolid(World world, int x, int y, int z) {
   if (world.isBlockNormalCube(x + 1, y, z)) {
     return true;
   } else if (world.getBlockId(x + 1, y, z) == TFCBlocks.stoneSlabs.blockID) {
     TileEntityPartial te = (TileEntityPartial) world.getBlockTileEntity(x + 1, y, z);
     if (BlockSlab.getWestChiselLevel(te.extraData) != 0) {
       return false;
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 4
0
 /** Ticks the block if it's been scheduled */
 public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   super.updateTick(par1World, par2, par3, par4, par5Random);
   if (par1World.provider.isSurfaceWorld()
       && par5Random.nextInt(2000) < par1World.difficultySetting) {
     int l;
     for (l = par3; !par1World.doesBlockHaveSolidTopSurface(par2, l, par4) && l > 0; --l) {;
     }
     if (l > 0 && !par1World.isBlockNormalCube(par2, l + 1, par4)) {
       Entity entity =
           ItemMonsterPlacer.spawnCreature(
               par1World, 57, (double) par2 + 0.5D, (double) l + 1.1D, (double) par4 + 0.5D);
       if (entity != null) {
         entity.timeUntilPortal = entity.getPortalCooldown();
       }
     }
   }
 }
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  @Override
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    if (par1World.worldProvider.worldType <= 0
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.obsidian.blockID
        && ((BlockPortal) Block.portal).tryToCreatePortal(par1World, par2, par3, par4)) {
      return;
    }

    if (!par1World.isBlockNormalCube(par2, par3 - 1, par4)
        && !canNeighborBurn(par1World, par2, par3, par4)) {
      par1World.setBlockWithNotify(par2, par3, par4, 0);
      return;
    } else {
      par1World.scheduleBlockUpdate(
          par2, par3, par4, blockID, tickRate() + par1World.rand.nextInt(10));
      return;
    }
  }
Ejemplo n.º 6
0
  private void calculateCurrentChanges(
      World par1World, int par2, int par3, int par4, int par5, int par6, int par7) {
    int var8 = par1World.getBlockMetadata(par2, par3, par4);
    int var9 = 0;
    this.wiresProvidePower = false;
    boolean var10 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
    this.wiresProvidePower = true;
    int var11;
    int var12;
    int var13;

    if (var10) {
      var9 = 15;
    } else {
      for (var11 = 0; var11 < 4; ++var11) {
        var12 = par2;
        var13 = par4;

        if (var11 == 0) {
          var12 = par2 - 1;
        }

        if (var11 == 1) {
          ++var12;
        }

        if (var11 == 2) {
          var13 = par4 - 1;
        }

        if (var11 == 3) {
          ++var13;
        }

        if (var12 != par5 || par3 != par6 || var13 != par7) {
          var9 = this.getMaxCurrentStrength(par1World, var12, par3, var13, var9);
        }

        if (par1World.isBlockNormalCube(var12, par3, var13)
            && !par1World.isBlockNormalCube(par2, par3 + 1, par4)) {
          if (var12 != par5 || par3 + 1 != par6 || var13 != par7) {
            var9 = this.getMaxCurrentStrength(par1World, var12, par3 + 1, var13, var9);
          }
        } else if (!par1World.isBlockNormalCube(var12, par3, var13)
            && (var12 != par5 || par3 - 1 != par6 || var13 != par7)) {
          var9 = this.getMaxCurrentStrength(par1World, var12, par3 - 1, var13, var9);
        }
      }

      if (var9 > 0) {
        --var9;
      } else {
        var9 = 0;
      }
    }

    if (var8 != var9) {
      par1World.editingBlocks = true;
      par1World.setBlockMetadataWithNotify(par2, par3, par4, var9);
      par1World.markBlockRangeForRenderUpdate(par2, par3, par4, par2, par3, par4);
      par1World.editingBlocks = false;

      for (var11 = 0; var11 < 4; ++var11) {
        var12 = par2;
        var13 = par4;
        int var14 = par3 - 1;

        if (var11 == 0) {
          var12 = par2 - 1;
        }

        if (var11 == 1) {
          ++var12;
        }

        if (var11 == 2) {
          var13 = par4 - 1;
        }

        if (var11 == 3) {
          ++var13;
        }

        if (par1World.isBlockNormalCube(var12, par3, var13)) {
          var14 += 2;
        }

        boolean var15 = false;
        int var16 = this.getMaxCurrentStrength(par1World, var12, par3, var13, -1);
        var9 = par1World.getBlockMetadata(par2, par3, par4);

        if (var9 > 0) {
          --var9;
        }

        if (var16 >= 0 && var16 != var9) {
          this.calculateCurrentChanges(par1World, var12, par3, var13, par2, par3, par4);
        }

        var16 = this.getMaxCurrentStrength(par1World, var12, var14, var13, -1);
        var9 = par1World.getBlockMetadata(par2, par3, par4);

        if (var9 > 0) {
          --var9;
        }

        if (var16 >= 0 && var16 != var9) {
          this.calculateCurrentChanges(par1World, var12, var14, var13, par2, par3, par4);
        }
      }

      if (var8 < var9 || var9 == 0) {
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2 - 1, par3, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2 + 1, par3, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 - 1, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3 + 1, par4));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 - 1));
        this.blocksNeedingUpdate.add(new ChunkPosition(par2, par3, par4 + 1));
      }
    }
  }
  /** Ticks the block if it's been scheduled */
  @Override
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    boolean flag = par1World.getBlockId(par2, par3 - 1, par4) == Block.netherrack.blockID;

    if ((par1World.worldProvider instanceof WorldProviderEnd)
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.bedrock.blockID) {
      flag = true;
    }

    if (!canPlaceBlockAt(par1World, par2, par3, par4)) {
      par1World.setBlockWithNotify(par2, par3, par4, 0);
    }

    if (!flag
        && par1World.isRaining()
        && (par1World.canLightningStrikeAt(par2, par3, par4)
            || par1World.canLightningStrikeAt(par2 - 1, par3, par4)
            || par1World.canLightningStrikeAt(par2 + 1, par3, par4)
            || par1World.canLightningStrikeAt(par2, par3, par4 - 1)
            || par1World.canLightningStrikeAt(par2, par3, par4 + 1))) {
      par1World.setBlockWithNotify(par2, par3, par4, 0);
      return;
    }

    int i = par1World.getBlockMetadata(par2, par3, par4);

    if (i < 15) {
      par1World.setBlockMetadata(par2, par3, par4, i + par5Random.nextInt(3) / 2);
    }

    par1World.scheduleBlockUpdate(par2, par3, par4, blockID, tickRate() + par5Random.nextInt(10));

    if (!flag && !canNeighborBurn(par1World, par2, par3, par4)) {
      if (!par1World.isBlockNormalCube(par2, par3 - 1, par4) || i > 3) {
        par1World.setBlockWithNotify(par2, par3, par4, 0);
      }

      return;
    }

    if (!flag
        && !canBlockCatchFire(par1World, par2, par3 - 1, par4)
        && i == 15
        && par5Random.nextInt(4) == 0) {
      par1World.setBlockWithNotify(par2, par3, par4, 0);
      return;
    }

    boolean flag1 = par1World.isBlockHighHumidity(par2, par3, par4);
    byte byte0 = 0;

    if (flag1) {
      byte0 = -50;
    }

    tryToCatchBlockOnFire(par1World, par2 + 1, par3, par4, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2 - 1, par3, par4, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3 - 1, par4, 250 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3 + 1, par4, 250 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3, par4 - 1, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3, par4 + 1, 300 + byte0, par5Random, i);

    for (int j = par2 - 1; j <= par2 + 1; j++) {
      for (int k = par4 - 1; k <= par4 + 1; k++) {
        for (int l = par3 - 1; l <= par3 + 4; l++) {
          if (j == par2 && l == par3 && k == par4) {
            continue;
          }

          int i1 = 100;

          if (l > par3 + 1) {
            i1 += (l - (par3 + 1)) * 100;
          }

          int j1 = getChanceOfNeighborsEncouragingFire(par1World, j, l, k);

          if (j1 <= 0) {
            continue;
          }

          int k1 = (j1 + 40) / (i + 30);

          if (flag1) {
            k1 /= 2;
          }

          if (k1 <= 0
              || par5Random.nextInt(i1) > k1
              || par1World.isRaining() && par1World.canLightningStrikeAt(j, l, k)
              || par1World.canLightningStrikeAt(j - 1, l, par4)
              || par1World.canLightningStrikeAt(j + 1, l, k)
              || par1World.canLightningStrikeAt(j, l, k - 1)
              || par1World.canLightningStrikeAt(j, l, k + 1)) {
            continue;
          }

          int l1 = i + par5Random.nextInt(5) / 4;

          if (l1 > 15) {
            l1 = 15;
          }

          par1World.setBlockAndMetadataWithNotify(j, l, k, blockID, l1);
        }
      }
    }
  }
  /** A randomly called display update to be able to add particles or other items for display */
  @Override
  public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (par5Random.nextInt(24) == 0) {
      par1World.playSoundEffect(
          (float) par2 + 0.5F,
          (float) par3 + 0.5F,
          (float) par4 + 0.5F,
          "fire.fire",
          1.0F + par5Random.nextFloat(),
          par5Random.nextFloat() * 0.7F + 0.3F);
    }

    if (par1World.isBlockNormalCube(par2, par3 - 1, par4)
        || ((BlockFire) Block.fire).canBlockCatchFire(par1World, par2, par3 - 1, par4)) {
      for (int i = 0; i < 3; i++) {
        float f = (float) par2 + par5Random.nextFloat();
        float f6 = (float) par3 + par5Random.nextFloat() * 0.5F + 0.5F;
        float f12 = (float) par4 + par5Random.nextFloat();
        par1World.spawnParticle("largesmoke", f, f6, f12, 0.0D, 0.0D, 0.0D);
      }
    } else {
      if (((BlockFire) Block.fire).canBlockCatchFire(par1World, par2 - 1, par3, par4)) {
        for (int j = 0; j < 2; j++) {
          float f1 = (float) par2 + par5Random.nextFloat() * 0.1F;
          float f7 = (float) par3 + par5Random.nextFloat();
          float f13 = (float) par4 + par5Random.nextFloat();
          par1World.spawnParticle("largesmoke", f1, f7, f13, 0.0D, 0.0D, 0.0D);
        }
      }

      if (((BlockFire) Block.fire).canBlockCatchFire(par1World, par2 + 1, par3, par4)) {
        for (int k = 0; k < 2; k++) {
          float f2 = (float) (par2 + 1) - par5Random.nextFloat() * 0.1F;
          float f8 = (float) par3 + par5Random.nextFloat();
          float f14 = (float) par4 + par5Random.nextFloat();
          par1World.spawnParticle("largesmoke", f2, f8, f14, 0.0D, 0.0D, 0.0D);
        }
      }

      if (((BlockFire) Block.fire).canBlockCatchFire(par1World, par2, par3, par4 - 1)) {
        for (int l = 0; l < 2; l++) {
          float f3 = (float) par2 + par5Random.nextFloat();
          float f9 = (float) par3 + par5Random.nextFloat();
          float f15 = (float) par4 + par5Random.nextFloat() * 0.1F;
          par1World.spawnParticle("largesmoke", f3, f9, f15, 0.0D, 0.0D, 0.0D);
        }
      }

      if (((BlockFire) Block.fire).canBlockCatchFire(par1World, par2, par3, par4 + 1)) {
        for (int i1 = 0; i1 < 2; i1++) {
          float f4 = (float) par2 + par5Random.nextFloat();
          float f10 = (float) par3 + par5Random.nextFloat();
          float f16 = (float) (par4 + 1) - par5Random.nextFloat() * 0.1F;
          par1World.spawnParticle("largesmoke", f4, f10, f16, 0.0D, 0.0D, 0.0D);
        }
      }

      if (((BlockFire) Block.fire).canBlockCatchFire(par1World, par2, par3 + 1, par4)) {
        for (int j1 = 0; j1 < 2; j1++) {
          float f5 = (float) par2 + par5Random.nextFloat();
          float f11 = (float) (par3 + 1) - par5Random.nextFloat() * 0.1F;
          float f17 = (float) par4 + par5Random.nextFloat();
          par1World.spawnParticle("largesmoke", f5, f11, f17, 0.0D, 0.0D, 0.0D);
        }
      }
    }
  }
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 @Override
 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
   return par1World.isBlockNormalCube(par2, par3 - 1, par4)
       || canNeighborBurn(par1World, par2, par3, par4);
 }