diff --git a/build.gradle.kts b/build.gradle.kts index d943eb68..14e8764b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -86,7 +86,7 @@ allprojects { compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library //compileOnly("it.unimi.dsi:fastutil:8.5.14") compileOnly("org.projectlombok:lombok:1.18.34") - compileOnly("me.lojosho:HibiscusCommons:0.6.2-d21ebed8") + compileOnly("me.lojosho:HibiscusCommons:0.6.3") // Handled by Spigot Library Loader compileOnly("net.kyori:adventure-api:4.19.0") diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java index 8a332bf1..5c799834 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/types/CosmeticBackpackType.java @@ -55,7 +55,7 @@ public class CosmeticBackpackType extends Cosmetic { } UserBackpackManager backpackManager = user.getUserBackpackManager(); - Location loc = entity.getLocation().clone().add(0, 2, 0); + Location loc = entity.getLocation(); loc.setPitch(0); List addedViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc); @@ -65,7 +65,7 @@ public class CosmeticBackpackType extends Cosmetic { user.getUserBackpackManager().getEntityManager().teleport(loc); HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.ITEM_DISPLAY, UUID.randomUUID(), addedViewers); - HMCCPacketManager.sendItemDisplayMetadata(entityId, backpackItem, false, addedViewers); + HMCCPacketManager.sendDisplayEntityMetadataPacket(backpackManager.getDisplayEntityId(), backpackItem, addedViewers); // If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getDisplayEntityId(), user.getUserBackpackManager().getEntityManager().getViewers()); else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getDisplayEntityId(), addedViewers); diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java index 466b7761..df06f5ae 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserBackpackManager.java @@ -69,7 +69,7 @@ public class UserBackpackManager { ItemStack backpackItem = user.getUserCosmeticItem(CosmeticSlot.BACKPACK); HMCCPacketManager.sendEntitySpawnPacket(loc, getDisplayEntityId(), EntityType.ITEM_DISPLAY, UUID.randomUUID(), outsideViewers); - HMCCPacketManager.sendItemDisplayMetadata(getDisplayEntityId(), backpackItem, false, outsideViewers); + HMCCPacketManager.sendDisplayEntityMetadataPacket(getDisplayEntityId(), backpackItem, outsideViewers); Entity entity = user.getEntity(); int[] passengerIDs = new int[entity.getPassengers().size() + 1]; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java index 0d008962..c6502b34 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java @@ -19,10 +19,7 @@ import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.util.packets.PacketManager; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.ItemDisplay; -import org.bukkit.entity.Player; +import org.bukkit.entity.*; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -378,6 +375,38 @@ public class HMCCPacketManager extends PacketManager { } } + public static void sendDisplayEntityMetadataPacket(int entityid, ItemStack backpackItem, List sendTo) { + // TODO: Make the default values adjustable + Vector3f translation = new Vector3f(0, 3, 0); + Vector3f scale = new Vector3f(1, 1, 1); + Quaternionf rotationLeft = new Quaternionf(); + Quaternionf rotationRight = new Quaternionf(); + Display.Billboard billboard = Display.Billboard.FIXED; + int blockLight = 15; + int skylight = 15; + int viewRange = Settings.getViewDistance(); + int width = 0; + int height = 0; + ItemDisplay.ItemDisplayTransform transform = ItemDisplay.ItemDisplayTransform.HEAD; + + NMSHandlers.getHandler().getPacketHandler().sendItemDisplayMetadata( + entityid, + translation, + scale, + rotationLeft, + rotationRight, + billboard, + blockLight, + skylight, + viewRange, + width, + height, + transform, + backpackItem, + sendTo + ); + } + /** * Gets the nearby players (or viewers) of a location through the view distance set in the config. If the view distance is 0, it will return all players in the world. * @param location