Example #1
0
  public static ItemPipe registerPipe(int key, Class<? extends Pipe> clas) {
    ItemPipe item = new ItemPipe(key);
    item.setUnlocalizedName("buildcraftPipe." + clas.getSimpleName().toLowerCase(Locale.ENGLISH));
    GameRegistry.registerItem(item, item.getUnlocalizedName());

    pipes.put(item.itemID, clas);

    Pipe dummyPipe = createPipe(item.itemID);
    if (dummyPipe != null) {
      item.setPipeIconIndex(dummyPipe.getIconIndexForItem());
      TransportProxy.proxy.setIconProviderFromPipe(item, dummyPipe);
    }
    return item;
  }
Example #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;
  }
Example #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;
  }