and some more
This commit is contained in:
@@ -501,11 +501,47 @@
|
||||
}
|
||||
|
||||
public boolean isFree(double x, double y, double z) {
|
||||
@@ -627,6 +_,7 @@
|
||||
@@ -626,7 +_,43 @@
|
||||
return this.onGround;
|
||||
}
|
||||
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ public final Object posLock = new Object(); // Paper - log detailed entity tick information
|
||||
+
|
||||
+ private Vec3 moveVector;
|
||||
+ private double moveStartX;
|
||||
+ private double moveStartY;
|
||||
+ private double moveStartZ;
|
||||
+
|
||||
+ public final Vec3 getMoveVector() {
|
||||
+ return this.moveVector;
|
||||
+ }
|
||||
+
|
||||
+ public final double getMoveStartX() {
|
||||
+ return this.moveStartX;
|
||||
+ }
|
||||
+
|
||||
+ public final double getMoveStartY() {
|
||||
+ return this.moveStartY;
|
||||
+ }
|
||||
+
|
||||
+ public final double getMoveStartZ() {
|
||||
+ return this.moveStartZ;
|
||||
+ }
|
||||
+ // Paper end - detailed watchdog information
|
||||
+
|
||||
public void move(MoverType type, Vec3 movement) {
|
||||
+ final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
+ synchronized (this.posLock) {
|
||||
+ this.moveStartX = this.getX();
|
||||
+ this.moveStartY = this.getY();
|
||||
+ this.moveStartZ = this.getZ();
|
||||
+ this.moveVector = movement;
|
||||
+ }
|
||||
+ try {
|
||||
+ // Paper end - detailed watchdog information
|
||||
if (this.noPhysics) {
|
||||
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
|
||||
} else {
|
||||
@@ -538,6 +574,20 @@
|
||||
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
|
||||
Entity.MovementEmission movementEmission = this.getMovementEmission();
|
||||
if (movementEmission.emitsAnything() && !this.isPassenger()) {
|
||||
@@ -713,6 +_,13 @@
|
||||
profilerFiller.pop();
|
||||
}
|
||||
}
|
||||
+ // Paper start - detailed watchdog information
|
||||
+ } finally {
|
||||
+ synchronized (this.posLock) { // Paper
|
||||
+ this.moveVector = null;
|
||||
+ } // Paper
|
||||
+ }
|
||||
+ // Paper end - detailed watchdog information
|
||||
}
|
||||
|
||||
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) {
|
||||
@@ -850,7 +_,7 @@
|
||||
}
|
||||
|
||||
@@ -1601,7 +1651,17 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3480,7 +_,39 @@
|
||||
@@ -3417,7 +_,9 @@
|
||||
}
|
||||
|
||||
public void setDeltaMovement(Vec3 deltaMovement) {
|
||||
+ synchronized (this.posLock) { // Paper - detailed watchdog information
|
||||
this.deltaMovement = deltaMovement;
|
||||
+ } // Paper - detailed watchdog information
|
||||
}
|
||||
|
||||
public void addDeltaMovement(Vec3 addend) {
|
||||
@@ -3480,9 +_,43 @@
|
||||
return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale);
|
||||
}
|
||||
|
||||
@@ -1639,8 +1699,12 @@
|
||||
+ }
|
||||
+ // Paper end - Fix MC-4
|
||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
+ synchronized (this.posLock) { // Paper - detailed watchdog information
|
||||
this.position = new Vec3(x, y, z);
|
||||
+ } // Paper - detailed watchdog information
|
||||
int floor = Mth.floor(x);
|
||||
int floor1 = Mth.floor(y);
|
||||
int floor2 = Mth.floor(z);
|
||||
@@ -3496,6 +_,12 @@
|
||||
|
||||
this.levelCallback.onMove();
|
||||
|
||||
@@ -1535,7 +1535,7 @@
|
||||
}
|
||||
|
||||
protected void internalSetAbsorptionAmount(float absorptionAmount) {
|
||||
@@ -3115,6 +_,11 @@
|
||||
@@ -3115,6 +_,15 @@
|
||||
return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
|
||||
}
|
||||
|
||||
@@ -1544,10 +1544,28 @@
|
||||
+ this.resendPossiblyDesyncedDataValues(java.util.List.of(DATA_LIVING_ENTITY_FLAGS), serverPlayer);
|
||||
+ }
|
||||
+ // Paper end - Properly cancel usable items
|
||||
+ // Paper start - lag compensate eating
|
||||
+ protected long eatStartTime;
|
||||
+ protected int totalEatTimeTicks;
|
||||
+ // Paper end - lag compensate eating
|
||||
private void updatingUsingItem() {
|
||||
if (this.isUsingItem()) {
|
||||
if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) {
|
||||
@@ -3154,8 +_,13 @@
|
||||
@@ -3128,7 +_,12 @@
|
||||
|
||||
protected void updateUsingItem(ItemStack usingItem) {
|
||||
usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks());
|
||||
- if (--this.useItemRemaining == 0 && !this.level().isClientSide && !usingItem.useOnRelease()) {
|
||||
+ // Paper start - lag compensate eating
|
||||
+ // we add 1 to the expected time to avoid lag compensating when we should not
|
||||
+ final boolean shouldLagCompensate = this.useItem.has(DataComponents.FOOD) && this.eatStartTime != -1 && (System.nanoTime() - this.eatStartTime) > ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L));
|
||||
+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !usingItem.useOnRelease()) {
|
||||
+ this.useItemRemaining = 0;
|
||||
+ // Paper end - lag compensate eating
|
||||
this.completeUsingItem();
|
||||
}
|
||||
}
|
||||
@@ -3154,10 +_,18 @@
|
||||
}
|
||||
|
||||
public void startUsingItem(InteractionHand hand) {
|
||||
@@ -1560,8 +1578,26 @@
|
||||
- if (!itemInHand.isEmpty() && !this.isUsingItem()) {
|
||||
+ if (!itemInHand.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack
|
||||
this.useItem = itemInHand;
|
||||
this.useItemRemaining = itemInHand.getUseDuration(this);
|
||||
- this.useItemRemaining = itemInHand.getUseDuration(this);
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = itemInHand.getUseDuration(this);
|
||||
+ this.eatStartTime = System.nanoTime();
|
||||
+ // Paper end - lag compensate eating
|
||||
if (!this.level().isClientSide) {
|
||||
this.setLivingEntityFlag(1, true);
|
||||
this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND);
|
||||
@@ -3181,7 +_,10 @@
|
||||
}
|
||||
} else if (!this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
- this.useItemRemaining = 0;
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = 0;
|
||||
+ this.eatStartTime = -1L;
|
||||
+ // Paper end - lag compensate eating
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3220,12 +_,49 @@
|
||||
this.releaseUsingItem();
|
||||
} else {
|
||||
@@ -1621,6 +1657,18 @@
|
||||
this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks());
|
||||
if (this.useItem.useOnRelease()) {
|
||||
this.updatingUsingItem();
|
||||
@@ -3267,7 +_,10 @@
|
||||
}
|
||||
|
||||
this.useItem = ItemStack.EMPTY;
|
||||
- this.useItemRemaining = 0;
|
||||
+ // Paper start - lag compensate eating
|
||||
+ this.useItemRemaining = this.totalEatTimeTicks = 0;
|
||||
+ this.eatStartTime = -1L;
|
||||
+ // Paper end - lag compensate eating
|
||||
}
|
||||
|
||||
public boolean isBlocking() {
|
||||
@@ -3281,12 +_,69 @@
|
||||
if (item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user