mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
send velocity packets before entity tick (#463)
This commit is contained in:
@@ -616,7 +616,7 @@ index f106373ef3ac4a8685c2939c9e8361688a285913..7df467924d029d6e42b1d0b039cb9272
|
||||
if (!this.players.isEmpty()) {
|
||||
for (ServerPlayer serverPlayer : Lists.newArrayList(this.players)) {
|
||||
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
||||
index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc8160b606 100644
|
||||
index 0dee18df07c979da6125a4e7a955343e44d67ac2..f033849629518a2afb60cf5bbf3de5ae7a0ae84c 100644
|
||||
--- a/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -57,11 +57,13 @@ public class ServerEntity {
|
||||
@@ -641,7 +641,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
this.positionCodec.setBase(entity.trackingPosition());
|
||||
this.lastSentMovement = entity.getDeltaMovement();
|
||||
this.lastSentYRot = Mth.packDegrees(entity.getYRot());
|
||||
@@ -105,204 +108,415 @@ public class ServerEntity {
|
||||
@@ -105,204 +108,413 @@ public class ServerEntity {
|
||||
|
||||
// Paper start - fix desync when a player is added to the tracker
|
||||
private boolean forceStateResync;
|
||||
@@ -1044,9 +1044,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
+
|
||||
+ this.tickCount++;
|
||||
+ if (this.entity.hurtMarked) {
|
||||
+ if (this.entity instanceof ServerPlayer serverPlayer) {
|
||||
+ ctx.playerVelocity(serverPlayer);
|
||||
+ } else {
|
||||
+ if (!(this.entity instanceof ServerPlayer)) {
|
||||
+ this.entity.hurtMarked = false;
|
||||
+ trackedEntity.leafBroadcastAndSend(ctx, new ClientboundSetEntityMotionPacket(this.entity));
|
||||
+ }
|
||||
@@ -1057,7 +1055,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
private Stream<Entity> mountedOrDismounted(List<Entity> entities) {
|
||||
return Streams.concat(
|
||||
this.lastPassengers.stream().filter(entity -> !entities.contains(entity)),
|
||||
@@ -356,6 +570,39 @@ public class ServerEntity {
|
||||
@@ -356,6 +568,39 @@ public class ServerEntity {
|
||||
this.positionCodec.setBase(this.entity.position());
|
||||
}
|
||||
|
||||
@@ -1097,7 +1095,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
public void removePairing(ServerPlayer player) {
|
||||
this.entity.stopSeenByPlayer(player);
|
||||
player.connection.send(new ClientboundRemoveEntitiesPacket(this.entity.getId()));
|
||||
@@ -368,8 +615,23 @@ public class ServerEntity {
|
||||
@@ -368,8 +613,23 @@ public class ServerEntity {
|
||||
this.entity.startSeenByPlayer(player);
|
||||
}
|
||||
|
||||
@@ -1121,7 +1119,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
// CraftBukkit start - Remove useless error spam, just return
|
||||
// LOGGER.warn("Fetching packet for removed entity {}", this.entity);
|
||||
return;
|
||||
@@ -407,7 +669,7 @@ public class ServerEntity {
|
||||
@@ -407,7 +667,7 @@ public class ServerEntity {
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list, true)); // Paper - data sanitization
|
||||
}
|
||||
@@ -1130,7 +1128,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
}
|
||||
|
||||
if (!this.entity.getPassengers().isEmpty()) {
|
||||
@@ -443,6 +705,7 @@ public class ServerEntity {
|
||||
@@ -443,6 +703,7 @@ public class ServerEntity {
|
||||
return Mth.unpackDegrees(this.lastSentYHeadRot);
|
||||
}
|
||||
|
||||
@@ -1138,7 +1136,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
public void sendDirtyEntityData() {
|
||||
SynchedEntityData entityData = this.entity.getEntityData();
|
||||
List<SynchedEntityData.DataValue<?>> list = entityData.packDirty();
|
||||
@@ -450,10 +713,12 @@ public class ServerEntity {
|
||||
@@ -450,10 +711,12 @@ public class ServerEntity {
|
||||
this.trackedDataValues = entityData.getNonDefaultValues();
|
||||
this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
|
||||
}
|
||||
@@ -1151,7 +1149,7 @@ index 0dee18df07c979da6125a4e7a955343e44d67ac2..dae07c6c31949c75c810c9260232cccc
|
||||
// CraftBukkit start - Send scaled max health
|
||||
if (this.entity instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.getBukkitEntity().injectScaledMaxHealth(attributesToSync, false);
|
||||
@@ -462,11 +727,38 @@ public class ServerEntity {
|
||||
@@ -462,11 +725,38 @@ public class ServerEntity {
|
||||
this.broadcastAndSend(new ClientboundUpdateAttributesPacket(this.entity.getId(), attributesToSync));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user