Beispiel #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);
 }
  /**
   * 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;
  }
Beispiel #3
0
 @Override
 @SideOnly(Side.CLIENT)
 public boolean addBlockDestroyEffects(
     World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
   Icon tex = lastRemovedComponetIcon;
   byte b0 = 4;
   for (int j1 = 0; j1 < b0; ++j1) {
     for (int k1 = 0; k1 < b0; ++k1) {
       for (int l1 = 0; l1 < b0; ++l1) {
         double d0 = x + (j1 + 0.5D) / b0;
         double d1 = y + (k1 + 0.5D) / b0;
         double d2 = z + (l1 + 0.5D) / b0;
         int i2 = this.rand.nextInt(6);
         EntityDiggingFX fx =
             new EntityDiggingFX(
                     world, d0, d1, d2, d0 - x - 0.5D, d1 - y - 0.5D, d2 - z - 0.5D, this, i2, 0)
                 .applyColourMultiplier(x, y, z);
         fx.func_110125_a(tex);
         effectRenderer.addEffect(fx);
       }
     }
   }
   return true;
 }
  /**
   * 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;
  }