diff --git a/.idea/modules/common/HMCCosmetics.common.main.iml b/.idea/modules/common/HMCCosmetics.common.main.iml index c0e03ea1..deb609c0 100644 --- a/.idea/modules/common/HMCCosmetics.common.main.iml +++ b/.idea/modules/common/HMCCosmetics.common.main.iml @@ -1,5 +1,15 @@ + + + + + SPIGOT + ADVENTURE + + + + diff --git a/1.16/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_16_R3.java b/1.16/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_16_R3.java index bfdf156b..9d9137cf 100644 --- a/1.16/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_16_R3.java +++ b/1.16/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_16_R3.java @@ -6,6 +6,7 @@ import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.PlayerInfoData; import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; @@ -77,6 +78,23 @@ public class PlayerPackets_1_16_R3 implements PlayerPackets { return playerPacket; } + @Override + public PacketContainer getOverlayPacket(final int entityId) { + final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); + + WrappedDataWatcher metaData = new WrappedDataWatcher(); + + final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); + + final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; + + metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(16, byteSerializer), mask); + + metaContainer.getIntegers().write(0, entityId); + metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); + return metaContainer; + } + private GameProfile getCopyProfile(final Player player, final UUID uuid) { final GameProfile playerProfile = ((CraftPlayer) player).getProfile(); final GameProfile profile = new GameProfile( diff --git a/1.17/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_17_R1.java b/1.17/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_17_R1.java index 5223bc31..2ae5fcfd 100644 --- a/1.17/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_17_R1.java +++ b/1.17/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_17_R1.java @@ -6,6 +6,7 @@ import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.PlayerInfoData; import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; @@ -77,6 +78,23 @@ public class PlayerPackets_1_17_R1 implements PlayerPackets { return playerPacket; } + @Override + public PacketContainer getOverlayPacket(final int entityId) { + final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); + + WrappedDataWatcher metaData = new WrappedDataWatcher(); + + final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); + + final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; + + metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, byteSerializer), mask); + + metaContainer.getIntegers().write(0, entityId); + metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); + return metaContainer; + } + private GameProfile getCopyProfile(final Player player, final UUID uuid) { final GameProfile playerProfile = ((CraftPlayer) player).getProfile(); final GameProfile profile = new GameProfile( diff --git a/1.18/build/classes/java/main/io/github/fisher2911/nms/PlayerPackets_1_18_R1.class b/1.18/build/classes/java/main/io/github/fisher2911/nms/PlayerPackets_1_18_R1.class index bf9e6dd7..dabcc790 100644 Binary files a/1.18/build/classes/java/main/io/github/fisher2911/nms/PlayerPackets_1_18_R1.class and b/1.18/build/classes/java/main/io/github/fisher2911/nms/PlayerPackets_1_18_R1.class differ diff --git a/1.18/build/libs/1.18.jar b/1.18/build/libs/1.18.jar index bfa2a91a..8db8ae95 100644 Binary files a/1.18/build/libs/1.18.jar and b/1.18/build/libs/1.18.jar differ diff --git a/1.18/build/tmp/compileJava/previous-compilation-data.bin b/1.18/build/tmp/compileJava/previous-compilation-data.bin index 3fa65bb6..919a5790 100644 Binary files a/1.18/build/tmp/compileJava/previous-compilation-data.bin and b/1.18/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/1.18/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_18_R1.java b/1.18/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_18_R1.java index 9b3f7743..8f173280 100644 --- a/1.18/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_18_R1.java +++ b/1.18/src/main/java/io/github/fisher2911/nms/PlayerPackets_1_18_R1.java @@ -6,6 +6,7 @@ import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.PlayerInfoData; import com.comphenix.protocol.wrappers.WrappedChatComponent; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; @@ -47,7 +48,7 @@ public class PlayerPackets_1_18_R1 implements PlayerPackets { playerInfoData.add(new PlayerInfoData(WrappedGameProfile .fromHandle(profile), 0, - EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), + EnumWrappers.NativeGameMode.fromBukkit(GameMode.SURVIVAL), WrappedChatComponent.fromText(profile.getName()))); action.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER); @@ -78,6 +79,23 @@ public class PlayerPackets_1_18_R1 implements PlayerPackets { return playerPacket; } + @Override + public PacketContainer getOverlayPacket(final int entityId) { + final PacketContainer metaContainer = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); + + WrappedDataWatcher metaData = new WrappedDataWatcher(); + + final WrappedDataWatcher.Serializer byteSerializer = WrappedDataWatcher.Registry.get(Byte.class); + + final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; + + metaData.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(17, byteSerializer), mask); + + metaContainer.getIntegers().write(0, entityId); + metaContainer.getWatchableCollectionModifier().write(0, metaData.getWatchableObjects()); + return metaContainer; + } + private GameProfile getCopyProfile(final Player player, final UUID uuid) { final GameProfile playerProfile = ((CraftPlayer) player).getProfile(); final GameProfile profile = new GameProfile( @@ -89,6 +107,9 @@ public class PlayerPackets_1_18_R1 implements PlayerPackets { Property textureProperty = playerProfile.getProperties().get("textures").iterator().next(); String texture = textureProperty.getValue(); String signature = textureProperty.getSignature(); + System.out.println("Texture of: " + uuid); + System.out.println("Texture is: " + texture); + System.out.println("Signature is: " + signature); profile.getProperties().put("textures", new Property("textures", texture, signature)); return profile; diff --git a/common/build/libs/HMCCosmetics.jar b/common/build/libs/HMCCosmetics.jar index a2a41ce9..438db611 100644 Binary files a/common/build/libs/HMCCosmetics.jar and b/common/build/libs/HMCCosmetics.jar differ diff --git a/common/build/tmp/compileJava/previous-compilation-data.bin b/common/build/tmp/compileJava/previous-compilation-data.bin index 8d03b4ec..39e958c9 100644 Binary files a/common/build/tmp/compileJava/previous-compilation-data.bin and b/common/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java index 3801a553..304a3630 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/packet/PacketManager.java @@ -191,6 +191,12 @@ public class PacketManager { return playerPackets.getPlayerInfoPacket(player, uuid); } + public static PacketContainer getPlayerOverlayPacket(final int playerId) throws IllegalStateException { + if (playerPackets == null) + throw new IllegalStateException("This cannot be used in version: " + Bukkit.getVersion()); + return playerPackets.getOverlayPacket(playerId); + } + public static PacketContainer getRemovePlayerPacket(final Player player, final UUID uuid, final int entityId) { if (playerPackets == null) throw new IllegalStateException("This cannot be used in version: " + Bukkit.getVersion()); diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java index 7d29be7e..e9f597ff 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/Wardrobe.java @@ -105,8 +105,13 @@ public class Wardrobe extends User { PacketManager.sendPacket(viewer, playerInfoPacket, playerSpawnPacket); this.spawnArmorStand(viewer, this.currentLocation, this.plugin.getSettings().getCosmeticSettings()); this.updateArmorStand(viewer, plugin.getSettings(), this.currentLocation); - PacketManager.sendPacket(viewer, PacketManager.getLookPacket(this.getEntityId(), this.currentLocation)); - PacketManager.sendPacket(viewer, PacketManager.getRotationPacket(this.getEntityId(), this.currentLocation)); + PacketManager.sendPacket( + viewer, + PacketManager.getLookPacket(this.getEntityId(), this.currentLocation), + PacketManager.getRotationPacket(this.getEntityId(), this.currentLocation), + PacketManager.getPlayerOverlayPacket(this.getEntityId()) + ); + viewer.sendMessage("Sent overlay"); this.spawned = true; this.startSpinTask(viewer); diff --git a/nms/src/main/java/io/github/fisher2911/nms/PlayerPackets.java b/nms/src/main/java/io/github/fisher2911/nms/PlayerPackets.java index 8487710d..d1080c3e 100644 --- a/nms/src/main/java/io/github/fisher2911/nms/PlayerPackets.java +++ b/nms/src/main/java/io/github/fisher2911/nms/PlayerPackets.java @@ -1,6 +1,8 @@ package io.github.fisher2911.nms; +import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -11,5 +13,6 @@ public interface PlayerPackets { PacketContainer getSpawnPacket(final Location location, UUID uuid, final int entityId); PacketContainer getPlayerInfoPacket(final Player player, final UUID uuid); PacketContainer getRemovePacket(final Player player, final UUID uuid, final int entityId); + PacketContainer getOverlayPacket(final int entityId); }