0
0
mirror of https://github.com/PaperMC/Paper.git synced 2024-11-25 04:06:25 +00:00
Paper/patches/server/0572-Change-EnderEye-target-without-changing-other-things.patch
Spottedleaf 8c5b837e05 Rework async chunk api implementation
Firstly, the old methods all routed to the CompletableFuture method.
However, the CF method could not guarantee that if the caller
was off-main that the future would be "completed" on-main. Since
the callback methods used the CF one, this meant that the callback
methods did not guarantee that the callbacks were to be called on
the main thread.

Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb)
so that the methods with the callback are guaranteed to invoke
the callback on the main thread. The CF behavior remains unchanged;
it may still appear to complete on main if invoked off-main.

Secondly, remove the scheduleOnMain invocation in the async
chunk completion. This unnecessarily delays the callback
by 1 tick.

Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which
will load chunks within an area. This method is provided as a helper
as keeping all chunks loaded within an area can be complicated to
implement for plugins (due to the lacking ticket API), and is
already implemented internally anyways.

Fourthly, remove the ticket addition that occured with getChunkAt
and getChunkAtAsync. The ticket addition may delay the unloading
of the chunk unnecessarily. It also fixes a very rare timing bug
where the future/callback would be completed after the chunk
unloads.
2024-11-18 23:00:59 -08:00

55 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sat, 21 Aug 2021 12:13:53 -0700
Subject: [PATCH] Change EnderEye target without changing other things
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
index 573b96c9e0c89860c3da031c5aa239f6a7ad0c6e..fd1f5de7dc151dfd187d23e022b2c5435ed8accc 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
@@ -76,6 +76,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
}
public void signalTo(BlockPos pos) {
+ // Paper start - Change EnderEye target without changing other things
+ this.signalTo(pos, true);
+ }
+ public void signalTo(BlockPos pos, boolean update) {
+ // Paper end - Change EnderEye target without changing other things
double d0 = (double) pos.getX();
int i = pos.getY();
double d1 = (double) pos.getZ();
@@ -93,8 +98,10 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
this.tz = d1;
}
+ if (update) { // Paper - Change EnderEye target without changing other things
this.life = 0;
this.surviveAfterDeath = this.random.nextInt(5) > 0;
+ } // Paper - Change EnderEye target without changing other things
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
index d4dfc7a0266086b9bf2c3966c6e149453d0583ba..27f56fa4b7ef92a9a4dfa6b782350424b88210f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
@@ -32,8 +32,15 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
@Override
public void setTargetLocation(Location location) {
+ // Paper start - Change EnderEye target without changing other things
+ this.setTargetLocation(location, true);
+ }
+
+ @Override
+ public void setTargetLocation(Location location, boolean update) {
+ // Paper end - Change EnderEye target without changing other things
Preconditions.checkArgument(this.getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
- this.getHandle().signalTo(CraftLocation.toBlockPosition(location));
+ this.getHandle().signalTo(CraftLocation.toBlockPosition(location), update); // Paper - Change EnderEye target without changing other things
}
@Override