AzRendererConfigs 101

The AzRendererConfig and its specialized subclasses (AzArmorRendererConfig, AzBlockEntityRendererConfig, AzEntityRendererConfig, and AzItemRendererConfig) are part of the AzureLib rendering pipeline.

Below, you will find an overview of each class, their purposes, and fully configured real-world usage examples.

AzRendererConfig

The base AzRendererConfig class serves as the foundation for all rendering configuration subclasses. Its features include:

  • Model and texture locations: Specify geo model and texture paths.
  • Animation support: Integrate animations using AzAnimator.
  • Alpha configuration: Customize object alpha value when RenderType supports it.
  • Scaling options: Customize object scaling during rendering.
  • Render layers: Add extra effects onto the rendering process.
  • Render Stage Hooks: Support hooks before, during, and after rendering through customizable lambdas.
  • Model Render configuration: Easily register your own custom ModelRenderer.
  • Pipeline Context configuration: Easily modify or register your own Pipeline Context.
  • Per Bone Texture and RenderTypes: Easily change the texture or RenderType of a bone through customizable lambdas.
  • Customizable RenderType: Fine-tune rendering styles like cutouts, translucency, and more.

AzArmorRendererConfig

The AzArmorRendererConfig is explicitly designed for rendering animated armor models. It also provides options such as:

  • Bone providers: A custom provider for managing custom bone structures

Example

Here’s an example of setting up an armor renderer with full configuration options:

public class ExampleArmorRenderer extends AzArmorRenderer {
private static final ResourceLocation MODEL = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "geo/armor/examplearmor.geo.json"
);
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/armor/examplearmor.png"
);
private static final ResourceLocation EXTRA_TEX = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/armor/examplearmor_extra.png"
);
public ExampleArmorRenderer() {
super(
AzArmorRendererConfig.builder(MODEL, TEXTURE)
.setAnimatorProvider(CustomArmorAnimator::new) // Custom animations
.setBoneProvider(new CustomArmorBoneProvider()) // Bone provider for skeleton animations
.setRenderType(RenderType.itemEntityTranslucentCull(TEXTURE)) // Sets RenderType
.setRenderType(exampleArmor -> RenderType.itemEntityTranslucentCull(TEXTURE)) // Sets RenderType with context
.setModelRenderer(ExampleCustomArmorModelRenderer::new) // Sets the Model Renderer of your render to the ExampleCustomArmorModelRenderer
.setPipelineContext(ExampleArmorRendererPipelineContext::new) // Sets the Pipeline Context to the ExampleArmorRendererPipelineContext
.setBoneTextureOverrideProvider(bone ->
"exampleBone".equals(bone.getName()) ? EXTRA_TEX : TEXTURE
)
.setBoneRenderTypeOverrideProvider(bone ->
"exampleBone".equals(bone.getName())
? RenderType.entityTranslucent(EXTRA_TEX)
: null
)
.setPrerenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Pre-render hook
.setRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Render hook
.setPostRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Post-render hook
.setAlpha(exampleArmor -> 1.0F) // Alpha with context, auto sets translucent with below 1.0F
.setAlpha(1.0F) // Alpha with just a value, auto sets translucent with below 1.0F
.setScale(1.0F, 1.0F) // Scale for width and height
.setScale(1.0F) // Scale for width and height being the same
.setScale(exampleArmor -> 1.0F) // Scale for width and height being the same with context
.setScale(exampleArmor -> 1.0F, exampleArmor -> 1.0F) // Scale for width and height with context
.build()
);
}
}

AzBlockEntityRendererConfig

The AzBlockEntityRendererConfig specializes in rendering block entities.

Example

Here’s an example of setting up a block entity renderer with full configuration options:

public class ExampleBERenderer extends AzBlockEntityRenderer<ExampleBE> {
private static final ResourceLocation MODEL = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "geo/block/examplebe.geo.json"
);
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/block/examplebe.png"
);
private static final ResourceLocation EXTRA_TEX = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/block/examplebe_extra.png"
);
public ExampleBERenderer() {
super(
AzBlockEntityRendererConfig.<ExampleBE>builder(MODEL, TEXTURE)
.setAnimatorProvider(ExampleBEAnimator::new) // Custom animator
.setRenderType(RenderType.entityTranslucent(TEXTURE)) // Sets RenderType
.setRenderType(exampleBEEntity -> RenderType.entityTranslucent(TEXTURE)) // Sets RenderType with context
.setModelRenderer(ExampleCustomBEModelRenderer::new) // Sets the Model Renderer of your render to the ExampleCustomBEModelRenderer
.setPipelineContext(ExampleBERendererPipelineContext::new) // Sets the Pipeline Context to the ExampleBERendererPipelineContext
.addRenderLayer(new CustomBlockRenderLayer()) // Add render layers
.setBoneTextureOverrideProvider(bone ->
"exampleBone".equals(bone.getName()) ? EXTRA_TEX : TEXTURE
)
.setBoneRenderTypeOverrideProvider(bone ->
"exampleBone".equals(bone.getName())
? RenderType.entityTranslucent(EXTRA_TEX)
: null
)
.setPrerenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Pre-render hook
.setRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Render hook
.setPostRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Post-render hook
.setAlpha(exampleBEEntity -> 1.0F) // Alpha with context
.setAlpha(1.0F) // Alpha with just a value
.setScale(1.0F, 1.0F) // Scale for width and height
.setScale(1.0F) // Scale for width and height being the same
.setScale(exampleBEEntity -> 1.0F) // Scale for width and height being the same with context
.setScale(exampleBEEntity -> 1.0F, exampleBEEntity -> 1.0F) // Scale for width and height with context
.build()
);
}
}

This configuration adds scaling, render layers, hooks for pre- and post-rendering, and full animation support.

AzEntityRendererConfig

The AzEntityRendererConfig supports rendering entities with death-specific behaviors such as rotation when the entity dies.

Example

Here’s an example of setting up an entity renderer with full configuration options:

public class ExampleEntityRenderer extends AzEntityRenderer<ExampleEntity> {
private static final ResourceLocation MODEL = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "geo/entity/exampleentity.geo.json"
);
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/entity/exampleentity.png"
);
private static final ResourceLocation EXTRA_TEX = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/entity/exampleentity_extra.png"
);
public ExampleEntityRenderer(EntityRendererProvider.Context context) {
super(
AzEntityRendererConfig.<ExampleEntity>builder(MODEL, TEXTURE)
.setAnimatorProvider(ExampleEntityAnimator::new) // Custom animator
.setDeathMaxRotation(180F) // Custom death rotation
.setShadowRadius(1.0F) // Sets a shadow radius
.setShadowRadius(exampleEntity -> 1.0F) // Sets a shadow radius with context
.setRenderType(RenderType.entityTranslucent(TEXTURE)) // Sets RenderType
.setRenderType(exampleEntity -> RenderType.entityTranslucent(TEXTURE)) // Sets RenderType with context
.addRenderLayer(new CustomEntityRenderLayer()) // Add render layers
.setModelRenderer(ExampleCustomEntityModelRenderer::new) // Sets the Model Renderer of your render to the ExampleCustomEntityModelRenderer
.setPipelineContext(ExampleEntityRendererPipelineContext::new) // Sets the Pipeline Context to the ExampleEntityRendererPipelineContext
.setBoneTextureOverrideProvider(bone ->
"exampleBone".equals(bone.getName()) ? EXTRA_TEX : TEXTURE
)
.setBoneRenderTypeOverrideProvider(bone ->
"exampleBone".equals(bone.getName())
? RenderType.entityTranslucent(EXTRA_TEX)
: null
)
.setPrerenderEntry(context2 -> {
// Insert code you want to run here
return context2;
}) // Pre-render hook
.setRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Render hook
.setPostRenderEntry(context2 -> {
// Insert code you want to run here
return context2;
}) // Post-render hook
.setAlpha(exampleEntity -> 1.0F) // Alpha with context
.setAlpha(1.0F) // Alpha with just a value
.setScale(1.0F, 1.0F) // Scale for width and height
.setScale(1.0F) // Scale for width and height being the same
.setScale(exampleEntity -> 1.0F) // Scale for width and height being the same with context
.setScale(exampleEntity -> 1.0F, exampleEntity -> 1.0F) // Scale for width and height with context
.build(),
context
);
}
}

This implementation allows you to define rotations, animations, and layers for the entity.

AzItemRendererConfig

The AzItemRendererConfig is tailored for rendering items. It also provides options such as:

  • Context-aware animations that can be enabled/disabled per display context
  • GUI Lighting switch: Toggle between flat item lighting and entity-style lighting for GUI contexts
  • Offset fix: Fixes items having incorrect positioning when exported from BlockBench 4.11+
  • Player Arms Integration: Automatic rendering of player arms for first-person items when leftArm or rightArm bones are present

Player Arms Feature

Items with bones named leftArm or rightArm will automatically render player arms in first-person view, creating immersive weapon and tool experiences. This feature is automatically disabled if the First Person Model mod is detected to prevent conflicts.

You download the example arms to import here

Example

Here’s an example of setting up an item renderer with full configuration options:

public class ExampleItemRenderer extends AzItemRenderer {
private static final ResourceLocation MODEL = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "geo/item/exampleitem.geo.json"
);
private static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/item/exampleitem.png"
);
private static final ResourceLocation EXTRA_TEX = ResourceLocation.fromNamespaceAndPath(
YOUR_MOD_ID, "textures/item/exampleitem_extra.png"
);
public ExampleItemRenderer() {
super(
AzItemRendererConfig.builder(MODEL, TEXTURE)
.setAnimatorProvider(ExampleItemAnimator::new) // Custom animator
.useEntityGuiLighting() // Enable GUI lighting
.useNewOffset(true) // Use new offset for BlockBench 4.11+
.setRenderType(RenderType.itemEntityTranslucentCull(TEXTURE)) // Sets RenderType
.setRenderType(exampleItem -> RenderType.itemEntityTranslucentCull(TEXTURE)) // Sets RenderType with context
.setModelRenderer(ExampleCustomItemModelRenderer::new) // Sets the Model Renderer of your render to the ExampleCustomItemModelRenderer
.setPipelineContext(ExampleItemRendererPipelineContext::new) // Sets the Pipeline Context to the ExampleItemRendererPipelineContext
.setBoneTextureOverrideProvider(bone ->
"exampleBone".equals(bone.getName()) ? EXTRA_TEX : TEXTURE
)
.setBoneRenderTypeOverrideProvider(bone ->
"exampleBone".equals(bone.getName())
? RenderType.entityTranslucent(EXTRA_TEX)
: null
)
.addRenderLayer(new CustomItemRenderLayer()) // Add render layers
.setPrerenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Pre-render hook
.setRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Render hook
.setPostRenderEntry(context -> {
// Insert code you want to run here
return context;
}) // Post-render hook
.disableAnimationInContexts(ItemDisplayContext.GUI, ItemDisplayContext.FIXED, ItemDisplayContext.GROUND) // Disable animations in multiple contexts
.enableAnimationOnlyInContexts(ItemDisplayContext.FIRST_PERSON_LEFT_HAND, ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) // Enable animations in multiple contexts
.setShouldAnimateInContext(context -> context != ItemDisplayContext.GUI && context != ItemDisplayContext.FIXED) // Custom animation logic with predicate
.setAlpha(exampleItem -> 1.0F) // Alpha with context, auto sets translucent with below 1.0F
.setAlpha(1.0F) // Alpha with just a value, auto sets translucent with below 1.0F
.setScale(1.0F, 1.0F) // Scale for width and height
.setScale(1.0F) // Scale for width and height being the same
.setScale(exampleItem -> 1.0F) // Scale for width and height being the same with context
.setScale(exampleItem -> 1.0F, exampleEntity -> 1.0F) // Scale for width and height with context
.build()
);
}
}

This setup provides GUI lighting support, offset handling, and numerous customization options for item rendering.