Search in sources :

Example 21 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel 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 22 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel 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 23 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.

the class ProxyArboricultureClient method onModelBake.

@SubscribeEvent
public <T extends Block & IWoodTyped> void onModelBake(ModelBakeEvent event) {
    IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
    for (WoodModelEntry<T> entry : woodModelEntrys) {
        T woodTyped = entry.woodTyped;
        WoodBlockKind woodKind = woodTyped.getBlockKind();
        IWoodStateMapper woodMapper = stateMappers.get(woodTyped);
        for (IBlockState blockState : woodTyped.getBlockState().getValidStates()) {
            IWoodType woodType;
            ItemStack itemStack;
            if (entry.withVariants) {
                int meta = woodTyped.getMetaFromState(blockState);
                woodType = woodTyped.getWoodType(meta);
                itemStack = new ItemStack(woodTyped, 1, meta);
            } else {
                woodType = woodTyped.getWoodType(0);
                itemStack = new ItemStack(woodTyped);
            }
            IWoodItemMeshDefinition definition = shapers.get(itemStack.getItem());
            ImmutableMap<String, String> textures = WoodTextureManager.getTextures(woodType, woodKind);
            if (definition != null) {
                retextureItemModel(registry, textures, woodType, woodKind, itemStack, definition);
            }
            if (woodMapper != null) {
                retexturBlockModel(registry, textures, woodType, woodKind, blockState, woodMapper);
            }
        }
    }
}
Also used : IWoodType(forestry.api.arboriculture.IWoodType) WoodBlockKind(forestry.api.arboriculture.WoodBlockKind) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IWoodStateMapper(forestry.api.arboriculture.IWoodStateMapper) IWoodItemMeshDefinition(forestry.api.arboriculture.IWoodItemMeshDefinition) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 24 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.

the class MultipartModel method bake.

@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    MultipartBakedModel.Builder builder = new MultipartBakedModel.Builder();
    for (Selector selector : multipart.getSelectors()) {
        IModel model = partModels.get(selector);
        IBakedModel bakedModel = model.bake(model.getDefaultState(), format, bakedTextureGetter);
        builder.putModel(selector.getPredicate(multipart.getStateContainer()), bakedModel);
    }
    return builder.makeMultipartModel();
}
Also used : IModel(net.minecraftforge.client.model.IModel) MultipartBakedModel(net.minecraft.client.renderer.block.model.MultipartBakedModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Selector(net.minecraft.client.renderer.block.model.multipart.Selector)

Example 25 with IBakedModel

use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.

the class ModelButterflyItem method bakeModel.

private IBakedModel bakeModel(IAlleleButterflySpecies species, float size) {
    ImmutableMap<String, String> textures = ImmutableMap.of("butterfly", species.getItemTexture());
    if (modelButterfly == null) {
        try {
            modelButterfly = ModelLoaderRegistry.getModel(new ResourceLocation(Constants.MOD_ID, "item/butterfly_ge"));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    IModel model = modelButterfly.retexture(textures);
    IBakedModel bakedModel = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE);
    float scale = 1F / 16F;
    IModelState state = ModelUtil.loadModelState(new ResourceLocation(Constants.MOD_ID, "models/item/butterfly_ge"));
    state = new ModelStateComposition(state, new SimpleModelState(getTransformations(size)));
    return new PerspectiveMapWrapper(new TRSRBakedModel(bakedModel, -0.03125F, 0.25F - size * 0.37F, -0.03125F + size * scale, size * 1.4F), state);
}
Also used : IModel(net.minecraftforge.client.model.IModel) SimpleModelState(net.minecraftforge.client.model.SimpleModelState) TRSRBakedModel(forestry.core.models.TRSRBakedModel) IModelState(net.minecraftforge.common.model.IModelState) PerspectiveMapWrapper(net.minecraftforge.client.model.PerspectiveMapWrapper) ModelStateComposition(net.minecraftforge.client.model.ModelStateComposition) ResourceLocation(net.minecraft.util.ResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)197 IBlockState (net.minecraft.block.state.IBlockState)94 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)42 BlockPos (net.minecraft.util.math.BlockPos)40 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)38 EnumFacing (net.minecraft.util.EnumFacing)38 ResourceLocation (net.minecraft.util.ResourceLocation)36 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)30 ItemStack (net.minecraft.item.ItemStack)27 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)24 Block (net.minecraft.block.Block)23 IModel (net.minecraftforge.client.model.IModel)22 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)22 ArrayList (java.util.ArrayList)20 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)15 List (java.util.List)14 ItemOverride (net.minecraft.client.renderer.block.model.ItemOverride)14 ImmutableList (com.google.common.collect.ImmutableList)13