Things, and DataConverter (maybe)

This commit is contained in:
Nassim Jahnke 2022-06-08 13:12:14 +02:00
parent 82f712c096
commit 8d5407b16f
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
11 changed files with 1026 additions and 319 deletions

View File

@ -9,12 +9,12 @@ Configurable under
`send-full-pos-for-hard-colliding-entities` `send-full-pos-for-hard-colliding-entities`
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 92413fd4132b1e5b63d4be0e9cf341d2a7200df4..5203a43d707010f6ba43be2d6627d48560b77731 100644 index 96d5b89d67f0904c0a6f68a7bbffc48457e850de..4b828da7f8dbadb8af66ffc04d631273cfccdf36 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -625,4 +625,10 @@ public class PaperConfig { @@ -615,4 +615,10 @@ public class PaperConfig {
private static void lagCompensateBlockBreaking() { }
lagCompensateBlockBreaking = getBoolean("settings.lag-compensate-block-breaking", true); }
} }
+ +
+ public static boolean sendFullPosForHardCollidingEntities; + public static boolean sendFullPosForHardCollidingEntities;
@ -24,11 +24,11 @@ index 92413fd4132b1e5b63d4be0e9cf341d2a7200df4..5203a43d707010f6ba43be2d6627d485
+ } + }
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index ea9cd490fc3bfcf6a2900a702615e6626f0ed98b..9760ff4b6ca0e555f01151968cbfe0cdb8960e35 100644 index 66df9492004ae648c5a5db8d1e76931284297ec1..2abfc5c801cd58223986d6c5012fc381e66f0d9a 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java --- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -172,7 +172,7 @@ public class ServerEntity { @@ -158,7 +158,7 @@ public class ServerEntity {
// Paper end - remove allocation of Vec3D here long i1 = this.positionCodec.encodeZ(vec3d);
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
- if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) { - if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) {

View File

@ -7,10 +7,10 @@ Reference2BooleanOpenHashMap is going to have
better lookups than HashMap. better lookups than HashMap.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index f4c1316ae1cadc1a7a7fed16e0e99704662c41e8..b0aaeb601c8d9df50bf612985bbcbef8a082551f 100644 index 66a627a6b58ef5b420aceb0a3a1bcf90aec13198..a32b5c194da4983ac21c88695f036689809c2133 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -110,6 +110,7 @@ import org.apache.commons.lang3.mutable.MutableObject; @@ -113,6 +113,7 @@ import org.apache.commons.lang3.mutable.MutableObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
// CraftBukkit end // CraftBukkit end
@ -18,7 +18,7 @@ index f4c1316ae1cadc1a7a7fed16e0e99704662c41e8..b0aaeb601c8d9df50bf612985bbcbef8
public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider {
@@ -2155,7 +2156,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -2198,7 +2199,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final Entity entity; final Entity entity;
private final int range; private final int range;
SectionPos lastSectionPos; SectionPos lastSectionPos;

View File

@ -7,7 +7,7 @@ Apparently the abstract block iteration was taking about
75% of the method call. 75% of the method call.
diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
index 26a88f9d55538761da4737c9518bc7042dc6f6ea..499eae5ab30921f49045dc73bd077941255f727a 100644 index 94ea6b8986c8fe3aee220ef0c95b65c5cef21c72..d089887030ac7c7a79abca97134ba9291e244059 100644
--- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java --- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java
@@ -138,19 +138,27 @@ public class FarmBlock extends Block { @@ -138,19 +138,27 @@ public class FarmBlock extends Block {

View File

@ -71,10 +71,10 @@ index 0000000000000000000000000000000000000000..e8b4053babe46999980b926431254050
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 32446e874fdad36f9f80d22481a4d990967f38e3..8f135c8a4c4fe7cc1b1b8ae8db6f740227b5df50 100644 index 4566c7b0cd5551f2e348e532911e77c62d3de2f2..6f0b2a6a79dfeb1c61cd0b316841f902d3377bdd 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -645,6 +645,10 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -662,6 +662,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
entityplayer.stopSleepInBed(false, false); entityplayer.stopSleepInBed(false, false);
}); });
} }
@ -85,7 +85,7 @@ index 32446e874fdad36f9f80d22481a4d990967f38e3..8f135c8a4c4fe7cc1b1b8ae8db6f7402
public void tickChunk(LevelChunk chunk, int randomTickSpeed) { public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
ChunkPos chunkcoordintpair = chunk.getPos(); ChunkPos chunkcoordintpair = chunk.getPos();
@@ -654,10 +658,10 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -671,10 +675,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
ProfilerFiller gameprofilerfiller = this.getProfiler(); ProfilerFiller gameprofilerfiller = this.getProfiler();
gameprofilerfiller.push("thunder"); gameprofilerfiller.push("thunder");
@ -98,7 +98,7 @@ index 32446e874fdad36f9f80d22481a4d990967f38e3..8f135c8a4c4fe7cc1b1b8ae8db6f7402
if (this.isRainingAt(blockposition)) { if (this.isRainingAt(blockposition)) {
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition); DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * paperConfig.skeleHorseSpawnChance && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD); // Paper boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * paperConfig.skeleHorseSpawnChance && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD); // Paper
@@ -681,64 +685,75 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -698,64 +702,75 @@ public class ServerLevel extends Level implements WorldGenLevel {
gameprofilerfiller.popPush("iceandsnow"); gameprofilerfiller.popPush("iceandsnow");
if (!this.paperConfig.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow if (!this.paperConfig.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow
@ -227,7 +227,7 @@ index 62251727788d48a461ea6f7945771d7d6bdc7282..106610ccc74b70b557b01c61262d56c4
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java
index 6426d6c2c31ead49444fe56e2230266290fa79dd..881a2318aac72526e0451688af58c620e4f525d1 100644 index 9b81ce9d85cba07e9752c29fb5a842c4b00aa873..36e33923bf48e56c743ed043bcbc66bc32f0422f 100644
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java --- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java +++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
@@ -124,6 +124,28 @@ public class SimpleBitStorage implements BitStorage { @@ -124,6 +124,28 @@ public class SimpleBitStorage implements BitStorage {
@ -280,10 +280,10 @@ index 9686ce7536c9924b1b2aced4f013f46759cbc72e..5d8e9bdf5538b19681f21949368d862f
public void getAll(IntConsumer action) { public void getAll(IntConsumer action) {
for(int i = 0; i < this.size; ++i) { for(int i = 0; i < this.size; ++i) {
diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java
index 1b0be28ebfd7ec2f978b5d87f6d26e4d5913fb06..ac17fd4454730db831cf9b781963062db8614bb7 100644 index 69c98c2cb2fd8f149a39bbddcbfe0c5c5adc3904..5575730aa6f77a91467c394fa8465c335d73db8e 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java --- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java +++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java
@@ -85,7 +85,7 @@ public class Turtle extends Animal { @@ -83,7 +83,7 @@ public class Turtle extends Animal {
} }
public void setHomePos(BlockPos pos) { public void setHomePos(BlockPos pos) {
@ -293,10 +293,10 @@ index 1b0be28ebfd7ec2f978b5d87f6d26e4d5913fb06..ac17fd4454730db831cf9b781963062d
public BlockPos getHomePos() { public BlockPos getHomePos() {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 843c36a8272ea5affe0a4f3baa9e15823ad74059..67cb2f94f1f2f2b8ae82d65e19b7f173157076b9 100644 index f0721f2311769cff31ffb83a6c1cfeb9927f32a4..ef873ee044113719ee3d25dc51385e98017dd1c0 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1318,10 +1318,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -1297,10 +1297,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract RecipeManager getRecipeManager(); public abstract RecipeManager getRecipeManager();
public BlockPos getBlockRandomPos(int x, int y, int z, int l) { public BlockPos getBlockRandomPos(int x, int y, int z, int l) {
@ -317,18 +317,18 @@ index 843c36a8272ea5affe0a4f3baa9e15823ad74059..67cb2f94f1f2f2b8ae82d65e19b7f173
public boolean noSave() { public boolean noSave() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
index cdd17e501c678a4f4bebbaaccdaec1682351e2f2..6afad987f6dd1fd7243dfa6c50549c2a88768962 100644 index 2ad73237f4664535c3d5120a54b713f44cddb793..c2e3df8331cec5fe5650501a4dc4ac47f23ef11b 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -26,6 +26,7 @@ public class LevelChunkSection { @@ -27,6 +27,7 @@ public class LevelChunkSection {
private short tickingFluidCount;
public final PalettedContainer<BlockState> states; public final PalettedContainer<BlockState> states;
private final PalettedContainer<Holder<Biome>> biomes; // CraftBukkit start - read/write
private PalettedContainer<Holder<Biome>> biomes;
+ public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper + public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
public LevelChunkSection(int chunkPos, PalettedContainer<BlockState> blockStateContainer, PalettedContainer<Holder<Biome>> biomeContainer) { public LevelChunkSection(int i, PalettedContainer<BlockState> datapaletteblock, PalettedContainer<Holder<Biome>> palettedcontainerro) {
this.bottomBlockY = LevelChunkSection.getBottomBlockY(chunkPos); // CraftBukkit end
@@ -83,6 +84,9 @@ public class LevelChunkSection { @@ -85,6 +86,9 @@ public class LevelChunkSection {
--this.nonEmptyBlockCount; --this.nonEmptyBlockCount;
if (iblockdata1.isRandomlyTicking()) { if (iblockdata1.isRandomlyTicking()) {
--this.tickingBlockCount; --this.tickingBlockCount;
@ -338,7 +338,7 @@ index cdd17e501c678a4f4bebbaaccdaec1682351e2f2..6afad987f6dd1fd7243dfa6c50549c2a
} }
} }
@@ -94,6 +98,9 @@ public class LevelChunkSection { @@ -96,6 +100,9 @@ public class LevelChunkSection {
++this.nonEmptyBlockCount; ++this.nonEmptyBlockCount;
if (state.isRandomlyTicking()) { if (state.isRandomlyTicking()) {
++this.tickingBlockCount; ++this.tickingBlockCount;
@ -348,7 +348,7 @@ index cdd17e501c678a4f4bebbaaccdaec1682351e2f2..6afad987f6dd1fd7243dfa6c50549c2a
} }
} }
@@ -125,40 +132,31 @@ public class LevelChunkSection { @@ -127,40 +134,31 @@ public class LevelChunkSection {
} }
public void recalcBlockCounts() { public void recalcBlockCounts() {
@ -410,10 +410,10 @@ index cdd17e501c678a4f4bebbaaccdaec1682351e2f2..6afad987f6dd1fd7243dfa6c50549c2a
public PalettedContainer<BlockState> getStates() { public PalettedContainer<BlockState> getStates() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
index d886320211c7fa80960042c9b9ef4951eb34aaf1..73d0a52e0b9bcd81caf5c8a91c3d8052ad6d1da8 100644 index 6800452604e0db660e8d5dca9778abd6e2f66478..6fb87dcdc4fab4b430a5c9003548c874e6b26734 100644
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
@@ -354,6 +354,14 @@ public class PalettedContainer<T> implements PaletteResize<T> { @@ -382,6 +382,14 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
} }
} }

View File

@ -20,7 +20,7 @@ up on this optimisation before he came along.
Locally this patch drops the entity tracker tick by a full 1.5x. Locally this patch drops the entity tracker tick by a full 1.5x.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index b27610cde8eaa7ff35c777039a0ca9d8eab748fe..d3a25cc5262843b5c9736ff32e300264d9847c9b 100644 index 094366b2c44992cbd41dceb5d71eb9f4edf3dd05..1e4b75ab79a1d63a82498907d72932d644552635 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -51,6 +51,8 @@ import org.slf4j.Logger; @@ -51,6 +51,8 @@ import org.slf4j.Logger;
@ -32,7 +32,7 @@ index b27610cde8eaa7ff35c777039a0ca9d8eab748fe..d3a25cc5262843b5c9736ff32e300264
public class Connection extends SimpleChannelInboundHandler<Packet<?>> { public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F; private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F;
@@ -399,9 +401,19 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -401,9 +403,19 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.eventLoop().inEventLoop()) { if (this.channel.eventLoop().inEventLoop()) {
this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter this.doSendPacket(packet, callback, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
} else { } else {

View File

@ -9,7 +9,7 @@ since the penalty of a map lookup could outweigh the benefits of
searching less players (as it basically did in the outside range patch). searching less players (as it basically did in the outside range patch).
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
index 469b921cceabc3f42961e8aa5314bdc849ad41b9..09616415e8f11d40435dc81282b818ac9cbbdcbe 100644 index 020617ec8e5e77920d36380f019e430286006f89..7471e5e94b9b4a4f9100b445ca85c74875007330 100644
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java --- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java +++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
@@ -91,6 +91,12 @@ public class ChunkHolder { @@ -91,6 +91,12 @@ public class ChunkHolder {
@ -39,10 +39,10 @@ index 469b921cceabc3f42961e8aa5314bdc849ad41b9..09616415e8f11d40435dc81282b818ac
// Paper end - optimise anyPlayerCloseEnoughForSpawning // Paper end - optimise anyPlayerCloseEnoughForSpawning
long lastAutoSaveTime; // Paper - incremental autosave long lastAutoSaveTime; // Paper - incremental autosave
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a541a3900f 100644 index a32b5c194da4983ac21c88695f036689809c2133..0df9da8773a32b4c7d21325c42635cd233cf8c46 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -164,6 +164,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -168,6 +168,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper
public final ReferenceOpenHashSet<ChunkHolder> needsChangeBroadcasting = new ReferenceOpenHashSet<>(); public final ReferenceOpenHashSet<ChunkHolder> needsChangeBroadcasting = new ReferenceOpenHashSet<>();
@ -56,7 +56,7 @@ index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a5
// CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
public final CallbackExecutor callbackExecutor = new CallbackExecutor(); public final CallbackExecutor callbackExecutor = new CallbackExecutor();
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable { public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
@@ -241,6 +248,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -245,6 +252,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end - use distance map to optimise entity tracker // Paper end - use distance map to optimise entity tracker
// Note: players need to be explicitly added to distance maps before they can be updated // Note: players need to be explicitly added to distance maps before they can be updated
this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -64,7 +64,7 @@ index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a5
// Paper start - per player mob spawning // Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) { if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.add(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance()); this.playerMobDistanceMap.add(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
@@ -259,6 +267,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -263,6 +271,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.playerMobSpawnMap.remove(player); this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player); this.playerChunkTickRangeMap.remove(player);
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -72,7 +72,7 @@ index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a5
// Paper start - per player mob spawning // Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) { if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.remove(player); this.playerMobDistanceMap.remove(player);
@@ -279,6 +288,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -283,6 +292,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
// Paper end - use distance map to optimise entity tracker // Paper end - use distance map to optimise entity tracker
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -80,7 +80,7 @@ index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a5
// Paper start - per player mob spawning // Paper start - per player mob spawning
if (this.playerMobDistanceMap != null) { if (this.playerMobDistanceMap != null) {
this.playerMobDistanceMap.update(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance()); this.playerMobDistanceMap.update(player, chunkX, chunkZ, this.distanceManager.getSimulationDistance());
@@ -440,6 +450,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -452,6 +462,23 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
}); });
// Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning // Paper end - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
@ -105,10 +105,10 @@ index b0aaeb601c8d9df50bf612985bbcbef8a082551f..bc6a4bfe7df804ee22791fb767f059a5
protected ChunkGenerator generator() { protected ChunkGenerator generator() {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 8f135c8a4c4fe7cc1b1b8ae8db6f740227b5df50..6053b7797cc4f6ed1ffbfc35048bab1a96586254 100644 index 6f0b2a6a79dfeb1c61cd0b316841f902d3377bdd..0e6405763ea40ca3f122130abb84b56e9bf92e73 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -400,6 +400,83 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -404,6 +404,83 @@ public class ServerLevel extends Level implements WorldGenLevel {
return this.getServer().getPlayerList().getPlayer(uuid); return this.getServer().getPlayerList().getPlayer(uuid);
} }
// Paper end // Paper end
@ -190,9 +190,9 @@ index 8f135c8a4c4fe7cc1b1b8ae8db6f740227b5df50..6053b7797cc4f6ed1ffbfc35048bab1a
+ } + }
+ // Paper end - optimise get nearest players for entity AI + // Paper end - optimise get nearest players for entity AI
// Add env and gen to constructor, WorldData -> WorldDataServer // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, ServerLevelData iworlddataserver, ResourceKey<Level> resourcekey, Holder<DimensionType> holder, ChunkProgressListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
@@ -490,6 +567,14 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -505,6 +582,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
} }
public void tick(BooleanSupplier shouldKeepTicking) { public void tick(BooleanSupplier shouldKeepTicking) {
@ -208,10 +208,10 @@ index 8f135c8a4c4fe7cc1b1b8ae8db6f740227b5df50..6053b7797cc4f6ed1ffbfc35048bab1a
this.handlingTick = true; this.handlingTick = true;
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index cd6c48bac5c782166de274da6a50629efbc82c4c..e3227a806d9e19923783122ea94ae19e7dbe71da 100644 index 11f3a492748d291c9c58c09d6ed62188f0868438..a55c30d86793bf224b536a7ceefce75c70b618c7 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java --- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -791,7 +791,12 @@ public abstract class Mob extends LivingEntity { @@ -802,7 +802,12 @@ public abstract class Mob extends LivingEntity {
if (this.level.getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { if (this.level.getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
this.discard(); this.discard();
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
@ -226,10 +226,10 @@ index cd6c48bac5c782166de274da6a50629efbc82c4c..e3227a806d9e19923783122ea94ae19e
if (entityhuman != null) { if (entityhuman != null) {
double d0 = entityhuman.distanceToSqr((Entity) this); double d0 = entityhuman.distanceToSqr((Entity) this);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 67cb2f94f1f2f2b8ae82d65e19b7f173157076b9..03824f73ecbac8ef6da586feb82f851557f82b6a 100644 index ef873ee044113719ee3d25dc51385e98017dd1c0..e3052c32624538d5394bf098c3b5db84e4cdb9b4 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -195,6 +195,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -201,6 +201,69 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.getChunkIfLoaded(chunkX, chunkZ) != null; return this.getChunkIfLoaded(chunkX, chunkZ) != null;
} }
// Paper end // Paper end
@ -300,10 +300,10 @@ index 67cb2f94f1f2f2b8ae82d65e19b7f173157076b9..03824f73ecbac8ef6da586feb82f8515
public abstract ResourceKey<LevelStem> getTypeKey(); public abstract ResourceKey<LevelStem> getTypeKey();
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
index 87d1f5b2717fc82203b5674ac0bf2704117f8f63..d87900e2a9559a34ee66e3cffab851a578c0278e 100644 index a04b8eeb9b4cbd700b95552c46fdf0da4c03b3eb..15cac62aa2901168e8cc0ba07981d9b8624b26f6 100644
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
@@ -258,7 +258,7 @@ public final class NaturalSpawner { @@ -259,7 +259,7 @@ public final class NaturalSpawner {
blockposition_mutableblockposition.set(l, i, i1); blockposition_mutableblockposition.set(l, i, i1);
double d0 = (double) l + 0.5D; double d0 = (double) l + 0.5D;
double d1 = (double) i1 + 0.5D; double d1 = (double) i1 + 0.5D;
@ -312,7 +312,7 @@ index 87d1f5b2717fc82203b5674ac0bf2704117f8f63..d87900e2a9559a34ee66e3cffab851a5
if (entityhuman != null) { if (entityhuman != null) {
double d2 = entityhuman.distanceToSqr(d0, (double) i, d1); double d2 = entityhuman.distanceToSqr(d0, (double) i, d1);
@@ -331,7 +331,7 @@ public final class NaturalSpawner { @@ -332,7 +332,7 @@ public final class NaturalSpawner {
} }
private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) { private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) {
@ -320,9 +320,9 @@ index 87d1f5b2717fc82203b5674ac0bf2704117f8f63..d87900e2a9559a34ee66e3cffab851a5
+ return squaredDistance <= 576.0D ? false : (world.getSharedSpawnPos().closerToCenterThan(new Vec3((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D), 24.0D) ? false : Objects.equals(new ChunkPos(pos), chunk.getPos()) || world.isNaturalSpawningAllowed((BlockPos) pos)); // Paper - diff on change, copy into caller + return squaredDistance <= 576.0D ? false : (world.getSharedSpawnPos().closerToCenterThan(new Vec3((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D), 24.0D) ? false : Objects.equals(new ChunkPos(pos), chunk.getPos()) || world.isNaturalSpawningAllowed((BlockPos) pos)); // Paper - diff on change, copy into caller
} }
private static Boolean isValidSpawnPostitionForType(ServerLevel world, MobCategory group, StructureFeatureManager structureAccessor, ChunkGenerator chunkGenerator, MobSpawnSettings.SpawnerData spawnEntry, BlockPos.MutableBlockPos pos, double squaredDistance) { // Paper private static Boolean isValidSpawnPostitionForType(ServerLevel world, MobCategory group, StructureManager structureAccessor, ChunkGenerator chunkGenerator, MobSpawnSettings.SpawnerData spawnEntry, BlockPos.MutableBlockPos pos, double squaredDistance) { // Paper
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 0388b89a5f67ebaf344de53464922daddd234199..14f956ad7c305a4d22370d705a70f77e65861007 100644 index 25132e88c08335e0cbd85d948d0863c9cbb28d3e..b57e8e21d75fae24a31effedce2e3c53d9e7d66f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -235,6 +235,98 @@ public class LevelChunk extends ChunkAccess { @@ -235,6 +235,98 @@ public class LevelChunk extends ChunkAccess {

View File

@ -8,10 +8,10 @@ Instead, only iterate over navigators in the current region that are
eligible for repathing. eligible for repathing.
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index bc6a4bfe7df804ee22791fb767f059a541a3900f..a578ff8a88ef944516150303e96f8b49bc797f64 100644 index 0df9da8773a32b4c7d21325c42635cd233cf8c46..3dd3ed91e702858f07c811afdcfa6c111f9e3d61 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java --- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -301,15 +301,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -305,15 +305,81 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
public final io.papermc.paper.chunk.SingleThreadChunkRegionManager dataRegionManager; public final io.papermc.paper.chunk.SingleThreadChunkRegionManager dataRegionManager;
public static final class DataRegionData implements io.papermc.paper.chunk.SingleThreadChunkRegionManager.RegionData { public static final class DataRegionData implements io.papermc.paper.chunk.SingleThreadChunkRegionManager.RegionData {
@ -93,7 +93,7 @@ index bc6a4bfe7df804ee22791fb767f059a541a3900f..a578ff8a88ef944516150303e96f8b49
} }
@Override @Override
@@ -319,6 +385,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -323,6 +389,15 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
final DataRegionSectionData sectionData = (DataRegionSectionData)section.sectionData; final DataRegionSectionData sectionData = (DataRegionSectionData)section.sectionData;
final DataRegionData oldRegionData = oldRegion == null ? null : (DataRegionData)oldRegion.regionData; final DataRegionData oldRegionData = oldRegion == null ? null : (DataRegionData)oldRegion.regionData;
final DataRegionData newRegionData = (DataRegionData)newRegion.regionData; final DataRegionData newRegionData = (DataRegionData)newRegion.regionData;
@ -110,10 +110,10 @@ index bc6a4bfe7df804ee22791fb767f059a541a3900f..a578ff8a88ef944516150303e96f8b49
} }
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 6053b7797cc4f6ed1ffbfc35048bab1a96586254..7922ecc1bfeb2d00a7a1bce0431efec4f8c57eec 100644 index 0e6405763ea40ca3f122130abb84b56e9bf92e73..d5585e1723eebce14c47c4a92ce339915cd936db 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java --- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1096,6 +1096,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1113,6 +1113,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
public void tickNonPassenger(Entity entity) { public void tickNonPassenger(Entity entity) {
// Paper start - log detailed entity tick information // Paper start - log detailed entity tick information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot tick an entity off-main"); io.papermc.paper.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
@ -121,7 +121,7 @@ index 6053b7797cc4f6ed1ffbfc35048bab1a96586254..7922ecc1bfeb2d00a7a1bce0431efec4
try { try {
if (currentlyTickingEntity.get() == null) { if (currentlyTickingEntity.get() == null) {
currentlyTickingEntity.lazySet(entity); currentlyTickingEntity.lazySet(entity);
@@ -1551,9 +1552,18 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1630,9 +1631,18 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (Shapes.joinIsNotEmpty(voxelshape, voxelshape1, BooleanOp.NOT_SAME)) { if (Shapes.joinIsNotEmpty(voxelshape, voxelshape1, BooleanOp.NOT_SAME)) {
List<PathNavigation> list = new ObjectArrayList(); List<PathNavigation> list = new ObjectArrayList();
@ -142,7 +142,7 @@ index 6053b7797cc4f6ed1ffbfc35048bab1a96586254..7922ecc1bfeb2d00a7a1bce0431efec4
// CraftBukkit start - fix SPIGOT-6362 // CraftBukkit start - fix SPIGOT-6362
Mob entityinsentient; Mob entityinsentient;
try { try {
@@ -1575,16 +1585,23 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -1654,16 +1664,23 @@ public class ServerLevel extends Level implements WorldGenLevel {
try { try {
this.isUpdatingNavigations = true; this.isUpdatingNavigations = true;
@ -169,7 +169,7 @@ index 6053b7797cc4f6ed1ffbfc35048bab1a96586254..7922ecc1bfeb2d00a7a1bce0431efec4
} }
} // Paper } // Paper
@@ -2384,10 +2401,12 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -2461,10 +2478,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
public void onTickingStart(Entity entity) { public void onTickingStart(Entity entity) {
ServerLevel.this.entityTickList.add(entity); ServerLevel.this.entityTickList.add(entity);
@ -183,10 +183,10 @@ index 6053b7797cc4f6ed1ffbfc35048bab1a96586254..7922ecc1bfeb2d00a7a1bce0431efec4
if (paperConfig.disableEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) { if (paperConfig.disableEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) {
pearl.cachedOwner = null; pearl.cachedOwner = null;
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
index b47cd6d8ed02875bd9af54d27b7c1cda340e7f9f..d35032a8d2612d555c3dad1fe496d7ae1c5a285b 100644 index af53372391d05dd6aa3757556418e8723b8b6d80..3f672d7c2377fca16a6d8d31cf7aaae4f009fdce 100644
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java --- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
@@ -27,7 +27,7 @@ import net.minecraft.world.phys.Vec3; @@ -29,7 +29,7 @@ import net.minecraft.world.phys.Vec3;
public abstract class PathNavigation { public abstract class PathNavigation {
private static final int MAX_TIME_RECOMPUTE = 20; private static final int MAX_TIME_RECOMPUTE = 20;
@ -195,7 +195,7 @@ index b47cd6d8ed02875bd9af54d27b7c1cda340e7f9f..d35032a8d2612d555c3dad1fe496d7ae
protected final Level level; protected final Level level;
@Nullable @Nullable
protected Path path; protected Path path;
@@ -40,7 +40,7 @@ public abstract class PathNavigation { @@ -42,7 +42,7 @@ public abstract class PathNavigation {
protected long lastTimeoutCheck; protected long lastTimeoutCheck;
protected double timeoutLimit; protected double timeoutLimit;
protected float maxDistanceToWaypoint = 0.5F; protected float maxDistanceToWaypoint = 0.5F;
@ -204,21 +204,7 @@ index b47cd6d8ed02875bd9af54d27b7c1cda340e7f9f..d35032a8d2612d555c3dad1fe496d7ae
protected long timeLastRecompute; protected long timeLastRecompute;
protected NodeEvaluator nodeEvaluator; protected NodeEvaluator nodeEvaluator;
@Nullable @Nullable
@@ -50,6 +50,13 @@ public abstract class PathNavigation { @@ -420,7 +420,7 @@ public abstract class PathNavigation {
public final PathFinder pathFinder;
private boolean isStuck;
+ // Paper start
+ public boolean isViableForPathRecalculationChecking() {
+ return !this.needsPathRecalculation() &&
+ (this.path != null && !this.path.isDone() && this.path.getNodeCount() != 0);
+ }
+ // Paper end
+
public PathNavigation(Mob mob, Level world) {
this.mob = mob;
this.level = world;
@@ -413,7 +420,7 @@ public abstract class PathNavigation {
public boolean shouldRecomputePath(BlockPos pos) { public boolean shouldRecomputePath(BlockPos pos) {
if (this.hasDelayedRecomputation) { if (this.hasDelayedRecomputation) {
return false; return false;
@ -227,8 +213,20 @@ index b47cd6d8ed02875bd9af54d27b7c1cda340e7f9f..d35032a8d2612d555c3dad1fe496d7ae
Node node = this.path.getEndNode(); Node node = this.path.getEndNode();
Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0D, ((double)node.y + this.mob.getY()) / 2.0D, ((double)node.z + this.mob.getZ()) / 2.0D); Vec3 vec3 = new Vec3(((double)node.x + this.mob.getX()) / 2.0D, ((double)node.y + this.mob.getY()) / 2.0D, ((double)node.z + this.mob.getZ()) / 2.0D);
return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex())); return pos.closerToCenterThan(vec3, (double)(this.path.getNodeCount() - this.path.getNextNodeIndex()));
@@ -436,4 +436,11 @@ public abstract class PathNavigation {
public boolean isStuck() {
return this.isStuck;
}
+
+ // Paper start
+ public boolean isViableForPathRecalculationChecking() {
+ return !this.needsPathRecalculation() &&
+ (this.path != null && !this.path.isDone() && this.path.getNodeCount() != 0);
+ }
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
index 5029ab81e3d7943a001b6367083eb511ce7d3572..db2ef605bccbb9024f787cd58f3cb93df03d5532 100644 index 3019646ae30ce7f89e1e1f3eb39eaa69e58a0f50..90dff6b5786933577cf070fe723872041e050738 100644
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java --- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java +++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -71,6 +71,65 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A @@ -71,6 +71,65 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Remove streams for villager AI
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
index e644bdd3a6f7c09a44149da03587b796674fa568..c67c448e0d8bdd788b94189651304110694c95da 100644 index 5a5d454b5987bb01d03f91c15b7a6bff46f1de71..c545539fc5d20cc69a0e5d2e261ef46a8f6fa4f0 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java --- a/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/GateBehavior.java
@@ -30,11 +30,19 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> { @@ -30,11 +30,19 @@ public class GateBehavior<E extends LivingEntity> extends Behavior<E> {
@ -128,26 +128,26 @@ index e644bdd3a6f7c09a44149da03587b796674fa568..c67c448e0d8bdd788b94189651304110
} }
} }
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
index 4f42344fec13b8d7fe0c1dd412525853c35bacca..b35abac7029708042b25d98ab11005c2ea8ae6ea 100644 index 090bba46b6ecd7d0e1415feb678b9b23264fe5e9..ca771d60283d94c00aa65d06ef93071e412357e8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java --- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
@@ -12,7 +12,7 @@ import java.util.Random; @@ -12,7 +12,7 @@ import java.util.stream.Stream;
import java.util.stream.Stream; import net.minecraft.util.RandomSource;
public class ShufflingList<U> { public class ShufflingList<U> {
- protected final List<ShufflingList.WeightedEntry<U>> entries; - protected final List<ShufflingList.WeightedEntry<U>> entries;
+ public final List<ShufflingList.WeightedEntry<U>> entries; // Paper - public + public final List<ShufflingList.WeightedEntry<U>> entries; // Paper - public
private final Random random = new Random(); private final RandomSource random = RandomSource.create();
private final boolean isUnsafe; // Paper private final boolean isUnsafe; // Paper
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 49f3b25d28072b61f5cc97260df61df892a58714..71f2692c83feafbb31f45427e6c738cb3881c82c 100644 index 1dfcc5cba6ffb463acf161a23fff1ca452184290..2c4517850a9692f1c2b1332b58e8312fe1166772 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
@@ -25,17 +25,20 @@ public class NearestItemSensor extends Sensor<Mob> { @@ -25,13 +25,16 @@ public class NearestItemSensor extends Sensor<Mob> {
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(8.0D, 4.0D, 8.0D), (itemEntity) -> { List<ItemEntity> list = world.getEntitiesOfClass(ItemEntity.class, entity.getBoundingBox().inflate(32.0D, 16.0D, 32.0D), (itemEntity) -> {
- return true; - return true;
+ return itemEntity.closerThan(entity, 9.0D) && entity.wantsToPickUp(itemEntity.getItem()); // Paper - move predicate into getEntities + return itemEntity.closerThan(entity, 9.0D) && entity.wantsToPickUp(itemEntity.getItem()); // Paper - move predicate into getEntities
}); });
@ -157,18 +157,14 @@ index 49f3b25d28072b61f5cc97260df61df892a58714..71f2692c83feafbb31f45427e6c738cb
// Paper start - remove streams in favour of lists // Paper start - remove streams in favour of lists
ItemEntity nearest = null; ItemEntity nearest = null;
- for (ItemEntity entityItem : list) { - for (ItemEntity entityItem : list) {
- if (entity.wantsToPickUp(entityItem.getItem()) && entityItem.closerThan(entity, 9.0D) && entity.hasLineOfSight(entityItem)) { - if (entity.wantsToPickUp(entityItem.getItem()) && entityItem.closerThan(entity, 32.0D) && entity.hasLineOfSight(entityItem)) {
+ for (int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) {
+ ItemEntity entityItem = list.get(i); + ItemEntity entityItem = list.get(i);
+ if (entity.hasLineOfSight(entityItem)) { + if (entity.hasLineOfSight(entityItem)) {
+ // Paper end - remove streams
nearest = entityItem; nearest = entityItem;
break; break;
} }
}
+ // Paper end - remove streams
brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, Optional.ofNullable(nearest));
// Paper end
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
index 312775d0430f793720211dc29bb293503e799d11..75d9c4f011b5a97def215784c92bb57bbb35d06b 100644 index 312775d0430f793720211dc29bb293503e799d11..75d9c4f011b5a97def215784c92bb57bbb35d06b 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java --- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java