use of net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel in project Botania by VazkiiMods.
the class FabricPlatformModel method emitBlockQuads.
@Override
public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<Random> randomSupplier, RenderContext context) {
if (!(state.getBlock() instanceof BlockPlatform)) {
context.fallbackConsumer().accept(Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getModelManager().getMissingModel());
return;
}
Object data = ((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos);
if (data instanceof TilePlatform.PlatformData) {
BlockPos heldPos = ((TilePlatform.PlatformData) data).pos();
BlockState heldState = ((TilePlatform.PlatformData) data).state();
if (heldState == null) {
// No camo
super.emitBlockQuads(blockView, state, pos, randomSupplier, context);
} else {
// Some people used this to get an invisible block in the past, accommodate that.
if (heldState.is(ModBlocks.manaGlass)) {
return;
}
BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getBlockModel(heldState);
if (model instanceof FabricBakedModel) {
// Steal camo's model
((FabricBakedModel) model).emitBlockQuads(blockView, heldState, heldPos, randomSupplier, context);
}
}
}
}
use of net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel in project Indium by comp500.
the class IndiumTerrainRenderContext method tesselateBlock.
/**
* Called from chunk renderer hook.
*/
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model, MatrixStack matrixStack) {
this.matrix = matrixStack.peek().getModel();
this.normalMatrix = matrixStack.peek().getNormal();
try {
aoCalc.clear();
blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
((FabricBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
} catch (Throwable var9) {
CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Indium Renderer");
CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
throw new CrashException(crashReport_1);
}
// false because we've already marked the chunk as populated - caller doesn't need to
return false;
}
use of net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel in project Indium by comp500.
the class MixinItemRenderer method hook_method_23179.
@Inject(at = @At("HEAD"), method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", cancellable = true)
public void hook_method_23179(ItemStack stack, ModelTransformation.Mode transformMode, boolean invert, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay, BakedModel model, CallbackInfo ci) {
final FabricBakedModel fabricModel = (FabricBakedModel) model;
if (!(stack.isEmpty() || fabricModel.isVanillaAdapter())) {
CONTEXTS.get().renderModel(stack, transformMode, invert, matrixStack, vertexConsumerProvider, light, overlay, fabricModel, vanillaHandler);
ci.cancel();
}
}
use of net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel in project fabric by FabricMC.
the class MixinItemRenderer method hookRenderModel.
@Inject(at = @At("HEAD"), method = "renderModel", cancellable = true)
private void hookRenderModel(BakedModel model, int color, ItemStack stack, CallbackInfo ci) {
FabricBakedModel fabricModel = (FabricBakedModel) model;
if (!fabricModel.isVanillaAdapter()) {
CONTEXTS.get().renderModel(fabricModel, color, stack, this::renderQuads);
ci.cancel();
}
}
use of net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel in project fabric by FabricMC.
the class TerrainRenderContext method tesselateBlock.
/**
* Called from chunk renderer hook.
*/
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model) {
try {
aoCalc.clear();
blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
chunkInfo.beginBlock();
((FabricBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
} catch (Throwable var9) {
CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Indigo Renderer");
CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
throw new CrashException(crashReport_1);
}
return chunkInfo.resultFlags[blockInfo.defaultLayerIndex];
}
Aggregations