From 30b9caf5faf3d5a4c45b49cbf0ecffaf39046c63 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Tue, 17 Sep 2019 00:45:39 +0200 Subject: [PATCH] Corrected some stuff --- .../java/org/geysermc/connector/entity/Entity.java | 7 +++---- .../network/session/cache/EntityCache.java | 14 +++++++++++++- .../spawn/JavaPlayerListEntryTranslator.java | 4 ++-- .../entity/spawn/JavaSpawnPlayerTranslator.java | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java index 814dedbd..3ff170f4 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java @@ -97,12 +97,11 @@ public class Entity { valid = true; session.getUpstream().sendPacket(addEntityPacket); - GeyserLogger.DEFAULT.info("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); + GeyserLogger.DEFAULT.debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); } public void despawnEntity(GeyserSession session) { - if (!valid) - return; + if (!valid) return; RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket(); removeEntityPacket.setUniqueEntityId(geyserId); @@ -125,7 +124,7 @@ public class Entity { } public void moveAbsolute(Vector3f position, float pitch, float yaw) { - moveAbsolute(position, new Vector3f(pitch, yaw, yaw)); + moveAbsolute(position, new Vector3f(pitch, yaw, 0)); } public void moveAbsolute(Vector3f position, Vector3f rotation) { diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java index 8493a2d6..88123003 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/EntityCache.java @@ -45,7 +45,7 @@ public class EntityCache { @Getter private Map entities = new HashMap<>(); private Map entityIdTranslations = new HashMap<>(); - public Map playerEntities = new HashMap<>(); + private Map playerEntities = new HashMap<>(); @Getter private AtomicLong nextEntityId = new AtomicLong(2L); @@ -75,4 +75,16 @@ public class EntityCache { public Entity getEntityByJavaId(long javaId) { return entities.get(entityIdTranslations.get(javaId)); } + + public void addPlayerEntity(PlayerEntity entity) { + playerEntities.put(entity.getUuid(), entity); + } + + public PlayerEntity getPlayerEntity(UUID uuid) { + return playerEntities.get(uuid); + } + + public void removePlayerEntity(UUID uuid) { + playerEntities.remove(uuid); + } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaPlayerListEntryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaPlayerListEntryTranslator.java index 43cb57ff..d40a2725 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaPlayerListEntryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaPlayerListEntryTranslator.java @@ -29,7 +29,7 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator