-
Notifications
You must be signed in to change notification settings - Fork 0
PulseLib Entities
Creating a PulseLib entity requires the following steps:
- Creating your Blockbench Model
- Creating your P Model Data
- Creating your entity class
- Creating and registering your renderer
Steps #1 and #2 are covered on their respective pages. This page focuses on steps #3 and #4.
Quick Summary
- implement PAnimatable
- Override
getAnimationManagerandregisterAnimationControllers - Create a
PAnimationManagerviaPLibHelper.createManager(this)and return it ingetAnimationManager - Add any controllers for your animations in
registerAnimationControllers
- Implement
PAnimatable- this makes your entity recognized as animatable. Override the required methods. - Create
PAnimationManager- stores your animatable instance for the renderer and other systems. Use:
private final PAnimationManager<TestEntity> animationManager = PLibHelper.createManager(this);- Override
getAnimationManager()– return your cached animation manager instance. - Override
registerAnimationControllers– define all animation controllers for your entity here.
Once these steps are done, your entity class is ready, and you just need to define your animations in registerAnimationControllers().
public class TestEntity extends Entity implements PAnimatable<TestEntity>
{
private static final PRawAnimation ANIMATION = PRawAnimation.begin().
thenPlay("animation").
thenWait(20).
thenLoop("animation").
build();
private final PAnimationManager<TestEntity> animationManager = PLibHelper.createManager(this);
public TestEntity(EntityType<?> type, Level level)
{
super(type, level);
}
@Override
public PAnimationManager<TestEntity> getAnimationManager(AnimManagerKey key)
{
return this.animationManager;
}
@Override
public void registerAnimationControllers(PAnimationManager.PAnimationRegistrar<TestEntity> registrar)
{
registrar.add(() -> state ->
{
state.controller().play(ANIMATION);
return ControllerState.PLAY;
});
}
}To display your entity in-game, you need a renderer.
With PulseLib:
- Use
PEntityRendererinstead of vanilla renderers. - No need to register model layers or mesh definitions.
- The renderer uses your
PModelDataand render context directly.
public class TestEntityRenderer extends PEntityRenderer<TestEntity> {
public TestEntityRenderer(EntityRendererProvider.Context context) {
super(context, new DefaultEntityModelData.DefaultEntityModelDataBuilder(
ResourceLocation.fromNamespaceAndPath("test_mod", "example_entity").
addTexture(ResourceLocation.fromNamespaceAndPath("test_mod", "example_entity")),
PRenderTypes.RenderTypeProvider :: trianglesSolid);
}
}Caution
PulseLib uses triangles for rendering instead of quads (vanilla).
This means you cannot use vanilla RenderType. Use the provided render types or create your own. Be aware, when you creating own RenderType you have to use this vertex format
Note
PulseLib uses instanced rendering for entity rendering. Coz Minecraft doesn't support this type of rendering by default, PulseLib rendering all entities in own pipeline. It's a bit later, then vanilla pipeline. So, if you want add something custom to your model, you should use preSubmit() or postSubmit() methods. You can directly add something to MultiBufferSource to use vanilla rendering or use PRenderQueue.submit() to add something to PulseLib render pipeline.
Start
Basics
In depth
Specifics