Allow overriding the head item name

This commit is contained in:
zontreck 2024-01-02 19:43:26 -07:00
parent e1f79b6af7
commit b9150379dc
3 changed files with 12 additions and 6 deletions

View file

@ -53,7 +53,7 @@ mod_name=Zontreck Library Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=GPLv3 mod_license=GPLv3
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.10.010224.1909 mod_version=1.10.010224.1940
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View file

@ -49,7 +49,7 @@ public class HeadCache
private HeadCacheItem() private HeadCacheItem()
{} {}
public ItemStack getAsItem() public ItemStack getAsItem(String itemName)
{ {
ItemStack head = new ItemStack(Items.PLAYER_HEAD, 1); ItemStack head = new ItemStack(Items.PLAYER_HEAD, 1);
@ -66,8 +66,14 @@ public class HeadCache
skullOwner.put("Properties", properties); skullOwner.put("Properties", properties);
head.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, skullOwner); head.addTagElement(PlayerHeadItem.TAG_SKULL_OWNER, skullOwner);
Component headname = ChatHelpers.macro("[0]'s Head", name); if(itemName == "")
head.setHoverName(headname); {
Component headname = ChatHelpers.macro("[0]'s Head", name);
head.setHoverName(headname);
}else {
head.setHoverName(ChatHelpers.macro(itemName));
}
return head; return head;

View file

@ -27,9 +27,9 @@ public class HeadUtilities {
} }
} }
public static ItemStack get(String playerName) public static ItemStack get(String playerName, String itemName)
{ {
return cachedLookup(playerName).getAsItem(); return cachedLookup(playerName).getAsItem(itemName);
} }
private static HeadCacheItem externalHeadRequest(String playerName) private static HeadCacheItem externalHeadRequest(String playerName)