13
0
geforkt von Mirrors/Paper

Apply optimise collision checking in move packet handling patch

Dieser Commit ist enthalten in:
Spottedleaf 2024-08-16 06:56:13 -07:00
Ursprung fee33bd1e2
Commit 1d4d2dc5f9

Datei anzeigen

@ -5,8 +5,6 @@ Subject: [PATCH] Optimise collision checking in player move packet handling
Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision
CHECK ME
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@ -142,22 +140,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private boolean hasNewCollision(final ServerLevel world, final Entity entity, final AABB oldBox, final AABB newBox) { + private boolean hasNewCollision(final ServerLevel world, final Entity entity, final AABB oldBox, final AABB newBox) {
+ final List<AABB> collisionsBB = new java.util.ArrayList<>(); + final List<AABB> collisionsBB = new java.util.ArrayList<>();
+ final List<VoxelShape> collisionsVoxel = new java.util.ArrayList<>(); + final List<VoxelShape> collisionsVoxel = new java.util.ArrayList<>();
+ io.papermc.paper.util.CollisionUtil.getCollisions( + ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisions(
+ world, entity, newBox, collisionsVoxel, collisionsBB, + world, entity, newBox, collisionsVoxel, collisionsBB,
+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER, + ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS | ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER,
+ null, null + null, null
+ ); + );
+ +
+ for (int i = 0, len = collisionsBB.size(); i < len; ++i) { + for (int i = 0, len = collisionsBB.size(); i < len; ++i) {
+ final AABB box = collisionsBB.get(i); + final AABB box = collisionsBB.get(i);
+ if (!io.papermc.paper.util.CollisionUtil.voxelShapeIntersect(box, oldBox)) { + if (!ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.voxelShapeIntersect(box, oldBox)) {
+ return true; + return true;
+ } + }
+ } + }
+ +
+ for (int i = 0, len = collisionsVoxel.size(); i < len; ++i) { + for (int i = 0, len = collisionsVoxel.size(); i < len; ++i) {
+ final VoxelShape voxel = collisionsVoxel.get(i); + final VoxelShape voxel = collisionsVoxel.get(i);
+ if (!io.papermc.paper.util.CollisionUtil.voxelShapeIntersectNoEmpty(voxel, oldBox)) { + if (!ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.voxelShapeIntersectNoEmpty(voxel, oldBox)) {
+ return true; + return true;
+ } + }
+ } + }