Search in sources :

Example 1 with IStateParticleBakedModel

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

the class BlockBase method addDestroyEffects.

@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) {
    IBlockState state = world.getBlockState(pos);
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
    if (model instanceof IStateParticleBakedModel) {
        state = getExtendedState(state.getActualState(world, pos), world, pos);
        TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, null);
        if (sprite != null) {
            for (int j = 0; j < 4; ++j) {
                for (int k = 0; k < 4; ++k) {
                    for (int l = 0; l < 4; ++l) {
                        double d0 = ((double) j + 0.5D) / 4.0D;
                        double d1 = ((double) k + 0.5D) / 4.0D;
                        double d2 = ((double) l + 0.5D) / 4.0D;
                        manager.addEffect(new ParticleDiggingCharset(world, (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, state, pos, sprite, getParticleTintIndex()));
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ParticleDiggingCharset(pl.asie.charset.lib.render.ParticleDiggingCharset) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IStateParticleBakedModel(pl.asie.charset.lib.render.model.IStateParticleBakedModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with IStateParticleBakedModel

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

the class UtilProxyClient method addRunningParticles.

@Override
public boolean addRunningParticles(IBlockState state, World world, BlockPos pos, Entity entity) {
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
    if (model instanceof IStateParticleBakedModel) {
        state = state.getBlock().getExtendedState(state.getActualState(world, pos), world, pos);
        TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, EnumFacing.UP);
        Particle particle = new ParticleDiggingCharset(world, entity.posX + ((double) PacketCustomBlockDust.rand.nextFloat() - 0.5D) * (double) entity.width, entity.getEntityBoundingBox().minY + 0.1D, entity.posZ + ((double) PacketCustomBlockDust.rand.nextFloat() - 0.5D) * (double) entity.width, -entity.motionX * 4.0D, 1.5D, -entity.motionZ * 4.0D, state, pos, sprite, ((BlockBase) state.getBlock()).getParticleTintIndex());
        Minecraft.getMinecraft().effectRenderer.addEffect(particle);
        return true;
    } else {
        return false;
    }
}
Also used : Particle(net.minecraft.client.particle.Particle) ParticleDiggingCharset(pl.asie.charset.lib.render.ParticleDiggingCharset) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IStateParticleBakedModel(pl.asie.charset.lib.render.model.IStateParticleBakedModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 3 with IStateParticleBakedModel

use of pl.asie.charset.lib.render.model.IStateParticleBakedModel 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)

Example 4 with IStateParticleBakedModel

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

the class BlockBase method addHitEffects.

@Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects(IBlockState state, World world, RayTraceResult target, ParticleManager manager) {
    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
    if (model instanceof IStateParticleBakedModel) {
        BlockPos pos = target.getBlockPos();
        EnumFacing side = target.sideHit;
        state = getExtendedState(state.getActualState(world, pos), world, pos);
        TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, side);
        if (sprite != null) {
            int i = pos.getX();
            int j = pos.getY();
            int k = pos.getZ();
            AxisAlignedBB axisalignedbb = state.getBoundingBox(world, pos);
            double d0 = (double) i + RANDOM.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minX;
            double d1 = (double) j + RANDOM.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minY;
            double d2 = (double) k + RANDOM.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minZ;
            if (side == EnumFacing.DOWN) {
                d1 = (double) j + axisalignedbb.minY - 0.10000000149011612D;
            }
            if (side == EnumFacing.UP) {
                d1 = (double) j + axisalignedbb.maxY + 0.10000000149011612D;
            }
            if (side == EnumFacing.NORTH) {
                d2 = (double) k + axisalignedbb.minZ - 0.10000000149011612D;
            }
            if (side == EnumFacing.SOUTH) {
                d2 = (double) k + axisalignedbb.maxZ + 0.10000000149011612D;
            }
            if (side == EnumFacing.WEST) {
                d0 = (double) i + axisalignedbb.minX - 0.10000000149011612D;
            }
            if (side == EnumFacing.EAST) {
                d0 = (double) i + axisalignedbb.maxX + 0.10000000149011612D;
            }
            Particle particle = new ParticleDiggingCharset(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, state, pos, sprite, getParticleTintIndex()).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
            manager.addEffect(particle);
            return true;
        }
    }
    return false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Particle(net.minecraft.client.particle.Particle) ParticleDiggingCharset(pl.asie.charset.lib.render.ParticleDiggingCharset) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IStateParticleBakedModel(pl.asie.charset.lib.render.model.IStateParticleBakedModel) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)4 IStateParticleBakedModel (pl.asie.charset.lib.render.model.IStateParticleBakedModel)4 Particle (net.minecraft.client.particle.Particle)3 ParticleDiggingCharset (pl.asie.charset.lib.render.ParticleDiggingCharset)3 IBlockState (net.minecraft.block.state.IBlockState)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 ParticleManager (net.minecraft.client.particle.ParticleManager)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 BlockBase (pl.asie.charset.lib.block.BlockBase)1 ParticleBlockDustCharset (pl.asie.charset.lib.render.ParticleBlockDustCharset)1