mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-29 11:59:21 +00:00
feat: balloons now disappear when hidden
This commit is contained in:
@@ -386,6 +386,10 @@ public class CosmeticUser {
|
||||
return this.userBackpackManager != null;
|
||||
}
|
||||
|
||||
public boolean isBalloonSpawned() {
|
||||
return this.userBalloonManager != null;
|
||||
}
|
||||
|
||||
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
|
||||
if (this.userBalloonManager != null) return;
|
||||
|
||||
@@ -424,6 +428,7 @@ public class CosmeticUser {
|
||||
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
|
||||
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
|
||||
despawnBalloon();
|
||||
if (hideCosmetics) return;
|
||||
spawnBalloon((CosmeticBalloonType) cosmetic);
|
||||
MessagesUtil.sendDebugMessages("Respawned Balloon for " + getEntity().getName());
|
||||
}
|
||||
@@ -511,8 +516,9 @@ public class CosmeticUser {
|
||||
hideCosmetics = true;
|
||||
hiddenReason = reason;
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||
getBalloonManager().sendRemoveLeashPacket();
|
||||
despawnBalloon();
|
||||
//getBalloonManager().removePlayerFromModel(getPlayer());
|
||||
//getBalloonManager().sendRemoveLeashPacket();
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
despawnBackpack();
|
||||
@@ -533,6 +539,7 @@ public class CosmeticUser {
|
||||
hideCosmetics = false;
|
||||
hiddenReason = HiddenReason.NONE;
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
if (!isBalloonSpawned()) respawnBalloon();
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
||||
getBalloonManager().addPlayerToModel(this, balloonType);
|
||||
List<Player> viewer = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
|
||||
@@ -144,15 +144,18 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
if (user.getBalloonManager() == null) user.respawnBalloon();
|
||||
if (user.isBalloonSpawned()) {
|
||||
CosmeticBalloonType cosmetic = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
|
||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||
HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||
user.getBalloonManager().setLocation(balloonLocation);
|
||||
Location balloonLocation = npcLocation.clone().add(cosmetic.getBalloonOffset());
|
||||
HMCCPacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation, false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
|
||||
user.getBalloonManager().setLocation(balloonLocation);
|
||||
}
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEnabledBossbar()) {
|
||||
@@ -214,7 +217,7 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
// NPC
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
if (user.isBalloonSpawned()) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
HMCCPacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||
HMCCPacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||
|
||||
@@ -304,7 +307,7 @@ public class UserWardrobeManager {
|
||||
HMCCPacketManager.sendEntityDestroyPacket(user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON) && user.isBalloonSpawned()) {
|
||||
// The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
|
||||
//PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
|
||||
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
|
||||
|
||||
Reference in New Issue
Block a user