mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-29 11:59:21 +00:00
fix: further wardrobe armor fixes for Optifine clients
This commit is contained in:
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -43,6 +44,7 @@ public class CosmeticArmorType extends Cosmetic {
|
||||
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
|
||||
|
||||
@@ -406,6 +406,7 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
CosmeticSlot cosmeticSlot = InventoryUtils.NMSCosmeticSlot(slotClicked);
|
||||
if (cosmeticSlot == null) return;
|
||||
if (!user.hasCosmeticInSlot(cosmeticSlot)) return;
|
||||
@@ -432,9 +433,11 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||
if (!user.isInWardrobe()) {
|
||||
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,6 +482,7 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
int slot = event.getPacket().getIntegers().read(2);
|
||||
MessagesUtil.sendDebugMessages("SetSlot Slot " + slot);
|
||||
@@ -497,9 +501,9 @@ public class PlayerGameListener implements Listener {
|
||||
int entityID = event.getPacket().getIntegers().read(0);
|
||||
// User
|
||||
CosmeticUser user = CosmeticUsers.getUser(entityID);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
List<com.comphenix.protocol.wrappers.Pair<EnumWrappers.ItemSlot, ItemStack>> armor = event.getPacket().getSlotStackPairLists().read(0);
|
||||
|
||||
for (int i = 0; i < armor.size(); i++) {
|
||||
|
||||
@@ -197,7 +197,7 @@ public class CosmeticUser {
|
||||
|
||||
for (Cosmetic cosmetic : getCosmetics()) {
|
||||
if (cosmetic instanceof CosmeticArmorType armorType) {
|
||||
if (getUserEmoteManager().isPlayingEmote()) return;
|
||||
if (getUserEmoteManager().isPlayingEmote() || isInWardrobe()) return;
|
||||
if (!Settings.isCosmeticForceOffhandCosmeticShow()
|
||||
&& armorType.getEquipSlot().equals(EquipmentSlot.OFF_HAND)
|
||||
&& !getPlayer().getInventory().getItemInOffHand().getType().isAir()) continue;
|
||||
|
||||
@@ -313,6 +313,8 @@ public class UserWardrobeManager {
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(user.getPlayer().getEntityId(), EquipmentSlot.HEAD, new ItemStack(Material.CARVED_PUMPKIN), viewer);
|
||||
} else {
|
||||
PacketManager.equipmentSlotUpdate(user.getPlayer(), true, viewer); // Optifine dumbassery
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,10 +25,7 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class PacketManager {
|
||||
|
||||
@@ -88,11 +85,13 @@ public class PacketManager {
|
||||
boolean empty,
|
||||
List<Player> sendTo
|
||||
) {
|
||||
HashMap<EquipmentSlot, ItemStack> items = new HashMap<>();
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemStack item = player.getInventory().getItem(slot);
|
||||
if (empty) item = new ItemStack(Material.AIR);
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), slot, item, sendTo);
|
||||
items.put(slot, item);
|
||||
}
|
||||
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), items, sendTo);
|
||||
}
|
||||
public static void equipmentSlotUpdate(
|
||||
@NotNull Player player,
|
||||
|
||||
Reference in New Issue
Block a user