Update work 989

This commit is contained in:
Bjarne Koll 2024-10-24 22:29:29 +02:00
parent 9fdcea361c
commit c8414e5d1d
9 changed files with 44 additions and 44 deletions

View File

@ -14,24 +14,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}; };
private static final Logger LOGGER = LogUtils.getLogger(); private static final Logger LOGGER = LogUtils.getLogger();
public static final BlockPos ZERO = new BlockPos(0, 0, 0); public static final BlockPos ZERO = new BlockPos(0, 0, 0);
- private static final int PACKED_X_LENGTH = 1 + Mth.log2(Mth.smallestEncompassingPowerOfTwo(30000000)); - public static final int PACKED_HORIZONTAL_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 - 2 * PACKED_HORIZONTAL_LENGTH;
- public static final int PACKED_Y_LENGTH = 64 - PACKED_X_LENGTH - PACKED_Z_LENGTH; - private static final long PACKED_X_MASK = (1L << PACKED_HORIZONTAL_LENGTH) - 1L;
- private static final long PACKED_X_MASK = (1L << PACKED_X_LENGTH) - 1L;
- private static final long PACKED_Y_MASK = (1L << PACKED_Y_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 long PACKED_Z_MASK = (1L << PACKED_HORIZONTAL_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;
+ // Paper start - Optimize Bit Operations by inlining + // Paper start - Optimize Bit Operations by inlining
+ private static final int PACKED_X_LENGTH = 26; + private static final int PACKED_HORIZONTAL_LENGTH = 26;
+ private static final int PACKED_Z_LENGTH = 26;
+ public static final int PACKED_Y_LENGTH = 12; + public static final int PACKED_Y_LENGTH = 12;
+ private static final long PACKED_X_MASK = 67108863; + private static final long PACKED_X_MASK = 67108863;
+ private static final long PACKED_Y_MASK = 4095; + private static final long PACKED_Y_MASK = 4095;
+ private static final long PACKED_Z_MASK = 67108863; + 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 Z_OFFSET = 12;
+ private static final int X_OFFSET = 38; + private static final int X_OFFSET = 38;
+ public static final int MAX_HORIZONTAL_COORDINATE = 33554431;
+ // Paper end - Optimize Bit Operations by inlining + // Paper end - Optimize Bit Operations by inlining
public BlockPos(int x, int y, int z) { public BlockPos(int x, int y, int z) {
@ -51,7 +51,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public static int getX(long packedPos) { 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 + return (int) (packedPos >> 38); // Paper - simplify/inline
} }
@ -61,7 +61,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public static int getZ(long packedPos) { 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 + return (int) ((packedPos << 26) >> 38); // Paper - simplify/inline
} }
@ -206,8 +206,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static Stream<SectionPos> aroundChunk(ChunkPos center, int radius, int minY, int maxY) { public static Stream<SectionPos> aroundChunk(ChunkPos center, int radius, int minY, int maxY) {
- int i = center.x; - int i = center.x;
- int j = center.z; - int j = center.z;
- return betweenClosedStream(i - radius, minY, j - radius, i + radius, maxY - 1, j + radius); - return betweenClosedStream(i - radius, minY, j - radius, i + radius, maxY, j + radius);
+ return betweenClosedStream(center.x - radius, 0, center.z - radius, center.x + radius, 15, center.z + radius); // Paper - simplify/inline + return betweenClosedStream(center.x - radius, minY, center.z - radius, center.x + radius, maxY, center.z + radius); // Paper - simplify/inline
} }
public static Stream<SectionPos> betweenClosedStream(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) { public static Stream<SectionPos> betweenClosedStream(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {

View File

@ -18,12 +18,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/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 { @@ -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 + 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 // CraftBukkit end
if (dimensiontransition.missingRespawnBlock()) { if (teleporttransition.missingRespawnBlock()) {
entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); 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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
@ -58,8 +58,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.pos.set(i, j, k); - this.pos.set(i, j, k);
- BlockState blockState = blockGetter.getBlockState(this.pos); - BlockState blockState = blockGetter.getBlockState(this.pos);
- if ((!this.onlySuffocatingBlocks || blockState.isSuffocating(blockGetter, 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 + // Paper start - ensure we don't load chunks
+ // BlockGetter blockGetter = this.getChunk(i, k); + // BlockGetter blockGetter = this.getChunk(i, k);
+ if (true) { + if (true) {
@ -70,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (this.collisionGetter instanceof net.minecraft.server.level.WorldGenRegion) { + if (this.collisionGetter instanceof net.minecraft.server.level.WorldGenRegion) {
+ BlockGetter blockGetter = this.getChunk(x, z); + BlockGetter blockGetter = this.getChunk(x, z);
+ if (blockGetter == null) { + if (blockGetter == null) {
+ continue; + continue;
+ } + }
+ blockState = blockGetter.getBlockState(this.pos); + blockState = blockGetter.getBlockState(this.pos);
+ } else if ((!far && source instanceof net.minecraft.server.level.ServerPlayer) || (source != null && source.collisionLoadChunks)) { + } else if ((!far && source instanceof net.minecraft.server.level.ServerPlayer) || (source != null && source.collisionLoadChunks)) {
@ -84,11 +82,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ continue; + 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 + if (true // onlySuffocatingBlocks is only true on the client, so we don't care about it here
+ // Paper end + // Paper end - ensure we don't load chunks
VoxelShape voxelShape = blockState.getCollisionShape(this.collisionGetter, this.pos, this.context); && (l != 1 || blockState.hasLargeCollisionShape())
if (voxelShape == Shapes.block()) { && (l != 2 || blockState.is(Blocks.MOVING_PISTON))) {
if (this.box.intersects((double)i, (double)j, (double)k, (double)i + 1.0, (double)j + 1.0, (double)k + 1.0)) { 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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/CollisionGetter.java --- 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 { @@ -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 + 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()) { if (!voxelShape.isEmpty()) {
return false; return false;
} }

View File

@ -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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java --- a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
+++ b/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; @@ -0,0 +0,0 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.util.Mth; import net.minecraft.world.level.Level;
public abstract class Goal { public abstract class Goal {
- private final EnumSet<Goal.Flag> flags = EnumSet.noneOf(Goal.Flag.class); - private final EnumSet<Goal.Flag> 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 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
+++ b/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 { @@ -0,0 +0,0 @@ public class GoalSelector {
};
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class); private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);
private final Set<WrappedGoal> availableGoals = new ObjectLinkedOpenHashSet<>(); private final Set<WrappedGoal> availableGoals = new ObjectLinkedOpenHashSet<>();
private final Supplier<ProfilerFiller> profiler;
- private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.class); - private final EnumSet<Goal.Flag> disabledFlags = EnumSet.noneOf(Goal.Flag.class);
+ private static final Goal.Flag[] GOAL_FLAG_VALUES = Goal.Flag.values(); // Paper - remove streams from pathfindergoalselector + private static final Goal.Flag[] GOAL_FLAG_VALUES = Goal.Flag.values(); // Paper - remove streams from pathfindergoalselector
+ private final ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> goalTypes = new ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector + private final ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet<net.minecraft.world.entity.ai.goal.Goal.Flag> 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<ProfilerFiller> profiler) { public void addGoal(int priority, Goal goal) {
@@ -0,0 +0,0 @@ public class GoalSelector { @@ -0,0 +0,0 @@ public class GoalSelector {
this.availableGoals.removeIf(wrappedGoalx -> wrappedGoalx.getGoal() == goal); this.availableGoals.removeIf(wrappedGoalx -> wrappedGoalx.getGoal() == goal);
} }

View File

@ -59,7 +59,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent 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 + 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); 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 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View File

@ -31,18 +31,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos)); + 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 + // 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(); this.nodeEvaluator.done();
return path; return path;
@@ -0,0 +0,0 @@ public class PathFinder { @@ -0,0 +0,0 @@ public class PathFinder {
} }
@Nullable @Nullable
- private Path findPath(ProfilerFiller profiler, Node startNode, Map<Target, BlockPos> positions, float followRange, int distance, float rangeMultiplier) { - private Path findPath(Node startNode, Map<Target, BlockPos> positions, float followRange, int distance, float rangeMultiplier) {
+ // Paper start - Perf: remove streams and optimize collection + // Paper start - Perf: remove streams and optimize collection
+ private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) { + private Path findPath(Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
profiler.push("find_path"); ProfilerFiller profilerFiller = Profiler.get();
profiler.markForCharting(MetricCategory.PATH_FINDING); profilerFiller.push("find_path");
profilerFiller.markForCharting(MetricCategory.PATH_FINDING);
- Set<Target> set = positions.keySet(); - Set<Target> set = positions.keySet();
+ // Set<Target> set = positions.keySet(); + // Set<Target> set = positions.keySet();
startNode.g = 0.0F; startNode.g = 0.0F;
@ -109,7 +110,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (best == null || comparator.compare(path, best) < 0) + if (best == null || comparator.compare(path, best) < 0)
+ best = path; + best = path;
+ } + }
profiler.pop(); profilerFiller.pop();
- return optional.isEmpty() ? null : optional.get(); - return optional.isEmpty() ? null : optional.get();
+ return best; + return best;
+ // Paper end - Perf: remove streams and optimize collection + // Paper end - Perf: remove streams and optimize collection

View File

@ -165,11 +165,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void doTick(ServerLevel world, Mob entity) { protected void doTick(ServerLevel world, Mob entity) {
Brain<?> brain = entity.getBrain(); Brain<?> brain = entity.getBrain();
- List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> true); - List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0, 16.0, 32.0), itemEntity -> true);
+ List<ItemEntity> 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<ItemEntity> 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)); list.sort(Comparator.comparingDouble(entity::distanceToSqr));
- Optional<ItemEntity> optional = list.stream() - Optional<ItemEntity> optional = list.stream()
- .filter(itemEntity -> entity.wantsToPickUp(itemEntity.getItem())) - .filter(itemEntity -> entity.wantsToPickUp(world, itemEntity.getItem()))
- .filter(itemEntity -> itemEntity.closerThan(entity, 32.0)) - .filter(itemEntityx -> itemEntityx.closerThan(entity, 32.0))
- .filter(entity::hasLineOfSight) - .filter(entity::hasLineOfSight)
- .findFirst(); - .findFirst();
- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional); - brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, optional);

View File

@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -0,0 +0,0 @@ dependencies { @@ -0,0 +0,0 @@ dependencies {
runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0") runtimeOnly("org.xerial:sqlite-jdbc:3.46.1.3")
runtimeOnly("com.mysql:mysql-connector-j:8.4.0") runtimeOnly("com.mysql:mysql-connector-j:9.1.0")
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
+ // Paper start - Use Velocity cipher + // Paper start - Use Velocity cipher
+ implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT") { + implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT") {