Class Utils
java.lang.Object
com.jeff.pets.client.Utils
A utility class used mainly in
Central and misc rendering classes. Contains various
shortcuts and utilities for spawning, despawning, and avoiding NullPointerExceptions,
as well as a shortcut to Identifier.fromNamespaceAndPath(String, String).- Since:
- 0.8.0 (Minecraft Earth Mob Pack)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcapitalize(String s) static voidcheckName(String activePet, AbstractPet entity, String petName) The method used inCentral.refreshPetNames().static StringChecks if the string isnulland sets it to an empty - but notnullString - if it is.static StringcheckNullString(String s, String defaultSkin) Similar to the checkNullString method above, but takes a default value instead of setting the String to an empty String.static voiddespawnEntity(net.minecraft.world.entity.Entity e) Despawns the inputted pet ifeis notnull.static Stringstatic Stringstatic net.minecraft.world.level.block.BlockgetBlockFromString(String string) static AbstractPetstatic voidsetActivePet(net.minecraft.world.entity.Entity e, String s) Sets the active pet inPetsConfig.activePetas well as inCentral.summonedEntitystatic voidsetActivePetName(String name) static booleansetActivePetSkin(String skin) static voidsummonPet(AbstractPet entity, String entityName) Used to summon a pet.static voidsummonPet(AbstractPet entity, String entityName, net.minecraft.world.entity.player.Player player) static net.minecraft.resources.IdentifierwithModNamespace(String path) Used as a shortcut toIdentifier.fromNamespaceAndPath(String, String), and sets the parameternamespacewithPetsInitializer.MOD_ID.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
summonPet
Used to summon a pet.- Parameters:
entity- the entity to be summoned.entityName- the name to set the custom entity to. (Technically not required since we use a method to refresh the names inCentral, but still). returns if theentity,player, orworldisnull
-
summonPet
public static void summonPet(AbstractPet entity, String entityName, net.minecraft.world.entity.player.Player player) -
checkName
The method used inCentral.refreshPetNames(). Checks whether the entities' name is equal to the name in the config, and assigns it the correct name if not. Additionally, this method provides a layer of safety that ensures that Minecraft will not throw aNullPointerExceptionifentityisnull.- Parameters:
activePet- TheactivePetvalue that matchesentityentity- The pet of which the name is checked.petName- TheCONFIG.xname that matchesentitythat the entities' current name is checked off of.
-
checkNullString
-
checkNullString
Similar to the checkNullString method above, but takes a default value instead of setting the String to an empty String. Used to set theCONFIG.xSkinvalues to a default value and avoidNullPointerExceptions.- Parameters:
s- The string to check if itnull.defaultSkin- The default value to setsto ifsisnull.- Returns:
- If the string is
null,defaultSkinis returned. If the string is notnull, simply returnss.
-
withModNamespace
Used as a shortcut toIdentifier.fromNamespaceAndPath(String, String), and sets the parameternamespacewithPetsInitializer.MOD_ID.- Parameters:
path- The String that goes in thepathparameter.- Returns:
Identifier.fromNamespaceAndPath(String, String), with the parameternamespaceset toPetsInitializer.MOD_IDand the parameterpathset to the user's input
-
despawnEntity
public static void despawnEntity(net.minecraft.world.entity.Entity e) Despawns the inputted pet ifeis notnull.- Parameters:
e- The entity to despawn
-
setActivePet
Sets the active pet inPetsConfig.activePetas well as inCentral.summonedEntity- Parameters:
e- The entity to be summoned and added toCentral.summonedEntitys- The value to setPetsConfig.activePetto that matchese
-
getBlockFromString
-
getPet
-
getActivePetName
-
setActivePetName
-
getActivePetSkin
-
setActivePetSkin
-
capitalize
-
getAllBlocks
-