Search in sources :

Example 1 with TRSRBakedModel

use of forestry.core.models.TRSRBakedModel 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)

Example 2 with TRSRBakedModel

use of forestry.core.models.TRSRBakedModel in project ForestryMC by ForestryMC.

the class ModelCrate method bakeModel.

/**
 * Bake the crate model.
 */
private List<IBakedModel> bakeModel(ItemCrated crateItem) {
    List<IBakedModel> models = new ArrayList<>();
    ItemStack contained = crateItem.getContained();
    if (!contained.isEmpty()) {
        IBakedModel containedModel = getCustomContentModel(crateItem);
        if (containedModel == null) {
            containedModel = ModelUtil.getModel(contained);
        }
        models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0.0625F, 0.5F));
        models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, -0.0625F, 0.5F));
    }
    return models;
}
Also used : TRSRBakedModel(forestry.core.models.TRSRBakedModel) ArrayList(java.util.ArrayList) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TRSRBakedModel (forestry.core.models.TRSRBakedModel)2 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)2 ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 IModel (net.minecraftforge.client.model.IModel)1 ModelStateComposition (net.minecraftforge.client.model.ModelStateComposition)1 PerspectiveMapWrapper (net.minecraftforge.client.model.PerspectiveMapWrapper)1 SimpleModelState (net.minecraftforge.client.model.SimpleModelState)1 IModelState (net.minecraftforge.common.model.IModelState)1