mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
Fixed offhand being weird in wardrobe mode
This commit is contained in:
@@ -29,6 +29,7 @@ public class PlayerPackets_1_17_R1 implements PlayerPackets {
|
||||
write(0, location.getX()).
|
||||
write(1, location.getY()).
|
||||
write(2, location.getZ());
|
||||
spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F)));
|
||||
|
||||
return spawnPacket;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class PlayerPackets_1_18_R1 implements PlayerPackets {
|
||||
write(0, location.getX()).
|
||||
write(1, location.getY()).
|
||||
write(2, location.getZ());
|
||||
spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F)));
|
||||
|
||||
return spawnPacket;
|
||||
}
|
||||
|
||||
@@ -89,13 +89,7 @@ public class User {
|
||||
return this.setItem(ArmorItem.empty(type));
|
||||
}
|
||||
|
||||
public void spawnArmorStand(final Player other) {
|
||||
final Player player = this.getPlayer();
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
final Location location = player.getLocation();
|
||||
|
||||
public void spawnArmorStand(final Player other, final Location location) {
|
||||
final PacketContainer packet = PacketManager.getEntitySpawnPacket(location, this.armorStandId, EntityType.ARMOR_STAND);
|
||||
|
||||
PacketManager.sendPacket(other, packet);
|
||||
@@ -107,8 +101,11 @@ public class User {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player player = this.getPlayer();
|
||||
if (player == null) return;
|
||||
|
||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||
this.spawnArmorStand(p);
|
||||
this.spawnArmorStand(p, player.getLocation());
|
||||
}
|
||||
|
||||
this.hasArmorStand = true;
|
||||
|
||||
@@ -98,7 +98,9 @@ public class UserManager {
|
||||
|
||||
public void resendCosmetics(final Player player) {
|
||||
for (final User user : this.userMap.values()) {
|
||||
user.spawnArmorStand(player);
|
||||
final Player p = user.getPlayer();
|
||||
if (p == null) continue;
|
||||
user.spawnArmorStand(player, p.getLocation());
|
||||
this.updateCosmetics(user, player);
|
||||
}
|
||||
}
|
||||
@@ -131,9 +133,9 @@ public class UserManager {
|
||||
|
||||
final boolean hidden = !user.shouldShow(other);
|
||||
|
||||
final ItemStack hat = this.getCosmeticItem(equipment, playerArmor.getHat(), EquipmentSlot.HEAD, hidden);
|
||||
final ItemStack hat = this.getCosmeticItem(user, equipment, playerArmor.getHat(), EquipmentSlot.HEAD, hidden);
|
||||
hatList.add(new Pair<>(EnumWrappers.ItemSlot.HEAD, hat));
|
||||
final ItemStack offHand = this.getCosmeticItem(equipment, playerArmor.getOffHand(), EquipmentSlot.OFF_HAND, hidden);
|
||||
final ItemStack offHand = this.getCosmeticItem(user, equipment, playerArmor.getOffHand(), EquipmentSlot.OFF_HAND, hidden);
|
||||
offHandList.add(new Pair<>(EnumWrappers.ItemSlot.OFFHAND, offHand));
|
||||
|
||||
if (!hat.equals(equipment.getItem(EquipmentSlot.HEAD))) {
|
||||
@@ -158,6 +160,7 @@ public class UserManager {
|
||||
}
|
||||
|
||||
private ItemStack getCosmeticItem(
|
||||
final User user,
|
||||
final Equipment equipment,
|
||||
final ArmorItem armorItem,
|
||||
final EquipmentSlot slot,
|
||||
@@ -175,7 +178,7 @@ public class UserManager {
|
||||
final boolean isAir = itemStack.getType().isAir();
|
||||
final boolean requireEmpty = cosmeticSettings.requireEmpty(slot);
|
||||
|
||||
if (!isAir && !requireEmpty && !hidden) return itemStack;
|
||||
if (!isAir && (!requireEmpty || user instanceof Wardrobe) && !hidden) return itemStack;
|
||||
|
||||
if (equipment == null) return itemStack;
|
||||
|
||||
|
||||
@@ -64,8 +64,9 @@ public class Wardrobe extends User {
|
||||
this.getUuid()
|
||||
);
|
||||
PacketManager.sendPacket(viewer, playerInfoPacket, playerSpawnPacket);
|
||||
this.spawnArmorStand(viewer);
|
||||
this.spawnArmorStand(viewer, this.currentLocation);
|
||||
this.updateArmorStand(viewer, plugin.getSettings(), this.currentLocation);
|
||||
// PacketManager.sendPacket(viewer, PacketManager.getRotationPacket(this.getEntityId(), this.currentLocation));
|
||||
this.spawned = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user