Skip to content

Commit 8478e87

Browse files
committed
fix: correct player spawn in 1.20.1-
1 parent 34db96d commit 8478e87

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,7 @@ public boolean spawn(Location location, EntityContainer parent) {
7777
this.spawned = true;
7878

7979
sendPacketsToViewers(
80-
new WrapperPlayServerSpawnEntity(
81-
entityId,
82-
Optional.of(this.uuid),
83-
entityType,
84-
location.getPosition(),
85-
location.getPitch(),
86-
location.getYaw(),
87-
location.getYaw(),
88-
getObjectData(),
89-
createVeloPacket()
90-
),
80+
createSpawnPacket(),
9181
entityMeta.createPacket()
9282
);
9383

@@ -238,7 +228,7 @@ public void sendActionbarToViewers(Component message) {
238228
sendPacketToViewers(new WrapperPlayServerSystemChatMessage(true, message));
239229
}
240230

241-
protected WrapperPlayServerSpawnEntity createSpawnPacket() {
231+
protected PacketWrapper<?> createSpawnPacket() {
242232
return new WrapperPlayServerSpawnEntity(
243233
entityId,
244234
Optional.of(this.uuid),

api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package me.tofaa.entitylib.wrapper;
22

3+
import com.github.retrooper.packetevents.manager.server.ServerVersion;
34
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
4-
import com.github.retrooper.packetevents.protocol.player.*;
5-
import com.github.retrooper.packetevents.protocol.world.Location;
6-
import com.github.retrooper.packetevents.util.Vector3d;
5+
import com.github.retrooper.packetevents.protocol.player.GameMode;
6+
import com.github.retrooper.packetevents.protocol.player.TextureProperty;
7+
import com.github.retrooper.packetevents.protocol.player.UserProfile;
78
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
8-
import com.github.retrooper.packetevents.wrapper.play.server.*;
9+
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities;
10+
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoRemove;
11+
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerInfoUpdate;
12+
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnPlayer;
913
import me.tofaa.entitylib.EntityLib;
1014
import me.tofaa.entitylib.meta.EntityMeta;
15+
import java.util.EnumSet;
16+
import java.util.List;
17+
import java.util.UUID;
1118
import net.kyori.adventure.text.Component;
1219

13-
import java.util.*;
14-
1520
public class WrapperPlayer extends WrapperLivingEntity {
1621

1722
private UserProfile profile;
@@ -25,6 +30,19 @@ public WrapperPlayer(UserProfile profile, int entityId) {
2530
this.profile = profile;
2631
}
2732

33+
@Override
34+
protected PacketWrapper<?> createSpawnPacket() {
35+
if (EntityLib.getApi().getPacketEvents().getServerManager().getVersion().isOlderThanOrEquals(ServerVersion.V_1_20_1)) {
36+
return new WrapperPlayServerSpawnPlayer(
37+
getEntityId(),
38+
profile.getUUID(),
39+
getLocation(),
40+
getEntityMeta().entityData()
41+
);
42+
}
43+
return super.createSpawnPacket();
44+
}
45+
2846
public WrapperPlayServerPlayerInfoUpdate tabListPacket() {
2947
EnumSet<WrapperPlayServerPlayerInfoUpdate.Action> actions = EnumSet.of(
3048
WrapperPlayServerPlayerInfoUpdate.Action.ADD_PLAYER,

0 commit comments

Comments
 (0)