geforkt von Mirrors/Paper
c5a10665b8
Spigot still maintains some partial implementation of "tick skipping", a practice in which the MinecraftServer.currentTick field is updated not by an increment of one per actual tick, but instead set to System.currentTimeMillis() / 50. This behaviour means that the tracked tick may "skip" a tick value in case a previous tick took more than the expected 50ms. To compensate for this in important paths, spigot/craftbukkit implements "wall-time". Instead of incrementing/decrementing ticks on block entities/entities by one for each call to their tick() method, they instead increment/decrement important values, like an ItemEntity's age or pickupDelay, by the difference of `currentTick - lastTick`, where `lastTick` is the value of `currentTick` during the last tick() call. These "fixes" however do not play nicely with minecraft's simulation distance as entities/block entities implementing the above behaviour would "catch up" their values when moving from a non-ticking chunk to a ticking one as their `lastTick` value remains stuck on the last tick in a ticking chunk and hence lead to a large "catch up" once ticked again. Paper completely removes the "tick skipping" behaviour (See patch "Further-improve-server-tick-loop"), making the above precautions completely unnecessary, which also rids paper of the previous described incompatibility with non-ticking chunks.
36 Zeilen
2.9 KiB
Diff
36 Zeilen
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Fri, 9 Dec 2022 03:10:23 -0800
|
|
Subject: [PATCH] Improve/fix EntityTargetLivingEntityEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
|
index cc7d161b53a2295fa1745254eafb8a70c7b6c7b2..508d4f391fe563453d7bf6782b3082741c358006 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/StopAttackingIfTargetInvalid.java
|
|
@@ -47,9 +47,22 @@ public class StopAttackingIfTargetInvalid {
|
|
if (entityinsentient.canAttack(entityliving) && (!shouldForgetIfTargetUnreachable || !StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !alternativeCondition.test(entityliving)) {
|
|
return true;
|
|
} else {
|
|
+ // Paper start - better track target change reason
|
|
+ final EntityTargetEvent.TargetReason reason;
|
|
+ if (!entityinsentient.canAttack(entityliving)) {
|
|
+ reason = EntityTargetEvent.TargetReason.TARGET_INVALID;
|
|
+ } else if (shouldForgetIfTargetUnreachable && StopAttackingIfTargetInvalid.isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) {
|
|
+ reason = EntityTargetEvent.TargetReason.FORGOT_TARGET;
|
|
+ } else if (!entityliving.isAlive()) {
|
|
+ reason = EntityTargetEvent.TargetReason.TARGET_DIED;
|
|
+ } else if (entityliving.level() != entityinsentient.level()) {
|
|
+ reason = EntityTargetEvent.TargetReason.TARGET_OTHER_LEVEL;
|
|
+ } else {
|
|
+ reason = EntityTargetEvent.TargetReason.TARGET_INVALID;
|
|
+ }
|
|
+ // Paper end
|
|
// CraftBukkit start
|
|
- LivingEntity old = entityinsentient.getBrain().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
|
|
- EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityinsentient, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
|
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(entityinsentient, null, reason); // Paper
|
|
if (event.isCancelled()) {
|
|
return false;
|
|
}
|