use of net.minecraft.client.render.model.BakedModel in project canvas by vram-guild.
the class TerrainRenderContext method tesselateBlock.
/**
* Called from chunk renderer hook.
*/
public void tesselateBlock(BlockState blockState, BlockPos blockPos) {
try {
final BakedModel model = blockRenderManager.getModel(blockState);
aoCalc.clear();
blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
chunkInfo.beginBlock();
((DynamicBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
} catch (final Throwable var9) {
final CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Canvas Renderer");
final CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
throw new CrashException(crashReport_1);
}
}
use of net.minecraft.client.render.model.BakedModel in project meteor-client by MeteorDevelopment.
the class SimpleBlockRenderer method render.
public static void render(BlockPos pos, BlockState state, VertexConsumerProvider consumerProvider) {
if (state.getRenderType() != BlockRenderType.MODEL)
return;
VertexConsumer consumer = consumerProvider.getBuffer(RenderLayer.getSolid());
BakedModel model = mc.getBlockRenderManager().getModel(state);
Vec3d offset = state.getModelOffset(mc.world, pos);
double offsetX = pos.getX() + offset.x;
double offsetY = pos.getY() + offset.y;
double offsetZ = pos.getZ() + offset.z;
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < DIRECTIONS.length; i++) {
List<BakedQuad> list = model.getQuads(state, DIRECTIONS[i], RANDOM);
if (!list.isEmpty())
renderQuads(list, offsetX, offsetY, offsetZ, consumer);
}
List<BakedQuad> list = model.getQuads(state, null, RANDOM);
if (!list.isEmpty())
renderQuads(list, offsetX, offsetY, offsetZ, consumer);
}
use of net.minecraft.client.render.model.BakedModel in project artifality by PinkGoosik.
the class ItemRendererMixin method twoModelsItemImplementation.
@Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", at = @At("HEAD"))
void twoModelsItemImplementation(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int seed, CallbackInfo ci) {
if (!stack.isEmpty() && entity != null) {
TwoModelsItemRegistry.ENTRIES.forEach((id, item) -> {
if (stack.isOf(item)) {
BakedModel model = models.getModelManager().getModel(new ModelIdentifier(id + "_in_hand#inventory"));
renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model);
matrices.scale(0, 0, 0);
}
});
}
/*
replaces the default enchanted book model
with the custom one if a book has a lunar
enchantment
*/
// if(!stack.isEmpty() && stack.isOf(Items.ENCHANTED_BOOK)) {
// NbtList enchantments = EnchantedBookItem.getEnchantmentNbt(stack);
//
// for(int i = 0; i < enchantments.size(); ++i) {
// NbtCompound nbtCompound = enchantments.getCompound(i);
//
// Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(nbtCompound.getString("id"))).ifPresent((enchantment) -> {
// if(enchantment instanceof LunarEnchantment) {
// BakedModel model = models.getModelManager().getModel(new ModelIdentifier("artifality:lunar_enchanted_book#inventory"));
// renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model);
// matrices.scale(0, 0, 0);
// }
// });
// }
// }
}
use of net.minecraft.client.render.model.BakedModel in project friends-and-foes by Faboslav.
the class MoobloomFlowerFeatureRenderer method render.
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, T moobloomEntity, float f, float g, float h, float j, float k, float l) {
if (!moobloomEntity.isBaby() && !moobloomEntity.isInvisible()) {
BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();
BlockState blockState = ModBlocks.BUTTERCUP.get().getDefaultState();
int overlay = LivingEntityRenderer.getOverlay(moobloomEntity, 0.0F);
MinecraftClient minecraftClient = MinecraftClient.getInstance();
boolean renderAsModel = minecraftClient.hasOutline(moobloomEntity) && moobloomEntity.isInvisible();
BakedModel bakedModel = blockRenderManager.getModel(blockState);
// Head
matrixStack.push();
this.getContextModel().getHead().rotate(matrixStack);
matrixStack.translate(0.09D, -0.6D, -0.185D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
// Body
matrixStack.push();
matrixStack.translate(0.22D, -0.28D, -0.06D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
matrixStack.push();
matrixStack.translate(-0.2D, -0.22D, 0.01D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
matrixStack.push();
matrixStack.translate(0.03D, -0.28D, 0.47D);
matrixStack.scale(-0.8F, -0.8F, 0.8F);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
matrixStack.pop();
}
}
use of net.minecraft.client.render.model.BakedModel in project Client by MatHax.
the class SimpleBlockRenderer method render.
public static void render(BlockPos pos, BlockState state, VertexConsumerProvider consumerProvider) {
if (state.getRenderType() != BlockRenderType.MODEL)
return;
VertexConsumer consumer = consumerProvider.getBuffer(RenderLayer.getSolid());
BakedModel model = mc.getBlockRenderManager().getModel(state);
Vec3d offset = state.getModelOffset(mc.world, pos);
double offsetX = pos.getX() + offset.x;
double offsetY = pos.getY() + offset.y;
double offsetZ = pos.getZ() + offset.z;
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < DIRECTIONS.length; i++) {
List<BakedQuad> list = model.getQuads(state, DIRECTIONS[i], RANDOM);
if (!list.isEmpty())
renderQuads(list, offsetX, offsetY, offsetZ, consumer);
}
List<BakedQuad> list = model.getQuads(state, null, RANDOM);
if (!list.isEmpty())
renderQuads(list, offsetX, offsetY, offsetZ, consumer);
}
Aggregations