mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
feat: basic itemdisplay cosmetic backpack impl
This commit is contained in:
@@ -69,6 +69,7 @@ allprojects {
|
|||||||
|
|
||||||
// Hibiscus Commons
|
// Hibiscus Commons
|
||||||
maven("https://repo.hibiscusmc.com/releases")
|
maven("https://repo.hibiscusmc.com/releases")
|
||||||
|
mavenLocal()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -83,7 +84,7 @@ allprojects {
|
|||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.13")
|
compileOnly("it.unimi.dsi:fastutil:8.5.13")
|
||||||
compileOnly("org.projectlombok:lombok:1.18.34")
|
compileOnly("org.projectlombok:lombok:1.18.34")
|
||||||
compileOnly("me.lojosho:HibiscusCommons:0.4.1")
|
compileOnly("me.lojosho:HibiscusCommons:0.4.7")
|
||||||
|
|
||||||
// Handled by Spigot Library Loader
|
// Handled by Spigot Library Loader
|
||||||
compileOnly("net.kyori:adventure-api:4.17.0")
|
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||||
@@ -139,7 +140,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
archiveFile.get().asFile.copyTo(layout.projectDirectory.file("run/plugins/HMCCosmeticsRemapped.jar").asFile, true)
|
archiveFile.get().asFile.copyTo(File("D:\\Server\\Paper1_21\\plugins\\${project.name}-${project.version}.jar"), true)
|
||||||
println("If you use the plugin, consider buying it for: ")
|
println("If you use the plugin, consider buying it for: ")
|
||||||
println("The custom resource pack, Oraxen + ItemAdder configurations, and Discord support!")
|
println("The custom resource pack, Oraxen + ItemAdder configurations, and Discord support!")
|
||||||
println("Polymart: https://polymart.org/resource/1879")
|
println("Polymart: https://polymart.org/resource/1879")
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
|||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -62,12 +61,12 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
backpackManager.getEntityManager().teleport(loc);
|
backpackManager.getEntityManager().teleport(loc);
|
||||||
backpackManager.getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
backpackManager.getEntityManager().setRotation((int) loc.getYaw(), isFirstPersonCompadible());
|
||||||
|
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), backpackManager.getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), outsideViewers);
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), backpackManager.getFirstItemDisplayId(), EntityType.ITEM_DISPLAY, UUID.randomUUID(), outsideViewers);
|
||||||
//HMCCPacketManager.sendArmorstandMetadata(backpackManager.getFirstArmorStandId(), outsideViewers);
|
//HMCCPacketManager.sendArmorstandMetadata(backpackManager.getFirstArmorStandId(), outsideViewers);
|
||||||
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
PacketManager.equipmentSlotUpdate(backpackManager.getFirstItemDisplayId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
||||||
// If true, it will send the riding packet to all players. If false, it will send the riding packet only to new players
|
// 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(), backpackManager.getFirstArmorStandId(), backpackManager.getEntityManager().getViewers());
|
if (Settings.isBackpackForceRidingEnabled()) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), backpackManager.getFirstItemDisplayId(), backpackManager.getEntityManager().getViewers());
|
||||||
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
else HMCCPacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstItemDisplayId(), outsideViewers);
|
||||||
|
|
||||||
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
if (!user.isInWardrobe() && isFirstPersonCompadible() && user.getPlayer() != null) {
|
||||||
List<Player> owner = List.of(user.getPlayer());
|
List<Player> owner = List.of(user.getPlayer());
|
||||||
@@ -80,16 +79,16 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), backpackManager.getFirstArmorStandId(), owner);
|
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), backpackManager.getFirstItemDisplayId(), owner);
|
||||||
if (!user.isHidden()) {
|
if (!user.isHidden()) {
|
||||||
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
//if (loc.getPitch() < -70) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, new ItemStack(Material.AIR), owner);
|
||||||
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
||||||
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
PacketManager.equipmentSlotUpdate(backpackManager.getFirstItemDisplayId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||||
}
|
}
|
||||||
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesUtil.sendDebugMessages("TTTTTTT " + backpackManager.refreshBlock(backpackManager.getEntityManager().getViewers()));
|
//MessagesUtil.sendDebugMessages("TTTTTTT " + backpackManager.refreshBlock(backpackManager.getEntityManager().getViewers()));
|
||||||
backpackManager.showBackpack();
|
backpackManager.showBackpack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
@@ -30,26 +32,26 @@ public class UserBackpackManager {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean backpackHidden;
|
private boolean backpackHidden;
|
||||||
@Getter
|
@Getter
|
||||||
private int invisibleArmorStand;
|
private int itemDisplayId;
|
||||||
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
private ArrayList<Integer> particleCloud = new ArrayList<>();
|
||||||
@Getter
|
@Getter
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
@Getter
|
@Getter
|
||||||
private UserEntity entityManager;
|
private UserEntity entityManager;
|
||||||
@Getter @Setter
|
//@Getter @Setter
|
||||||
private boolean inBlock;
|
//private boolean inBlock;
|
||||||
|
|
||||||
public UserBackpackManager(CosmeticUser user) {
|
public UserBackpackManager(CosmeticUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.backpackHidden = false;
|
this.backpackHidden = false;
|
||||||
this.inBlock = false;
|
//this.inBlock = false;
|
||||||
this.invisibleArmorStand = ServerUtils.getNextEntityId();
|
this.itemDisplayId = ServerUtils.getNextEntityId();
|
||||||
this.entityManager = new UserEntity(user.getUniqueId());
|
this.entityManager = new UserEntity(user.getUniqueId());
|
||||||
if (user.getEntity() != null) this.entityManager.refreshViewers(user.getEntity().getLocation()); // Fixes an issue where a player, who somehow removes their potions, but doesn't have an entity produces an NPE (it's dumb)
|
if (user.getEntity() != null) this.entityManager.refreshViewers(user.getEntity().getLocation()); // Fixes an issue where a player, who somehow removes their potions, but doesn't have an entity produces an NPE (it's dumb)
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFirstArmorStandId() {
|
public int getFirstItemDisplayId() {
|
||||||
return invisibleArmorStand;
|
return itemDisplayId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
@@ -59,21 +61,22 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
getEntityManager().setIds(List.of(invisibleArmorStand));
|
getEntityManager().setIds(List.of(itemDisplayId));
|
||||||
getEntityManager().teleport(user.getEntity().getLocation());
|
getEntityManager().teleport(user.getEntity().getLocation());
|
||||||
List<Player> outsideViewers = getEntityManager().getViewers();
|
List<Player> outsideViewers = getEntityManager().getViewers();
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstArmorStandId(), EntityType.ARMOR_STAND, UUID.randomUUID(), getEntityManager().getViewers());
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), getFirstItemDisplayId(), EntityType.ITEM_DISPLAY, UUID.randomUUID(), getEntityManager().getViewers());
|
||||||
if (Settings.isBackpackBlockDetection()) {
|
/*if (Settings.isBackpackBlockDetection()) {
|
||||||
if (checkBlock()) {
|
if (checkBlock()) {
|
||||||
setInBlock(true);
|
setInBlock(true);
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), outsideViewers);
|
||||||
} else {
|
} else {
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), outsideViewers);
|
||||||
}
|
}
|
||||||
//refreshBlock(outsideViewers);
|
refreshBlock(outsideViewers);
|
||||||
} else {
|
} else {
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), Settings.isBackpackLightEmination(), outsideViewers);
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), outsideViewers);
|
||||||
}
|
}*/
|
||||||
|
//HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), new ItemStack(Material.AIR), outsideViewers);
|
||||||
|
|
||||||
Entity entity = user.getEntity();
|
Entity entity = user.getEntity();
|
||||||
|
|
||||||
@@ -83,7 +86,7 @@ public class UserBackpackManager {
|
|||||||
passengerIDs[i] = entity.getPassengers().get(i).getEntityId();
|
passengerIDs[i] = entity.getPassengers().get(i).getEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
passengerIDs[passengerIDs.length - 1] = this.getFirstArmorStandId();
|
passengerIDs[passengerIDs.length - 1] = this.getFirstItemDisplayId();
|
||||||
|
|
||||||
ArrayList<Player> owner = new ArrayList<>();
|
ArrayList<Player> owner = new ArrayList<>();
|
||||||
if (user.getPlayer() != null) owner.add(user.getPlayer());
|
if (user.getPlayer() != null) owner.add(user.getPlayer());
|
||||||
@@ -100,10 +103,12 @@ public class UserBackpackManager {
|
|||||||
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
if (i == 0) HMCCPacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
|
||||||
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
else HMCCPacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
|
||||||
}
|
}
|
||||||
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
|
HMCCPacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstItemDisplayId(), owner);
|
||||||
if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
//if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstItemDisplayId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
||||||
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), outsideViewers);
|
||||||
}
|
}
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
//PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||||
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
||||||
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
HMCCPacketManager.sendRidingPacket(entity.getEntityId(), passengerIDs, outsideViewers);
|
||||||
|
|
||||||
// No one should be using ME because it barely works but some still use it, so it's here
|
// No one should be using ME because it barely works but some still use it, so it's here
|
||||||
@@ -124,13 +129,13 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBackpack() {
|
public void despawnBackpack() {
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(invisibleArmorStand, getEntityManager().getViewers());
|
IntList entityIds = IntArrayList.of(itemDisplayId);
|
||||||
if (particleCloud != null) {
|
if (particleCloud != null) {
|
||||||
for (Integer entityId : particleCloud) {
|
entityIds.addAll(particleCloud);
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(entityId, getEntityManager().getViewers());
|
|
||||||
}
|
|
||||||
this.particleCloud = null;
|
this.particleCloud = null;
|
||||||
}
|
}
|
||||||
|
HMCCPacketManager.sendEntityDestroyPacket(entityIds, getEntityManager().getViewers());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideBackpack() {
|
public void hideBackpack() {
|
||||||
@@ -156,28 +161,30 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack item) {
|
public void setItem(ItemStack item) {
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
//PacketManager.equipmentSlotUpdate(getFirstItemDisplayId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||||
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), item, getEntityManager().getViewers());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearItems() {
|
public void clearItems() {
|
||||||
ItemStack item = new ItemStack(Material.AIR);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
//PacketManager.equipmentSlotUpdate(getFirstItemDisplayId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
||||||
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), item, getEntityManager().getViewers());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the block detection for the backpack
|
* Refreshes the block detection for the backpack
|
||||||
* @param outsideViewers
|
* @param outsideViewers
|
||||||
* @return true if the entity was updated, false if not
|
* @return true if the entity was updated, false if not
|
||||||
*/
|
*//*
|
||||||
public boolean refreshBlock(List<Player> outsideViewers) {
|
public boolean refreshBlock(List<Player> outsideViewers) {
|
||||||
if (Settings.isBackpackBlockDetection()) {
|
if (Settings.isBackpackBlockDetection()) {
|
||||||
if (isInBlock() && checkBlock()) {
|
if (isInBlock() && checkBlock()) {
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), false, outsideViewers);
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), false, outsideViewers);
|
||||||
setInBlock(false);
|
setInBlock(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!isInBlock() && !checkBlock()) {
|
if (!isInBlock() && !checkBlock()) {
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), true, outsideViewers);
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), true, outsideViewers);
|
||||||
setInBlock(true);
|
setInBlock(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -191,5 +198,5 @@ public class UserBackpackManager {
|
|||||||
return block.getType().isAir();
|
return block.getType().isAir();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
|
|
||||||
private final CosmeticUser user;
|
private final CosmeticUser user;
|
||||||
private String emotePlaying;
|
private String emotePlaying;
|
||||||
private final int armorStandId;
|
private final int itemDisplayId;
|
||||||
private GameMode originalGamemode;
|
private GameMode originalGamemode;
|
||||||
|
|
||||||
public UserEmoteModel(@NotNull CosmeticUser user) {
|
public UserEmoteModel(@NotNull CosmeticUser user) {
|
||||||
super(user.getPlayer());
|
super(user.getPlayer());
|
||||||
this.user = user;
|
this.user = user;
|
||||||
armorStandId = ServerUtils.getNextEntityId();
|
itemDisplayId = ServerUtils.getNextEntityId();
|
||||||
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
getRangeManager().setRenderDistance(Settings.getViewDistance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,12 +75,12 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||||
}
|
}
|
||||||
|
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
HMCCPacketManager.sendEntitySpawnPacket(thirdPersonLocation, itemDisplayId, EntityType.ITEM_DISPLAY, UUID.randomUUID(), viewer);
|
||||||
HMCCPacketManager.sendInvisibilityPacket(armorStandId, viewer);
|
//HMCCPacketManager.sendInvisibilityPacket(itemDisplayId, viewer);
|
||||||
HMCCPacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
|
HMCCPacketManager.sendLookPacket(itemDisplayId, thirdPersonLocation, viewer);
|
||||||
|
|
||||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||||
HMCCPacketManager.sendCameraPacket(armorStandId, viewer);
|
HMCCPacketManager.sendCameraPacket(itemDisplayId, viewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public class UserEmoteModel extends PlayerModel {
|
|||||||
|
|
||||||
int entityId = player.getEntityId();
|
int entityId = player.getEntityId();
|
||||||
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
HMCCPacketManager.sendEntityDestroyPacket(itemDisplayId, viewer);
|
||||||
if (this.originalGamemode != null) {
|
if (this.originalGamemode != null) {
|
||||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
||||||
player.setGameMode(this.originalGamemode);
|
player.setGameMode(this.originalGamemode);
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -45,6 +47,7 @@ public class UserEntity {
|
|||||||
|
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
IntList ids = new IntArrayList(this.ids);
|
||||||
if (user != null && owner != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
|
if (user != null && owner != user.getUniqueId() && user.isInWardrobe()) { // Fixes issue where players in wardrobe would see other players cosmetics if they were not in wardrobe
|
||||||
removePlayers.add(player);
|
removePlayers.add(player);
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
HMCCPacketManager.sendEntityDestroyPacket(ids, List.of(player));
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class UserWardrobeManager {
|
|||||||
@Getter
|
@Getter
|
||||||
private final int NPC_ID;
|
private final int NPC_ID;
|
||||||
@Getter
|
@Getter
|
||||||
private final int ARMORSTAND_ID;
|
private final int ITEM_DISPLAY_ID;
|
||||||
@Getter
|
@Getter
|
||||||
private final UUID WARDROBE_UUID;
|
private final UUID WARDROBE_UUID;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -72,7 +72,7 @@ public class UserWardrobeManager {
|
|||||||
|
|
||||||
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
public UserWardrobeManager(CosmeticUser user, Wardrobe wardrobe) {
|
||||||
NPC_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
NPC_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||||
ARMORSTAND_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
ITEM_DISPLAY_ID = me.lojosho.hibiscuscommons.util.ServerUtils.getNextEntityId();
|
||||||
WARDROBE_UUID = UUID.randomUUID();
|
WARDROBE_UUID = UUID.randomUUID();
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
|
||||||
@@ -105,16 +105,16 @@ public class UserWardrobeManager {
|
|||||||
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
||||||
|
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
// Armorstand
|
// ItemDisplay
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ARMORSTAND_ID, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
HMCCPacketManager.sendEntitySpawnPacket(viewingLocation, ITEM_DISPLAY_ID, EntityType.ITEM_DISPLAY, UUID.randomUUID(), viewer);
|
||||||
HMCCPacketManager.sendArmorstandMetadata(ARMORSTAND_ID, viewer);
|
HMCCPacketManager.sendItemDisplayMetadata(ITEM_DISPLAY_ID, new ItemStack(Material.AIR), viewer);
|
||||||
HMCCPacketManager.sendLookPacket(ARMORSTAND_ID, viewingLocation, viewer);
|
HMCCPacketManager.sendLookPacket(ITEM_DISPLAY_ID, viewingLocation, viewer);
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
user.getPlayer().teleport(viewingLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
user.getPlayer().teleport(viewingLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
user.getPlayer().setInvisible(true);
|
user.getPlayer().setInvisible(true);
|
||||||
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
HMCCPacketManager.gamemodeChangePacket(player, 3);
|
||||||
HMCCPacketManager.sendCameraPacket(ARMORSTAND_ID, viewer);
|
HMCCPacketManager.sendCameraPacket(ITEM_DISPLAY_ID, viewer);
|
||||||
|
|
||||||
// NPC
|
// NPC
|
||||||
npcName = "WardrobeNPC-" + NPC_ID;
|
npcName = "WardrobeNPC-" + NPC_ID;
|
||||||
@@ -142,8 +142,9 @@ public class UserWardrobeManager {
|
|||||||
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
||||||
if (user.isBackpackSpawned()) {
|
if (user.isBackpackSpawned()) {
|
||||||
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
||||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
//PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstItemDisplayId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
HMCCPacketManager.sendItemDisplayMetadata(ITEM_DISPLAY_ID, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
||||||
|
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstItemDisplayId(), viewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ public class UserWardrobeManager {
|
|||||||
user.getPlayer().setInvisible(false);
|
user.getPlayer().setInvisible(false);
|
||||||
|
|
||||||
// Armorstand
|
// Armorstand
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
HMCCPacketManager.sendEntityDestroyPacket(ITEM_DISPLAY_ID, viewer); // Sucess
|
||||||
|
|
||||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||||
if (WardrobeSettings.isForceExitGamemode()) {
|
if (WardrobeSettings.isForceExitGamemode()) {
|
||||||
@@ -315,10 +316,10 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
|
||||||
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstArmorStandId(), location, false, viewer);
|
HMCCPacketManager.sendTeleportPacket(user.getUserBackpackManager().getFirstItemDisplayId(), location, false, viewer);
|
||||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstItemDisplayId(), viewer);
|
||||||
user.getUserBackpackManager().getEntityManager().setRotation(nextyaw);
|
user.getUserBackpackManager().getEntityManager().setRotation(nextyaw);
|
||||||
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstItemDisplayId(), outsideViewers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON) && user.isBalloonSpawned()) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON) && user.isBalloonSpawned()) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.ItemDisplay;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -33,7 +34,7 @@ public class HMCCPacketManager extends PacketManager {
|
|||||||
final int entityId,
|
final int entityId,
|
||||||
final EntityType entityType,
|
final EntityType entityType,
|
||||||
final UUID uuid
|
final UUID uuid
|
||||||
) {
|
) {
|
||||||
sendEntitySpawnPacket(location, entityId, entityType, uuid, getViewers(location));
|
sendEntitySpawnPacket(location, entityId, entityType, uuid, getViewers(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,16 +45,7 @@ public class HMCCPacketManager extends PacketManager {
|
|||||||
final UUID uuid,
|
final UUID uuid,
|
||||||
final @NotNull List<Player> sendTo
|
final @NotNull List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY);
|
PacketManager.sendEntitySpawnPacket(location, entityId, entityType, uuid, sendTo);
|
||||||
packet.getModifier().writeDefaults();
|
|
||||||
packet.getUUIDs().write(0, uuid);
|
|
||||||
packet.getIntegers().write(0, entityId);
|
|
||||||
packet.getEntityTypeModifier().write(0, entityType);
|
|
||||||
packet.getDoubles().
|
|
||||||
write(0, location.getX()).
|
|
||||||
write(1, location.getY()).
|
|
||||||
write(2, location.getZ());
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void equipmentSlotUpdate(
|
public static void equipmentSlotUpdate(
|
||||||
@@ -96,33 +88,12 @@ public class HMCCPacketManager extends PacketManager {
|
|||||||
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
equipmentSlotUpdate(entityId, HMCCInventoryUtils.getEquipmentSlot(cosmeticSlot), user.getUserCosmeticItem(cosmeticSlot), sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendArmorstandMetadata(
|
public static void sendItemDisplayMetadata(
|
||||||
int entityId,
|
int entityId,
|
||||||
|
ItemStack itemStack,
|
||||||
List<Player> sendTo
|
List<Player> sendTo
|
||||||
) {
|
) {
|
||||||
sendArmorstandMetadata(entityId, false, sendTo);
|
PacketManager.sendItemDisplayMetadataPacket(entityId, 1f, 1f, 32, 15, 15, ItemDisplay.ItemDisplayTransform.NONE, itemStack, sendTo);
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendArmorstandMetadata(
|
|
||||||
int entityId,
|
|
||||||
boolean onFire,
|
|
||||||
List<Player> sendTo
|
|
||||||
) {
|
|
||||||
byte mask = 0x20;
|
|
||||||
if (onFire) {
|
|
||||||
// 0x21 = Invisible + Fire (Aka, burns to make it not take the light of the block its in, avoiding turning it black)
|
|
||||||
mask = 0x21;
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
|
||||||
packet.getModifier().writeDefaults();
|
|
||||||
packet.getIntegers().write(0, entityId);
|
|
||||||
final List<WrappedDataValue> wrappedDataValueList = Lists.newArrayList();
|
|
||||||
|
|
||||||
wrappedDataValueList.add(new WrappedDataValue(0, WrappedDataWatcher.Registry.get(Byte.class), mask));
|
|
||||||
wrappedDataValueList.add(new WrappedDataValue(15, WrappedDataWatcher.Registry.get(Byte.class), (byte) 0x10));
|
|
||||||
packet.getDataValueCollectionModifier().write(0, wrappedDataValueList);
|
|
||||||
for (Player p : sendTo) sendPacket(p, packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendInvisibilityPacket(
|
public static void sendInvisibilityPacket(
|
||||||
|
|||||||
Reference in New Issue
Block a user