mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-20 15:39:16 +00:00
Compare commits
6 Commits
v2.7.5
...
display-en
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74fce41db0 | ||
|
|
fb6f402c69 | ||
|
|
ed4803f36b | ||
|
|
0041f29ed7 | ||
|
|
967668321c | ||
|
|
1b897c390f |
@@ -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")
|
||||||
|
|||||||
@@ -2,16 +2,23 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
import me.lojosho.hibiscuscommons.config.serializer.ItemSerializer;
|
||||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||||
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
import me.lojosho.shaded.configurate.serialize.SerializationException;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Display;
|
||||||
|
import org.bukkit.entity.ItemDisplay;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public abstract class Cosmetic {
|
public abstract class Cosmetic {
|
||||||
@@ -76,4 +83,52 @@ public abstract class Cosmetic {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ItemDisplayMetadata generateItemDisplayMetadata(ConfigurationNode config) {
|
||||||
|
ItemDisplayMetadata metadata = new ItemDisplayMetadata();
|
||||||
|
if (!config.virtual()) {
|
||||||
|
ConfigurationNode translationNode = config.node("translation");
|
||||||
|
ConfigurationNode scaleNode = config.node("scale");
|
||||||
|
ConfigurationNode rotationLeftNode = config.node("rotation-left");
|
||||||
|
ConfigurationNode rotationRightNode = config.node("rotation-right");
|
||||||
|
ConfigurationNode skyLightNode = config.node("sky-light");
|
||||||
|
ConfigurationNode viewRangeNode = config.node("viewrange");
|
||||||
|
ConfigurationNode widthNode = config.node("width");
|
||||||
|
ConfigurationNode heightNode = config.node("height");
|
||||||
|
ConfigurationNode displayTransformNode = config.node("display-transform");
|
||||||
|
ConfigurationNode itemstackNode = config.node("item");
|
||||||
|
|
||||||
|
if (!translationNode.virtual()) metadata.translation = stringToVector(translationNode.getString("0,0,0"));
|
||||||
|
if (!scaleNode.virtual()) metadata.scale = stringToVector(scaleNode.getString("1,1,1"));
|
||||||
|
if (!rotationLeftNode.virtual()) metadata.rotationLeft = stringToQuaternion(rotationLeftNode.getString("0,0,0,1"));
|
||||||
|
if (!rotationRightNode.virtual()) metadata.rotationRight = stringToQuaternion(rotationRightNode.getString("0,0,0,1"));
|
||||||
|
if (!skyLightNode.virtual()) metadata.skyLight = skyLightNode.getInt(15);
|
||||||
|
if (!viewRangeNode.virtual()) metadata.viewRange = viewRangeNode.getFloat(1);
|
||||||
|
if (!widthNode.virtual()) metadata.width = widthNode.getFloat(0);
|
||||||
|
if (!heightNode.virtual()) metadata.height = heightNode.getFloat(0);
|
||||||
|
if (!displayTransformNode.virtual()) try {
|
||||||
|
metadata.displayTransform = ItemDisplay.ItemDisplayTransform.valueOf(displayTransformNode.getString());
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
if (!itemstackNode.virtual()) try {
|
||||||
|
metadata.itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, itemstackNode);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Vector3f stringToVector(String string) {
|
||||||
|
List<String> vector = Arrays.stream(string.replace(" ", "").split(",", 3)).toList();
|
||||||
|
while (vector.size() < 3) vector.add("0");
|
||||||
|
float x = Float.parseFloat(vector.get(0)), y = Float.parseFloat(vector.get(1)), z = Float.parseFloat(vector.get(2));
|
||||||
|
return new Vector3f(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Quaternionf stringToQuaternion(String string) {
|
||||||
|
List<String> vector = Arrays.stream(string.replace(" ", "").split(",", 4)).toList();
|
||||||
|
while (vector.size() < 3) vector.add("0");
|
||||||
|
if (vector.size() < 4) vector.add("1");
|
||||||
|
float x = Float.parseFloat(vector.get(0)), y = Float.parseFloat(vector.get(1)), z = Float.parseFloat(vector.get(2)), w = Float.parseFloat(vector.get(3));
|
||||||
|
return new Quaternionf(x, y, z, w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,16 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
import lombok.Setter;
|
||||||
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;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -31,16 +30,24 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
@Getter
|
@Getter
|
||||||
private int height = -1;
|
private int height = -1;
|
||||||
private ItemStack firstPersonBackpack;
|
private ItemStack firstPersonBackpack;
|
||||||
|
@Getter @Setter
|
||||||
|
private ItemDisplayMetadata metadata;
|
||||||
|
@Getter @Setter
|
||||||
|
private ItemDisplayMetadata firstPersonMetadata;
|
||||||
|
|
||||||
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
public CosmeticBackpackType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
modelName = config.node("model").getString();
|
modelName = config.node("model").getString();
|
||||||
|
|
||||||
if (!config.node("firstperson-item").virtual()) {
|
ConfigurationNode firstPersonNode = config.node("firstperson-item");
|
||||||
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
|
if (!firstPersonNode.virtual()) {
|
||||||
|
this.firstPersonBackpack = generateItemStack(firstPersonNode);
|
||||||
this.height = config.node("height").getInt(5);
|
this.height = config.node("height").getInt(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.firstPersonMetadata = generateItemDisplayMetadata(config.node("firstperson-metadata")).setVertical();
|
||||||
|
this.metadata = generateItemDisplayMetadata(config.node("metadata")).setFixed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,7 +55,7 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
Entity entity = Bukkit.getEntity(user.getUniqueId());
|
||||||
if (entity == null) return;
|
if (entity == null) return;
|
||||||
|
|
||||||
Location loc = entity.getLocation().clone().add(0, 2, 0);
|
Location loc = entity.getLocation();
|
||||||
|
|
||||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||||
if (user.isHidden()) {
|
if (user.isHidden()) {
|
||||||
@@ -59,17 +66,16 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
List<Player> outsideViewers = user.getUserBackpackManager().getEntityManager().refreshViewers(loc);
|
||||||
|
|
||||||
UserBackpackManager backpackManager = user.getUserBackpackManager();
|
UserBackpackManager backpackManager = user.getUserBackpackManager();
|
||||||
backpackManager.getEntityManager().teleport(loc);
|
//backpackManager.getEntityManager().setRotation((int) loc.getYaw(), false);
|
||||||
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);
|
//metadata.rotationLeft.rotateY((float) Math.toRadians(loc.getYaw()));
|
||||||
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(this, getItem()), outsideViewers);
|
HMCCPacketManager.sendItemDisplayMetadata(backpackManager.getFirstItemDisplayId(), metadata, 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() && isFirstPersonCompatible() && user.getPlayer() != null) {
|
||||||
List<Player> owner = List.of(user.getPlayer());
|
List<Player> owner = List.of(user.getPlayer());
|
||||||
|
|
||||||
ArrayList<Integer> particleCloud = backpackManager.getAreaEffectEntityId();
|
ArrayList<Integer> particleCloud = backpackManager.getAreaEffectEntityId();
|
||||||
@@ -80,20 +86,18 @@ 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);
|
HMCCPacketManager.sendItemDisplayMetadata(backpackManager.getFirstItemDisplayId(), firstPersonMetadata, user.getUserCosmeticItem(this, firstPersonBackpack), owner);
|
||||||
//else NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
|
|
||||||
PacketManager.equipmentSlotUpdate(backpackManager.getFirstArmorStandId(), 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFirstPersonCompadible() {
|
public boolean isFirstPersonCompatible() {
|
||||||
return firstPersonBackpack != null;
|
return firstPersonBackpack != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,28 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||||
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 me.lojosho.hibiscuscommons.hooks.Hooks;
|
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||||
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
import me.lojosho.hibiscuscommons.util.ServerUtils;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
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;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@@ -30,26 +31,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 +60,12 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
private void spawn(CosmeticBackpackType cosmeticBackpackType) {
|
||||||
getEntityManager().setIds(List.of(invisibleArmorStand));
|
Location entityLoc = user.getEntity().getLocation();
|
||||||
getEntityManager().teleport(user.getEntity().getLocation());
|
entityLoc.setPitch(0f);
|
||||||
|
getEntityManager().setIds(List.of(itemDisplayId));
|
||||||
|
getEntityManager().teleport(entityLoc);
|
||||||
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(entityLoc, getFirstItemDisplayId(), EntityType.ITEM_DISPLAY, UUID.randomUUID(), getEntityManager().getViewers());
|
||||||
if (Settings.isBackpackBlockDetection()) {
|
|
||||||
if (checkBlock()) {
|
|
||||||
setInBlock(true);
|
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
|
|
||||||
} else {
|
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), isInBlock(), outsideViewers);
|
|
||||||
}
|
|
||||||
//refreshBlock(outsideViewers);
|
|
||||||
} else {
|
|
||||||
HMCCPacketManager.sendArmorstandMetadata(getFirstArmorStandId(), Settings.isBackpackLightEmination(), outsideViewers);
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity entity = user.getEntity();
|
Entity entity = user.getEntity();
|
||||||
|
|
||||||
@@ -83,12 +75,12 @@ 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());
|
||||||
|
|
||||||
if (cosmeticBackpackType.isFirstPersonCompadible()) {
|
if (cosmeticBackpackType.isFirstPersonCompatible()) {
|
||||||
for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) {
|
for (int i = particleCloud.size(); i < cosmeticBackpackType.getHeight(); i++) {
|
||||||
int entityId = ServerUtils.getNextEntityId();
|
int entityId = ServerUtils.getNextEntityId();
|
||||||
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
HMCCPacketManager.sendEntitySpawnPacket(user.getEntity().getLocation(), entityId, EntityType.AREA_EFFECT_CLOUD, UUID.randomUUID());
|
||||||
@@ -100,10 +92,11 @@ 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),getFirstItemDisplayId(), owner);
|
||||||
if (!user.isHidden()) PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), owner);
|
if (!user.isHidden()) HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), cosmeticBackpackType.getFirstPersonMetadata(), user.getUserCosmeticItem(cosmeticBackpackType, cosmeticBackpackType.getFirstPersonBackpack()), outsideViewers);
|
||||||
}
|
}
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(cosmeticBackpackType), outsideViewers);
|
|
||||||
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), cosmeticBackpackType.getMetadata(), 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 +117,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 +149,30 @@ public class UserBackpackManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack item) {
|
public void setItem(ItemStack item) {
|
||||||
PacketManager.equipmentSlotUpdate(getFirstArmorStandId(), EquipmentSlot.HEAD, item, getEntityManager().getViewers());
|
ItemDisplayMetadata metadata = Optional.ofNullable((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK)).map(CosmeticBackpackType::getMetadata).orElse(new ItemDisplayMetadata());
|
||||||
|
HMCCPacketManager.sendItemDisplayMetadata(getFirstItemDisplayId(), metadata, 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 +186,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));
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
|
|||||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
@@ -13,6 +14,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -41,7 +43,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 +74,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 +107,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;
|
||||||
@@ -139,11 +141,13 @@ public class UserWardrobeManager {
|
|||||||
// Misc
|
// Misc
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
// Maybe null as backpack maybe despawned before entering
|
// Maybe null as backpack maybe despawned before entering
|
||||||
if (user.getUserBackpackManager() == null) user.respawnBackpack();
|
UserBackpackManager userBackpackManager = user.getUserBackpackManager();
|
||||||
|
if (userBackpackManager == null) user.respawnBackpack();
|
||||||
if (user.isBackpackSpawned()) {
|
if (user.isBackpackSpawned()) {
|
||||||
user.getUserBackpackManager().getEntityManager().teleport(npcLocation.clone().add(0, 2, 0));
|
userBackpackManager.getEntityManager().teleport(npcLocation.clone());
|
||||||
PacketManager.equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, user.getUserCosmeticItem(user.getCosmetic(CosmeticSlot.BACKPACK)), viewer);
|
CosmeticBackpackType backpackCosmetic = (CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK);
|
||||||
HMCCPacketManager.ridingMountPacket(NPC_ID, user.getUserBackpackManager().getFirstArmorStandId(), viewer);
|
HMCCPacketManager.sendItemDisplayMetadata(ITEM_DISPLAY_ID, backpackCosmetic.getMetadata(), user.getUserCosmeticItem(backpackCosmetic), viewer);
|
||||||
|
HMCCPacketManager.ridingMountPacket(NPC_ID, userBackpackManager.getFirstItemDisplayId(), viewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +236,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 +319,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()) {
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.util.misc;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Display;
|
||||||
|
import org.bukkit.entity.ItemDisplay;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ItemDisplayMetadata {
|
||||||
|
|
||||||
|
public Vector3f translation;
|
||||||
|
public Vector3f scale;
|
||||||
|
public Quaternionf rotationLeft;
|
||||||
|
public Quaternionf rotationRight;
|
||||||
|
public Display.Billboard billboard;
|
||||||
|
public int skyLight;
|
||||||
|
public float viewRange;
|
||||||
|
public float width;
|
||||||
|
public float height;
|
||||||
|
public ItemDisplay.ItemDisplayTransform displayTransform;
|
||||||
|
public ItemStack itemStack;
|
||||||
|
|
||||||
|
public ItemDisplayMetadata() {
|
||||||
|
this.translation = new Vector3f();
|
||||||
|
this.scale = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||||
|
this.rotationLeft = new Quaternionf();
|
||||||
|
this.rotationRight = new Quaternionf();
|
||||||
|
this.skyLight = 15;
|
||||||
|
this.viewRange = 1.0f;
|
||||||
|
this.width = 0.0f;
|
||||||
|
this.height = 0.0f;
|
||||||
|
this.displayTransform = ItemDisplay.ItemDisplayTransform.NONE;
|
||||||
|
this.itemStack = new ItemStack(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemDisplayMetadata setFixed() {
|
||||||
|
this.billboard = Display.Billboard.FIXED;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemDisplayMetadata setVertical() {
|
||||||
|
this.billboard = Display.Billboard.VERTICAL;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,17 +12,22 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.misc.ItemDisplayMetadata;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove;
|
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove;
|
||||||
import me.lojosho.hibiscuscommons.util.packets.PacketManager;
|
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.Display;
|
||||||
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;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -44,16 +49,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 +92,17 @@ 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, ItemStack itemStack, List<Player> sendTo) {
|
||||||
int entityId,
|
ItemDisplayMetadata metadata = new ItemDisplayMetadata();
|
||||||
List<Player> sendTo
|
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo);
|
||||||
) {
|
|
||||||
sendArmorstandMetadata(entityId, false, sendTo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendArmorstandMetadata(
|
public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, List<Player> sendTo) {
|
||||||
int entityId,
|
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, metadata.itemStack, sendTo);
|
||||||
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);
|
public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, ItemStack itemStack, List<Player> sendTo) {
|
||||||
packet.getModifier().writeDefaults();
|
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo);
|
||||||
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