diff --git a/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java b/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java index e3e7041..40c8de9 100644 --- a/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java +++ b/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java @@ -77,17 +77,7 @@ public class WrapperEntity implements Tickable { this.spawned = true; sendPacketsToViewers( - new WrapperPlayServerSpawnEntity( - entityId, - Optional.of(this.uuid), - entityType, - location.getPosition(), - location.getPitch(), - location.getYaw(), - location.getYaw(), - getObjectData(), - createVeloPacket() - ), + createSpawnPacket(), entityMeta.createPacket() ); @@ -238,7 +228,7 @@ public class WrapperEntity implements Tickable { sendPacketToViewers(new WrapperPlayServerSystemChatMessage(true, message)); } - protected WrapperPlayServerSpawnEntity createSpawnPacket() { + protected PacketWrapper createSpawnPacket() { return new WrapperPlayServerSpawnEntity( entityId, Optional.of(this.uuid), diff --git a/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java b/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java index ad4e0cd..d50a91b 100644 --- a/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java +++ b/api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java @@ -1,16 +1,24 @@ package me.tofaa.entitylib.wrapper; +import com.github.retrooper.packetevents.manager.server.ServerVersion; import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes; -import com.github.retrooper.packetevents.protocol.player.*; -import com.github.retrooper.packetevents.protocol.world.Location; -import com.github.retrooper.packetevents.util.Vector3d; +import com.github.retrooper.packetevents.protocol.player.GameMode; +import com.github.retrooper.packetevents.protocol.player.TextureProperty; +import com.github.retrooper.packetevents.protocol.player.UserProfile; import com.github.retrooper.packetevents.wrapper.PacketWrapper; -import com.github.retrooper.packetevents.wrapper.play.server.*; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityHeadLook; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityRotation; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoRemove; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoUpdate; +import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnPlayer; import me.tofaa.entitylib.EntityLib; import me.tofaa.entitylib.meta.EntityMeta; +import java.util.EnumSet; +import java.util.List; +import java.util.UUID; import net.kyori.adventure.text.Component; - -import java.util.*; +import org.jetbrains.annotations.NotNull; public class WrapperPlayer extends WrapperLivingEntity { @@ -25,6 +33,27 @@ public class WrapperPlayer extends WrapperLivingEntity { this.profile = profile; } + @Override + protected PacketWrapper createSpawnPacket() { + if (EntityLib.getApi().getPacketEvents().getServerManager().getVersion().isOlderThanOrEquals(ServerVersion.V_1_20_1)) { + return new WrapperPlayServerSpawnPlayer( + getEntityId(), + profile.getUUID(), + getLocation(), + getEntityMeta().entityData() + ); + } + return super.createSpawnPacket(); + } + + @Override + public @NotNull List> createSpawnPackets() { + final List> packets = super.createSpawnPackets(); + packets.add(new WrapperPlayServerEntityRotation(getEntityId(), getYaw(), getPitch(), isOnGround())); + packets.add(new WrapperPlayServerEntityHeadLook(getEntityId(), getYaw())); + return packets; + } + public WrapperPlayServerPlayerInfoUpdate tabListPacket() { EnumSet actions = EnumSet.of( WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER,