Exemplo n.º 1
0
  private boolean smeltBlock(Coord4D block) {
    ItemStack stack = block.getStack(worldObj);

    if (stack == null) {
      return false;
    }

    ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(block.getStack(worldObj));

    if (result != null) {
      if (!worldObj.isRemote) {
        Block b = block.getBlock(worldObj);
        int meta = block.getMetadata(worldObj);

        if (Block.getBlockFromItem(result.getItem()) != Blocks.air) {
          worldObj.setBlock(
              block.xCoord,
              block.yCoord,
              block.zCoord,
              Block.getBlockFromItem(result.getItem()),
              result.getItemDamage(),
              3);
        } else {
          worldObj.setBlockToAir(block.xCoord, block.yCoord, block.zCoord);

          EntityItem item =
              new EntityItem(
                  worldObj,
                  block.xCoord + 0.5,
                  block.yCoord + 0.5,
                  block.zCoord + 0.5,
                  result.copy());
          item.motionX = 0;
          item.motionY = 0;
          item.motionZ = 0;
          worldObj.spawnEntityInWorld(item);
        }

        worldObj.playAuxSFXAtEntity(
            null,
            2001,
            block.xCoord,
            block.yCoord,
            block.zCoord,
            Block.getIdFromBlock(b) + (meta << 12));
      }

      spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5));

      return true;
    }

    return false;
  }
  public boolean canReplace(Coord4D coord, boolean checkNodes, boolean isPathfinding) {
    if (checkNodes && usedNodes.contains(coord)) {
      return false;
    }

    if (coord.isAirBlock(worldObj) || MekanismUtils.isDeadFluid(worldObj, coord)) {
      return true;
    }

    if (MekanismUtils.isFluid(worldObj, coord)) {
      return isPathfinding;
    }

    return coord
        .getBlock(worldObj)
        .isReplaceable(worldObj, coord.xCoord, coord.yCoord, coord.zCoord);
  }