RiftLibrary Projectiles - Rift-Modding-Group/RiftLibrary GitHub Wiki
Steps
Creating a projectile in RiftLibrary requires the following steps:
- Creating your Blockbench Model
- Creating your Geo Model
- Creating your entity class
- Creating and registering your renderer
Steps #1 and #2 will not be covered on this page, instead visit their respective links for info. This page will focus on steps #3 and #4
The Projectile Class
Unlike entities, blocks, items, or armor, RiftLibrary projectiles require you to extend from RiftLibProjectile
. Here's an example class that shows the result:
public class ExampleProjectile extends RiftLibProjectile {
public ExampleProjectile(World worldIn) {
super(worldIn);
}
@Override
public void projectileEntityEffects(EntityLivingBase entityLivingBase) {
}
@Override
public double getDamage() {
return 0f;
}
@Override
public void registerControllers(AnimationData data) {
}
@Override
public SoundEvent getOnProjectileHitSound() {
return null;
}
}
projectileEntityEffects(EntityLivingBase entityLivingBase)
is for code that will be run upon hiting the ground or an entity, withentityLivingBase
being the entity hit by the projectileregisterControllers(AnimationData)
is for running animationsgetOnProjectileHitSound()
is for the sound event that will play upon hitting the ground or an entitygetDamage()
is for how much damage the projectile deals
Some other handy methods that you may overwrite include:
canSelfDestroyUponHit()
is for whether or not the projectile must be destroyed upon hitting the ground or an entity. By default it's true.canRotateVertically()
is for whether or not the projectile must rotate vertically when shot. By default it's true.
The Renderer
Rendering a projectile requires you to extend from GeoProjectileRenderer
, as shown below.
public class ExampleProjectileRenderer extends GeoProjectileRenderer<ExampleProjectile> {
public ExampleProjectileRenderer(RenderManager renderManager) {
super(renderManager, new ExampleProjectileModel());
}
}
Register the projectile's renderer is the same with any other entity.