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();
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<SectionPos> 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<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
+++ 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;
}

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
--- 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<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
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
@@ -0,0 +0,0 @@ public class GoalSelector {
};
private final Map<Goal.Flag, WrappedGoal> lockedFlags = new EnumMap<>(Goal.Flag.class);
private final Set<WrappedGoal> availableGoals = new ObjectLinkedOpenHashSet<>();
private final Supplier<ProfilerFiller> profiler;
- 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 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 {
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
+ 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

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));
+ }
+ // 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<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
+ private Path findPath(ProfilerFiller profiler, Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
profiler.push("find_path");
profiler.markForCharting(MetricCategory.PATH_FINDING);
+ private Path findPath(Node startNode, List<Map.Entry<Target, BlockPos>> positions, float followRange, int distance, float rangeMultiplier) {
ProfilerFiller profilerFiller = Profiler.get();
profilerFiller.push("find_path");
profilerFiller.markForCharting(MetricCategory.PATH_FINDING);
- Set<Target> set = positions.keySet();
+ // Set<Target> 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

View file

@ -165,11 +165,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void doTick(ServerLevel world, Mob entity) {
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 -> 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));
- Optional<ItemEntity> 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);

View file

@ -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") {