CustomParticleHandler.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:CodeChickenLib 作者:
/**
 * {@link Block#addHitEffects}
 * Provided the model bound is an instance of IModelParticleProvider, you will have landing particles just handled for you.
 * Use the default PerspectiveModel implementations inside CCL, Destroy effects will just be handled for you.
 *
 * @param world   The world.
 * @param pos     The position of the block.
 * @param manager The ParticleManager.
 * @return True if particles were added, basically just return the result of this method inside {@link Block#addHitEffects}
 */
@SideOnly (Side.CLIENT)
public static boolean handleDestroyEffects(World world, BlockPos pos, ParticleManager manager) {
    IBlockState state = world.getBlockState(pos);
    BlockModelShapes modelProvider = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
    try {
        state = state.getActualState(world, pos);
    } catch (Throwable ignored) {
    }
    IBakedModel model = modelProvider.getModelForState(state);
    state = state.getBlock().getExtendedState(state, world, pos);
    if (model instanceof IModelParticleProvider) {
        Cuboid6 bounds = new Cuboid6(state.getBoundingBox(world, pos));
        Set<TextureAtlasSprite> destroySprites = ((IModelParticleProvider) model).getDestroyEffects(state, world, pos);
        List<TextureAtlasSprite> sprites = destroySprites.stream().filter(sprite -> !ignoredParticleSprites.contains(sprite)).collect(Collectors.toList());
        addBlockDestroyEffects(world, bounds.add(pos), sprites, manager);
        return true;
    }
    return false;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号