Class PetsModAddons
java.lang.Object
com.jeff.pets.client.addon.PetsModAddons
The base class for creating Pets Mod addons. Each instance is supposed to
represent an addon. Create an instance with
registerAddon(String)
Additionally, it has a few internal helper methods for me to manage addons- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddPet(@NotNull net.minecraft.world.entity.EntityType<? extends AbstractPet> type, @NotNull String entityValue, @NotNull Field entityName, Optional<PetSkin> skin) The standard method to add a pet.static voidforEachAddedPet(PetRunnable runnable) Internal methodstatic voidforEachAddedPetSafe(SafePetRunnable runnable) Internal methodstatic StringgetIdByEntityType(net.minecraft.world.entity.EntityType<?> type) Internal methodstatic PetsModAddonsregisterAddon(String id) Method used to create and register a new addon.
-
Method Details
-
registerAddon
Method used to create and register a new addon. Store it in a static accessible field somewhere so you can access it easily.Example Usage
public static final String MY_MOD_ID = "my_mod_id"; public static final PetsModAddons ADDON = PetsModAddons.registerAddon(MY_MOD_ID); -
forEachAddedPet
Internal method -
forEachAddedPetSafe
Internal method -
getIdByEntityType
Internal method -
addPet
public PetsModAddons addPet(@NotNull @NotNull net.minecraft.world.entity.EntityType<? extends AbstractPet> type, @NotNull @NotNull String entityValue, @NotNull @NotNull Field entityName, Optional<PetSkin> skin) The standard method to add a pet. Generally you would want to call it in aClientStartedEvent.Example Usage
*public static String entityName = ""; //important: MUST BE STATIC public MyModClass() { ADDON.addPet(MyEntityType.MY_PET.get(), "pet", this.getClass().getDeclaredField("entityName"), Optional.empty()); }- Parameters:
type- The entity type to be used.entityValue- What your pet will be referred to in code. Generally just what the pet is called (for example, if your pet is a goose, you would pass"goose"here.)entityName- This one is a bit of a doozy, so stay with me - this field needs to be serialized and deserialized intopetsconfig.jsonto avoid forcing developers to serialize their own stuff. Refer to the 'example usage' section for further instructions.- Returns:
- The instance that you are currently on
-