2022-12-27 23:56:19 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: SoSeDiK <mrsosedik@gmail.com>
|
|
|
|
Date: Tue, 11 Oct 2022 23:30:32 +0300
|
|
|
|
Subject: [PATCH] Expose pre-collision moving velocity to
|
|
|
|
VehicleBlockCollisionEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
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-19 07:34:32 +01:00
|
|
|
index 4135eeab128fc989d9357dee59c779d2812106e8..61bd5290d0056656ab761ecf38cf8c8bbb80ab94 100644
|
2022-12-27 23:56:19 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -969,6 +969,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2024-01-23 18:01:39 +01:00
|
|
|
}
|
|
|
|
|
2024-10-24 00:08:29 +02:00
|
|
|
public void move(MoverType type, Vec3 movement) {
|
2024-01-23 18:01:39 +01:00
|
|
|
+ final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity
|
|
|
|
if (this.noPhysics) {
|
|
|
|
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
|
|
|
|
} else {
|
2024-11-04 18:42:38 +01:00
|
|
|
@@ -1060,7 +1061,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
2022-12-27 23:56:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!bl.getType().isAir()) {
|
|
|
|
- VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
|
2024-01-23 18:01:39 +01:00
|
|
|
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl, org.bukkit.craftbukkit.util.CraftVector.toBukkit(originalMovement)); // Paper - Expose pre-collision velocity
|
2022-12-27 23:56:19 +01:00
|
|
|
this.level.getCraftServer().getPluginManager().callEvent(event);
|
|
|
|
}
|
|
|
|
}
|