예제 #1
0
 @SideOnly(Side.CLIENT)
 private void addBlockHitEffects(
     World world, EffectRenderer effectRenderer, int x, int y, int z, int side, Icon tex) {
   float f = 0.1F;
   double d0 =
       x
           + rand.nextDouble() * (getBlockBoundsMaxX() - getBlockBoundsMinX() - f * 2.0F)
           + f
           + getBlockBoundsMinX();
   double d1 =
       y
           + rand.nextDouble() * (getBlockBoundsMaxY() - getBlockBoundsMinY() - f * 2.0F)
           + f
           + getBlockBoundsMinY();
   double d2 =
       z
           + rand.nextDouble() * (getBlockBoundsMaxZ() - getBlockBoundsMinZ() - f * 2.0F)
           + f
           + getBlockBoundsMinZ();
   if (side == 0) {
     d1 = y + getBlockBoundsMinY() - f;
   } else if (side == 1) {
     d1 = y + getBlockBoundsMaxY() + f;
   } else if (side == 2) {
     d2 = z + getBlockBoundsMinZ() - f;
   } else if (side == 3) {
     d2 = z + getBlockBoundsMaxZ() + f;
   } else if (side == 4) {
     d0 = x + getBlockBoundsMinX() - f;
   } else if (side == 5) {
     d0 = x + getBlockBoundsMaxX() + f;
   }
   EntityDiggingFX digFX = new EntityDiggingFX(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, this, side, 0);
   digFX.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
   digFX.func_110125_a(tex);
   effectRenderer.addEffect(digFX);
 }
예제 #2
0
  /**
   * Spawn particles for when the block is destroyed. Due to the nature of how this is invoked, the
   * x/y/z locations are not always guaranteed to host your block. So be sure to do proper sanity
   * checks before assuming that the location is this block.
   *
   * @param world The current world
   * @param x X position to spawn the particle
   * @param y Y position to spawn the particle
   * @param z Z position to spawn the particle
   * @param meta The metadata for the block before it was destroyed.
   * @param effectRenderer A reference to the current effect renderer.
   * @return True to prevent vanilla break particles from spawning.
   */
  @SideOnly(Side.CLIENT)
  @Override
  public boolean addBlockDestroyEffects(
      World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
    Pipe pipe = getPipe(worldObj, x, y, z);
    if (pipe == null) return false;

    Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());

    byte its = 4;
    for (int i = 0; i < its; ++i) {
      for (int j = 0; j < its; ++j) {
        for (int k = 0; k < its; ++k) {
          double px = x + (i + 0.5D) / (double) its;
          double py = y + (j + 0.5D) / (double) its;
          double pz = z + (k + 0.5D) / (double) its;
          int random = rand.nextInt(6);
          EntityDiggingFX fx =
              new EntityDiggingFX(
                  worldObj,
                  px,
                  py,
                  pz,
                  px - x - 0.5D,
                  py - y - 0.5D,
                  pz - z - 0.5D,
                  BuildCraftTransport.genericPipeBlock,
                  random,
                  meta);
          fx.func_110125_a(icon);
          effectRenderer.addEffect(fx.applyColourMultiplier(x, y, z));
        }
      }
    }
    return true;
  }
예제 #3
0
  /**
   * Spawn a digging particle effect in the world, this is a wrapper around
   * EffectRenderer.addBlockHitEffects to allow the block more control over the particles. Useful
   * when you have entirely different texture sheets for different sides/locations in the world.
   *
   * @param world The current world
   * @param target The target the player is looking at {x/y/z/side/sub}
   * @param effectRenderer A reference to the current effect renderer.
   * @return True to prevent vanilla digging particles form spawning.
   */
  @SideOnly(Side.CLIENT)
  @Override
  public boolean addBlockHitEffects(
      World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
    int x = target.blockX;
    int y = target.blockY;
    int z = target.blockZ;

    Pipe pipe = getPipe(worldObj, x, y, z);
    if (pipe == null) return false;

    Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem());

    int sideHit = target.sideHit;

    Block block = BuildCraftTransport.genericPipeBlock;
    float b = 0.1F;
    double px =
        x
            + rand.nextDouble()
                * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (b * 2.0F))
            + b
            + block.getBlockBoundsMinX();
    double py =
        y
            + rand.nextDouble()
                * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (b * 2.0F))
            + b
            + block.getBlockBoundsMinY();
    double pz =
        z
            + rand.nextDouble()
                * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (b * 2.0F))
            + b
            + block.getBlockBoundsMinZ();

    if (sideHit == 0) {
      py = (double) y + block.getBlockBoundsMinY() - (double) b;
    }

    if (sideHit == 1) {
      py = (double) y + block.getBlockBoundsMaxY() + (double) b;
    }

    if (sideHit == 2) {
      pz = (double) z + block.getBlockBoundsMinZ() - (double) b;
    }

    if (sideHit == 3) {
      pz = (double) z + block.getBlockBoundsMaxZ() + (double) b;
    }

    if (sideHit == 4) {
      px = (double) x + block.getBlockBoundsMinX() - (double) b;
    }

    if (sideHit == 5) {
      px = (double) x + block.getBlockBoundsMaxX() + (double) b;
    }

    EntityDiggingFX fx =
        new EntityDiggingFX(
            worldObj,
            px,
            py,
            pz,
            0.0D,
            0.0D,
            0.0D,
            block,
            sideHit,
            worldObj.getBlockMetadata(x, y, z));
    fx.func_110125_a(icon);
    effectRenderer.addEffect(
        fx.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
    return true;
  }