PetManager

public final class PetManager

Owns every pet: the species read from the *.pet.yml files in the models folder, the bodies alive in the world, and the collections of online players. Bodies are vanilla mobs (an allay by default) carrying a FreeMinecraftModels model and driven by a MagmaCore Mind program, assembled from the pet behavior modules in plugins/FreeMinecraftModels/pet_behaviors/ that the pet file lists (see PetPrograms); they are never saved with their chunk, so an owned pet is re-created next to its owner, and a wild one waits in the WildPetStore until its chunk loads again. Everything runs on the server thread.

Functions

Link copied to clipboard
public void bodyDied(PetControl control)
A pet body died: drop it from the maps, and send an owned pet home or out of the collection.
Link copied to clipboard
public void bodyRemovedByPlugin(Entity entity)
A plugin removed a wild pet's body.
Link copied to clipboard
public boolean canMigrate(PetSpecies pet)
Whether a night flock of the species flies its route: the species flies, and every model its migrants may wear runs the migrate module.
Link copied to clipboard
public void chunkGenerated(World world, int cx, int cz)
A newly generated chunk loaded; it is stocked next tick.
Link copied to clipboard
public PetCollection collection(Player player)
Link copied to clipboard
public void despawn(PetControl control)
Removes a pet body from the world and from every map.
Link copied to clipboard
public String displayName(PetRecord record)
Link copied to clipboard
public boolean equip(Player player, PetRecord record)
Link copied to clipboard
public static PetManager get()
The running manager, or null when pets are unavailable on this server or no species are installed.
Link copied to clipboard
public PetRecord give(Player player, PetSpecies pet)
Adds a new adult of the species to the player's collection and brings it out.
Link copied to clipboard
public static void initialize()
(Re)loads the species and the behavior modules, builds every species' programs, and brings back the equipped pets of everyone online.
Link copied to clipboard
public boolean interact(Player player, PetControl control)
A player right-clicked a pet.
Link copied to clipboard
public static boolean isPetBody(Entity entity)
Whether the entity is a pet body, live or left over from before a restart.
Link copied to clipboard
public PetControl liveBody(UUID owner, PetRecord record)
Link copied to clipboard
public PetControl pet(Entity entity)
The pet behind a body, or null when the entity is not a live pet.
Link copied to clipboard
public Collection<PetControl> pets()
Link copied to clipboard
public void playerJoined(Player player)
Link copied to clipboard
public void playerLeft(Player player)
Link copied to clipboard
public void saveWild()
Writes the waiting wild pets to disk; called with every world save.
Link copied to clipboard
public static void shutdown()
Despawns every pet body; collections are already saved on the players, and wild pets go to the store to come back after the restart or reload.
Link copied to clipboard
public PetControl spawnMigrant(PetSpecies pet, Location at, String model, double sizeMultiplier, int viewDistance, MigrationRoute route)
Puts a wild pet on a migration route: an ordinary wild pet of the species, wearing its full model, flying the route at the top of its Mind program.
Link copied to clipboard
public PetControl spawnOwned(Player owner, PetRecord record)
Puts an equipped pet from the collection into the world beside its owner.
Link copied to clipboard
public PetControl spawnWild(PetSpecies pet, Location location)
Link copied to clipboard
public Collection<PetSpecies> species()
public PetSpecies species(String id)
Link copied to clipboard
public static void start(Plugin plugin)
Creates the Mind host and the pet clock, then loads the species.
Link copied to clipboard
public static void stop()
Despawns every pet and lets go of the host; NMSManager's shutdown closes the host itself.
Link copied to clipboard
public static long ticks()
The pet clock's tick count, the time base for love and interaction debouncing.
Link copied to clipboard
public void unequip(Player player, PetRecord record)