Fixed custom model data of skins not working in 1.20.5+

This commit is contained in:
Jules 2024-06-19 18:13:36 -07:00
parent 63a5fabc56
commit e39f73e5ce
2 changed files with 7 additions and 10 deletions

View File

@ -137,10 +137,6 @@ public class ItemSkin extends UseItem {
target.addTag(new ItemTag(SKIN_ID_TAG, appliedSkinId));
target.addTag(new ItemTag(SKIN_TYPE_TAG, appliedTypeId));
// Custom model data
if (nbtSkin.getInteger("CustomModelData") != 0)
target.addTag(new ItemTag("CustomModelData", nbtSkin.getInteger("CustomModelData")));
// Particles
if (!nbtSkin.getString("MMOITEMS_ITEM_PARTICLES").isEmpty())
target.addTag(new ItemTag("MMOITEMS_ITEM_PARTICLES", nbtSkin.getString("MMOITEMS_ITEM_PARTICLES")));
@ -155,6 +151,9 @@ public class ItemSkin extends UseItem {
// TODO SkinStat interface
// Custom model data
if (skinMeta.hasCustomModelData()) meta.setCustomModelData(skinMeta.getCustomModelData());
// Unbreakable & durability
if (skinMeta.isUnbreakable()) {
meta.setUnbreakable(true);

View File

@ -53,12 +53,6 @@ public class CanDeskin extends BooleanStat implements ConsumableItemInteraction
MMOItem originalMmoitem = targetTemplate.newBuilder(playerData.getRPG()).build();
ItemStack originalItem = targetTemplate.newBuilder(playerData.getRPG()).build().newBuilder().build();
int originalCustomModelData = originalItem.getItemMeta().hasCustomModelData() ? originalItem.getItemMeta().getCustomModelData() : -1;
if (originalCustomModelData != -1)
target.addTag(new ItemTag("CustomModelData", originalCustomModelData));
else
target.removeTag("CustomModelData");
if (originalMmoitem.hasData(ItemStats.ITEM_PARTICLES)) {
JsonObject itemParticles = ((ParticleData) originalMmoitem.getData(ItemStats.ITEM_PARTICLES)).toJson();
target.addTag(new ItemTag("MMOITEMS_ITEM_PARTICLES", itemParticles.toString()));
@ -69,6 +63,10 @@ public class CanDeskin extends BooleanStat implements ConsumableItemInteraction
ItemMeta targetItemMeta = targetItem.getItemMeta();
ItemMeta originalItemMeta = originalItem.getItemMeta();
// Custom model data
final Integer originalCustomModelData = originalItemMeta.hasCustomModelData() ? originalItemMeta.getCustomModelData() : null;
targetItemMeta.setCustomModelData(originalCustomModelData);
// TODO SkinStat
if (targetItemMeta.isUnbreakable()) {