Class Central

java.lang.Object
com.jeff.pets.client.Central

public class Central extends Object
This class is the "central" of the logic that despawns, spawns, and swaps out pets, as well as creating all the commands. It contains important logic and methods to manage the pets, additionally one of the entrypoints. to run a large amount of logic in the Central() method.

See Also:
  • Field Details

  • Constructor Details

    • Central

      public Central()
      Required constructor that calls the initial code.

      - Initializes all of the commands

      - Gets the default head skin

      - Registers the config

      Do NOT ever call CONFIG before it is called here or in any other mod initializer implementation, as it will cause a RuntimeException.

  • Method Details

    • createPetCommand

      public static void createPetCommand(net.neoforged.neoforge.client.event.RegisterClientCommandsEvent event)
    • despawnPet

      public static void despawnPet()
      Despawns the entity to ensure that only one is present at a time. For the helper method used, see Utils.despawnEntity(Entity)
    • summonPet

      public static void summonPet()
      Controls the base logic for how and when to summon the pets. For the helper methods used, see Utils.summonPet(AbstractPet, String)
    • refreshPetNames

      public static void refreshPetNames()
      Runs every tick in the createTickWatcher(ClientTickEvent.Post) below. Checks if the entities' names match the name defined in the config, and if they don't, assings them the correct name. For the helper methods used, see Utils.checkName(String, AbstractPet, String)
    • updateSuggestions

      public static void updateSuggestions(net.minecraft.client.Minecraft client)
      Assigns the correct matching suggestions depending on what the current active pet is.
      See Also:
    • refreshChatSuggestor

      public static void refreshChatSuggestor(net.minecraft.client.Minecraft client)
      Refreshes the chat suggestions so that the user sees a fresh set of suggestions when changing their pet.
      See Also:
    • saveConfig

      public static void saveConfig()
    • createPetSkinCommand

      public static void createPetSkinCommand(net.neoforged.neoforge.client.event.RegisterClientCommandsEvent event)
      Creates the command that allows users to use /petskin. Some of the code is slightly malformed (specifically the switch statements) as this file was re-created from a bytecode after a change messed it up around version 0.6.0
    • checkValidPet

      public static void checkValidPet(boolean isValid, com.mojang.brigadier.context.CommandContext<?> ignored, String species)
    • getBlockFromString

      public static net.minecraft.world.level.block.Block getBlockFromString(String string)
    • checkForNullObjects

      public void checkForNullObjects()
      Utilizes the Utils class to set any null Strings that might appear to a default value before they invoke a NullPointerException.
    • createPetsList

      public static void createPetsList()