Entity Class
package com.github.mnesikos.lilcritters.entity;
/*
* Full roster zoo animals should extend one of the following ZAWA classes: ZawaLandEntity, ZawaFlyingEntity, ZawaSemiAquaticEntity, or ZawaAquaticEntity
* Ambients should extend: ZawaAmbientFishEntity, ZawaAmbientFlyingEntity, or ZawaAmbientLandEntity
*/
public class TreeSquirrelEntity extends ZawaLandEntity {
public TreeSquirrelEntity(EntityType<? extends ZawaBaseEntity> type, World world) {
super(type, world);
}
/*
* Create your entity's movement speed, max health, and attack damage. Flying entities will need to add flying speed.
*/
public static AttributeModifierMap.MutableAttribute registerAttributes() {
return createMobAttributes().add(Attributes.MOVEMENT_SPEED, 0.3F).add(Attributes.MAX_HEALTH, 4.0).add(Attributes.ATTACK_DAMAGE, 1.0);
}
/*
* If following the guide on discord, your TREE_SQUIRREL equivalent won't exist yet.
*/
@Nullable
@Override
public AgeableEntity getBreedOffspring(ServerWorld world, AgeableEntity entity) {
return LCEntities.TREE_SQUIRREL.get().create(world);
}
}
Entity's Model Class
package com.github.mnesikos.lilcritters.client.model;
/*
* To save space and time, I will only be showing 1 piece from my model.
* Copy and paste from your model's Java export into the appropriate sections.
*/
@OnlyIn(Dist.CLIENT)
public abstract class TreeSquirrelModel extends ZawaBaseModel<TreeSquirrelEntity> {
// Your export will not have ZawaModelRenderer pieces, rename that part of each line to match this.
protected ZawaModelRenderer body;
private Iterable<ModelRenderer> parts;
// "body" should be your main body piece that everything is parented to.
public Iterable<ModelRenderer> parts() {
if (this.parts == null) {
this.parts = ImmutableList.of(body);
}
return this.parts;
}
public static class Adult extends TreeSquirrelModel {
public Adult() {
// Depending on the version of your java export, names might not match. Rename them to match what I have here.
this.texWidth = 96;
this.texHeight = 64;
this.body = new ZawaModelRenderer(this, 21, 0);
this.body.setPos(0.0F, 19.7F, -2.5F);
this.body.addBox(-3.0F, -3.5F, -4.0F, 6, 7, 8, 0.0F);
// make sure to add the line below
this.saveBase();
}
@Override
public void setupAnim(TreeSquirrelEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
}
@Override
public void playIdleAnimation(Entity entity, float v, float v1, float v2, float v3, float v4) {}
@Override
public void playMovementAnimation(Entity entity, float v, float v1, float v2, float v3, float v4) {}
}
public static class Child extends TreeSquirrelModel {
public Child() {
// My squirrel does not have a child model, only include this Child class if yours has one.
this.saveBase();
}
@Override
public void setupAnim(TreeSquirrelEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
super.setupAnim(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
}
@Override
public void playIdleAnimation(Entity entity, float v, float v1, float v2, float v3, float v4) {}
@Override
public void playMovementAnimation(Entity entity, float v, float v1, float v2, float v3, float v4) {}
}
}
Entity's Renderer Class
package com.github.mnesikos.lilcritters.client.render.entity;
public class TreeSquirrelRenderer extends ZawaMobRenderer<TreeSquirrelEntity, TreeSquirrelModel> {
private final TreeSquirrelModel adultModel;
private final TreeSquirrelModel babyModel;
public TreeSquirrelRenderer(EntityRendererManager rendererManager) {
super(rendererManager, new TreeSquirrelModel.Adult(), 1.0F);
adultModel = model;
babyModel = new TreeSquirrelModel.Child();
}
@Override
public void render(TreeSquirrelEntity entity, float entityYaw, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int packedLight) {
model = entity.isBaby() ? babyModel : adultModel;
super.render(entity, entityYaw, partialTicks, matrixStack, buffer, packedLight);
}
@Override
public void setupAdultTextures(TreeSquirrelEntity entity) {
int variantCount = entity.getTotalVariants();
adultTextures = new ResourceLocation[variantCount];
for (int i = 0; i < variantCount; i++)
adultTextures[i] = new ResourceLocation(ZawaEssentials.MOD_ID, "textures/entity/tree_squirrel/tree_squirrel_" + (i + 1) + ".png");
}
@Override
public void setupBabyTextures(TreeSquirrelEntity entity) {
int variantCount = entity.getTotalVariants();
babyTextures = new ResourceLocation[variantCount];
for (int i = 0; i < variantCount; i++)
babyTextures[i] = new ResourceLocation(ZawaEssentials.MOD_ID, "textures/entity/tree_squirrel/tree_squirrel_" + (i + 1) + ".png");
}
}