Search in sources :

Example 1 with SimpleModelState

use of net.minecraftforge.client.model.SimpleModelState 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 SimpleModelState

use of net.minecraftforge.client.model.SimpleModelState in project HorsePower by GoryMoon.

the class BakedChopperModel method getActualModel.

protected IBakedModel getActualModel(String texture, String top_texture, EnumFacing facing) {
    IBakedModel bakedModel = standard;
    if (texture != null) {
        if (cache.containsKey(texture)) {
            bakedModel = cache.get(texture);
        } else if (choppingModel != null) {
            ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
            builder.put("2", texture);
            builder.put("1", top_texture);
            IModel retexturedModel = choppingModel.retexture(builder.build());
            IModelState modelState = new SimpleModelState(transforms);
            bakedModel = retexturedModel.bake(modelState, format, textureGetter);
            cache.put(texture, bakedModel);
        }
    }
    final IBakedModel parentModel = bakedModel;
    try {
        bakedModel = tableCombinedCache.get(new TableCombinationCacheKey(bakedModel, facing), () -> getCombinedBakedModel(facing, parentModel));
    } catch (ExecutionException ignored) {
    }
    return bakedModel;
}
Also used : IModel(net.minecraftforge.client.model.IModel) SimpleModelState(net.minecraftforge.client.model.SimpleModelState) CacheBuilder(com.google.common.cache.CacheBuilder) IModelState(net.minecraftforge.common.model.IModelState) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with SimpleModelState

use of net.minecraftforge.client.model.SimpleModelState in project Binnie by ForestryMC.

the class ModelManager method mergeStates.

private static IModelState mergeStates(IModelState state, IModelState secondaryState) {
    Map<TransformType, TRSRTransformation> tMap = Maps.newHashMap();
    TRSRTransformation guiTransformation = secondaryState.apply(Optional.of(TransformType.GUI)).get();
    tMap.putAll(PerspectiveMapWrapper.getTransforms(state));
    tMap.put(TransformType.GUI, guiTransformation);
    return new SimpleModelState(ImmutableMap.copyOf(tMap));
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) SimpleModelState(net.minecraftforge.client.model.SimpleModelState) TransformType(net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)

Example 4 with SimpleModelState

use of net.minecraftforge.client.model.SimpleModelState in project Railcraft by Railcraft.

the class Transforms method getItem.

public static IModelState getItem() {
    TRSRTransformation thirdPerson = get(0, 3, 1, 0, 0, 0, 0.55f);
    TRSRTransformation firstPerson = get(1.13f, 3.2f, 1.13f, 0, -90, 25, 0.68f);
    ImmutableMap.Builder<ItemCameraTransforms.TransformType, TRSRTransformation> builder = ImmutableMap.builder();
    builder.put(ItemCameraTransforms.TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.5f));
    builder.put(ItemCameraTransforms.TransformType.HEAD, get(0, 13, 7, 0, 180, 0, 1));
    builder.put(ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, thirdPerson);
    builder.put(ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, leftify(thirdPerson));
    builder.put(ItemCameraTransforms.TransformType.FIRST_PERSON_RIGHT_HAND, firstPerson);
    builder.put(ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, leftify(firstPerson));
    return new SimpleModelState(builder.build());
}
Also used : TRSRTransformation(net.minecraftforge.common.model.TRSRTransformation) SimpleModelState(net.minecraftforge.client.model.SimpleModelState) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

SimpleModelState (net.minecraftforge.client.model.SimpleModelState)4 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)2 IModel (net.minecraftforge.client.model.IModel)2 IModelState (net.minecraftforge.common.model.IModelState)2 TRSRTransformation (net.minecraftforge.common.model.TRSRTransformation)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 TRSRBakedModel (forestry.core.models.TRSRBakedModel)1 ExecutionException (java.util.concurrent.ExecutionException)1 TransformType (net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ModelStateComposition (net.minecraftforge.client.model.ModelStateComposition)1 PerspectiveMapWrapper (net.minecraftforge.client.model.PerspectiveMapWrapper)1