Search in sources :

Example 1 with WrappedBakedModel

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

the class ModelShelf method bake.

@Override
public IBakedModel bake(ShelfCacheInfo info, boolean isItem, BlockRenderLayer layer) {
    IModel retexturedModel = (shelfModel.retexture(ImmutableMap.of("plank", info.plank.getIconName()))).uvlock(false);
    IModelState state = ModelRotation.getModelRotation(0, (int) info.facing.getHorizontalAngle());
    if (info.back) {
        state = new ModelStateComposition(state, STATE_BACK);
    }
    return new WrappedBakedModel(retexturedModel.bake(state, DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter()), info.plank).addDefaultBlockTransforms();
}
Also used : ModelStateComposition(net.minecraftforge.client.model.ModelStateComposition) IModel(net.minecraftforge.client.model.IModel) IModelState(net.minecraftforge.common.model.IModelState) WrappedBakedModel(pl.asie.charset.lib.render.model.WrappedBakedModel)

Example 2 with WrappedBakedModel

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

the class BarrelModel method bake.

@Override
public IBakedModel bake(BarrelCacheInfo info, boolean isItem, BlockRenderLayer layer) {
    TextureAtlasSprite log = info.log;
    TextureAtlasSprite plank = info.plank;
    TextureAtlasSprite top = info.isMetal ? this.top_metal : this.top;
    TextureAtlasSprite front = this.front;
    TextureAtlasSprite side = this.side;
    if (info.upgrades.contains(BarrelUpgrade.STICKY)) {
        side = this.side_sticky;
        front = info.upgrades.contains(BarrelUpgrade.SILKY) ? this.front_silky_sticky : this.front_sticky;
    } else if (info.upgrades.contains(BarrelUpgrade.SILKY)) {
        front = this.front_silky;
    }
    ImmutableMap.Builder<String, String> textures = new ImmutableMap.Builder<>();
    if (isItem || layer == BlockRenderLayer.SOLID) {
        textures.put("log", log.getIconName());
        textures.put("plank", plank.getIconName());
    } else {
        textures.put("#log", "");
        textures.put("log", "");
        textures.put("#plank", "");
        textures.put("plank", "");
    }
    if (isItem || layer == BlockRenderLayer.TRANSLUCENT) {
        if (info.upgrades.contains(BarrelUpgrade.HOPPING)) {
            top = this.top_hopping;
            textures.put("hopping", side_hopping.getIconName());
        } else {
            textures.put("#hopping", "");
            textures.put("hopping", "");
        }
        textures.put("top", top.getIconName());
        textures.put("front", front.getIconName());
        textures.put("side", side.getIconName());
    } else {
        textures.put("#top", "");
        textures.put("top", "");
        textures.put("#front", "");
        textures.put("front", "");
        textures.put("#side", "");
        textures.put("side", "");
        textures.put("#hopping", "");
        textures.put("hopping", "");
    }
    IModelState state = info.orientation.toTransformation();
    IModel retexture = template.retexture(textures.build());
    return new WrappedBakedModel(retexture.bake(state, DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter()), log).addDefaultBlockTransforms();
}
Also used : IModel(net.minecraftforge.client.model.IModel) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IModelState(net.minecraftforge.common.model.IModelState) WrappedBakedModel(pl.asie.charset.lib.render.model.WrappedBakedModel) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

IModel (net.minecraftforge.client.model.IModel)2 IModelState (net.minecraftforge.common.model.IModelState)2 WrappedBakedModel (pl.asie.charset.lib.render.model.WrappedBakedModel)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 ModelStateComposition (net.minecraftforge.client.model.ModelStateComposition)1