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);
  }
Пример #2
0
  private void calculateVector() {
    Vec3 localVec = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 motionVec =
        Vec3.createVectorHelper(posX + motionX * 2, posY + motionY * 2, posZ + motionZ * 2);
    MovingObjectPosition mop = worldObj.func_147447_a(localVec, motionVec, true, false, false);
    localVec = Vec3.createVectorHelper(posX, posY, posZ);
    motionVec = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);

    if (mop != null) {
      motionVec = Vec3.createVectorHelper(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
    }

    Entity entity = null;
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double entityDist = 0.0D;
    int i;

    for (Entity entity1 : (List<Entity>) list) {
      if ((entity1 instanceof EntityItem || entity1.canBeCollidedWith()) && entity1 != owner) {
        float boundsScale = 0.3F;
        AxisAlignedBB newBounds =
            entity1.boundingBox.expand(
                (double) boundsScale, (double) boundsScale, (double) boundsScale);
        MovingObjectPosition movingobjectposition1 =
            newBounds.calculateIntercept(localVec, motionVec);

        if (movingobjectposition1 != null) {
          double dist = localVec.distanceTo(movingobjectposition1.hitVec);

          if (dist < entityDist || entityDist == 0) {
            entity = entity1;
            entityDist = dist;
          }
        }
      }
    }

    if (entity != null) {
      mop = new MovingObjectPosition(entity);
    }

    if (mop != null && mop.entityHit instanceof EntityPlayer) {
      EntityPlayer entityplayer = (EntityPlayer) mop.entityHit;

      if (entityplayer.capabilities.disableDamage
          || owner instanceof EntityPlayer
              && !((EntityPlayer) owner).canAttackPlayer(entityplayer)) {
        mop = null;
      }
    }

    if (mop != null) {
      if (mop.entityHit != null && !mop.entityHit.isImmuneToFire()) {
        if (mop.entityHit instanceof EntityItem) {
          if (mop.entityHit.ticksExisted > 80) {
            if (!smeltItem((EntityItem) mop.entityHit)) {
              burn(mop.entityHit);
            }
          }
        } else {
          burn(mop.entityHit);
        }
      } else {
        Block block = worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ);
        int meta = worldObj.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ);
        boolean fluid =
            MekanismUtils.isFluid(worldObj, mop.blockX, mop.blockY, mop.blockZ)
                || MekanismUtils.isDeadFluid(worldObj, mop.blockX, mop.blockY, mop.blockZ);

        Coord4D sideCoord =
            new Coord4D(mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId)
                .getFromSide(ForgeDirection.getOrientation(mop.sideHit));

        if (general.aestheticWorldDamage
            && !fluid
            && (sideCoord.isAirBlock(worldObj) || sideCoord.isReplaceable(worldObj))) {
          if (!smeltBlock(new Coord4D(mop.blockX, mop.blockY, mop.blockZ))) {
            if (!worldObj.isRemote) {
              worldObj.setBlock(sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, Blocks.fire);
            }
          }
        }

        if (fluid) {
          spawnParticlesAt(new Pos3D(this));
          worldObj.playSoundAtEntity(this, "random.fizz", 1.0F, 1.0F);
        }
      }

      setDead();
    }
  }