Search in sources :

Example 1 with ParticleDigging

use of net.minecraft.client.particle.ParticleDigging in project ForestryMC by ForestryMC.

the class ParticleHelper method addBlockHitEffects.

@SideOnly(Side.CLIENT)
public static boolean addBlockHitEffects(World world, BlockPos pos, EnumFacing side, ParticleManager effectRenderer, Callback callback) {
    IBlockState iblockstate = world.getBlockState(pos);
    if (iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
        int x = pos.getX();
        int y = pos.getY();
        int z = pos.getZ();
        float f = 0.1F;
        AxisAlignedBB axisalignedbb = iblockstate.getBoundingBox(world, pos);
        double px = x + world.rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - f * 2.0F) + f + axisalignedbb.minX;
        double py = y + world.rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - f * 2.0F) + f + axisalignedbb.minY;
        double pz = z + world.rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - f * 2.0F) + f + axisalignedbb.minZ;
        if (side == EnumFacing.DOWN) {
            py = y + axisalignedbb.minY - f;
        }
        if (side == EnumFacing.UP) {
            py = y + axisalignedbb.maxY + f;
        }
        if (side == EnumFacing.NORTH) {
            pz = z + axisalignedbb.minZ - f;
        }
        if (side == EnumFacing.SOUTH) {
            pz = z + axisalignedbb.maxZ + f;
        }
        if (side == EnumFacing.WEST) {
            px = x + axisalignedbb.minX - f;
        }
        if (side == EnumFacing.EAST) {
            px = x + axisalignedbb.maxX + f;
        }
        ParticleDigging fx = (ParticleDigging) effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_DUST.getParticleID(), px, py, pz, 0.0D, 0.0D, 0.0D, Block.getStateId(iblockstate));
        if (fx != null) {
            callback.addHitEffects(fx, world, pos, iblockstate);
            effectRenderer.addEffect(fx.setBlockPos(new BlockPos(x, y, z)).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
        }
    }
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with ParticleDigging

use of net.minecraft.client.particle.ParticleDigging in project EnderIO by SleepyTrousers.

the class BlockConduitBundle method addBlockHitEffects.

@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);
    }
}
Also used : ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with ParticleDigging

use of net.minecraft.client.particle.ParticleDigging in project EnderIO by SleepyTrousers.

the class PaintHelper method addDestroyEffects.

@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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IPaintable(crazypants.enderio.base.paint.IPaintable) ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with ParticleDigging

use of net.minecraft.client.particle.ParticleDigging in project EnderIO by SleepyTrousers.

the class PaintHelper method addBlockHitEffects.

@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!
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Particle(net.minecraft.client.particle.Particle) ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with ParticleDigging

use of net.minecraft.client.particle.ParticleDigging in project EnderIO by SleepyTrousers.

the class BlockConduitBundle method addDestroyEffects.

@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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ParticleDigging (net.minecraft.client.particle.ParticleDigging)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 IBlockState (net.minecraft.block.state.IBlockState)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 IPaintable (crazypants.enderio.base.paint.IPaintable)1 Particle (net.minecraft.client.particle.Particle)1 BlockPos (net.minecraft.util.math.BlockPos)1