use of net.minecraft.client.renderer.model.BlockPart 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);
}
Aggregations