/* * Decompiled with CFR 0.152. */ package net.minecraft.client.renderer.block.model; import java.util.List; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; import net.minecraft.client.renderer.block.model.FaceBakery; import net.minecraft.client.renderer.block.model.TextureSlots; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.ModelBaker; import net.minecraft.client.resources.model.ModelDebugName; import net.minecraft.client.resources.model.ModelState; import net.minecraft.client.resources.model.QuadCollection; import net.minecraft.client.resources.model.SpriteGetter; import net.minecraft.client.resources.model.UnbakedGeometry; import net.minecraft.core.Direction; public record SimpleUnbakedGeometry(List elements) implements UnbakedGeometry { @Override public QuadCollection bake(TextureSlots textures, ModelBaker modelBaker, ModelState modelState, ModelDebugName name) { return SimpleUnbakedGeometry.bake(this.elements, textures, modelBaker.sprites(), modelState, name); } public static QuadCollection bake(List elements, TextureSlots textures, SpriteGetter sprites, ModelState modelState, ModelDebugName name) { QuadCollection.Builder builder = new QuadCollection.Builder(); for (BlockElement element : elements) { element.faces().forEach((facing, face) -> { TextureAtlasSprite icon = sprites.resolveSlot(textures, face.texture(), name); if (face.cullForDirection() == null) { builder.addUnculledFace(SimpleUnbakedGeometry.bakeFace(element, face, icon, facing, modelState)); } else { builder.addCulledFace(Direction.rotate(modelState.transformation().getMatrix(), face.cullForDirection()), SimpleUnbakedGeometry.bakeFace(element, face, icon, facing, modelState)); } }); } return builder.build(); } private static BakedQuad bakeFace(BlockElement element, BlockElementFace face, TextureAtlasSprite icon, Direction facing, ModelState modelState) { return FaceBakery.bakeQuad(element.from(), element.to(), face, icon, facing, modelState, element.rotation(), element.shade(), element.lightEmission()); } }