Basic Properties
The two default properties are animalName and modId
public class ExampleAttributes<T extends ExampleEntity> extends TravelersAnimalAttributes<T> {public ExampleAttributes() {super("test_entity", "{YOUR_MOD_ID}")}}
To actually apply properties you could do one of the following:
public class ExampleAttributes<T extends ExampleEntity> extends TravelersAnimalAttributes<T> {public ExampleAttributes() {super("test_entity", "{YOUR_MOD_ID}")getEntityAttributeProperties().setFlyingSpeed(1.0);}}
These two aren't the ideal situation for this, you'd ideally want to put this in the animal.
Examples:
public abstract class AbstractExampleAnimal<T extends SmartAnimalBase> extends TravelersAnimal<T> {public AbstractExampleAnimal(String name) {super(new TravelersAnimalAttributes<>(name, "{YOUR_MOD_ID}"));init();// Since this is safe to do, we automatically register the entity here too!TravelersAnimalRegistry.register(this);}protected void init() {var animalAttributes = getAnimalAttributes();applyTravelersProperties(animalAttributes.getEntityAttributeProperties(), animalAttributes.getEntityBaseProperties());}protected abstract void applyTravelersProperties(EntityAttributeProperties<T> attributes, EntityBaseProperties<T> base);}
Now how do we store our own properties?
We can make our own attributeProvider
public class ExampleAttributes {private boolean shouldBeAbleToClimb = false;public void setShouldBeAbleToClimb(boolean shouldBeAbleToClimb) {this.shouldBeAbleToClimb = shouldBeAbleToClimb;}public boolean isShouldBeAbleToClimb() {return shouldBeAbleToClimb;}}
Now lets link this to the previous example we've made
public abstract class AbstractExampleAnimal<T extends SmartAnimalBase> extends TravelersAnimal<T> {public AbstractExampleAnimal(String name) {super(new ExampleAnimalAttributes<>(name, "{YOUR_MOD_ID}"));init();// Since this is safe to do, we automatically register the entity here too!TravelersAnimalRegistry.register(this);}// Otherwise the getter wouldn't get the new attributes we've just set@Overridepublic ExampleAnimalAttributes<T> getAnimalAttributes() {return (ExampleAnimalAttributes<T>) super.getAnimalAttributes();}protected void init() {var animalAttributes = getAnimalAttributes();applyTravelersProperties(animalAttributes.getEntityAttributeProperties(), animalAttributes.getEntityBaseProperties());applyExampleAttributes(animalAttributes.getExampleAttributes());}protected abstract void applyExampleAttributes(ExampleAttributes exampleAttributes);protected abstract void applyTravelersProperties(EntityAttributeProperties<T> attributes, EntityBaseProperties<T> base);}
ResourceLocator
Inside EntityBaseProperties
The ResourceLocator is an powerfull and easy to understand tool once you get the hang of it.
There is one provided by TravelersLib:
GeoSingleTextureLocator This is the most basic locator for your entities:
public class GeoSingleTextureLocator<T extends SmartAnimalBase> extends ResourceLocator<T> {public ResourceLocation getTextureLocation(T entity) {String entity_name = entity.getAnimal().getAnimalAttributes().getAnimalName().toLowerCase(Locale.ROOT);return TravelersLib.get().handler().createLocation(this.modId, "textures/geo/animal/" + entity_name + "/" + entity_name + ".png");}public ResourceLocation getModelLocation(T entity) {String entity_name = entity.getAnimal().getAnimalAttributes().getAnimalName().toLowerCase(Locale.ROOT);return TravelersLib.get().handler().createLocation(this.modId, "travelers/models/" + entity_name + ".geo.json");}public ResourceLocation getAnimationLocation(T entity) {String entity_name = entity.getAnimal().getAnimalAttributes().getAnimalName().toLowerCase(Locale.ROOT);return TravelersLib.get().handler().createLocation(this.modId, "travelers/animations/" + entity_name + ".animation.json");}}
For this example:
Model -> [your_mod_id/]/travelers/models/[your_mod_id/].geo.jsonTexture -> [your_mod_id/]/textures/geo/animal/[your_mod_id/]/[your_mod_id/].pngAnimation -> [your_mod_id/]/travelers/animations/[your_mod_id/].geo.json
But you can also make your own textureLocators.
Example:
base.setLocator(new ResourceLocator<>() {private static final ResourceLocation model = TravelersLib.get().handler().createLocation("{YOUR_MOD_ID}", "travelers/models/entity/example.geo.json");private static final ResourceLocation texture = TravelersLib.get().handler().createLocation("{YOUR_MOD_ID}", "textures/geo/entity/example/example.png");private static final ResourceLocation anim = TravelersLib.get().handler().createLocation("{YOUR_MOD_ID}", "travelers/animations/entity/example.animation.json");@Overridepublic ResourceLocation getTextureLocation(ExampleEntity entity) {return texture;}@Overridepublic ResourceLocation getModelLocation(ExampleEntity entity) {return model;}@Overridepublic ResourceLocation getAnimationLocation(ExampleEntity entity) {return anim;}});
In theory that should be all for the attributes, as you can see it's an powerfull but simple data-holding tool