Exemplo n.º 1
0
 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);
 }
 /** Called whenever the block is added into the world. Args: world, x, y, z */
 public void onBlockAdded(World par1World, int par2, int par3, int par4) {
   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);
   par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
   par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
 }
Exemplo n.º 3
0
 /**
  * Calls World.notifyBlocksOfNeighborChange() for all neighboring blocks, but only if the given
  * block is a redstone wire.
  */
 private void notifyWireNeighborsOfNeighborChange(World par1World, int par2, int par3, int par4) {
   if (par1World.getBlockId(par2, par3, par4) == this.blockID) {
     par1World.notifyBlocksOfNeighborChange(par2, par3, 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);
     par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
   }
 }
Exemplo n.º 4
0
  /** Called right before the block is destroyed by a player. Args: world, x, y, z, metaData */
  public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {
    if (this.isRepeaterPowered) {
      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);
      par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
    }

    super.onBlockDestroyedByPlayer(par1World, par2, par3, par4, par5);
  }
 private void notifyWireNeighborsOfNeighborChange(World world, int i, int j, int k) {
   if (world.getBlockId(i, j, k) != blockID) {
     return;
   } else {
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
     world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
     return;
   }
 }
Exemplo n.º 6
0
  public static void placeDoorBlock(
      World par0World, int par1, int par2, int par3, int par4, Block par5Block) {
    byte byte0 = 0;
    byte byte1 = 0;

    if (par4 == 0) {
      byte1 = 1;
    }

    if (par4 == 1) {
      byte0 = -1;
    }

    if (par4 == 2) {
      byte1 = -1;
    }

    if (par4 == 3) {
      byte0 = 1;
    }

    int i =
        (par0World.isBlockNormalCube(par1 - byte0, par2, par3 - byte1) ? 1 : 0)
            + (par0World.isBlockNormalCube(par1 - byte0, par2 + 1, par3 - byte1) ? 1 : 0);
    int j =
        (par0World.isBlockNormalCube(par1 + byte0, par2, par3 + byte1) ? 1 : 0)
            + (par0World.isBlockNormalCube(par1 + byte0, par2 + 1, par3 + byte1) ? 1 : 0);
    boolean flag =
        par0World.getBlockId(par1 - byte0, par2, par3 - byte1) == par5Block.blockID
            || par0World.getBlockId(par1 - byte0, par2 + 1, par3 - byte1) == par5Block.blockID;
    boolean flag1 =
        par0World.getBlockId(par1 + byte0, par2, par3 + byte1) == par5Block.blockID
            || par0World.getBlockId(par1 + byte0, par2 + 1, par3 + byte1) == par5Block.blockID;
    boolean flag2 = false;

    if (flag && !flag1) {
      flag2 = true;
    } else if (j > i) {
      flag2 = true;
    }

    par0World.editingBlocks = true;
    par0World.setBlockAndMetadataWithNotify(par1, par2, par3, par5Block.blockID, par4);
    par0World.setBlockAndMetadataWithNotify(
        par1, par2 + 1, par3, par5Block.blockID, 8 | (flag2 ? 1 : 0));
    par0World.editingBlocks = false;
    par0World.notifyBlocksOfNeighborChange(par1, par2, par3, par5Block.blockID);
    par0World.notifyBlocksOfNeighborChange(par1, par2 + 1, par3, par5Block.blockID);
  }
Exemplo n.º 7
0
 /**
  * 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
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (!this.canBlockStay(par1World, par2, par3, par4)) {
     this.dropBlockAsItem(
         par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
     par1World.setBlockToAir(par2, par3, par4);
     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);
     par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
   } else {
     this.func_94479_f(par1World, par2, par3, par4, par5);
   }
 }
 public void onBlockRemoval(World world, int i, int j, int k) {
   super.onBlockRemoval(world, i, j, k);
   if (world.multiplayerWorld) {
     return;
   }
   world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
   world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
   updateAndPropagateCurrentStrength(world, i, j, k);
   notifyWireNeighborsOfNeighborChange(world, i - 1, j, k);
   notifyWireNeighborsOfNeighborChange(world, i + 1, j, k);
   notifyWireNeighborsOfNeighborChange(world, i, j, k - 1);
   notifyWireNeighborsOfNeighborChange(world, i, j, k + 1);
   if (world.isBlockOpaqueCube(i - 1, j, k)) {
     notifyWireNeighborsOfNeighborChange(world, i - 1, j + 1, k);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i - 1, j - 1, k);
   }
   if (world.isBlockOpaqueCube(i + 1, j, k)) {
     notifyWireNeighborsOfNeighborChange(world, i + 1, j + 1, k);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i + 1, j - 1, k);
   }
   if (world.isBlockOpaqueCube(i, j, k - 1)) {
     notifyWireNeighborsOfNeighborChange(world, i, j + 1, k - 1);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i, j - 1, k - 1);
   }
   if (world.isBlockOpaqueCube(i, j, k + 1)) {
     notifyWireNeighborsOfNeighborChange(world, i, j + 1, k + 1);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i, j - 1, k + 1);
   }
 }
 public static void unpath(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> notify = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     depolarize(world, coords.posX + 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY + 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ + 1, blocks);
     depolarize(world, coords.posX - 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY - 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ - 1, blocks);
     notify.add(coords);
   }
   for (ChunkCoordinates coords : notify) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
 private void updateAndPropagateCurrentStrength(World world, int i, int j, int k) {
   func_21030_a(world, i, j, k, i, j, k);
   ArrayList arraylist = new ArrayList(field_21031_b);
   field_21031_b.clear();
   for (int l = 0; l < arraylist.size(); l++) {
     ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l);
     world.notifyBlocksOfNeighborChange(
         chunkposition.x, chunkposition.y, chunkposition.z, blockID);
   }
 }
Exemplo n.º 11
0
  /**
   * Sets the strength of the wire current (0-15) for this block based on neighboring blocks and
   * propagates to neighboring redstone wires
   */
  private void updateAndPropagateCurrentStrength(World par1World, int par2, int par3, int par4) {
    this.calculateCurrentChanges(par1World, par2, par3, par4, par2, par3, par4);
    ArrayList var5 = new ArrayList(this.blocksNeedingUpdate);
    this.blocksNeedingUpdate.clear();

    for (int var6 = 0; var6 < var5.size(); ++var6) {
      ChunkPosition var7 = (ChunkPosition) var5.get(var6);
      par1World.notifyBlocksOfNeighborChange(var7.x, var7.y, var7.z, this.blockID);
    }
  }
  /**
   * Sets the strength of the wire current (0-15) for this block based on neighboring blocks and
   * propagates to neighboring redstone wires
   */
  private void updateAndPropagateCurrentStrength(World par1World, int par2, int par3, int par4) {
    this.calculateCurrentChanges(par1World, par2, par3, par4, par2, par3, par4);
    ArrayList var5 = new ArrayList(this.blocksNeedingUpdate);
    this.blocksNeedingUpdate.clear();
    Iterator var6 = var5.iterator();

    while (var6.hasNext()) {
      ChunkPosition var7 = (ChunkPosition) var6.next();
      par1World.notifyBlocksOfNeighborChange(var7.x, var7.y, var7.z, this.blockID);
    }
  }
Exemplo n.º 13
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);
      }
    }
  }
Exemplo n.º 14
0
 private static void pathto(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> portals = Lists.newLinkedList();
   List<ChunkCoordinates> repath = Lists.newLinkedList();
   List<ChunkCoordinates> redraw = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while ((portals.size() > 0) || (blocks.size() > 0)) {
     while (blocks.size() > 0) {
       ChunkCoordinates coords = blocks.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       redraw.add(coords);
     }
     if (portals.size() > 0) {
       ChunkCoordinates coords = portals.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
         repath.add(coords);
       }
     }
   }
   while (repath.size() > 0) {
     ChunkCoordinates coords = repath.remove(0);
     if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
       if (!BlockPortal.isValidPortal(world, coords.posX, coords.posY, coords.posZ)) {
         repathNeighbors(world, coords.posX, coords.posY, coords.posZ);
         world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.air, 0, 0);
         addSurrounding(repath, coords.posX, coords.posY, coords.posZ);
       } else {
         redraw.add(coords);
       }
     }
   }
   for (ChunkCoordinates coords : redraw) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
Exemplo n.º 15
0
  /**
   * 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
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    if (!this.canBlockStay(par1World, par2, par3, par4)) {
      this.dropBlockAsItem(
          par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
      par1World.setBlockWithNotify(par2, par3, par4, 0);
      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);
      par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
    } else {
      int var6 = par1World.getBlockMetadata(par2, par3, par4);
      boolean var7 = this.ignoreTick(par1World, par2, par3, par4, var6);
      int var8 = (var6 & 12) >> 2;

      if (this.isRepeaterPowered && !var7) {
        par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, repeaterState[var8] * 2);
      } else if (!this.isRepeaterPowered && var7) {
        par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, repeaterState[var8] * 2);
      }
    }
  }
Exemplo n.º 16
0
  protected void func_94483_i_(World par1World, int par2, int par3, int par4) {
    int var5 = getDirection(par1World.getBlockMetadata(par2, par3, par4));

    if (var5 == 1) {
      par1World.notifyBlockOfNeighborChange(par2 + 1, par3, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID, 4);
    }

    if (var5 == 3) {
      par1World.notifyBlockOfNeighborChange(par2 - 1, par3, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID, 5);
    }

    if (var5 == 2) {
      par1World.notifyBlockOfNeighborChange(par2, par3, par4 + 1, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID, 2);
    }

    if (var5 == 0) {
      par1World.notifyBlockOfNeighborChange(par2, par3, par4 - 1, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID, 3);
    }
  }
Exemplo n.º 17
0
  /** attempts to extend the piston. returns false if impossible. */
  private boolean tryExtend(World par1World, int par2, int par3, int par4, int par5) {
    int var6 = par2 + Facing.offsetsXForSide[par5];
    int var7 = par3 + Facing.offsetsYForSide[par5];
    int var8 = par4 + Facing.offsetsZForSide[par5];
    int var9 = 0;

    while (true) {
      int var10;

      if (var9 < 13) {
        if (var7 <= 0 || var7 >= 255) {
          return false;
        }

        var10 = par1World.getBlockId(var6, var7, var8);

        if (var10 != 0) {
          if (!canPushBlock(var10, par1World, var6, var7, var8, true)) {
            return false;
          }

          if (Block.blocksList[var10].getMobilityFlag() != 1) {
            if (var9 == 12) {
              return false;
            }

            var6 += Facing.offsetsXForSide[par5];
            var7 += Facing.offsetsYForSide[par5];
            var8 += Facing.offsetsZForSide[par5];
            ++var9;
            continue;
          }

          Block.blocksList[var10].dropBlockAsItem(
              par1World, var6, var7, var8, par1World.getBlockMetadata(var6, var7, var8), 0);
          par1World.setBlockToAir(var6, var7, var8);
        }
      }

      var9 = var6;
      var10 = var7;
      int var11 = var8;
      int var12 = 0;
      int[] var13;
      int var14;
      int var15;
      int var16;

      for (var13 = new int[13]; var6 != par2 || var7 != par3 || var8 != par4; var8 = var16) {
        var14 = var6 - Facing.offsetsXForSide[par5];
        var15 = var7 - Facing.offsetsYForSide[par5];
        var16 = var8 - Facing.offsetsZForSide[par5];
        int var17 = par1World.getBlockId(var14, var15, var16);
        int var18 = par1World.getBlockMetadata(var14, var15, var16);

        if (var17 == this.blockID && var14 == par2 && var15 == par3 && var16 == par4) {
          par1World.setBlock(
              var6, var7, var8, Block.pistonMoving.blockID, par5 | (this.isSticky ? 8 : 0), 4);
          par1World.setBlockTileEntity(
              var6,
              var7,
              var8,
              BlockPistonMoving.getTileEntity(
                  Block.pistonExtension.blockID,
                  par5 | (this.isSticky ? 8 : 0),
                  par5,
                  true,
                  false));
        } else {
          par1World.setBlock(var6, var7, var8, Block.pistonMoving.blockID, var18, 4);
          par1World.setBlockTileEntity(
              var6, var7, var8, BlockPistonMoving.getTileEntity(var17, var18, par5, true, false));
        }

        var13[var12++] = var17;
        var6 = var14;
        var7 = var15;
      }

      var6 = var9;
      var7 = var10;
      var8 = var11;

      for (var12 = 0; var6 != par2 || var7 != par3 || var8 != par4; var8 = var16) {
        var14 = var6 - Facing.offsetsXForSide[par5];
        var15 = var7 - Facing.offsetsYForSide[par5];
        var16 = var8 - Facing.offsetsZForSide[par5];
        par1World.notifyBlocksOfNeighborChange(var14, var15, var16, var13[var12++]);
        var6 = var14;
        var7 = var15;
      }

      return true;
    }
  }
Exemplo n.º 18
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, 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 var9 = this.tickRate(par1World);
    int var11;

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

      if (var11 >= 8 || var13 < 0) {
        var11 = -1;
      }

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

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

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

      if (this.blockMaterial == Material.lava
          && var6 < 8
          && var11 < 8
          && var11 > var6
          && par5Random.nextInt(4) != 0) {
        var9 *= 4;
      }

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

        if (var11 < 0) {
          par1World.setBlockToAir(par2, par3, par4);
        } else {
          par1World.setBlockMetadata(par2, par3, par4, var11, 2);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, var9);
          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.setBlock(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))) {
      boolean[] var14 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var11 = var6 + var7;

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

      if (var11 >= 8) {
        return;
      }

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

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

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

      if (var14[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var11);
      }
    }
  }
Exemplo n.º 19
0
 public void updateTick(World world, int i, int j, int k, Random random) {
   int l = getFlowDecay(world, i, j, k);
   byte byte0 = 1;
   if (blockMaterial == Material.lava && !world.worldProvider.isHellWorld) {
     byte0 = 2;
   }
   boolean flag = true;
   if (l > 0) {
     int i1 = -100;
     numAdjacentSources = 0;
     i1 = getSmallestFlowDecay(world, i - 1, j, k, i1);
     i1 = getSmallestFlowDecay(world, i + 1, j, k, i1);
     i1 = getSmallestFlowDecay(world, i, j, k - 1, i1);
     i1 = getSmallestFlowDecay(world, i, j, k + 1, i1);
     int j1 = i1 + byte0;
     if (j1 >= 8 || i1 < 0) {
       j1 = -1;
     }
     if (getFlowDecay(world, i, j + 1, k) >= 0) {
       int l1 = getFlowDecay(world, i, j + 1, k);
       if (l1 >= 8) {
         j1 = l1;
       } else {
         j1 = l1 + 8;
       }
     }
     if (numAdjacentSources >= 2 && blockMaterial == Material.water) {
       if (world.getBlockMaterial(i, j - 1, k).isSolid()) {
         j1 = 0;
       } else if (world.getBlockMaterial(i, j - 1, k) == blockMaterial
           && world.getBlockMetadata(i, j, k) == 0) {
         j1 = 0;
       }
     }
     if (blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && random.nextInt(4) != 0) {
       j1 = l;
       flag = false;
     }
     if (j1 != l) {
       l = j1;
       if (l < 0) {
         world.setBlockWithNotify(i, j, k, 0);
       } else {
         world.setBlockMetadataWithNotify(i, j, k, l);
         world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
         world.notifyBlocksOfNeighborChange(i, j, k, blockID);
       }
     } else if (flag) {
       func_30003_j(world, i, j, k);
     }
   } else {
     func_30003_j(world, i, j, k);
   }
   if (liquidCanDisplaceBlock(world, i, j - 1, k)) {
     if (l >= 8) {
       world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l);
     } else {
       world.setBlockAndMetadataWithNotify(i, j - 1, k, blockID, l + 8);
     }
   } else if (l >= 0 && (l == 0 || blockBlocksFlow(world, i, j - 1, k))) {
     boolean aflag[] = getOptimalFlowDirections(world, i, j, k);
     int k1 = l + byte0;
     if (l >= 8) {
       k1 = 1;
     }
     if (k1 >= 8) {
       return;
     }
     if (aflag[0]) {
       flowIntoBlock(world, i - 1, j, k, k1);
     }
     if (aflag[1]) {
       flowIntoBlock(world, i + 1, j, k, k1);
     }
     if (aflag[2]) {
       flowIntoBlock(world, i, j, k - 1, k1);
     }
     if (aflag[3]) {
       flowIntoBlock(world, i, j, k + 1, k1);
     }
   }
 }
Exemplo n.º 20
0
 private void setStateIfMobInteractsWithPlate(World world, int i, int j, int k) {
   boolean flag = world.getBlockMetadata(i, j, k) == 1;
   boolean flag1 = false;
   float f = 0.125F;
   List list = null;
   if (triggerMobType == EnumMobType.everything) {
     list =
         world.getEntitiesWithinAABBExcludingEntity(
             null,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.mobs) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityLiving.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.players) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityPlayer.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (list.size() > 0) {
     flag1 = true;
   }
   if (flag1 && !flag) {
     world.setBlockMetadataWithNotify(i, j, k, 1);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.6F);
   }
   if (!flag1 && flag) {
     world.setBlockMetadataWithNotify(i, j, k, 0);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.5F);
   }
   if (flag1) {
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
   }
 }
Exemplo n.º 21
0
  /**
   * 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
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    if (!par1World.isRemote) {
      int var6 = par1World.getBlockMetadata(par2, par3, par4);
      int var7 = var6;

      if (this.isPowered) {
        var7 = var6 & 7;
      }

      boolean var8 = false;

      if (!par1World.isBlockSolidOnSide(par2, par3 - 1, par4, 1)) {
        var8 = true;
      }

      if (var7 == 2 && !par1World.isBlockSolidOnSide(par2 + 1, par3, par4, 1)) {
        var8 = true;
      }

      if (var7 == 3 && !par1World.isBlockSolidOnSide(par2 - 1, par3, par4, 1)) {
        var8 = true;
      }

      if (var7 == 4 && !par1World.isBlockSolidOnSide(par2, par3, par4 - 1, 1)) {
        var8 = true;
      }

      if (var7 == 5 && !par1World.isBlockSolidOnSide(par2, par3, par4 + 1, 1)) {
        var8 = true;
      }

      if (var8) {
        this.dropBlockAsItem(
            par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
        par1World.setBlockWithNotify(par2, par3, par4, 0);
      } else if (this.blockID == Block.railPowered.blockID) {
        boolean var9 = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4);
        var9 =
            var9
                || this.isNeighborRailPowered(par1World, par2, par3, par4, var6, true, 0)
                || this.isNeighborRailPowered(par1World, par2, par3, par4, var6, false, 0);
        boolean var10 = false;

        if (var9 && (var6 & 8) == 0) {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var7 | 8);
          var10 = true;
        } else if (!var9 && (var6 & 8) != 0) {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var7);
          var10 = true;
        }

        if (var10) {
          par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);

          if (var7 == 2 || var7 == 3 || var7 == 4 || var7 == 5) {
            par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
          }
        }
      } else if (par5 > 0
          && Block.blocksList[par5].canProvidePower()
          && !this.isPowered
          && RailLogic.getNAdjacentTracks(new RailLogic(this, par1World, par2, par3, par4)) == 3) {
        this.refreshTrackShape(par1World, par2, par3, par4, false);
      }
    }
  }