Renamed method

This commit is contained in:
Németh Noel 2021-05-01 00:51:10 +02:00
parent 5e55c0199d
commit 998d0d6f5c
2 changed files with 12 additions and 10 deletions

View File

@ -269,7 +269,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
refreshPosition(teleportPosition);
refreshView(teleportPosition.getYaw(), teleportPosition.getPitch());
sendTeleportPacket();
synchronizePosition();
OptionalCallback.execute(callback);
};
@ -634,7 +634,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
// Synchronization and packets...
if (!isNettyClient) {
sendTeleportPacket();
synchronizePosition();
}
// Verify if velocity packet has to be sent
if (hasVelocity() || (!isNettyClient && gravityTickCount > 0)) {
@ -705,7 +705,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
// Scheduled synchronization
if (!Cooldown.hasCooldown(time, lastAbsoluteSynchronizationTime, getSynchronizationCooldown())) {
sendTeleportPacket();
synchronizePosition();
}
if (shouldRemove() && !MinecraftServer.isStopping()) {
@ -1539,10 +1539,13 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
}
/**
* Used to synchronize entity position with viewers
* Used to synchronize entity position with viewers by sending an
* {@link EntityTeleportPacket} to viewers, in case of a player this is
* overridden in order to send an additional {@link PlayerPositionAndLookPacket}
* to itself.
*/
@ApiStatus.Internal
protected void sendTeleportPacket() {
protected void synchronizePosition() {
final Position pos = position.clone();
final EntityTeleportPacket entityTeleportPacket = new EntityTeleportPacket();
entityTeleportPacket.entityId = getEntityId();

View File

@ -63,7 +63,6 @@ import net.minestom.server.sound.SoundCategory;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.stat.PlayerStatistic;
import net.minestom.server.utils.*;
import net.minestom.server.utils.callback.OptionalCallback;
import net.minestom.server.utils.chunk.ChunkCallback;
import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.utils.entity.EntityUtils;
@ -715,7 +714,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
}
if (dimensionChange || firstSpawn) {
sendTeleportPacket(); // So the player doesn't get stuck
synchronizePosition(); // So the player doesn't get stuck
this.inventory.update();
}
@ -2021,18 +2020,18 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
}
/**
* @see Entity#sendTeleportPacket()
* @see Entity#synchronizePosition()
*/
@Override
@ApiStatus.Internal
protected void sendTeleportPacket() {
protected void synchronizePosition() {
final PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
positionAndLookPacket.position = position.clone();
positionAndLookPacket.flags = 0x00;
positionAndLookPacket.teleportId = teleportId.incrementAndGet();
playerConnection.sendPacket(positionAndLookPacket);
super.sendTeleportPacket();
super.synchronizePosition();
}
/**