Package net.citizensnpcs.trait
Class SkinTrait
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.SkinTrait
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTextureInternal(String signature, String value) voidClears skin texture and name.booleanWhether to fetch the Mojang skin using the NPC's name on spawn.voidonSpawn()Called when anNPCis spawned.voidrun()Called every tick if overridden.voidsetFetchDefaultSkin(boolean fetch) voidsetShouldUpdateSkins(boolean update) voidsetSkinName(String name) Sets the skin name - will respawn NPC if spawned.voidsetSkinName(String name, boolean forceUpdate) Sets the skin name - will respawn NPC if spawned.voidsetSkinPatch(SkinnableEntity.PlayerSkinModelType modelType, NamespacedKey body, NamespacedKey cape, NamespacedKey elytra) Sets the skin texture patch.voidsetSkinPersistent(String skinName, String signature, String data) Sets the skin data directly, respawning the NPC if spawned.voidsetSkinPersistent(Player player) Set skin data copying from aPlayer.boolean
-
Constructor Details
-
SkinTrait
public SkinTrait()
-
-
Method Details
-
applyTextureInternal
-
clearTexture
public void clearTexture()Clears skin texture and name. -
fetchDefaultSkin
public boolean fetchDefaultSkin()Whether to fetch the Mojang skin using the NPC's name on spawn. -
getSignature
- Returns:
- The texture signature, or null
-
getSkinName
- Returns:
- The skin name if set, or null (i.e. using the NPC's name)
-
getTexture
- Returns:
- The encoded texture data, or null
-
onSpawn
public void onSpawn()Description copied from class:TraitCalled when anNPCis spawned.NPC.getEntity()will return null until this is called. This is also called onAttach when the NPC is already spawned. -
run
public void run()Description copied from class:TraitCalled every tick if overridden. -
setFetchDefaultSkin
public void setFetchDefaultSkin(boolean fetch) - See Also:
-
setShouldUpdateSkins
public void setShouldUpdateSkins(boolean update) - See Also:
-
setSkinName
Sets the skin name - will respawn NPC if spawned.- Parameters:
name- The skin name
-
setSkinName
Sets the skin name - will respawn NPC if spawned.- Parameters:
name- The skin nameforceUpdate- Whether to force update if no data has been fetched yet- See Also:
-
setSkinPatch
public void setSkinPatch(SkinnableEntity.PlayerSkinModelType modelType, NamespacedKey body, NamespacedKey cape, NamespacedKey elytra) Sets the skin texture patch. Only guaranteed to work on Mannequin NPCs.- Parameters:
patch-
-
setSkinPersistent
Set skin data copying from aPlayer. Not subject to rate limiting from Mojang.- Parameters:
player- The player to copy
-
setSkinPersistent
Sets the skin data directly, respawning the NPC if spawned.- Parameters:
skinName- Skin name or cache keysignature-getSignature()data-getTexture()
-
shouldUpdateSkins
public boolean shouldUpdateSkins()- Returns:
- Whether the skin should be updated from Mojang periodically
-