9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-29 20:09:13 +00:00

fix: enchants not being passed to cosmetics

This commit is contained in:
LoJoSho
2023-12-18 19:23:53 -06:00
parent 93fb885195
commit 2910540c26
2 changed files with 8 additions and 3 deletions

View File

@@ -40,11 +40,13 @@ public class CosmeticArmorType extends Cosmetic {
}
public ItemStack getItem(@NotNull CosmeticUser user) {
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
return getItem(user, user.getUserCosmeticItem(this));
}
public ItemStack getItem(@NotNull CosmeticUser user, ItemStack cosmeticItem) {
if (!(user.getEntity() instanceof HumanEntity humanEntity)) return null;
if (Settings.getShouldAddEnchants(equipSlot)) {
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
MessagesUtil.sendDebugMessages("CosmeticArmorType - " + equippedItem.getEnchantments().values().toString());
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
}
// Basically, if force offhand is off AND there is no item in an offhand slot, then the equipment packet to add the cosmetic

View File

@@ -221,7 +221,10 @@ public class CosmeticUser {
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticBalloonType) return new ItemStack(Material.AIR);
return getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmetic.getSlot()));
}
if (cosmetic instanceof CosmeticArmorType || cosmetic instanceof CosmeticMainhandType || cosmetic instanceof CosmeticBackpackType) {
if (cosmetic instanceof CosmeticArmorType armorType) {
item = armorType.getItem(this, cosmetic.getItem());
}
if (cosmetic instanceof CosmeticBackpackType || cosmetic instanceof CosmeticMainhandType) {
item = cosmetic.getItem();
}
if (cosmetic instanceof CosmeticBalloonType) {