Search in sources :

Example 1 with ParticleBlockDustCharset

use of pl.asie.charset.lib.render.ParticleBlockDustCharset in project Charset by CharsetMC.

the class UtilProxyClient method spawnBlockDustClient.

@Override
public void spawnBlockDustClient(World world, BlockPos pos, Random rand, float posX, float posY, float posZ, int numberOfParticles, float particleSpeed, EnumFacing facing) {
    TextureAtlasSprite sprite;
    int tintIndex = -1;
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof BlockBase) {
        tintIndex = ((BlockBase) state.getBlock()).getParticleTintIndex();
    }
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
    if (model instanceof IStateParticleBakedModel) {
        state = state.getBlock().getExtendedState(state.getActualState(world, pos), world, pos);
        sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, facing);
    } else {
        sprite = model.getParticleTexture();
    }
    ParticleManager manager = Minecraft.getMinecraft().effectRenderer;
    for (int i = 0; i < numberOfParticles; i++) {
        double xSpeed = rand.nextGaussian() * particleSpeed;
        double ySpeed = rand.nextGaussian() * particleSpeed;
        double zSpeed = rand.nextGaussian() * particleSpeed;
        try {
            Particle particle = new ParticleBlockDustCharset(world, posX, posY, posZ, xSpeed, ySpeed, zSpeed, state, pos, sprite, tintIndex);
            manager.addEffect(particle);
        } catch (Throwable var16) {
            ModCharset.logger.warn("Could not spawn block particle!");
            return;
        }
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) IBlockState(net.minecraft.block.state.IBlockState) BlockBase(pl.asie.charset.lib.block.BlockBase) ParticleBlockDustCharset(pl.asie.charset.lib.render.ParticleBlockDustCharset) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IStateParticleBakedModel(pl.asie.charset.lib.render.model.IStateParticleBakedModel) ParticleManager(net.minecraft.client.particle.ParticleManager) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)1 Particle (net.minecraft.client.particle.Particle)1 ParticleManager (net.minecraft.client.particle.ParticleManager)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 BlockBase (pl.asie.charset.lib.block.BlockBase)1 ParticleBlockDustCharset (pl.asie.charset.lib.render.ParticleBlockDustCharset)1 IStateParticleBakedModel (pl.asie.charset.lib.render.model.IStateParticleBakedModel)1