3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-27 12:00:07 +01:00

Merge pull request #66 from MagicCraft-Mc/master

Add CustomModelData option for itemInfo(ItemStack is)
Dieser Commit ist enthalten in:
St3venAU 2022-01-12 12:24:54 +08:00 committet von GitHub
Commit 92e915dfa5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -166,6 +166,11 @@ class Utils {
}
return tags.length() == 0 ? "" : tags.toString();
}
static private int getItemCustomModelData(ItemStack is) {
if(is == null || is.getItemMeta() == null || is.getItemMeta().getCustomModelData() == null) return 0;
return is.getItemMeta().getCustomModelData();
}
static private String skullOwner(ItemStack is) {
if(is == null || is.getItemMeta() == null || !(is.getItemMeta() instanceof SkullMeta skull)) return "";
@ -187,6 +192,7 @@ class Utils {
@SuppressWarnings("deprecation")
short durability = is.getDurability();
String skullOwner = skullOwner(is);
int customModelData = getItemCustomModelData(is);
int n = 0;
if(itemStackTags.length() > 0 || durability > 0 || skullOwner.length() > 0) {
sb.append(",tag:{");
@ -194,6 +200,11 @@ class Utils {
sb.append("Damage:").append(durability);
n++;
}
if(customModelData > 0) {
if(n > 0) sb.append(",");
sb.append("CustomModelData:").append(customModelData);
n++;
}
if(itemStackTags.length() > 0) {
if(n > 0) sb.append(",");
sb.append(itemStackTags);