3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Corrected some stuff

Dieser Commit ist enthalten in:
Tim203 2019-09-17 00:45:39 +02:00
Ursprung 1c74a6252a
Commit 30b9caf5fa
4 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -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) {

Datei anzeigen

@ -45,7 +45,7 @@ public class EntityCache {
@Getter
private Map<Long, Entity> entities = new HashMap<>();
private Map<Long, Long> entityIdTranslations = new HashMap<>();
public Map<UUID, PlayerEntity> playerEntities = new HashMap<>();
private Map<UUID, PlayerEntity> 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);
}
}

Datei anzeigen

@ -29,7 +29,7 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator<ServerPlayer
if (packet.getAction() == PlayerListEntryAction.ADD_PLAYER) {
long geyserId = session.getEntityCache().getNextEntityId().incrementAndGet();
session.getEntityCache().playerEntities.put(entry.getProfile().getId(), new PlayerEntity(
session.getEntityCache().addPlayerEntity(new PlayerEntity(
entry.getProfile(),
-1,
geyserId,
@ -49,7 +49,7 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator<ServerPlayer
entry1.setXuid("");
entry1.setPlatformChatId("WIN10");
} else {
session.getEntityCache().playerEntities.remove(entry.getProfile().getId());
session.getEntityCache().removePlayerEntity(entry.getProfile().getId());
}
translate.getEntries().add(entry1);
}

Datei anzeigen

@ -39,7 +39,7 @@ public class JavaSpawnPlayerTranslator extends PacketTranslator<ServerSpawnPlaye
Vector3f position = new Vector3f(packet.getX(), packet.getY(), packet.getZ());
Vector3f rotation = new Vector3f(packet.getPitch(), packet.getYaw(), packet.getYaw());
PlayerEntity entity = session.getEntityCache().playerEntities.get(packet.getUUID());
PlayerEntity entity = session.getEntityCache().getPlayerEntity(packet.getUUID());
if (entity == null) {
Geyser.getLogger().error("Haven't received PlayerListEntry packet before spawning player! We ignore the player");
return;