9
0
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:
HeroBrineGoat
2022-02-06 23:15:40 -05:00
parent 977b5e388a
commit 2347c5175d
5 changed files with 16 additions and 13 deletions

View File

@@ -29,6 +29,7 @@ public class PlayerPackets_1_17_R1 implements PlayerPackets {
write(0, location.getX()). write(0, location.getX()).
write(1, location.getY()). write(1, location.getY()).
write(2, location.getZ()); write(2, location.getZ());
spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F)));
return spawnPacket; return spawnPacket;
} }

View File

@@ -30,6 +30,7 @@ public class PlayerPackets_1_18_R1 implements PlayerPackets {
write(0, location.getX()). write(0, location.getX()).
write(1, location.getY()). write(1, location.getY()).
write(2, location.getZ()); write(2, location.getZ());
spawnPacket.getBytes().write(0, (byte)(((location.getYaw() * 256.0F) / 360.0F)));
return spawnPacket; return spawnPacket;
} }

View File

@@ -89,13 +89,7 @@ public class User {
return this.setItem(ArmorItem.empty(type)); return this.setItem(ArmorItem.empty(type));
} }
public void spawnArmorStand(final Player other) { public void spawnArmorStand(final Player other, final Location location) {
final Player player = this.getPlayer();
if (player == null) return;
final Location location = player.getLocation();
final PacketContainer packet = PacketManager.getEntitySpawnPacket(location, this.armorStandId, EntityType.ARMOR_STAND); final PacketContainer packet = PacketManager.getEntitySpawnPacket(location, this.armorStandId, EntityType.ARMOR_STAND);
PacketManager.sendPacket(other, packet); PacketManager.sendPacket(other, packet);
@@ -107,8 +101,11 @@ public class User {
return; return;
} }
final Player player = this.getPlayer();
if (player == null) return;
for (final Player p : Bukkit.getOnlinePlayers()) { for (final Player p : Bukkit.getOnlinePlayers()) {
this.spawnArmorStand(p); this.spawnArmorStand(p, player.getLocation());
} }
this.hasArmorStand = true; this.hasArmorStand = true;

View File

@@ -98,7 +98,9 @@ public class UserManager {
public void resendCosmetics(final Player player) { public void resendCosmetics(final Player player) {
for (final User user : this.userMap.values()) { 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); this.updateCosmetics(user, player);
} }
} }
@@ -131,9 +133,9 @@ public class UserManager {
final boolean hidden = !user.shouldShow(other); 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)); 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)); offHandList.add(new Pair<>(EnumWrappers.ItemSlot.OFFHAND, offHand));
if (!hat.equals(equipment.getItem(EquipmentSlot.HEAD))) { if (!hat.equals(equipment.getItem(EquipmentSlot.HEAD))) {
@@ -158,6 +160,7 @@ public class UserManager {
} }
private ItemStack getCosmeticItem( private ItemStack getCosmeticItem(
final User user,
final Equipment equipment, final Equipment equipment,
final ArmorItem armorItem, final ArmorItem armorItem,
final EquipmentSlot slot, final EquipmentSlot slot,
@@ -175,7 +178,7 @@ public class UserManager {
final boolean isAir = itemStack.getType().isAir(); final boolean isAir = itemStack.getType().isAir();
final boolean requireEmpty = cosmeticSettings.requireEmpty(slot); 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; if (equipment == null) return itemStack;

View File

@@ -64,8 +64,9 @@ public class Wardrobe extends User {
this.getUuid() this.getUuid()
); );
PacketManager.sendPacket(viewer, playerInfoPacket, playerSpawnPacket); PacketManager.sendPacket(viewer, playerInfoPacket, playerSpawnPacket);
this.spawnArmorStand(viewer); this.spawnArmorStand(viewer, this.currentLocation);
this.updateArmorStand(viewer, plugin.getSettings(), this.currentLocation); this.updateArmorStand(viewer, plugin.getSettings(), this.currentLocation);
// PacketManager.sendPacket(viewer, PacketManager.getRotationPacket(this.getEntityId(), this.currentLocation));
this.spawned = true; this.spawned = true;
} }