Update work 989

This commit is contained in:
Bjarne Koll 2024-10-24 22:29:29 +02:00
parent fe142cdcd5
commit 35e01d7a80
No known key found for this signature in database
GPG key ID: 27F6CCCF55D2EE62
9 changed files with 92 additions and 92 deletions

View file

@ -5,12 +5,12 @@ Subject: [PATCH] Use Velocity compression and cipher natives
diff --git a/build.gradle.kts b/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts
index 9de7a09c5f1b23754a2823978fa3ff218aadcfa7..4f6136ae3ac4890b21a5fb3f69f9c1474a0773d1 100644 index 25001d6cf4f70bd01ab304625b49ec45f5b1f525..9966576652ed6007d2228237f292c1dc83ede485 100644
--- a/build.gradle.kts --- a/build.gradle.kts
+++ b/build.gradle.kts +++ b/build.gradle.kts
@@ -37,6 +37,11 @@ dependencies { @@ -37,6 +37,11 @@ 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") {
@ -352,7 +352,7 @@ index 4abe4f75956e4c16f8b4e0b2f77ad64d7914aa65..3a9e25b436f366fffe08c3b0c1fce11e
protected void initChannel(Channel channel) { protected void initChannel(Channel channel) {
try { try {
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 35faa10f3b82504ae9d3f923fc04c5a99c1a624a..40638b439966619e9c70a18a32abd95b2178fe9f 100644 index 4a89b73d972f366e70f4d2bd96c6ee413593baba..033755682c61c889723c3669b5cff4de147f637e 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -287,12 +287,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -287,12 +287,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,

View file

@ -14,22 +14,22 @@ movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups. massive amounts of surrounding chunks due to large AABB lookups.
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index db0a5c6258fa2b9a5d960f82f6b1f3bc2b386bc9..3a90dd1289d393426151d4457edaf99731cc34db 100644 index cde19fddfc9b1c8edbc565bec4f043803651313e..4b9761e58f404eedf9db835fc923a88fc1896e96 100644
--- 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
@@ -869,6 +869,7 @@ public abstract class PlayerList { @@ -827,6 +827,7 @@ 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 242d9213d22cb552e48beee03aa2db141e39d1c4..52f3d0d4ce28cc6566166ae9a5a1b236ff8c027d 100644 index f4b1a773bf809bde8cea919a418700f3d6850389..ea7100c8ac5da730d55136ac2ab608c2a7ac0ba8 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -250,6 +250,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -258,6 +258,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
// Paper end - Share random for entities to make them more random // Paper end - Share random for entities to make them more random
public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason
@ -38,10 +38,10 @@ index 242d9213d22cb552e48beee03aa2db141e39d1c4..52f3d0d4ce28cc6566166ae9a5a1b236
public CraftEntity getBukkitEntity() { public CraftEntity getBukkitEntity() {
diff --git a/src/main/java/net/minecraft/world/level/BlockCollisions.java b/src/main/java/net/minecraft/world/level/BlockCollisions.java diff --git a/src/main/java/net/minecraft/world/level/BlockCollisions.java b/src/main/java/net/minecraft/world/level/BlockCollisions.java
index 1c10835b59aaefa3a65ff64f784620bdc54ddcdc..cd89623a44f02d7db77f0d0f87545cf80841f403 100644 index 12a14b8fdb079fd8c367e51299486761ebdaeb5b..b360594424118d9d11d00ea140160485048591ca 100644
--- a/src/main/java/net/minecraft/world/level/BlockCollisions.java --- a/src/main/java/net/minecraft/world/level/BlockCollisions.java
+++ b/src/main/java/net/minecraft/world/level/BlockCollisions.java +++ b/src/main/java/net/minecraft/world/level/BlockCollisions.java
@@ -66,18 +66,37 @@ public class BlockCollisions<T> extends AbstractIterator<T> { @@ -72,16 +72,37 @@ public class BlockCollisions<T> extends AbstractIterator<T> {
@Override @Override
protected T computeNext() { protected T computeNext() {
while (this.cursor.advance()) { while (this.cursor.advance()) {
@ -58,8 +58,6 @@ index 1c10835b59aaefa3a65ff64f784620bdc54ddcdc..cd89623a44f02d7db77f0d0f87545cf8
- 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) {
@ -84,21 +82,22 @@ index 1c10835b59aaefa3a65ff64f784620bdc54ddcdc..cd89623a44f02d7db77f0d0f87545cf8
+ } + }
+ 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 e57cb7fe53e915d24246e44c7f49971f5b2ab2cf..1ad0c976c6e2d6d31397dff850a9de7c16d16fba 100644 index 6b63dc10c0a4db8a484588a6d67911ea1023457e..f4c251c2bcfa96ba22e338b97a1de7f0abac5a6f 100644
--- a/src/main/java/net/minecraft/world/level/CollisionGetter.java --- a/src/main/java/net/minecraft/world/level/CollisionGetter.java
+++ b/src/main/java/net/minecraft/world/level/CollisionGetter.java +++ b/src/main/java/net/minecraft/world/level/CollisionGetter.java
@@ -44,11 +44,13 @@ public interface CollisionGetter extends BlockGetter { @@ -50,11 +50,13 @@ 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

@ -7,11 +7,11 @@ Optimise the stream.anyMatch statement to move to a bitset
where we can replace the call with a single bitwise operation. where we can replace the call with a single bitwise operation.
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java b/src/main/java/net/minecraft/world/entity/ai/goal/Goal.java
index 16f9a98b8a939e5ca7e2dc04f87134a7ed66736b..47741efa48258c3c30b1d59504bf3121c236cadb 100644 index acc25b08ed3b9f978229fa017d23f9fa0da519e3..71c952621580fe95730835ed0eab7c9852550030 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
@@ -4,7 +4,16 @@ import java.util.EnumSet; @@ -7,7 +7,16 @@ 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);
@ -28,7 +28,7 @@ index 16f9a98b8a939e5ca7e2dc04f87134a7ed66736b..47741efa48258c3c30b1d59504bf3121
public abstract boolean canUse(); public abstract boolean canUse();
@@ -30,8 +39,13 @@ public abstract class Goal { @@ -33,8 +42,13 @@ public abstract class Goal {
} }
public void setFlags(EnumSet<Goal.Flag> controls) { public void setFlags(EnumSet<Goal.Flag> controls) {
@ -44,7 +44,7 @@ index 16f9a98b8a939e5ca7e2dc04f87134a7ed66736b..47741efa48258c3c30b1d59504bf3121
} }
@Override @Override
@@ -39,8 +53,10 @@ public abstract class Goal { @@ -42,8 +56,10 @@ public abstract class Goal {
return this.getClass().getSimpleName(); return this.getClass().getSimpleName();
} }
@ -58,20 +58,20 @@ index 16f9a98b8a939e5ca7e2dc04f87134a7ed66736b..47741efa48258c3c30b1d59504bf3121
protected int adjustedTickDelay(int ticks) { protected int adjustedTickDelay(int ticks) {
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java
index 074ef807258139f818e30494126585262c2f33c0..9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8 100644 index d871975f943a04b49644dc6eb18314d65a7836dc..29ae74339a4831ccef3d01e8054931715ba192ad 100644
--- 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
@@ -25,7 +25,8 @@ public class GoalSelector { @@ -24,7 +24,8 @@ 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) {
@@ -65,18 +66,18 @@ public class GoalSelector { @@ -60,18 +61,18 @@ public class GoalSelector {
this.availableGoals.removeIf(wrappedGoalx -> wrappedGoalx.getGoal() == goal); this.availableGoals.removeIf(wrappedGoalx -> wrappedGoalx.getGoal() == goal);
} }
@ -99,7 +99,7 @@ index 074ef807258139f818e30494126585262c2f33c0..9bdbf3e9453bc3ce96d52d04b8cde0d0
if (!goalsByControl.getOrDefault(flag, NO_GOAL).canBeReplacedBy(goal)) { if (!goalsByControl.getOrDefault(flag, NO_GOAL).canBeReplacedBy(goal)) {
return false; return false;
} }
@@ -90,7 +91,7 @@ public class GoalSelector { @@ -85,7 +86,7 @@ public class GoalSelector {
profilerFiller.push("goalCleanup"); profilerFiller.push("goalCleanup");
for (WrappedGoal wrappedGoal : this.availableGoals) { for (WrappedGoal wrappedGoal : this.availableGoals) {
@ -108,7 +108,7 @@ index 074ef807258139f818e30494126585262c2f33c0..9bdbf3e9453bc3ce96d52d04b8cde0d0
wrappedGoal.stop(); wrappedGoal.stop();
} }
} }
@@ -100,11 +101,14 @@ public class GoalSelector { @@ -95,11 +96,14 @@ public class GoalSelector {
profilerFiller.push("goalUpdate"); profilerFiller.push("goalUpdate");
for (WrappedGoal wrappedGoal2 : this.availableGoals) { for (WrappedGoal wrappedGoal2 : this.availableGoals) {
@ -128,7 +128,7 @@ index 074ef807258139f818e30494126585262c2f33c0..9bdbf3e9453bc3ce96d52d04b8cde0d0
WrappedGoal wrappedGoal3 = this.lockedFlags.getOrDefault(flag, NO_GOAL); WrappedGoal wrappedGoal3 = this.lockedFlags.getOrDefault(flag, NO_GOAL);
wrappedGoal3.stop(); wrappedGoal3.stop();
this.lockedFlags.put(flag, wrappedGoal2); this.lockedFlags.put(flag, wrappedGoal2);
@@ -136,11 +140,11 @@ public class GoalSelector { @@ -131,11 +135,11 @@ public class GoalSelector {
} }
public void disableControlFlag(Goal.Flag control) { public void disableControlFlag(Goal.Flag control) {

View file

@ -50,22 +50,22 @@ index 0000000000000000000000000000000000000000..5c42823726e70ce6c9d0121d07431548
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 999e9c8f842423e6f1a3e80902e9d076e01f6694..c13b4f39c19dd6a62ae39688bde5a4739b391e59 100644 index 21660e4284cfabb333a3edf9224c892ef80b2403..dcf046dd1eb8c2b724c971c4adf4462895183f0a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1719,6 +1719,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1724,6 +1724,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
ServerLevel worldserver = (ServerLevel) iterator.next(); ServerLevel worldserver = (ServerLevel) iterator.next();
worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
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 96b24c1415af531feef7d8ab4724f7fed3ae8388..eec0ec43590be7e8ae5b530a7404c98b5e23cb53 100644 index 4f20e5bb143e152e19e5fb57f66d0344001ffbd9..888454ff588927e8accc215e7429f72bb286f5aa 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java --- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -809,10 +809,16 @@ public final class ItemStack implements DataComponentHolder { @@ -876,10 +876,16 @@ public final class ItemStack implements DataComponentHolder {
} }
public ItemStack copy() { public ItemStack copy() {
@ -85,7 +85,7 @@ index 96b24c1415af531feef7d8ab4724f7fed3ae8388..eec0ec43590be7e8ae5b530a7404c98b
itemstack.setPopTime(this.getPopTime()); itemstack.setPopTime(this.getPopTime());
return itemstack; return itemstack;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
index a1d7ae987327382d9566860b991dc361225c7938..7dfabb11d3c8112f6daef35d204a2e324f4ddb5e 100644 index b4aff394694417cff1930cf8fbd6696b9f9c9d01..fb00e5a02bb8c64e27d6d009068ba041098951d6 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -38,6 +38,7 @@ import co.aikar.timings.MinecraftTimings; // Paper @@ -38,6 +38,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
@ -96,7 +96,7 @@ index a1d7ae987327382d9566860b991dc361225c7938..7dfabb11d3c8112f6daef35d204a2e32
public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper
// CraftBukkit start - data containers // CraftBukkit start - data containers
@@ -229,6 +230,7 @@ public abstract class BlockEntity { @@ -230,6 +231,7 @@ public abstract class BlockEntity {
public void setChanged() { public void setChanged() {
if (this.level != null) { if (this.level != null) {
@ -105,7 +105,7 @@ index a1d7ae987327382d9566860b991dc361225c7938..7dfabb11d3c8112f6daef35d204a2e32
} }
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 542a5501ac94f57810d34e0f769a9a7855604f91..cab403efd471bb61835224eea4e99570d34dcaaa 100644 index b35b44f0776aeb95ef0eda666ba0b652c5e90274..5ebbdb94d9b91c442ff60eb6872f740ebd790fa0 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -156,6 +156,43 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -156,6 +156,43 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@ -650,7 +650,7 @@ index 542a5501ac94f57810d34e0f769a9a7855604f91..cab403efd471bb61835224eea4e99570
@Override @Override
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index 13c9a68b604d4c7c6e09e72b3cea7ab2214b06ab..e2752752417c50b06f7c15b7d00bda0eaad3b0ae 100644 index fc657b6052d4310ad9c28988042c2cf37cf5d213..a459163bd7148a27c60e030479df4da91e957049 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
@@ -53,7 +53,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @@ -53,7 +53,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc

View file

@ -68,10 +68,10 @@ index e164c524aef4fa81fe96ac43454eecff1c38b9c1..9cfbbc61fcfc678f0988d6d45c7994d1
this.firstIndices = new int[k]; this.firstIndices = new int[k];
this.secondIndices = new int[k]; this.secondIndices = new int[k];
diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java diff --git a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
index 7ede56f77af1d40e10fde2e660d5794e4b37dc5d..c348171c150bf69d24303d0862e45ab78baddcab 100644 index 5a0b0b47da3d796c391ac15eb573af25a1dfcd32..76d7435e6fe81a3f1d24b35eae72d06232a1792b 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java --- a/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java +++ b/src/main/java/net/minecraft/world/phys/shapes/Shapes.java
@@ -343,9 +343,21 @@ public final class Shapes { @@ -267,9 +267,21 @@ public final class Shapes {
} }
@VisibleForTesting @VisibleForTesting
@ -94,7 +94,7 @@ index 7ede56f77af1d40e10fde2e660d5794e4b37dc5d..c348171c150bf69d24303d0862e45ab7
if (first instanceof CubePointRange && second instanceof CubePointRange) { if (first instanceof CubePointRange && second instanceof CubePointRange) {
long l = lcm(i, j); long l = lcm(i, j);
if ((long)size * l <= 256L) { if ((long)size * l <= 256L) {
@@ -353,15 +365,22 @@ public final class Shapes { @@ -277,15 +289,22 @@ public final class Shapes {
} }
} }

View file

@ -7,36 +7,36 @@ Inline bit operations and reduce instruction count to make these hot
operations faster operations faster
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
index 12ff8886bb53ca15db745989c25b9bd2f45335e4..2767d6f97e8b314d23a8e62f22dfd396f5660d31 100644 index 0d51fb4be8b49e3b57c3c55aff6bcf13d5c78ddd..afbd1651cb29e95b5cc7474f986c52c29676fb8a 100644
--- a/src/main/java/net/minecraft/core/BlockPos.java --- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java +++ b/src/main/java/net/minecraft/core/BlockPos.java
@@ -50,15 +50,16 @@ public class BlockPos extends Vec3i { @@ -50,15 +50,17 @@ public class BlockPos extends Vec3i {
}; };
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) {
super(x, y, z); super(x, y, z);
@@ -68,28 +69,29 @@ public class BlockPos extends Vec3i { @@ -68,28 +70,29 @@ public class BlockPos extends Vec3i {
this(pos.getX(), pos.getY(), pos.getZ()); this(pos.getX(), pos.getY(), pos.getZ());
} }
@ -51,7 +51,7 @@ index 12ff8886bb53ca15db745989c25b9bd2f45335e4..2767d6f97e8b314d23a8e62f22dfd396
} }
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 12ff8886bb53ca15db745989c25b9bd2f45335e4..2767d6f97e8b314d23a8e62f22dfd396
} }
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
} }
@ -71,7 +71,7 @@ index 12ff8886bb53ca15db745989c25b9bd2f45335e4..2767d6f97e8b314d23a8e62f22dfd396
} }
public static BlockPos containing(double x, double y, double z) { public static BlockPos containing(double x, double y, double z) {
@@ -113,10 +115,7 @@ public class BlockPos extends Vec3i { @@ -113,10 +116,7 @@ public class BlockPos extends Vec3i {
} }
public static long asLong(int x, int y, int z) { public static long asLong(int x, int y, int z) {
@ -84,7 +84,7 @@ index 12ff8886bb53ca15db745989c25b9bd2f45335e4..2767d6f97e8b314d23a8e62f22dfd396
public static long getFlatIndex(long y) { public static long getFlatIndex(long y) {
diff --git a/src/main/java/net/minecraft/core/SectionPos.java b/src/main/java/net/minecraft/core/SectionPos.java diff --git a/src/main/java/net/minecraft/core/SectionPos.java b/src/main/java/net/minecraft/core/SectionPos.java
index 27e0d53d5893a13a340deddc93a1128968db7e5b..fe3577e533fb829c85fd4881b1bcca3b70aaf1a5 100644 index 14e852684dcbba43abab0ec7de38f4fc09babd27..137a15e142c6e934804e3f2a072cdac8d40a2ab2 100644
--- a/src/main/java/net/minecraft/core/SectionPos.java --- a/src/main/java/net/minecraft/core/SectionPos.java
+++ b/src/main/java/net/minecraft/core/SectionPos.java +++ b/src/main/java/net/minecraft/core/SectionPos.java
@@ -38,7 +38,7 @@ public class SectionPos extends Vec3i { @@ -38,7 +38,7 @@ public class SectionPos extends Vec3i {
@ -206,8 +206,8 @@ index 27e0d53d5893a13a340deddc93a1128968db7e5b..fe3577e533fb829c85fd4881b1bcca3b
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

@ -157,7 +157,7 @@ index aa32804bc9affe9a615d3ffaa513f6f09aab3f32..c7f012674361a323c1efeca4660cd3f4
public Stream<GossipContainer.GossipEntry> unpack(UUID target) { public Stream<GossipContainer.GossipEntry> unpack(UUID target) {
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
index 28fd073ddad358e087e8c78985a97cad21be81b7..a5bd308d1b3ea5db185c06a287167d1d8894a987 100644 index ba6fd4df02d3097d3ea4273092e27592893de445..de768cf877b899f640b5e13ea9ea9c6410a2e79e 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java --- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java +++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestItemSensor.java
@@ -24,13 +24,17 @@ public class NearestItemSensor extends Sensor<Mob> { @@ -24,13 +24,17 @@ public class NearestItemSensor extends Sensor<Mob> {
@ -165,11 +165,11 @@ index 28fd073ddad358e087e8c78985a97cad21be81b7..a5bd308d1b3ea5db185c06a287167d1d
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

@ -16,10 +16,10 @@ This lets us get faster foreach iteration, as well as avoids map lookups on
the values when needed. the values when needed.
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
index 8a483c8d2a54617d78af19de32fa0ded71b3223a..18bbb3f8f99849333ff4bc020c8ce758a69312a5 100644 index 17006cd22152cf942455437ff7b21a8645259578..cc7d94144e39f7dace7b569b4567def98396e8f9 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java --- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java
@@ -38,8 +38,12 @@ public class PathFinder { @@ -43,8 +43,12 @@ public class PathFinder {
if (node == null) { if (node == null) {
return null; return null;
} else { } else {
@ -31,18 +31,19 @@ index 8a483c8d2a54617d78af19de32fa0ded71b3223a..18bbb3f8f99849333ff4bc020c8ce758
+ 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;
@@ -47,18 +51,19 @@ public class PathFinder { @@ -52,19 +56,20 @@ 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;
@ -59,7 +60,7 @@ index 8a483c8d2a54617d78af19de32fa0ded71b3223a..18bbb3f8f99849333ff4bc020c8ce758
int j = (int)((float)this.maxVisitedNodes * rangeMultiplier); int j = (int)((float)this.maxVisitedNodes * rangeMultiplier);
while (!this.openSet.isEmpty()) { while (!this.openSet.isEmpty()) {
@@ -69,14 +74,18 @@ public class PathFinder { @@ -75,14 +80,18 @@ public class PathFinder {
Node node = this.openSet.pop(); Node node = this.openSet.pop();
node.closed = true; node.closed = true;
@ -81,7 +82,7 @@ index 8a483c8d2a54617d78af19de32fa0ded71b3223a..18bbb3f8f99849333ff4bc020c8ce758
break; break;
} }
@@ -91,7 +100,7 @@ public class PathFinder { @@ -97,7 +106,7 @@ public class PathFinder {
if (node2.walkedDistance < followRange && (!node2.inOpenSet() || g < node2.g)) { if (node2.walkedDistance < followRange && (!node2.inOpenSet() || g < node2.g)) {
node2.cameFrom = node; node2.cameFrom = node;
node2.g = g; node2.g = g;
@ -90,7 +91,7 @@ index 8a483c8d2a54617d78af19de32fa0ded71b3223a..18bbb3f8f99849333ff4bc020c8ce758
if (node2.inOpenSet()) { if (node2.inOpenSet()) {
this.openSet.changeCost(node2, node2.g + node2.h); this.openSet.changeCost(node2, node2.g + node2.h);
} else { } else {
@@ -103,23 +112,32 @@ public class PathFinder { @@ -109,23 +118,32 @@ public class PathFinder {
} }
} }
@ -109,7 +110,7 @@ index 8a483c8d2a54617d78af19de32fa0ded71b3223a..18bbb3f8f99849333ff4bc020c8ce758
+ 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

@ -10,10 +10,10 @@ when if this was fixed on the client, that wouldn't be needed.
Mojira Issue: https://bugs.mojang.com/browse/MC-235045 Mojira Issue: https://bugs.mojang.com/browse/MC-235045
diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java
index 4017b82e72fefd6685e9250a936686fd8a0891f1..2d344df35d47b4b1ecddf32ccaa4dae41e5f58cb 100644 index 3549ffea451b932602efb113844ba21a7bc72371..13bd145b1e8006a53c22f5dc0c78f29b540c7663 100644
--- a/src/main/java/net/minecraft/commands/CommandSourceStack.java --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java
+++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java
@@ -447,4 +447,20 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS @@ -454,4 +454,20 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
return this.source.getBukkitSender(this); return this.source.getBukkitSender(this);
} }
// CraftBukkit end // CraftBukkit end
@ -35,10 +35,10 @@ index 4017b82e72fefd6685e9250a936686fd8a0891f1..2d344df35d47b4b1ecddf32ccaa4dae4
+ // Paper end - tell clients to ask server for suggestions for EntityArguments + // Paper end - tell clients to ask server for suggestions for EntityArguments
} }
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 74fcdc74dc6c5cbf81abb7d46fc700473bd00eff..5ff234c4efdc5347e01ad7473751606198de62e8 100644 index b1571c162fd8ab7239a7f4aafea5187feb694761..1e7b99a82184f73aa31cb2e0d4e52a806240926f 100644
--- a/src/main/java/net/minecraft/commands/Commands.java --- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -529,6 +529,7 @@ public class Commands { @@ -534,6 +534,7 @@ public class Commands {
resultNodes.keySet().removeIf((node) -> !org.spigotmc.SpigotConfig.sendNamespaced && node.getName().contains( ":" )); // Paper - Remove namedspaced from result nodes to prevent redirect trimming ~ see comment below resultNodes.keySet().removeIf((node) -> !org.spigotmc.SpigotConfig.sendNamespaced && node.getName().contains( ":" )); // Paper - Remove namedspaced from result nodes to prevent redirect trimming ~ see comment below
Iterator iterator = tree.getChildren().iterator(); Iterator iterator = tree.getChildren().iterator();
@ -46,7 +46,7 @@ index 74fcdc74dc6c5cbf81abb7d46fc700473bd00eff..5ff234c4efdc5347e01ad74737516061
while (iterator.hasNext()) { while (iterator.hasNext()) {
CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next(); CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
// Paper start - Brigadier API // Paper start - Brigadier API
@@ -591,6 +592,12 @@ public class Commands { @@ -596,6 +597,12 @@ public class Commands {
if (requiredargumentbuilder.getSuggestionsProvider() != null) { if (requiredargumentbuilder.getSuggestionsProvider() != null) {
requiredargumentbuilder.suggests(SuggestionProviders.safelySwap(requiredargumentbuilder.getSuggestionsProvider())); requiredargumentbuilder.suggests(SuggestionProviders.safelySwap(requiredargumentbuilder.getSuggestionsProvider()));
@ -114,7 +114,7 @@ index 9d31e29ec62f437e642ed60da69c4b106bd9e770..ce200e673b54c66cfdf34657db28d3ee
this.level = MinMaxBounds.Ints.ANY; this.level = MinMaxBounds.Ints.ANY;
this.rotX = WrappedMinMaxBounds.ANY; this.rotX = WrappedMinMaxBounds.ANY;
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java b/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java diff --git a/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java b/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java
index 44982ff2cdd6e03f0b9ce8c3cc87561ef183ef06..626fe7a45c2edba68eb201974e9f8f5eebf75cc0 100644 index 5d0c82ba9465bf75640e52bf71924ee5862937f0..e27bd295adcf3289a7c71e044ae392884fe01e0a 100644
--- a/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java --- a/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java
+++ b/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java +++ b/src/main/java/net/minecraft/commands/arguments/selector/options/EntitySelectorOptions.java
@@ -76,6 +76,19 @@ public class EntitySelectorOptions { @@ -76,6 +76,19 @@ public class EntitySelectorOptions {