Refactor armor stand spawning logic

Add pitch and yaw values to the spawn packet and use EntityType.ARMOR_STAND for setting the entity type. This change ensures the armor stand is created with the correct orientation and type.
This commit is contained in:
Teriuihi 2024-10-20 20:29:38 +02:00
parent d4eccf478f
commit d3d0aa182d

View File

@ -9,6 +9,7 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import lombok.extern.slf4j.Slf4j;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import java.util.List;
import java.util.Optional;
@ -39,7 +40,9 @@ public class HoverText {
.write(0, location.getX())
.write(1, location.getY())
.write(2, location.getZ());
spawnPacket.getIntegers().write(1, 78); // Armor Stand type
spawnPacket.getIntegers().write(4, 0); // Pitch
spawnPacket.getIntegers().write(5, 0); // Yaw
spawnPacket.getEntityTypeModifier().write(0, EntityType.ARMOR_STAND);
PacketContainer destroyPacket = protocolManager.createPacket(PacketType.Play.Server.ENTITY_DESTROY);
destroyPacket.getIntLists().write(0, List.of(entityId));
return Optional.of(new LeaderboardLineEntity(entityId, spawnPacket, destroyPacket));