Moved cloning back into methods

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

View File

@ -269,7 +269,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
refreshPosition(teleportPosition);
refreshView(teleportPosition.getYaw(), teleportPosition.getPitch());
sendTeleportPacket(teleportPosition);
sendTeleportPacket();
OptionalCallback.execute(callback);
};
@ -634,7 +634,7 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
// Synchronization and packets...
if (!isNettyClient) {
sendTeleportPacket(position.clone());
sendTeleportPacket();
}
// 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(position.clone());
sendTeleportPacket();
}
if (shouldRemove() && !MinecraftServer.isStopping()) {
@ -1540,11 +1540,10 @@ public class Entity implements Viewable, Tickable, EventHandler, DataContainer,
/**
* Used to synchronize entity position with viewers
*
* @param pos Should be {@link Entity#position#clone()}
*/
@ApiStatus.Internal
protected void sendTeleportPacket(final Position pos) {
protected void sendTeleportPacket() {
final Position pos = position.clone();
final EntityTeleportPacket entityTeleportPacket = new EntityTeleportPacket();
entityTeleportPacket.entityId = getEntityId();
entityTeleportPacket.position = pos;

View File

@ -715,7 +715,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
}
if (dimensionChange || firstSpawn) {
sendTeleportPacket(position.clone()); // So the player doesn't get stuck
sendTeleportPacket(); // So the player doesn't get stuck
this.inventory.update();
}
@ -2021,19 +2021,18 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
}
/**
* @see Entity#sendTeleportPacket(Position)
* @param pos Should be {@link Entity#position#clone()}
* @see Entity#sendTeleportPacket()
*/
@Override
@ApiStatus.Internal
protected void sendTeleportPacket(final Position pos) {
protected void sendTeleportPacket() {
final PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
positionAndLookPacket.position = pos;
positionAndLookPacket.position = position.clone();
positionAndLookPacket.flags = 0x00;
positionAndLookPacket.teleportId = teleportId.incrementAndGet();
playerConnection.sendPacket(positionAndLookPacket);
super.sendTeleportPacket(pos);
super.sendTeleportPacket();
}
/**