Search in sources :

Example 1 with BlockPartFace

use of net.minecraft.client.renderer.model.BlockPartFace in project Ceramics by KnightMiner.

the class CrackedModel method bake.

@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation location) {
    // fetch textures
    RenderMaterial[] textures = new RenderMaterial[5];
    for (int i = 0; i < 5; i++) {
        textures[i] = owner.resolveTexture("cracks_" + (i + 1));
    }
    // create extra quads
    List<BlockPart> elements = model.getElements();
    List<BlockPart> newElements = new ArrayList<>(elements.size() * 2);
    newElements.addAll(elements);
    for (BlockPart element : elements) {
        Map<Direction, BlockPartFace> mapFaces = new HashMap<>();
        for (Entry<Direction, BlockPartFace> entry : element.mapFaces.entrySet()) {
            BlockPartFace face = entry.getValue();
            mapFaces.put(entry.getKey(), new BlockPartFace(face.cullFace, -1, "cracks", face.blockFaceUV));
        }
        newElements.add(new BlockPart(element.positionFrom, element.positionTo, mapFaces, element.partRotation, element.shade));
    }
    // wrap the original model
    IBakedModel original = model.bakeModel(owner, transform, OVERRIDES, spriteGetter, location);
    return new BakedModel(original, owner, newElements, textures, transform);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.Direction) BlockPart(net.minecraft.client.renderer.model.BlockPart) BlockPartFace(net.minecraft.client.renderer.model.BlockPartFace) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) RenderMaterial(net.minecraft.client.renderer.model.RenderMaterial) IBakedModel(net.minecraft.client.renderer.model.IBakedModel)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BlockPart (net.minecraft.client.renderer.model.BlockPart)1 BlockPartFace (net.minecraft.client.renderer.model.BlockPartFace)1 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)1 RenderMaterial (net.minecraft.client.renderer.model.RenderMaterial)1 Direction (net.minecraft.util.Direction)1