mirror of
https://github.com/Minestom/Minestom.git
synced 2025-03-02 11:21:15 +01:00
Fix velocity for netty clients
This commit is contained in:
parent
626d48a0fb
commit
9775262c6a
@ -415,6 +415,8 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean isNettyClient = PlayerUtils.isNettyClient(this);
|
||||||
|
|
||||||
// Synchronization with updated fields in #getPosition()
|
// Synchronization with updated fields in #getPosition()
|
||||||
{
|
{
|
||||||
final boolean positionChange = cacheX != position.getX() ||
|
final boolean positionChange = cacheX != position.getX() ||
|
||||||
@ -424,7 +426,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
cachePitch != position.getPitch();
|
cachePitch != position.getPitch();
|
||||||
final double distance = positionChange ? position.getDistance(cacheX, cacheY, cacheZ) : 0;
|
final double distance = positionChange ? position.getDistance(cacheX, cacheY, cacheZ) : 0;
|
||||||
|
|
||||||
if (distance >= 8 || (positionChange && PlayerUtils.isNettyClient(this))) {
|
if (distance >= 8 || (positionChange && isNettyClient)) {
|
||||||
// Teleport has the priority over everything else
|
// Teleport has the priority over everything else
|
||||||
teleport(position);
|
teleport(position);
|
||||||
} else if (positionChange && viewChange) {
|
} else if (positionChange && viewChange) {
|
||||||
@ -471,9 +473,9 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
// Velocity
|
// Velocity
|
||||||
boolean applyVelocity;
|
boolean applyVelocity;
|
||||||
// Non-player entities with either velocity or gravity enabled
|
// Non-player entities with either velocity or gravity enabled
|
||||||
applyVelocity = !PlayerUtils.isNettyClient(this) && (hasVelocity() || !hasNoGravity());
|
applyVelocity = !isNettyClient && (hasVelocity() || !hasNoGravity());
|
||||||
// Players with a velocity applied (client is responsible for gravity)
|
// Players with a velocity applied (client is responsible for gravity)
|
||||||
applyVelocity |= PlayerUtils.isNettyClient(this) && hasVelocity();
|
applyVelocity |= isNettyClient && hasVelocity();
|
||||||
|
|
||||||
if (applyVelocity) {
|
if (applyVelocity) {
|
||||||
final float tps = MinecraftServer.TICK_PER_SECOND;
|
final float tps = MinecraftServer.TICK_PER_SECOND;
|
||||||
@ -533,7 +535,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop player velocity
|
// Stop player velocity
|
||||||
if (PlayerUtils.isNettyClient(this)) {
|
if (isNettyClient) {
|
||||||
this.velocity.zero();
|
this.velocity.zero();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -545,10 +547,12 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer, P
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Synchronization and packets...
|
// Synchronization and packets...
|
||||||
sendSynchronization();
|
if (!isNettyClient) {
|
||||||
|
sendSynchronization();
|
||||||
|
}
|
||||||
// Verify if velocity packet has to be sent
|
// Verify if velocity packet has to be sent
|
||||||
if (hasVelocity() || gravityTickCount > 0) {
|
if (hasVelocity() || (!isNettyClient && gravityTickCount > 0)) {
|
||||||
sendPacketsToViewers(getVelocityPacket());
|
sendPacketToViewersAndSelf(getVelocityPacket());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user