From c8414e5d1d879c0b7813ef2f8849f7589485a053 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Thu, 24 Oct 2024 22:29:29 +0200 Subject: [PATCH] Update work 989 --- ...y-type-tags-suggestions-in-selectors.patch | 0 .../Optimize-Bit-Operations-by-inlining.patch | 28 +++++++++---------- ...ptimize-Collision-to-not-load-chunks.patch | 25 ++++++++--------- ...oalSelector-Goal.Flag-Set-operations.patch | 10 +++---- .../server/Optimize-Hoppers.patch | 2 +- ...der-Remove-Streams-Optimized-collect.patch | 13 +++++---- .../server/Optimize-Voxel-Shape-Merging.patch | 0 .../server/Remove-streams-from-hot-code.patch | 6 ++-- ...ocity-compression-and-cipher-natives.patch | 4 +-- 9 files changed, 44 insertions(+), 44 deletions(-) rename patches/{unapplied => }/server/Fix-entity-type-tags-suggestions-in-selectors.patch (100%) rename patches/{unapplied => }/server/Optimize-Bit-Operations-by-inlining.patch (90%) rename patches/{unapplied => }/server/Optimize-Collision-to-not-load-chunks.patch (85%) rename patches/{unapplied => }/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch (97%) rename patches/{unapplied => }/server/Optimize-Hoppers.patch (99%) rename patches/{unapplied => }/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch (92%) rename patches/{unapplied => }/server/Optimize-Voxel-Shape-Merging.patch (100%) rename patches/{unapplied => }/server/Remove-streams-from-hot-code.patch (97%) rename patches/{unapplied => }/server/Use-Velocity-compression-and-cipher-natives.patch (99%) diff --git a/patches/unapplied/server/Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch similarity index 100% rename from patches/unapplied/server/Fix-entity-type-tags-suggestions-in-selectors.patch rename to patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch diff --git a/patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch b/patches/server/Optimize-Bit-Operations-by-inlining.patch similarity index 90% rename from patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch rename to patches/server/Optimize-Bit-Operations-by-inlining.patch index 9e77b0a62c..895ee41942 100644 --- a/patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch +++ b/patches/server/Optimize-Bit-Operations-by-inlining.patch @@ -14,24 +14,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 }; private static final Logger LOGGER = LogUtils.getLogger(); public static final BlockPos ZERO = new BlockPos(0, 0, 0); -- private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000)); -- private static final int PACKED_Z_LENGTH = PACKED_X_LENGTH; -- public static final int PACKED_Y_LENGTH = 64 - PACKED_X_LENGTH - PACKED_Z_LENGTH; -- private static final long PACKED_X_MASK = (1L << PACKED_X_LENGTH) - 1L; +- public static final int PACKED_HORIZONTAL_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000)); +- public static final int PACKED_Y_LENGTH = 64 - 2 * PACKED_HORIZONTAL_LENGTH; +- private static final long PACKED_X_MASK = (1L << PACKED_HORIZONTAL_LENGTH) - 1L; - private static final long PACKED_Y_MASK = (1L << PACKED_Y_LENGTH) - 1L; -- private static final long PACKED_Z_MASK = (1L << PACKED_Z_LENGTH) - 1L; -- private static final int Y_OFFSET = 0; -- private static final int Z_OFFSET = PACKED_Y_LENGTH; -- private static final int X_OFFSET = PACKED_Y_LENGTH + PACKED_Z_LENGTH; +- private static final long PACKED_Z_MASK = (1L << PACKED_HORIZONTAL_LENGTH) - 1L; + // Paper start - Optimize Bit Operations by inlining -+ private static final int PACKED_X_LENGTH = 26; -+ private static final int PACKED_Z_LENGTH = 26; ++ private static final int PACKED_HORIZONTAL_LENGTH = 26; + public static final int PACKED_Y_LENGTH = 12; + private static final long PACKED_X_MASK = 67108863; + private static final long PACKED_Y_MASK = 4095; + private static final long PACKED_Z_MASK = 67108863; + private static final int Y_OFFSET = 0; +- private static final int Z_OFFSET = PACKED_Y_LENGTH; +- private static final int X_OFFSET = PACKED_Y_LENGTH + PACKED_HORIZONTAL_LENGTH; +- public static final int MAX_HORIZONTAL_COORDINATE = (1 << PACKED_HORIZONTAL_LENGTH) / 2 - 1; + private static final int Z_OFFSET = 12; + private static final int X_OFFSET = 38; ++ public static final int MAX_HORIZONTAL_COORDINATE = 33554431; + // Paper end - Optimize Bit Operations by inlining public BlockPos(int x, int y, int z) { @@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public static int getX(long packedPos) { -- return (int)(packedPos << 64 - X_OFFSET - PACKED_X_LENGTH >> 64 - PACKED_X_LENGTH); +- return (int)(packedPos << 64 - X_OFFSET - PACKED_HORIZONTAL_LENGTH >> 64 - PACKED_HORIZONTAL_LENGTH); + return (int) (packedPos >> 38); // Paper - simplify/inline } @@ -61,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public static int getZ(long packedPos) { -- return (int)(packedPos << 64 - Z_OFFSET - PACKED_Z_LENGTH >> 64 - PACKED_Z_LENGTH); +- return (int)(packedPos << 64 - Z_OFFSET - PACKED_HORIZONTAL_LENGTH >> 64 - PACKED_HORIZONTAL_LENGTH); + return (int) ((packedPos << 26) >> 38); // Paper - simplify/inline } @@ -206,8 +206,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static Stream aroundChunk(ChunkPos center, int radius, int minY, int maxY) { - int i = center.x; - int j = center.z; -- return betweenClosedStream(i - radius, minY, j - radius, i + radius, maxY - 1, j + radius); -+ return betweenClosedStream(center.x - radius, 0, center.z - radius, center.x + radius, 15, center.z + radius); // Paper - simplify/inline +- return betweenClosedStream(i - radius, minY, j - radius, i + radius, maxY, j + radius); ++ return betweenClosedStream(center.x - radius, minY, center.z - radius, center.x + radius, maxY, center.z + radius); // Paper - simplify/inline } public static Stream betweenClosedStream(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { diff --git a/patches/unapplied/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch similarity index 85% rename from patches/unapplied/server/Optimize-Collision-to-not-load-chunks.patch rename to patches/server/Optimize-Collision-to-not-load-chunks.patch index 3d4f5503e4..ea83ee9244 100644 --- a/patches/unapplied/server/Optimize-Collision-to-not-load-chunks.patch +++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch @@ -18,12 +18,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - Vec3 vec3d = dimensiontransition.pos(); + Vec3 vec3d = teleporttransition.position(); - entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, dimensiontransition.yRot(), dimensiontransition.xRot()); + entityplayer1.forceSetPositionRotation(vec3d.x, vec3d.y, vec3d.z, teleporttransition.yRot(), teleporttransition.xRot()); + worldserver.getChunkSource().addRegionTicket(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(net.minecraft.util.Mth.floor(vec3d.x()) >> 4, net.minecraft.util.Mth.floor(vec3d.z()) >> 4), 1, entityplayer.getId()); // Paper // CraftBukkit end - if (dimensiontransition.missingRespawnBlock()) { + if (teleporttransition.missingRespawnBlock()) { entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -58,8 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.pos.set(i, j, k); - BlockState blockState = blockGetter.getBlockState(this.pos); - if ((!this.onlySuffocatingBlocks || blockState.isSuffocating(blockGetter, this.pos)) -- && (l != 1 || blockState.hasLargeCollisionShape()) -- && (l != 2 || blockState.is(Blocks.MOVING_PISTON))) { + // Paper start - ensure we don't load chunks + // BlockGetter blockGetter = this.getChunk(i, k); + if (true) { @@ -70,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (this.collisionGetter instanceof net.minecraft.server.level.WorldGenRegion) { + BlockGetter blockGetter = this.getChunk(x, z); + if (blockGetter == null) { -+ continue; ++ continue; + } + blockState = blockGetter.getBlockState(this.pos); + } else if ((!far && source instanceof net.minecraft.server.level.ServerPlayer) || (source != null && source.collisionLoadChunks)) { @@ -84,11 +82,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + continue; + } -+ if (/*(!this.onlySuffocatingBlocks || blockState.isSuffocating(blockGetter, this.pos)) &&*/ (l != 1 || blockState.hasLargeCollisionShape()) && (l != 2 || blockState.is(Blocks.MOVING_PISTON))) { // Paper - onlySuffocatingBlocks is only true on the client, so we don't care about it here -+ // Paper end - VoxelShape voxelShape = blockState.getCollisionShape(this.collisionGetter, this.pos, this.context); - if (voxelShape == Shapes.block()) { - if (this.box.intersects((double)i, (double)j, (double)k, (double)i + 1.0, (double)j + 1.0, (double)k + 1.0)) { ++ if (true // onlySuffocatingBlocks is only true on the client, so we don't care about it here ++ // Paper end - ensure we don't load chunks + && (l != 1 || blockState.hasLargeCollisionShape()) + && (l != 2 || blockState.is(Blocks.MOVING_PISTON))) { + VoxelShape voxelShape = this.context.getCollisionShape(blockState, this.collisionGetter, this.pos); diff --git a/src/main/java/net/minecraft/world/level/CollisionGetter.java b/src/main/java/net/minecraft/world/level/CollisionGetter.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/CollisionGetter.java @@ -96,9 +94,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface CollisionGetter extends BlockGetter { } - default boolean noCollision(@Nullable Entity entity, AABB box) { + default boolean noCollision(@Nullable Entity entity, AABB box, boolean checkFluid) { +- for (VoxelShape voxelShape : checkFluid ? this.getBlockAndLiquidCollisions(entity, box) : this.getBlockCollisions(entity, box)) { + try { if (entity != null) entity.collisionLoadChunks = true; // Paper - for (VoxelShape voxelShape : this.getBlockCollisions(entity, box)) { ++ for (VoxelShape voxelShape : checkFluid ? this.getBlockAndLiquidCollisions(entity, box) : this.getBlockCollisions(entity, box)) { if (!voxelShape.isEmpty()) { return false; } diff --git a/patches/unapplied/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/patches/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 97% rename from patches/unapplied/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to patches/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch index a0bdcc4ab3..2ac567e484 100644 --- a/patches/unapplied/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch +++ b/patches/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch @@ -10,8 +10,8 @@ diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java -@@ -0,0 +0,0 @@ import java.util.EnumSet; - import net.minecraft.util.Mth; +@@ -0,0 +0,0 @@ import net.minecraft.world.entity.Entity; + import net.minecraft.world.level.Level; public abstract class Goal { - private final EnumSet flags = EnumSet.noneOf(Goal.Flag.class); @@ -62,15 +62,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -0,0 +0,0 @@ public class GoalSelector { + }; private final Map lockedFlags = new EnumMap<>(Goal.Flag.class); private final Set availableGoals = new ObjectLinkedOpenHashSet<>(); - private final Supplier profiler; - private final EnumSet disabledFlags = EnumSet.noneOf(Goal.Flag.class); + private static final Goal.Flag[] GOAL_FLAG_VALUES = Goal.Flag.values(); // Paper - remove streams from pathfindergoalselector + private final ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet goalTypes = new ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector - private int curRate; + private int curRate; // Paper - EAR 2 - public GoalSelector(Supplier profiler) { + public void addGoal(int priority, Goal goal) { @@ -0,0 +0,0 @@ public class GoalSelector { this.availableGoals.removeIf(wrappedGoalx -> wrappedGoalx.getGoal() == goal); } diff --git a/patches/unapplied/server/Optimize-Hoppers.patch b/patches/server/Optimize-Hoppers.patch similarity index 99% rename from patches/unapplied/server/Optimize-Hoppers.patch rename to patches/server/Optimize-Hoppers.patch index 6a0d7fcc89..2f79c8aa44 100644 --- a/patches/unapplied/server/Optimize-Hoppers.patch +++ b/patches/server/Optimize-Hoppers.patch @@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent + net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers - this.profiler.push(() -> { + gameprofilerfiller.push(() -> { String s = String.valueOf(worldserver); diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/unapplied/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch similarity index 92% rename from patches/unapplied/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch rename to patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch index e0d4f9a991..fabf3cd051 100644 --- a/patches/unapplied/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch +++ b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch @@ -31,18 +31,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos)); + } + // Paper end - Perf: remove streams and optimize collection - Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier); + Path path = this.findPath(node, map, followRange, distance, rangeMultiplier); this.nodeEvaluator.done(); return path; @@ -0,0 +0,0 @@ public class PathFinder { } @Nullable -- private Path findPath(ProfilerFiller profiler, Node startNode, Map positions, float followRange, int distance, float rangeMultiplier) { +- private Path findPath(Node startNode, Map positions, float followRange, int distance, float rangeMultiplier) { + // Paper start - Perf: remove streams and optimize collection -+ private Path findPath(ProfilerFiller profiler, Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { - profiler.push("find_path"); - profiler.markForCharting(MetricCategory.PATH_FINDING); ++ private Path findPath(Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("find_path"); + profilerFiller.markForCharting(MetricCategory.PATH_FINDING); - Set set = positions.keySet(); + // Set set = positions.keySet(); startNode.g = 0.0F; @@ -109,7 +110,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (best == null || comparator.compare(path, best) < 0) + best = path; + } - profiler.pop(); + profilerFiller.pop(); - return optional.isEmpty() ? null : optional.get(); + return best; + // Paper end - Perf: remove streams and optimize collection diff --git a/patches/unapplied/server/Optimize-Voxel-Shape-Merging.patch b/patches/server/Optimize-Voxel-Shape-Merging.patch similarity index 100% rename from patches/unapplied/server/Optimize-Voxel-Shape-Merging.patch rename to patches/server/Optimize-Voxel-Shape-Merging.patch diff --git a/patches/unapplied/server/Remove-streams-from-hot-code.patch b/patches/server/Remove-streams-from-hot-code.patch similarity index 97% rename from patches/unapplied/server/Remove-streams-from-hot-code.patch rename to patches/server/Remove-streams-from-hot-code.patch index fca4da6dcc..815e75e1bd 100644 --- a/patches/unapplied/server/Remove-streams-from-hot-code.patch +++ b/patches/server/Remove-streams-from-hot-code.patch @@ -165,11 +165,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected void doTick(ServerLevel world, Mob entity) { Brain brain = entity.getBrain(); - List list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> true); -+ List list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> itemEntity.closerThan(entity, MAX_DISTANCE_TO_WANTED_ITEM) && entity.wantsToPickUp(itemEntity.getItem())); // Paper - Perf: Move predicate into getEntities ++ List list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> itemEntity.closerThan(entity, MAX_DISTANCE_TO_WANTED_ITEM) && entity.wantsToPickUp(world, itemEntity.getItem())); // Paper - Perf: Move predicate into getEntities list.sort(Comparator.comparingDouble(entity::distanceToSqr)); - Optional optional = list.stream() -- .filter(itemEntity -> entity.wantsToPickUp(itemEntity.getItem())) -- .filter(itemEntity -> itemEntity.closerThan(entity, 32.0)) +- .filter(itemEntity -> entity.wantsToPickUp(world, itemEntity.getItem())) +- .filter(itemEntityx -> itemEntityx.closerThan(entity, 32.0)) - .filter(entity::hasLineOfSight) - .findFirst(); - brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional); diff --git a/patches/unapplied/server/Use-Velocity-compression-and-cipher-natives.patch b/patches/server/Use-Velocity-compression-and-cipher-natives.patch similarity index 99% rename from patches/unapplied/server/Use-Velocity-compression-and-cipher-natives.patch rename to patches/server/Use-Velocity-compression-and-cipher-natives.patch index e49b6d2bfa..13feca9073 100644 --- a/patches/unapplied/server/Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/Use-Velocity-compression-and-cipher-natives.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0") - runtimeOnly("com.mysql:mysql-connector-j:8.4.0") + runtimeOnly("org.xerial:sqlite-jdbc:3.46.1.3") + runtimeOnly("com.mysql:mysql-connector-j:9.1.0") runtimeOnly("com.lmax:disruptor:3.4.4") // Paper + // Paper start - Use Velocity cipher + implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT") {