Skip to content

Commit

Permalink
fix: skulls after 1.20.5 (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBauHD authored Dec 3, 2024
1 parent e8f49c1 commit 15b6d25
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/java/net/arcaniax/buildersutilities/utils/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@ public static ItemStack create(Material mat, String name, String lore) {
}

public static ItemStack create(Material mat, short data, int amount, String name, String lore) {
ItemStack is = new ItemStack(mat);
is.setAmount(amount);
ItemStack is = new ItemStack(mat, amount);
ItemMeta meta = is.getItemMeta();
if (!lore.equals("")) {
if (!lore.isEmpty()) {
String[] loreListArray = lore.split("__");
List<String> loreList = new ArrayList<>();
for (String s : loreListArray) {
loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
}
meta.setLore(loreList);
}
if (!name.equals("")) {
if (!name.isEmpty()) {
meta.setDisplayName(name.replace('&', ChatColor.COLOR_CHAR));
}
is.setItemMeta(meta);
Expand All @@ -79,18 +78,17 @@ public static ItemStack color(ItemStack is, int r, int g, int b) {


public static ItemStack createHead(String data, int amount, String name, String lore) {
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
item.setAmount(amount);
ItemStack item = new ItemStack(Material.PLAYER_HEAD, amount);
ItemMeta meta = item.getItemMeta();
if (!lore.equals("")) {
if (!lore.isEmpty()) {
String[] loreListArray = lore.split("__");
List<String> loreList = new ArrayList<>();
for (String s : loreListArray) {
loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
}
meta.setLore(loreList);
}
if (!name.equals("")) {
if (!name.isEmpty()) {
meta.setDisplayName(name.replace('&', ChatColor.COLOR_CHAR));
}
item.setItemMeta(meta);
Expand All @@ -101,7 +99,12 @@ public static ItemStack createHead(String data, int amount, String name, String
try {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
if (profileField.getType() == GameProfile.class) {
profileField.set(headMeta, profile);
} else {
Class<?> resolvableProfileClass = Class.forName("net.minecraft.world.item.component.ResolvableProfile");
profileField.set(headMeta, resolvableProfileClass.getConstructor(GameProfile.class).newInstance(profile));
}
} catch (Exception ignored) {
}
item.setItemMeta(headMeta);
Expand Down

0 comments on commit 15b6d25

Please # to comment.