Java 类net.minecraft.client.particle.ParticleDigging 实例源码

项目:EnderIO    文件:BlockConduitBundle.java   
@SideOnly(Side.CLIENT)
private void addBlockHitEffects(@Nonnull World world, @Nonnull ParticleManager effectRenderer, double xCoord, double yCoord, double zCoord,
    @Nonnull EnumFacing sideEnum, @Nonnull TextureAtlasSprite tex) {

  double d0 = xCoord;
  double d1 = yCoord;
  double d2 = zCoord;
  if (sideEnum.getAxis() != Axis.X) {
    d0 += rand.nextDouble() * 0.4 - rand.nextDouble() * 0.4;
  }
  if (sideEnum.getAxis() != Axis.Y) {
    d1 += rand.nextDouble() * 0.4 - rand.nextDouble() * 0.4;
  }
  if (sideEnum.getAxis() != Axis.Z) {
    d2 += rand.nextDouble() * 0.4 - rand.nextDouble() * 0.4;
  }

  ParticleDigging digFX = (ParticleDigging) Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), d0, d1,
      d2, 0, 0, 0, 0);
  if (digFX != null) {
    digFX.init().multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
    digFX.setParticleTexture(tex);
  }
}
项目:CrystalMod    文件:BlockPipe.java   
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager effectRenderer) {
    IBlockState state = world.getBlockState(pos);
    if (state == null || state.getBlock() != this) {
        return false;
    }
    state = state.getBlock().getActualState(state, world, pos);
    int i = 4;
    TextureAtlasSprite tex = null;
    TileEntity tile = world.getTileEntity(pos);
    if(Util.notNullAndInstanceOf(tile, TileEntityPipe.class)){
        TileEntityPipe pipe = ((TileEntityPipe)tile);
        tex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(pipe.getPipeType().getCoreTexture(pipe));

        if(tex == null){
            return false;
        }
    }
    for (int j = 0; j < i; ++j) {
        for (int k = 0; k < i; ++k) {
            for (int l = 0; l < i; ++l) {
                double d0 = pos.getX() + (j + 0.5D) / i;
                double d1 = pos.getY() + (k + 0.5D) / i;
                double d2 = pos.getZ() + (l + 0.5D) / i;
                ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D,
                        d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0);
                fx.setBlockPos(pos);
                fx.setParticleTexture(tex);
                effectRenderer.addEffect(fx);
            }
        }
    }

    return true;
}
项目:EnderIO    文件:BlockConduitBundle.java   
@SideOnly(Side.CLIENT)
@Override
public boolean addDestroyEffects(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ParticleManager effectRenderer) {
  if (lastHitIcon == null) {
    lastHitIcon = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes()
        .getTexture(ModObject.block_machine_base.getBlockNN().getDefaultState());
  }

  IBlockState state = world.getBlockState(pos);
  TextureAtlasSprite tex = lastHitIcon;
  if (state.getBlock() != this || tex == null) {
    return false;
  }
  state = state.getActualState(world, pos);
  int i = 4;
  for (int j = 0; j < i; ++j) {
    for (int k = 0; k < i; ++k) {
      for (int l = 0; l < i; ++l) {
        double d0 = pos.getX() + (j + 0.5D) / i;
        double d1 = pos.getY() + (k + 0.5D) / i;
        double d2 = pos.getZ() + (l + 0.5D) / i;
        ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D,
            d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0);
        fx.setBlockPos(pos);
        fx.setParticleTexture(tex);
        effectRenderer.addEffect(fx);
      }
    }
  }

  return true;
}
项目:EnderIO    文件:PaintHelper.java   
@SideOnly(Side.CLIENT)
public static boolean addDestroyEffects(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ParticleManager effectRenderer) {

  TextureAtlasSprite texture = null;
  IBlockState state = world.getBlockState(pos);
  if (state.getBlock() instanceof IPaintable) {
    IBlockState paintSource = ((IPaintable) state.getBlock()).getPaintSource(state, world, pos);
    if (paintSource != null) {
      texture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(paintSource);
    }
  }
  if (texture == null) {
    texture = lastTexture;
    if (texture == null) {
      return false;
    }
  }

  int i = 4;
  for (int j = 0; j < i; ++j) {
    for (int k = 0; k < i; ++k) {
      for (int l = 0; l < i; ++l) {
        double d0 = pos.getX() + (j + 0.5D) / i;
        double d1 = pos.getY() + (k + 0.5D) / i;
        double d2 = pos.getZ() + (l + 0.5D) / i;
        ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D,
            d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0);
        fx.setBlockPos(pos);
        fx.setParticleTexture(texture);
        effectRenderer.addEffect(fx);
      }
    }
  }

  return true;
}
项目:CrystalMod    文件:BlockPipe.java   
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
@Override
public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager effectRenderer)
{
    BlockPos pos = target.getBlockPos();
    EnumFacing side = target.sideHit;
    IBlockState iblockstate = worldObj.getBlockState(pos);

    TextureAtlasSprite sprite = null;

    TileEntity tile = worldObj.getTileEntity(pos);
    if(Util.notNullAndInstanceOf(tile, TileEntityPipe.class)){
        TileEntityPipe pipe = ((TileEntityPipe)tile);
        sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(pipe.getPipeType().getCoreTexture(pipe));

        CoverData data = pipe.getCoverData(side);
        if(data !=null && data.getBlockState() !=null){
            if(data.getBlockState().getBlock().addHitEffects(data.getBlockState(), new PipeWorldWrapper(worldObj, pos, side), target, effectRenderer)){
                return true;
            }
            sprite = RenderUtil.getTexture(data.getBlockState());
        }
        if(sprite == null){
            return false;
        }
    }

    if(iblockstate == null)return false;

    Block block = iblockstate.getBlock();

    if (block.getRenderType(iblockstate) != EnumBlockRenderType.INVISIBLE)
    {
        AxisAlignedBB blockBounds = block.getBoundingBox(iblockstate, new PipeWorldWrapper(worldObj, pos, side), pos);
        int i = pos.getX();
        int j = pos.getY();
        int k = pos.getZ();
        float f = 0.1F;
        double d0 = i + this.rand.nextDouble() * (blockBounds.maxX - blockBounds.minX - f * 2.0F) + f + blockBounds.minX;
        double d1 = j + this.rand.nextDouble() * (blockBounds.maxY - blockBounds.minY - f * 2.0F) + f + blockBounds.minY;
        double d2 = k + this.rand.nextDouble() * (blockBounds.maxZ - blockBounds.minZ - f * 2.0F) + f + blockBounds.minZ;

        if (side == EnumFacing.DOWN)
        {
            d1 = j + blockBounds.minY - f;
        }

        if (side == EnumFacing.UP)
        {
            d1 = j + blockBounds.maxY + f;
        }

        if (side == EnumFacing.NORTH)
        {
            d2 = k + blockBounds.minZ - f;
        }

        if (side == EnumFacing.SOUTH)
        {
            d2 = k + blockBounds.maxZ + f;
        }

        if (side == EnumFacing.WEST)
        {
            d0 = i + blockBounds.minX - f;
        }

        if (side == EnumFacing.EAST)
        {
            d0 = i + blockBounds.maxX + f;
        }
        ParticleDigging fx = (ParticleDigging) Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), d0, d1,
                d2, 0, 0, 0, 0);
        fx.init().multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
        fx.setParticleTexture(sprite);
        effectRenderer.addEffect(fx);
        return true;
    }
    return super.addHitEffects(state, worldObj, target, effectRenderer);
}
项目:EnderIO    文件:PaintHelper.java   
@SideOnly(Side.CLIENT)
public static void addBlockHitEffects(@Nonnull World world, @Nonnull IBlockState realBlock, @Nonnull IBlockState paintBlock, @Nonnull BlockPos pos,
    @Nonnull EnumFacing side, @Nonnull ParticleManager effectRenderer) {
  int i = pos.getX();
  int j = pos.getY();
  int k = pos.getZ();
  float f = 0.1F;
  AxisAlignedBB axisalignedbb = realBlock.getBoundingBox(world, pos);
  double d0 = i + rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - f * 2.0F) + f + axisalignedbb.minX;
  double d1 = j + rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - f * 2.0F) + f + axisalignedbb.minY;
  double d2 = k + rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - f * 2.0F) + f + axisalignedbb.minZ;

  switch (side) {
  case DOWN:
    d1 = j + axisalignedbb.minY - f;
    break;
  case UP:
    d1 = j + axisalignedbb.maxY + f;
    break;
  case NORTH:
    d2 = k + axisalignedbb.minZ - f;
    break;
  case SOUTH:
    d2 = k + axisalignedbb.maxZ + f;
    break;
  case WEST:
    d0 = i + axisalignedbb.minX - f;
    break;
  case EAST:
    d0 = i + axisalignedbb.maxX + f;
    break;
  }

  // this state sets the gravity and texture. this pos sets the lighting, so we better use our block pos
  Particle digFX = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), i, j, k, 0, 0, 0,
      Block.getStateId(paintBlock));
  if (digFX instanceof ParticleDigging) {
    // this pos sets the tint...wrongly
    ((ParticleDigging) digFX).setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
    // manually fixing the tint
    if (paintBlock.getBlock() == Blocks.GRASS) {
      digFX.setRBGColorF(0.6f, 0.6f, 0.6f);
    } else {
      int tint = Minecraft.getMinecraft().getBlockColors().colorMultiplier(paintBlock, world, pos, 0);
      float particleRed = 0.6f * (tint >> 16 & 255) / 255.0F;
      float particleGreen = 0.6f * (tint >> 8 & 255) / 255.0F;
      float particleBlue = 0.6f * (tint & 255) / 255.0F;
      digFX.setRBGColorF(particleRed, particleGreen, particleBlue);
    }
    /// and this is the pos we actually want the particle to be
    digFX.setPosition(d0, d1, d2);
    // and that's it, spawn my monkeys, spawn!
  }
}