mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-02-23 02:52:38 +01:00
Changes to allow overwriting the player_head model with custom model data
This commit is contained in:
parent
e2ffc63499
commit
540f77965c
@ -7,15 +7,16 @@ Items:
|
||||
# The texture value for the head.
|
||||
# Heads can be found here: https://minecraft-heads.com/custom-heads/
|
||||
# The correct value is the one listed on the head page under Other/Value
|
||||
Model: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGRjYzZlYjQwZjNiYWRhNDFlNDMzOTg4OGQ2ZDIwNzQzNzU5OGJkYmQxNzVjMmU3MzExOTFkNWE5YTQyZDNjOCJ9fX0="
|
||||
HeadValue: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGRjYzZlYjQwZjNiYWRhNDFlNDMzOTg4OGQ2ZDIwNzQzNzU5OGJkYmQxNzVjMmU3MzExOTFkNWE5YTQyZDNjOCJ9fX0="
|
||||
# Only relevant for MC 1.14 and newer. Will set the custom_model_data so that you can overwrite the head with your own model if your players are using your texture pack
|
||||
Model: 57045
|
||||
DisplayName: "&eBackpack"
|
||||
Lore:
|
||||
- "Right click to open your backpack."
|
||||
- "Drag items on it to place them in your backpack."
|
||||
Minepacks:
|
||||
Material: shulker_shell
|
||||
# Will set the damage value and unbreakable
|
||||
on MC versions older than 1.14 or the custom_model_data for MC 1.14 and newer
|
||||
# Will set the damage value and unbreakable on MC versions older than 1.14 or the custom_model_data for MC 1.14 and newer
|
||||
Model: 10
|
||||
DisplayName: "&eBackpack"
|
||||
Lore:
|
||||
|
@ -60,13 +60,14 @@ private void loadItemConfigs()
|
||||
}
|
||||
final String displayName = ChatColor.translateAlternateColorCodes('&', getConfigE().getString(key + ".DisplayName", "&eBackpack"));
|
||||
final String material = getYamlE().getString(key + ".Material", "player_head");
|
||||
final int model = getYamlE().getInt(key + ".Model", 1);
|
||||
if(material.equalsIgnoreCase("player_head"))
|
||||
{
|
||||
itemConfigs.put(key, new ItemConfigHead(displayName, getConfigE().getString(key + ".Model", ""), loreFinal));
|
||||
itemConfigs.put(key, new ItemConfigHead(displayName, getConfigE().getString(key + ".HeadValue", ""), model, loreFinal));
|
||||
}
|
||||
else
|
||||
{
|
||||
itemConfigs.put(key, new ItemConfigItem(getMaterialFromString(material), displayName, getYamlE().getInt(key + ".Model", 1), loreFinal));
|
||||
itemConfigs.put(key, new ItemConfigItem(getMaterialFromString(material), displayName, model, loreFinal));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ public abstract class ItemConfig
|
||||
{
|
||||
protected final @NotNull String displayName;
|
||||
protected final @Nullable List<String> lore;
|
||||
protected final int model;
|
||||
|
||||
public abstract ItemStack make(final int amount);
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.Item;
|
||||
|
||||
import at.pcgamingfreaks.Bukkit.HeadUtils;
|
||||
import at.pcgamingfreaks.Bukkit.MCVersion;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -35,9 +36,9 @@ public class ItemConfigHead extends ItemConfig
|
||||
private static final UUID MINEPACKS_UUID = UUID.nameUUIDFromBytes("Minepacks".getBytes());
|
||||
@Getter protected final String value;
|
||||
|
||||
public ItemConfigHead(final @NotNull String displayName, final @NotNull String value, final @Nullable List<String> lore)
|
||||
public ItemConfigHead(final @NotNull String displayName, final @NotNull String value, final int model, final @Nullable List<String> lore)
|
||||
{
|
||||
super(displayName, lore);
|
||||
super(displayName, lore, MCVersion.isNewerOrEqualThan(MCVersion.MC_1_14) ? model : -1);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -49,6 +50,7 @@ public ItemStack make(final int amount)
|
||||
{
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setLore(lore);
|
||||
if(model >= 0) meta.setCustomModelData(model);
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
return stack;
|
||||
|
@ -20,7 +20,6 @@
|
||||
import at.pcgamingfreaks.Bukkit.MCVersion;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -35,13 +34,11 @@ public class ItemConfigItem extends ItemConfig
|
||||
{
|
||||
private static final Producer PRODUCER = MCVersion.isOlderThan(MCVersion.MC_1_14) ? new ProducerLegacy() : new ProducerModelId();
|
||||
protected final @NotNull Material material;
|
||||
protected final int value;
|
||||
|
||||
public ItemConfigItem(final @NotNull Material material, final @NotNull String displayName, final int value, final @Nullable List<String> lore)
|
||||
{
|
||||
super(displayName, lore);
|
||||
super(displayName, lore, value);
|
||||
this.material = material;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -61,7 +58,7 @@ private static class ProducerLegacy implements Producer
|
||||
@Override
|
||||
public ItemStack make(final @NotNull ItemConfigItem itemConfig, final int amount)
|
||||
{
|
||||
ItemStack stack = new ItemStack(itemConfig.material, amount, (short) itemConfig.value);
|
||||
ItemStack stack = new ItemStack(itemConfig.material, amount, (short) itemConfig.model);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
assert meta != null;
|
||||
meta.setDisplayName(itemConfig.displayName);
|
||||
@ -81,7 +78,7 @@ public ItemStack make(@NotNull ItemConfigItem itemConfig, int amount)
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
assert meta != null;
|
||||
meta.setDisplayName(itemConfig.displayName);
|
||||
meta.setCustomModelData(itemConfig.value);
|
||||
meta.setCustomModelData(itemConfig.model);
|
||||
if(itemConfig.lore != null) meta.setLore(itemConfig.lore);
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
|
Loading…
Reference in New Issue
Block a user