Пример #1
0
  /*
   * (non-Javadoc)
   * @see com.nitnelave.CreeperHeal.block.Replaceable#replace(boolean)
   */
  @Override
  public boolean replace(boolean shouldDrop) {
    Block block = getBlock();
    int blockId = block.getTypeId();

    if (!CreeperConfig.overwriteBlocks && !isEmpty(blockId)) {
      if (CreeperConfig.dropDestroyedBlocks) drop();
      return true;
    } else if (CreeperConfig.overwriteBlocks
        && !isEmpty(blockId)
        && CreeperConfig.dropDestroyedBlocks) {
      CreeperBlock.newBlock(block.getState()).drop();
      block.setTypeIdAndData(0, (byte) 0, false);
    }

    if (!shouldDrop
        && isDependent(getTypeId())
        && isEmpty(getBlock().getRelative(getAttachingFace()).getTypeId())) {
      delay_replacement();
      return true;
    } else update();

    // TODO: Check the necessity, and move to CreeperRail if possible.
    checkForAscendingRails();

    return true;
  }
Пример #2
0
 /*
  * Test the blocks directly in contact, and if they are ascending rails, add
  * them to the updatePrevention list.
  */
 private void checkForAscendingRails() {
   BlockFace[] cardinals = {
     BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.UP
   };
   Block block = blockState.getBlock();
   for (BlockFace face : cardinals) {
     Block tmp_block = block.getRelative(face);
     if (tmp_block.getState() instanceof Rails) {
       byte data = tmp_block.getData();
       if (data > 1 && data < 6) {
         BlockFace facing = null;
         if (data == 2) facing = BlockFace.EAST;
         else if (data == 3) facing = BlockFace.WEST;
         else if (data == 4) facing = BlockFace.NORTH;
         else if (data == 5) facing = BlockFace.SOUTH;
         if (tmp_block.getRelative(facing).getType() == Material.AIR)
           BlockManager.putUpdatePrevention(CreeperBlock.newBlock(tmp_block.getState()));
       }
     }
   }
 }