mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-29 04:28:21 +01:00
Don't send scheduled sync to the player it self
This commit is contained in:
parent
19e22d03ce
commit
e3d31f113a
@ -268,7 +268,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
|
|||||||
final ChunkCallback endCallback = (chunk) -> {
|
final ChunkCallback endCallback = (chunk) -> {
|
||||||
refreshPosition(teleportPosition);
|
refreshPosition(teleportPosition);
|
||||||
|
|
||||||
synchronizePosition();
|
synchronizePosition(true);
|
||||||
|
|
||||||
OptionalCallback.execute(callback);
|
OptionalCallback.execute(callback);
|
||||||
};
|
};
|
||||||
@ -594,7 +594,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
|
|||||||
|
|
||||||
// Synchronization and packets...
|
// Synchronization and packets...
|
||||||
if (!isNettyClient) {
|
if (!isNettyClient) {
|
||||||
synchronizePosition();
|
synchronizePosition(true);
|
||||||
}
|
}
|
||||||
// Verify if velocity packet has to be sent
|
// Verify if velocity packet has to be sent
|
||||||
if (hasVelocity() || (!isNettyClient && gravityTickCount > 0)) {
|
if (hasVelocity() || (!isNettyClient && gravityTickCount > 0)) {
|
||||||
@ -665,7 +665,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
|
|||||||
|
|
||||||
// Scheduled synchronization
|
// Scheduled synchronization
|
||||||
if (!Cooldown.hasCooldown(time, lastAbsoluteSynchronizationTime, getSynchronizationCooldown())) {
|
if (!Cooldown.hasCooldown(time, lastAbsoluteSynchronizationTime, getSynchronizationCooldown())) {
|
||||||
synchronizePosition();
|
synchronizePosition(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldRemove() && !MinecraftServer.isStopping()) {
|
if (shouldRemove() && !MinecraftServer.isStopping()) {
|
||||||
@ -680,7 +680,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
|
|||||||
* The following packets are sent to viewers (check are performed in this order):
|
* The following packets are sent to viewers (check are performed in this order):
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>{@link EntityTeleportPacket} if {@code distanceX > 8 || distanceY > 8 || distanceZ > 8}
|
* <li>{@link EntityTeleportPacket} if {@code distanceX > 8 || distanceY > 8 || distanceZ > 8}
|
||||||
* <i>(performed using {@link #synchronizePosition()})</i></li>
|
* <i>(performed using {@link #synchronizePosition(boolean)})</i></li>
|
||||||
* <li>{@link EntityPositionAndRotationPacket} if {@code positionChange && viewChange}</li>
|
* <li>{@link EntityPositionAndRotationPacket} if {@code positionChange && viewChange}</li>
|
||||||
* <li>{@link EntityPositionPacket} if {@code positionChange}</li>
|
* <li>{@link EntityPositionPacket} if {@code positionChange}</li>
|
||||||
* <li>{@link EntityRotationPacket} and {@link EntityHeadLookPacket} if {@code viewChange}</li>
|
* <li>{@link EntityRotationPacket} and {@link EntityHeadLookPacket} if {@code viewChange}</li>
|
||||||
@ -698,7 +698,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
|
|||||||
final boolean positionChange = (distanceX+distanceY+distanceZ) > 0;
|
final boolean positionChange = (distanceX+distanceY+distanceZ) > 0;
|
||||||
|
|
||||||
if (distanceX > 8 || distanceY > 8 || distanceZ > 8) {
|
if (distanceX > 8 || distanceY > 8 || distanceZ > 8) {
|
||||||
synchronizePosition();
|
synchronizePosition(true);
|
||||||
// #synchronizePosition sets sync fields, it's safe to return
|
// #synchronizePosition sets sync fields, it's safe to return
|
||||||
return;
|
return;
|
||||||
} else if (positionChange && viewChange) {
|
} else if (positionChange && viewChange) {
|
||||||
@ -1583,9 +1583,11 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
|
|||||||
* {@link EntityTeleportPacket} to viewers, in case of a player this is
|
* {@link EntityTeleportPacket} to viewers, in case of a player this is
|
||||||
* overridden in order to send an additional {@link PlayerPositionAndLookPacket}
|
* overridden in order to send an additional {@link PlayerPositionAndLookPacket}
|
||||||
* to itself.
|
* to itself.
|
||||||
|
* @param includeSelf if {@code true} and this is a {@link Player} an additional {@link PlayerPositionAndLookPacket}
|
||||||
|
* will be sent to the player itself
|
||||||
*/
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
protected void synchronizePosition() {
|
protected void synchronizePosition(boolean includeSelf) {
|
||||||
final Position pos = position.clone();
|
final Position pos = position.clone();
|
||||||
final EntityTeleportPacket entityTeleportPacket = new EntityTeleportPacket();
|
final EntityTeleportPacket entityTeleportPacket = new EntityTeleportPacket();
|
||||||
entityTeleportPacket.entityId = getEntityId();
|
entityTeleportPacket.entityId = getEntityId();
|
||||||
|
@ -661,7 +661,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dimensionChange || firstSpawn) {
|
if (dimensionChange || firstSpawn) {
|
||||||
synchronizePosition(); // So the player doesn't get stuck
|
synchronizePosition(true); // So the player doesn't get stuck
|
||||||
this.inventory.update();
|
this.inventory.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1984,18 +1984,19 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Entity#synchronizePosition()
|
* @see Entity#synchronizePosition(boolean)
|
||||||
|
* @param includeSelf
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
protected void synchronizePosition() {
|
protected void synchronizePosition(boolean includeSelf) {
|
||||||
final PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
|
final PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
|
||||||
positionAndLookPacket.position = position.clone();
|
positionAndLookPacket.position = position.clone();
|
||||||
positionAndLookPacket.flags = 0x00;
|
positionAndLookPacket.flags = 0x00;
|
||||||
positionAndLookPacket.teleportId = teleportId.incrementAndGet();
|
positionAndLookPacket.teleportId = teleportId.incrementAndGet();
|
||||||
playerConnection.sendPacket(positionAndLookPacket);
|
playerConnection.sendPacket(positionAndLookPacket);
|
||||||
|
|
||||||
super.synchronizePosition();
|
super.synchronizePosition(includeSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user