From 3946a4493757c74642c9dc35b749df3a2693b2e5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 4 Mar 2022 23:05:09 +0100 Subject: [PATCH] Test spawn, remove debug Signed-off-by: Lixfel --- .../steamwar/fightsystem/record/REntity.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java index 0abe2b2..5b76758 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java @@ -129,6 +129,8 @@ public class REntity { private int fireTick; private boolean sneaks; + private boolean playerSpawned = false; + public REntity(int internalId, int userId){ this.internalId = internalId; this.entityType = EntityType.PLAYER; @@ -144,11 +146,9 @@ public class REntity { this.uuid = user.getUUID(); this.name = user.getUserName(); - System.out.println(name + " joins"); entities.put(internalId, this); ProtocolAPI.broadcastPacket(getPlayerInfoPacket()); - ProtocolAPI.broadcastPacket(getNamedSpawnPacket()); team.addEntry(name); } @@ -167,14 +167,14 @@ public class REntity { this.locX = locX; this.locY = locY; this.locZ = locZ; + if(entityType == EntityType.PLAYER && !playerSpawned) { + ProtocolAPI.broadcastPacket(getNamedSpawnPacket()); + playerSpawned = true; + } + this.yaw = (byte)((int)(yaw * 256.0F / 360.0F)); this.pitch = (byte)((int)(pitch * 256.0F / 360.0F)); this.headYaw = headYaw; - - if(entityType == EntityType.PLAYER) { - System.out.println("Player moves " + locX + " " + locY + " " + locZ); - } - ProtocolAPI.broadcastPacket(getTeleportPacket()); ProtocolAPI.broadcastPacket(getHeadRotationPacket()); } @@ -337,10 +337,16 @@ public class REntity { public static final Class namedSpawnPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutNamedEntitySpawn"); private static final Reflection.FieldAccessor namedSpawnEntity = Reflection.getField(namedSpawnPacket, int.class, 0); private static final Reflection.FieldAccessor namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0); + private static final Reflection.FieldAccessor namedSpawnX = Reflection.getField(namedSpawnPacket, double.class, 0); + private static final Reflection.FieldAccessor namedSpawnY = Reflection.getField(namedSpawnPacket, double.class, 1); + private static final Reflection.FieldAccessor namedSpawnZ = Reflection.getField(namedSpawnPacket, double.class, 2); private Object getNamedSpawnPacket(){ Object packet = Reflection.newInstance(namedSpawnPacket); namedSpawnEntity.set(packet, entityId); namedSpawnUUID.set(packet, uuid); + namedSpawnX.set(packet, locX); + namedSpawnX.set(packet, locY); + namedSpawnX.set(packet, locZ); FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet); return packet; }