}
private void processEvents(NetData.NetMessage message) {
boolean lagCompensated = false;
PredictionSystem predictionSystem = CoreRegistry.get(PredictionSystem.class);
for (NetData.EventMessage eventMessage : message.getEventList()) {
Event event = eventSerializer.deserialize(eventMessage.getEvent());
EventMetadata<?> metadata = entitySystemLibrary.getEventLibrary().getMetadata(event.getClass());
if (metadata.getNetworkEventType() != NetworkEventType.SERVER) {
logger.warn("Received non-server event '{}' from client '{}'", metadata, getName());
continue;
}
if (!lagCompensated && metadata.isLagCompensated()) {
if (predictionSystem != null) {
predictionSystem.lagCompensate(getEntity(), lastReceivedTime);
}
lagCompensated = true;
}
EntityRef target = EntityRef.NULL;
if (eventMessage.hasTargetId()) {
target = networkSystem.getEntity(eventMessage.getTargetId());
}
if (target.exists()) {
if (Objects.equal(networkSystem.getOwner(target), this)) {
target.send(event);
} else {
logger.warn("Received event {} for non-owned entity {} from {}", event, target, this);
}
}
}
if (lagCompensated && predictionSystem != null) {
predictionSystem.restoreToPresent();
}
}