even even even even even even more work

This commit is contained in:
Spottedleaf 2020-06-25 18:53:21 -07:00
parent c300745c8b
commit 939690baea
52 changed files with 793 additions and 781 deletions

View File

@ -5,4 +5,5 @@
* Mini: "MC-50319": fix if still works
* Mini: I definetly dropped a patch I didnt want to drop, we need to go thru in the end and see if all patches are still in, lol
* Make sure the flat bedrock setting doesn't do anything stupid
* Check DataBits foreach
* Check DataBits foreach
* Update MobGoalHelper

View File

@ -0,0 +1,135 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 2 Apr 2020 02:37:57 -0400
Subject: [PATCH] Optimize Collision to not load chunks
The collision code takes an AABB and generates a cuboid of checks rather
than a cylinder, so at high velocity this can generate a lot of chunk checks.
Treat an unloaded chunk as a collision for entities, and also for players if
the "prevent moving into unloaded chunks" setting is enabled.
If that serting is not enabled, collisions will be ignored for players, since
movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 59d72dfc903bb7a9c50baf59fface280b44a6d5b..8b7f59577416468a89a99954e2a00b3704ffbd40 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -81,6 +81,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
private CraftEntity bukkitEntity;
PlayerChunkMap.EntityTracker tracker; // Paper
+ boolean collisionLoadChunks = false; // Paper
Throwable addedToWorldStack; // Paper - entity debug
public CraftEntity getBukkitEntity() {
if (bukkitEntity == null) {
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index b27260270de80de371a5a71fa0516aa43c44c83e..1cc40b1f0af9e617b2a71bcc442543e10b2dc61a 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -46,7 +46,9 @@ public interface ICollisionAccess extends IBlockAccess {
}
default boolean b(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<Entity> predicate) {
+ try { if (entity != null) entity.collisionLoadChunks = true; // Paper
return this.d(entity, axisalignedbb, predicate).allMatch(VoxelShape::isEmpty);
+ } finally { if (entity != null) entity.collisionLoadChunks = false; } // Paper
}
Stream<VoxelShape> c(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<Entity> predicate);
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 0b6bb4b2a679c6a3589ce30becbf2af498804aff..ea287e9c21ee1b4cf692d8c7b3df530766f2d26a 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -723,6 +723,7 @@ public abstract class PlayerList {
entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// CraftBukkit end
+ worldserver.getChunkProvider().addTicket(TicketType.POST_TELEPORT, new ChunkCoordIntPair(location.getBlockX() >> 4, location.getBlockZ() >> 4), 1, entityplayer.getId()); // Paper
while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
}
diff --git a/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java b/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java
index 4967d1ebd109c462a322e4829d01ff519d1b5366..ed0f3ddbcb7d6ce8a59ae3829f4cb11ae75046cb 100644
--- a/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java
+++ b/src/main/java/net/minecraft/server/VoxelShapeSpliterator.java
@@ -9,13 +9,13 @@ import javax.annotation.Nullable;
public class VoxelShapeSpliterator extends AbstractSpliterator<VoxelShape> {
@Nullable
- private final Entity a;
+ private final Entity a; final Entity getEntity() { return this.a; } // Paper - OBFHELPER
private final AxisAlignedBB b;
private final VoxelShapeCollision c;
private final CursorPosition d;
- private final BlockPosition.MutableBlockPosition e;
+ private final BlockPosition.MutableBlockPosition e; final BlockPosition.MutableBlockPosition getMutablePos() { return this.e; } // Paper - OBFHELPER
private final VoxelShape f;
- private final ICollisionAccess g;
+ private final ICollisionAccess g; final ICollisionAccess getCollisionAccess() { return this.g; } // Paper - OBFHELPER
private boolean h;
private final BiPredicate<IBlockData, BlockPosition> i;
@@ -52,23 +52,37 @@ public class VoxelShapeSpliterator extends AbstractSpliterator<VoxelShape> {
boolean a(Consumer<? super VoxelShape> consumer) {
while (true) {
if (this.d.a()) {
- int i = this.d.b();
- int j = this.d.c();
- int k = this.d.d();
+ int i = this.d.b(); final int x = i;
+ int j = this.d.c(); final int y = j;
+ int k = this.d.d(); final int z = k;
int l = this.d.e();
if (l == 3) {
continue;
}
- IBlockAccess iblockaccess = this.a(i, k);
-
- if (iblockaccess == null) {
+ // Paper start - ensure we don't load chunks
+ Entity entity = this.getEntity();
+ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = this.getMutablePos();
+ boolean far = entity != null && MCUtil.distanceSq(entity.locX(), y, entity.locZ(), x, y, z) > 14;
+ blockposition_mutableblockposition.setValues(x, y, z);
+
+ boolean isRegionLimited = this.getCollisionAccess() instanceof RegionLimitedWorldAccess;
+ IBlockData iblockdata = isRegionLimited ? Blocks.VOID_AIR.getBlockData() : ((!far && entity instanceof EntityPlayer) || (entity != null && entity.collisionLoadChunks)
+ ? this.getCollisionAccess().getType(blockposition_mutableblockposition)
+ : this.getCollisionAccess().getTypeIfLoaded(blockposition_mutableblockposition)
+ );
+
+ if (iblockdata == null) {
+ if (!(entity instanceof EntityPlayer) || entity.world.paperConfig.preventMovingIntoUnloadedChunks) {
+ VoxelShape voxelshape3 = VoxelShapes.of(far ? entity.getBoundingBox() : new AxisAlignedBB(new BlockPosition(x, y, z)));
+ consumer.accept(voxelshape3);
+ return true;
+ }
continue;
}
-
- this.e.d(i, j, k);
- IBlockData iblockdata = iblockaccess.getType(this.e);
+ // Paper - moved up
+ // Paper end
if (!this.i.test(iblockdata, this.e) || l == 1 && !iblockdata.d() || l == 2 && !iblockdata.a(Blocks.MOVING_PISTON)) {
continue;
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
index b6e2a3d8d0cf510f497c6f974356fafaf2adc13b..4acde367542247627574fdeb586fb8c9087eef1a 100644
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
@@ -239,7 +239,8 @@ public final class VoxelShapes {
if (k2 < 3) {
blockposition_mutableblockposition.a(enumaxiscycle1, i2, j2, l1);
- IBlockData iblockdata = iworldreader.getType(blockposition_mutableblockposition);
+ IBlockData iblockdata = iworldreader.getTypeIfLoaded(blockposition_mutableblockposition); // Paper
+ if (iblockdata == null) return 0.0D; // Paper
if ((k2 != 1 || iblockdata.d()) && (k2 != 2 || iblockdata.a(Blocks.MOVING_PISTON))) {
d0 = iblockdata.b((IBlockAccess) iworldreader, blockposition_mutableblockposition, voxelshapecollision).a(enumdirection_enumaxis2, axisalignedbb.d((double) (-blockposition_mutableblockposition.getX()), (double) (-blockposition_mutableblockposition.getY()), (double) (-blockposition_mutableblockposition.getZ())), d0);

View File

@ -7,15 +7,15 @@ Causes sync chunk loads and who knows what all else.
This is safe because Spectators are skipped in unloaded chunks too in vanilla.
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 52544730a2cce4db4f912ad1109945ac4e53a9b6..f4215d38acef8018f09dff5f379c14336647687d 100644
index 9d7096c61fed5f5b8b45273e146862688df22c59..559da47b80f21f0da59da9410288835c0d394fd8 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -429,7 +429,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -472,7 +472,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public void playerTick() {
try {
- if (!this.isSpectator() || this.world.isLoaded(new BlockPosition(this))) {
+ if (valid && (!this.isSpectator() || this.world.isLoaded(new BlockPosition(this)))) { // Paper - don't tick dead players that are not in the world currently (pending respawn)
- if (!this.isSpectator() || this.world.isLoaded(this.getChunkCoordinates())) {
+ if (valid && !this.isSpectator() || this.world.isLoaded(this.getChunkCoordinates())) { // Paper - don't tick dead players that are not in the world currently (pending respawn)
super.tick();
}

View File

@ -7,10 +7,10 @@ This fixes a lot of game state issues where packets were delayed for processing
due to 1.15's new queue but processed while dead.
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 61c9e030a105ee78a7e59fbf36cf7a77f87a0e88..c4d433430503e844121f1917c6caf05823af0a34 100644
index 8af8676888e4deff66094053d14203c2f5b20ab1..0bf9de73e800cbbe0553bf491cb1546bb1677b63 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -978,7 +978,7 @@ public abstract class EntityHuman extends EntityLiving {
@@ -952,7 +952,7 @@ public abstract class EntityHuman extends EntityLiving {
@Override
protected boolean isFrozen() {

View File

@ -57,23 +57,23 @@ index 0000000000000000000000000000000000000000..f6ff4d8132a95895680f5bc81f8f873e
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 9e3471be219b5e061486c8a3e4b638a45e6f28f5..9d5275c628b3963befdfa60841ef3c3331c8338c 100644
index ba9f75bd8f6fe1990d485548f4481bd1762d93af..e14e8bcf235339c1537a1e0a7702a364ee784c93 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -766,7 +766,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -756,7 +756,7 @@ public class ChunkProviderServer extends IChunkProvider {
entityPlayer.playerNaturallySpawnedEvent.callEvent();
};
// Paper end
- this.playerChunkMap.f().forEach((playerchunk) -> {
- this.playerChunkMap.f().forEach((playerchunk) -> { // Paper - no... just no...
+ this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<Chunk> optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
if (optional.isPresent()) {
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index ea087800eb838371d5da70538091e1148816296e..ce0bf608b71cf492fc31e89a360ecd83fa5c23a6 100644
index b2e8ddc9ff1bf5f519d971455d48a2faad3638f2..2f9c014454cf5fe771c6da84ad4af7e7790fdc7d 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -610,7 +610,7 @@ public final class MCUtil {
@@ -598,7 +598,7 @@ public final class MCUtil {
WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)bukkitWorld).getHandle();
PlayerChunkMap chunkMap = world.getChunkProvider().playerChunkMap;
@ -83,10 +83,10 @@ index ea087800eb838371d5da70538091e1148816296e..ce0bf608b71cf492fc31e89a360ecd83
List<PlayerChunk> allChunks = new ArrayList<>(visibleChunks.values());
List<EntityPlayer> players = world.players;
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca8bea5e06 100644
index c9be4ae99458863bf91687c3667d67bc6b37b0f0..9d4c5f32036118bf7c5081c55bea71efd606b8f6 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -55,8 +55,33 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -56,8 +56,33 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private static final Logger LOGGER = LogManager.getLogger();
public static final int GOLDEN_TICKET = 33 + ChunkStatus.b();
@ -124,14 +124,14 @@ index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca
public final WorldServer world;
@@ -130,7 +155,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public PlayerChunkMap(WorldServer worldserver, File file, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator<?> chunkgenerator, WorldLoadListener worldloadlistener, Supplier<WorldPersistentData> supplier, int i) {
super(new File(worldserver.getWorldProvider().getDimensionManager().a(file), "region"), datafixer);
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
super(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag);
- this.visibleChunks = this.updatingChunks.clone();
+ //this.visibleChunks = this.updatingChunks.clone(); // Paper - no more cloning
this.pendingUnload = new Long2ObjectLinkedOpenHashMap();
this.loadedChunks = new LongOpenHashSet();
this.unloadQueue = new LongOpenHashSet();
@@ -221,9 +246,52 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -222,9 +247,52 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return (PlayerChunk) this.updatingChunks.get(i);
}
@ -185,7 +185,7 @@ index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca
}
protected IntSupplier c(long i) {
@@ -411,8 +479,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -412,8 +480,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper end
protected void save(boolean flag) {
@ -196,7 +196,7 @@ index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca
MutableBoolean mutableboolean = new MutableBoolean();
do {
@@ -440,7 +509,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -441,7 +510,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// this.i(); // Paper - nuke IOWorker
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName());
} else {
@ -205,7 +205,7 @@ index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca
IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
@@ -611,7 +680,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -612,7 +681,20 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
if (!this.updatingChunksModified) {
return false;
} else {
@ -227,7 +227,7 @@ index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca
this.updatingChunksModified = false;
return true;
}
@@ -1048,12 +1130,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1080,12 +1162,12 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
protected Iterable<PlayerChunk> f() {
@ -243,10 +243,10 @@ index 6a2cf0c6f649e7a74b58fc292f57a08c0663b0a4..ea6b310e8e4741c8bb301e5bc586faca
while (objectbidirectionaliterator.hasNext()) {
Entry<PlayerChunk> entry = (Entry) objectbidirectionaliterator.next();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index c030ff7b34fdd4c4632714a800935a6a5f8082cb..1929aacbe83c401c7254484aa8df62ed1554e3ba 100644
index 84c6dfcd87d9d893e846c08c9d14e01fbfb15fb2..e044534d3cb47cf1228c5e5fa8920df8264fd0b5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -74,6 +74,7 @@ import net.minecraft.server.GameRules;
@@ -73,6 +73,7 @@ import net.minecraft.server.GameRules;
import net.minecraft.server.GroupDataEntity;
import net.minecraft.server.IBlockData;
import net.minecraft.server.IChunkAccess;
@ -254,7 +254,7 @@ index c030ff7b34fdd4c4632714a800935a6a5f8082cb..1929aacbe83c401c7254484aa8df62ed
import net.minecraft.server.MinecraftKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.MovingObjectPosition;
@@ -291,6 +292,7 @@ public class CraftWorld implements World {
@@ -292,6 +293,7 @@ public class CraftWorld implements World {
return ret;
}
public int getTileEntityCount() {
@ -262,7 +262,7 @@ index c030ff7b34fdd4c4632714a800935a6a5f8082cb..1929aacbe83c401c7254484aa8df62ed
// We don't use the full world tile entity list, so we must iterate chunks
Long2ObjectLinkedOpenHashMap<PlayerChunk> chunks = world.getChunkProvider().playerChunkMap.visibleChunks;
int size = 0;
@@ -302,11 +304,13 @@ public class CraftWorld implements World {
@@ -303,11 +305,13 @@ public class CraftWorld implements World {
size += chunk.tileEntities.size();
}
return size;
@ -276,7 +276,7 @@ index c030ff7b34fdd4c4632714a800935a6a5f8082cb..1929aacbe83c401c7254484aa8df62ed
int ret = 0;
for (PlayerChunk chunkHolder : world.getChunkProvider().playerChunkMap.visibleChunks.values()) {
@@ -315,7 +319,7 @@ public class CraftWorld implements World {
@@ -316,7 +320,7 @@ public class CraftWorld implements World {
}
}
@ -285,7 +285,7 @@ index c030ff7b34fdd4c4632714a800935a6a5f8082cb..1929aacbe83c401c7254484aa8df62ed
}
public int getPlayerCount() {
return world.players.size();
@@ -435,6 +439,14 @@ public class CraftWorld implements World {
@@ -436,6 +440,14 @@ public class CraftWorld implements World {
@Override
public Chunk[] getLoadedChunks() {

View File

@ -14,10 +14,10 @@ light engine on shutdown...
The queue size only puts a cap on max loss, doesn't solve that problem.
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 598f27bc1b95132ded224dd5c7a0e2639ab2bd12..ea5f306ef57fe5958a554f4bdf866a36d2b185e0 100644
index 2688b3018eaab4e7ba95754164f83065a98e53fc..e4821d4c23689aaf51b60c66fc1e6bc7a0b02fd5 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -665,4 +665,9 @@ public class PaperWorldConfig {
@@ -622,4 +622,9 @@ public class PaperWorldConfig {
private void zombieVillagerInfectionChance() {
zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance);
}
@ -28,15 +28,15 @@ index 598f27bc1b95132ded224dd5c7a0e2639ab2bd12..ea5f306ef57fe5958a554f4bdf866a36
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 234c6f1854d4a491f6233fbd4677719a0503d3a1..508aa4866e47f3865a8c51f7c8e3b842be216923 100644
index 281b8d508e569c7a5e2112e72a45fa088e7cacce..917d5eb4a660134468cc45982aae07b704b0cd0e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -637,7 +637,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -663,7 +663,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.executeModerately();
// CraftBukkit end
worldloadlistener.b();
- chunkproviderserver.getLightEngine().a(5);
+ chunkproviderserver.getLightEngine().a(worldserver.paperConfig.lightQueueSize); // Paper - increase light queue size
this.ba();
// CraftBukkit start
this.forceTicks = false;

View File

@ -42,10 +42,10 @@ index a58ef60d9976b3afc50e94364cf474bd2e5fdfd6..dd07223978c9aa648673d96ba7b3db11
public static final Timing commandFunctionsTimer = Timings.ofSafe("Command Functions");
public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index f1b41e16c8ce8323a896339c5d822f8ff7d8f7e6..f8f225e18fa38cad917f52a379233e0a7a869b07 100644
index c03ff5f856f669ed535379f6c9d41812b7472743..5814c0da1fe82ccf9a74c6418bee021543749d86 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -425,4 +425,9 @@ public class PaperConfig {
@@ -404,4 +404,9 @@ public class PaperConfig {
log("Async Chunks: Enabled - Chunks will be loaded much faster, without lag.");
}
}
@ -56,10 +56,10 @@ index f1b41e16c8ce8323a896339c5d822f8ff7d8f7e6..f8f225e18fa38cad917f52a379233e0a
+ }
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 9d5275c628b3963befdfa60841ef3c3331c8338c..b6146330a55665a0365ff7474f1843766e0c0ce1 100644
index e14e8bcf235339c1537a1e0a7702a364ee784c93..d1f832db33f21f8ba910d2c0c163af78718d298f 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -699,6 +699,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -694,6 +694,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().enter("purge");
this.world.timings.doChunkMap.startTiming(); // Spigot
this.chunkMapDistance.purgeTickets();
@ -67,7 +67,7 @@ index 9d5275c628b3963befdfa60841ef3c3331c8338c..b6146330a55665a0365ff7474f184376
this.tickDistanceManager();
this.world.timings.doChunkMap.stopTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("chunks");
@@ -708,6 +709,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -703,6 +704,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.timings.doChunkUnload.startTiming(); // Spigot
this.world.getMethodProfiler().exitEnter("unload");
this.playerChunkMap.unloadChunks(booleansupplier);
@ -75,24 +75,24 @@ index 9d5275c628b3963befdfa60841ef3c3331c8338c..b6146330a55665a0365ff7474f184376
this.world.timings.doChunkUnload.stopTiming(); // Spigot
this.world.getMethodProfiler().exit();
this.clearCache();
@@ -766,7 +768,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -756,7 +758,7 @@ public class ChunkProviderServer extends IChunkProvider {
entityPlayer.playerNaturallySpawnedEvent.callEvent();
};
// Paper end
- this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
+ final int[] chunksTicked = {0}; this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<Chunk> optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
if (optional.isPresent()) {
@@ -849,6 +851,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
this.world.a(chunk, k);
this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
+ if (chunksTicked[0]++ % 10 == 0) this.world.getMinecraftServer().midTickLoadChunks(); // Paper
@@ -780,6 +782,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.timings.chunkTicks.startTiming(); // Spigot // Paper
this.world.a(chunk, k);
this.world.timings.chunkTicks.stopTiming(); // Spigot // Paper
+ if (chunksTicked[0]++ % 10 == 0) this.world.getMinecraftServer().midTickLoadChunks(); // Paper
}
}
}
});
@@ -990,6 +993,41 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -936,6 +939,41 @@ public class ChunkProviderServer extends IChunkProvider {
super.executeTask(runnable);
}
@ -135,10 +135,10 @@ index 9d5275c628b3963befdfa60841ef3c3331c8338c..b6146330a55665a0365ff7474f184376
protected boolean executeNext() {
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea168c6d2f4f 100644
index 917d5eb4a660134468cc45982aae07b704b0cd0e..37ecdf66d705454bc818195476d25fbfa6628004 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -910,6 +910,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -942,6 +942,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// Paper end
tickSection = curTime;
}
@ -146,7 +146,7 @@ index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea16
// Spigot end
//MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time
@@ -980,7 +981,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1011,7 +1012,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
@ -154,8 +154,8 @@ index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea16
+ public boolean canSleepForTick() { // Paper
// CraftBukkit start
if (isOversleep) return canOversleep();// Paper - because of our changes, this logic is broken
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.ac ? this.ab : this.nextTick);
@@ -1010,6 +1011,23 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
return this.forceTicks || this.isEntered() || SystemUtils.getMonotonicMillis() < (this.X ? this.W : this.nextTick);
@@ -1041,6 +1042,23 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
});
}
@ -179,7 +179,7 @@ index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea16
@Override
protected TickTask postToMainThread(Runnable runnable) {
return new TickTask(this.ticks, runnable);
@@ -1096,6 +1114,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1127,6 +1145,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// Paper start - move oversleep into full server tick
isOversleep = true;MinecraftTimings.serverOversleep.startTiming();
this.awaitTasks(() -> {
@ -187,7 +187,7 @@ index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea16
return !this.canOversleep();
});
isOversleep = false;MinecraftTimings.serverOversleep.stopTiming();
@@ -1178,13 +1197,16 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1209,13 +1228,16 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
protected void b(BooleanSupplier booleansupplier) {
@ -204,7 +204,7 @@ index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea16
this.methodProfiler.exitEnter("levels");
Iterator iterator = this.getWorlds().iterator();
@@ -1195,7 +1217,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1226,7 +1248,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
processQueue.remove().run();
}
MinecraftTimings.processQueueTimer.stopTiming(); // Spigot
@ -213,49 +213,49 @@ index 508aa4866e47f3865a8c51f7c8e3b842be216923..11349565e71d97384d3dcab9cdf6ea16
MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
// Send time updates to everyone, it will get the right time from the world the player is in.
// Paper start - optimize time updates
@@ -1238,9 +1260,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.enter("tick");
@@ -1268,9 +1290,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.methodProfiler.enter("tick");
try {
+ midTickLoadChunks(); // Paper
worldserver.timings.doTick.startTiming(); // Spigot
worldserver.doTick(booleansupplier);
worldserver.timings.doTick.stopTiming(); // Spigot
+ midTickLoadChunks(); // Paper
} catch (Throwable throwable) {
// Spigot Start
CrashReport crashreport;
try {
+ midTickLoadChunks(); // Paper
worldserver.timings.doTick.startTiming(); // Spigot
worldserver.doTick(booleansupplier);
worldserver.timings.doTick.stopTiming(); // Spigot
+ midTickLoadChunks(); // Paper
} catch (Throwable throwable) {
// Spigot Start
CrashReport crashreport;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index dfc9f4d5738b01e3f80af8f3d25aec51b6e9d8d9..69e6614049e490dc70baf745761c62b173cf693e 100644
index 2609ae63556053adccdce19677d2e52aaab4ebf6..661718302a2eac338d9185d9d31ab7f704d4bee3 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -432,6 +432,7 @@ public class WorldServer extends World {
@@ -453,6 +453,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
timings.scheduledBlocks.stopTiming(); // Spigot
timings.scheduledBlocks.stopTiming(); // Paper
+ this.getMinecraftServer().midTickLoadChunks(); // Paper
gameprofilerfiller.exitEnter("raid");
this.timings.raids.startTiming(); // Paper - timings
this.persistentRaid.a();
@@ -444,6 +445,7 @@ public class WorldServer extends World {
@@ -461,6 +462,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
timings.doSounds.startTiming(); // Spigot
this.ad();
this.ah();
timings.doSounds.stopTiming(); // Spigot
+ this.getMinecraftServer().midTickLoadChunks(); // Paper
this.ticking = false;
gameprofilerfiller.exitEnter("entities");
boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
@@ -529,6 +531,7 @@ public class WorldServer extends World {
@@ -528,6 +530,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
timings.entityTick.stopTiming(); // Spigot
this.tickingEntities = false;
+ this.getMinecraftServer().midTickLoadChunks(); // Paper
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
while ((entity = (Entity) this.entitiesToAdd.poll()) != null) {
@@ -539,6 +542,7 @@ public class WorldServer extends World {
Entity entity2;
@@ -537,6 +540,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
}
gameprofilerfiller.exit();
timings.tickEntities.stopTiming(); // Spigot
+ this.getMinecraftServer().midTickLoadChunks(); // Paper
this.tickBlockEntities();

View File

@ -10,44 +10,45 @@ larger than the keep loaded range.
By skipping this, we avoid potential for a large spike on server start.
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index f4215d38acef8018f09dff5f379c14336647687d..4e4c0acc6c103c85b7ba2a390a54d3513939d547 100644
index 559da47b80f21f0da59da9410288835c0d394fd8..ec664e43009d0878ac6a2e35ae6b4595eb7aea44 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -114,7 +114,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -118,7 +118,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.serverStatisticManager = minecraftserver.getPlayerList().getStatisticManager(this);
this.advancementDataPlayer = minecraftserver.getPlayerList().f(this);
this.H = 1.0F;
- this.a(worldserver);
+ //this.a(worldserver); // Paper - don't move to spawn on login, only first join
this.G = 1.0F;
- this.b(worldserver);
+ //this.b(worldserver); // Paper - don't move to spawn on login, only first join
this.cachedSingleHashSet = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<>(this); // Paper
@@ -162,6 +162,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -171,6 +171,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
// CraftBukkit end
+ public void moveToSpawn(WorldServer worldserver) { a(worldserver); } // Paper - OBFHELPER
private void a(WorldServer worldserver) {
+ public final void moveToSpawn(WorldServer worldserver) { b(worldserver); } // Paper - OBFHELPER
private void b(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSpawn();
@@ -302,7 +303,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
position = new Vec3D(world.getSpawn());
@@ -346,7 +347,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
position = Vec3D.a(((WorldServer) world).getSpawn());
}
this.world = world;
- this.setPosition(position.getX(), position.getY(), position.getZ());
+ this.setPositionRaw(position.getX(), position.getY(), position.getZ()); // Paper - don't register to chunks yet
}
this.dimension = ((WorldServer) this.world).getWorldProvider().getDimensionManager();
this.playerInteractManager.a((WorldServer) world);
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 0e9ba6319472f54a1f77a9d2cdfb86d7490f0572..80f1c41062de9251343c3d9be4e076315cdbf88d 100644
index ea287e9c21ee1b4cf692d8c7b3df530766f2d26a..7a65b4f2cc6f3430bdad9df95b035ff29c8a2700 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -108,6 +108,7 @@ public abstract class PlayerList {
NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
@@ -134,6 +134,8 @@ public abstract class PlayerList {
worldserver1 = worldserver;
}
+ if (nbttagcompound == null) entityplayer.moveToSpawn(worldserver); // Paper - only move to spawn on first login, otherwise, stay where you are....
// CraftBukkit end
entityplayer.spawnIn(worldserver);
+ if (nbttagcompound == null) entityplayer.moveToSpawn(worldserver1); // Paper - only move to spawn on first login, otherwise, stay where you are....
+
entityplayer.spawnIn(worldserver1);
entityplayer.playerInteractManager.a((WorldServer) entityplayer.world);
String s1 = "local";

View File

@ -75,10 +75,10 @@ index 0000000000000000000000000000000000000000..d0211d4f39f9d6af1d751ac66342b42c
+ }
+}
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index f8f225e18fa38cad917f52a379233e0a7a869b07..3ee7e5671dd2519cec72b81211f1f39176a228ba 100644
index 5814c0da1fe82ccf9a74c6418bee021543749d86..c31a97c6ae0dd1493039158e67c5f3ba237ad234 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -70,6 +70,7 @@ public class PaperConfig {
@@ -68,6 +68,7 @@ public class PaperConfig {
commands = new HashMap<String, Command>();
commands.put("paper", new PaperCommand("paper"));
@ -87,23 +87,23 @@ index f8f225e18fa38cad917f52a379233e0a7a869b07..3ee7e5671dd2519cec72b81211f1f391
version = getInt("config-version", 20);
set("config-version", 20);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 11349565e71d97384d3dcab9cdf6ea168c6d2f4f..a0e33d42a158defc8b4a72de5d01b9395dca42eb 100644
index 37ecdf66d705454bc818195476d25fbfa6628004..826db17cdc83833ec93289ee7695171fc136bf8e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -106,6 +106,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -107,6 +107,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private int F;
private int G;
private int H;
public final long[] f = new long[100]; public long[] getTickTimes() { return f; } // Paper - OBFHELPER
public final long[] h; public long[] getTickTimes() { return h; } // Paper - OBFHELPER
+ // Paper start
+ public final TickTimes tickTimes5s = new TickTimes(100);
+ public final TickTimes tickTimes10s = new TickTimes(200);
+ public final TickTimes tickTimes60s = new TickTimes(1200);
+ // Paper end
@Nullable
private KeyPair I;
private KeyPair H;
@Nullable
@@ -1189,6 +1194,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.av = this.av * 0.8F + (float) l / 1000000.0F * 0.19999999F;
@@ -1220,6 +1225,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.ag = this.ag * 0.8F + (float) l / 1000000.0F * 0.19999999F;
long i1 = SystemUtils.getMonotonicNanos();
+ // Paper start
@ -115,10 +115,10 @@ index 11349565e71d97384d3dcab9cdf6ea168c6d2f4f..a0e33d42a158defc8b4a72de5d01b939
this.circularTimer.a(i1 - i);
this.methodProfiler.exit();
org.spigotmc.WatchdogThread.tick(); // Spigot
@@ -2277,4 +2288,30 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
return SERVER; // Paper
@@ -2175,4 +2186,30 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public SaveData getSaveData() {
return this.saveData;
}
// CraftBukkit end
+
+ // Paper start
+ public static class TickTimes {
@ -147,10 +147,10 @@ index 11349565e71d97384d3dcab9cdf6ea168c6d2f4f..a0e33d42a158defc8b4a72de5d01b939
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e8d3528d515754affb14c947109ccdf1739d9745..4a41003203b316e45622360f97a897d1fad6cda0 100644
index 181616c93656e45ec83659e59ac77cedce8af682..fb4172a8708cbf76ec44dafb966538c6345dc23d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2053,6 +2053,16 @@ public final class CraftServer implements Server {
@@ -2108,6 +2108,16 @@ public final class CraftServer implements Server {
net.minecraft.server.MinecraftServer.getServer().tps15.getAverage()
};
}

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Expose MinecraftServer#isRunning
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4a41003203b316e45622360f97a897d1fad6cda0..b627180729a24a83ca383f83aee53133ea1b398e 100644
index fb4172a8708cbf76ec44dafb966538c6345dc23d..06b56bd65803bddc634d4984b8da29d910d31ee7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2218,5 +2218,10 @@ public final class CraftServer implements Server {
@@ -2273,5 +2273,10 @@ public final class CraftServer implements Server {
public int getCurrentTick() {
return net.minecraft.server.MinecraftServer.currentTick;
}

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Add Raw Byte ItemStack Serialization
Serializes using NBT which is safer for server data migrations than bukkits format.
diff --git a/src/main/java/net/minecraft/server/DataConverterRegistry.java b/src/main/java/net/minecraft/server/DataConverterRegistry.java
index 77c77973bb335cc89dae31bef2bbbcd4adc1d14b..d957d5fc2dc724cdda553e3a67ffe65e1e41c304 100644
index d7ebbce930fc65437697d25637346b9c99e6a8fa..5d807082281527c78a08d01430e42b3ecee6d2cf 100644
--- a/src/main/java/net/minecraft/server/DataConverterRegistry.java
+++ b/src/main/java/net/minecraft/server/DataConverterRegistry.java
@@ -22,6 +22,7 @@ public class DataConverterRegistry {
@@ -24,6 +24,7 @@ public class DataConverterRegistry {
return datafixerbuilder.build(SystemUtils.e());
}
@ -18,10 +18,10 @@ index 77c77973bb335cc89dae31bef2bbbcd4adc1d14b..d957d5fc2dc724cdda553e3a67ffe65e
return DataConverterRegistry.c;
}
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index d6e43313bf0c678cf78fe77de2f8f4b6f819e3f4..ea60880c6f15b1a39579896d78cf641563621aa4 100644
index 64150130fa0081786190eada4cd2d1312a51572d..00725529793d6c2fe26ecacf900355b40e31dad8 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -140,6 +140,7 @@ public final class ItemStack {
@@ -144,6 +144,7 @@ public final class ItemStack {
this.checkEmpty();
}
@ -50,7 +50,7 @@ index 2322c0c8c5aacebb6317eab8ce4245554f6d9d55..3e6f878cdbbf5ebfa7fb390745ead135
DataOutputStream dataoutputstream = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(outputstream)));
Throwable throwable = null;
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 6363074c38312387b62e6cf5df2592aefb078f29..004b6ce132f8a686116b2a03a0a57461c8e164cf 100644
index 6e6da966a8c5b40494213f914db5b9449aea4f43..aba492876c66661f12eba6340aae53fa519688bf 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -319,6 +319,46 @@ public final class CraftMagicNumbers implements UnsafeValues {

View File

@ -10,7 +10,7 @@ Also optimise the stream.anyMatch statement to move to a bitset
where we can replace the call with a single bitwise operation.
diff --git a/src/main/java/net/minecraft/server/PathfinderGoal.java b/src/main/java/net/minecraft/server/PathfinderGoal.java
index bdb90a346639db37d3c72359c28b72d021d1b389..93009d83f07bdaf7bc424ffb99cbfe716ca0d66d 100644
index 384300894d19ff70556c23b130c01b2e49aa3f20..a85d81186ae92dec72f2cc3a1dcd8c4b7e7ede62 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoal.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoal.java
@@ -1,10 +1,12 @@
@ -53,7 +53,7 @@ index bdb90a346639db37d3c72359c28b72d021d1b389..93009d83f07bdaf7bc424ffb99cbfe71
public static enum Type {
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c74f8c56e4 100644
index b18e53220d8dbd50723c4201231091cbe4f4119a..22f4fec58fbaab24673dd418700c51671248c510 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
@@ -1,8 +1,10 @@
@ -66,18 +66,18 @@ index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c7
+import java.util.Iterator; // Paper - remove streams from pathfindergoalselector
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
@@ -26,7 +28,8 @@ public class PathfinderGoalSelector {
import java.util.function.Supplier;
@@ -27,7 +29,8 @@ public class PathfinderGoalSelector {
private final Map<PathfinderGoal.Type, PathfinderGoalWrapped> c = new EnumMap(PathfinderGoal.Type.class);
private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet();private Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER
private final GameProfilerFiller e;
private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet(); private Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER
private final Supplier<GameProfilerFiller> e;
- private final EnumSet<PathfinderGoal.Type> f = EnumSet.noneOf(PathfinderGoal.Type.class);
+ private final EnumSet<PathfinderGoal.Type> f = EnumSet.noneOf(PathfinderGoal.Type.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be.
+ private final OptimizedSmallEnumSet<PathfinderGoal.Type> goalTypes = new OptimizedSmallEnumSet<>(PathfinderGoal.Type.class); // Paper - remove streams from pathfindergoalselector
private int g = 3;private int getTickRate() { return g; } // Paper - OBFHELPER
private int curRate;private int getCurRate() { return curRate; } private void incRate() { this.curRate++; } // Paper TODO
@@ -58,33 +61,36 @@ public class PathfinderGoalSelector {
@@ -59,35 +62,38 @@ public class PathfinderGoalSelector {
// Paper end
public void a(PathfinderGoal pathfindergoal) {
@ -104,8 +104,10 @@ index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c7
+ private static final PathfinderGoal.Type[] PATHFINDER_GOAL_TYPES = PathfinderGoal.Type.values(); // Paper - remove streams from pathfindergoalselector
+
public void doTick() {
this.e.enter("goalCleanup");
- this.c().filter((pathfindergoalwrapped) -> {
GameProfilerFiller gameprofilerfiller = (GameProfilerFiller) this.e.get();
gameprofilerfiller.enter("goalCleanup");
- this.d().filter((pathfindergoalwrapped) -> {
- boolean flag;
-
- if (pathfindergoalwrapped.g()) {
@ -136,10 +138,10 @@ index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c7
this.c.forEach((pathfindergoal_type, pathfindergoalwrapped) -> {
if (!pathfindergoalwrapped.g()) {
this.c.remove(pathfindergoal_type);
@@ -93,30 +99,58 @@ public class PathfinderGoalSelector {
@@ -96,30 +102,58 @@ public class PathfinderGoalSelector {
});
this.e.exit();
this.e.enter("goalUpdate");
gameprofilerfiller.exit();
gameprofilerfiller.enter("goalUpdate");
- this.d.stream().filter((pathfindergoalwrapped) -> {
- return !pathfindergoalwrapped.g();
- }).filter((pathfindergoalwrapped) -> {
@ -203,9 +205,9 @@ index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c7
+ wrappedGoal.c();
+ }
+ // Paper end - remove streams from pathfindergoalselector
this.e.exit();
this.e.enter("goalTick");
- this.c().forEach(PathfinderGoalWrapped::e);
gameprofilerfiller.exit();
gameprofilerfiller.enter("goalTick");
- this.d().forEach(PathfinderGoalWrapped::e);
+ // Paper start - remove streams from pathfindergoalselector
+ for (Iterator<PathfinderGoalWrapped> iterator = this.d.iterator(); iterator.hasNext();) {
+ PathfinderGoalWrapped wrappedGoal = iterator.next();
@ -214,10 +216,10 @@ index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c7
+ }
+ }
+ // Paper end - remove streams from pathfindergoalselector
this.e.exit();
gameprofilerfiller.exit();
}
@@ -125,11 +159,11 @@ public class PathfinderGoalSelector {
@@ -128,11 +162,11 @@ public class PathfinderGoalSelector {
}
public void a(PathfinderGoal.Type pathfindergoal_type) {
@ -232,7 +234,7 @@ index 935136771e776fe498f608a159a41393340adc4e..84d2abbcb90eb09a19fa0922cfc053c7
public void a(PathfinderGoal.Type pathfindergoal_type, boolean flag) {
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java b/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
index 29657fed75184aee0c89e56f5e642a5d68eda444..1b800c558f0988ffc0270b86d1a59ea3bb245116 100644
index 04b28555b1bb68536e40bb652613678775337b31..96f4401044cacf88e8e00b5b18821c105e634fba 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
@@ -59,9 +59,10 @@ public class PathfinderGoalWrapped extends PathfinderGoal {

View File

@ -6,12 +6,12 @@ Subject: [PATCH] Delay unsafe actions until after entity ticking is done
This will help prevent many cases of unregistering entities during entity ticking
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 69e6614049e490dc70baf745761c62b173cf693e..aaf85a1497de98522e3a01d4f81a267c4b0cc087 100644
index 661718302a2eac338d9185d9d31ab7f704d4bee3..d0493919e71159ac6b38a64b2411fea722b53306 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -60,6 +60,16 @@ public class WorldServer extends World {
private final Queue<Entity> entitiesToAdd = Queues.newArrayDeque();
@@ -61,6 +61,16 @@ public class WorldServer extends World implements GeneratorAccessSeed {
public final List<EntityPlayer> players = Lists.newArrayList(); // Paper - private -> public
public final ChunkProviderServer chunkProvider; // Paper - public
boolean tickingEntities;
+ // Paper start
+ List<java.lang.Runnable> afterEntityTickingTasks = Lists.newArrayList();
@ -24,9 +24,9 @@ index 69e6614049e490dc70baf745761c62b173cf693e..aaf85a1497de98522e3a01d4f81a267c
+ }
+ // Paper end
private final MinecraftServer server;
private final WorldNBTStorage dataManager;
public final WorldDataServer worldDataServer; // CraftBukkit - type
public boolean savingDisabled;
@@ -531,6 +541,16 @@ public class WorldServer extends World {
@@ -530,6 +540,16 @@ public class WorldServer extends World implements GeneratorAccessSeed {
timings.entityTick.stopTiming(); // Spigot
this.tickingEntities = false;
@ -42,4 +42,4 @@ index 69e6614049e490dc70baf745761c62b173cf693e..aaf85a1497de98522e3a01d4f81a267c
+ // Paper end
this.getMinecraftServer().midTickLoadChunks(); // Paper
try (co.aikar.timings.Timing ignored = this.timings.newEntities.startTiming()) { // Paper - timings
Entity entity2;

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Async command map building
diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java
index 37b1a7947c2d5ce954d83f599453db86ca1eb131..2414b0a552e5d6fb449bca163add7a9bac39e943 100644
index e6030512dbbfac3c2ab29e20562ad666f7608295..1229aaf19de60f1e3ce161b5c3b7ef659d14c018 100644
--- a/src/main/java/net/minecraft/server/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
@@ -241,6 +241,14 @@ public class CommandDispatcher {
@@ -242,6 +242,14 @@ public class CommandDispatcher {
if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot
// CraftBukkit start
// Register Vanilla commands into builtRoot as before
@ -23,7 +23,7 @@ index 37b1a7947c2d5ce954d83f599453db86ca1eb131..2414b0a552e5d6fb449bca163add7a9b
Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
RootCommandNode vanillaRoot = new RootCommandNode();
@@ -258,7 +266,14 @@ public class CommandDispatcher {
@@ -259,7 +267,14 @@ public class CommandDispatcher {
for (CommandNode node : rootcommandnode.getChildren()) {
bukkit.add(node.getName());
}

View File

@ -55,7 +55,7 @@ index e257d6b36e0e78dac5b8320017d92776171e1bb0..24641501aeae0f2c2c5ce877775c7b97
}
}, 1000 * 60 * 5, 1000 * 60 * 30);
diff --git a/src/main/java/net/minecraft/server/CrashReport.java b/src/main/java/net/minecraft/server/CrashReport.java
index 3de19c998b749ccf74958c2412a8c9506457383e..c7dc8787cc3456c5540d6a00a6ff051533edc25a 100644
index 95e6a6de7ccfc4445d0ac19c5f874c0d533b1712..cc6e6f245ee5e73bd570cf42381bf55ee0b364d3 100644
--- a/src/main/java/net/minecraft/server/CrashReport.java
+++ b/src/main/java/net/minecraft/server/CrashReport.java
@@ -257,6 +257,7 @@ public class CrashReport {
@ -67,19 +67,19 @@ index 3de19c998b749ccf74958c2412a8c9506457383e..c7dc8787cc3456c5540d6a00a6ff0515
throwable = throwable.getCause();
}
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index 1ef7890da599d13e784861035e7891efcc4cd504..32cd645abb236b355f4f4f0f810e56342ee6cc06 100644
index 4fa8d40d84884f17b4bbcc357a6bb902f8f668cd..22ee001a8d5a3c93303d036daa7ee12a6ec802bb 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -299,7 +299,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
long l = SystemUtils.getMonotonicNanos() - i;
String s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D);
@@ -242,7 +242,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
long j = SystemUtils.getMonotonicNanos() - i;
String s = String.format(Locale.ROOT, "%.3fs", (double) j / 1.0E9D);
- DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s2);
+ //DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s2); // Paper moved to after init
- DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s);
+ //DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s); // Paper moved to after init
if (dedicatedserverproperties.announcePlayerAchievements != null) {
((GameRules.GameRuleBoolean) this.getGameRules().get(GameRules.ANNOUNCE_ADVANCEMENTS)).a(dedicatedserverproperties.announcePlayerAchievements, (MinecraftServer) this);
}
@@ -422,6 +422,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@@ -368,6 +368,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
//this.remoteStatusListener.b(); // Paper - don't wait for remote connections
}
@ -87,17 +87,17 @@ index 1ef7890da599d13e784861035e7891efcc4cd504..32cd645abb236b355f4f4f0f810e5634
System.exit(0); // CraftBukkit
}
@@ -750,7 +751,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@@ -696,7 +697,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
@Override
public void stop() {
super.stop();
- SystemUtils.f();
+ //SystemUtils.f(); // Paper - moved into super
- SystemUtils.h();
+ //SystemUtils.h(); // Paper - moved into super
}
@Override
diff --git a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
index cfe43e882e524b6ab3d9702e81269c97e6b75eba..2632c7c3ec77918be7979f2aa49209e566cafc77 100644
index 63fdae15ccbef0c39718b320dbd096794bcfa3b4..6beefff203ed6e448898eb5b2e95800def868381 100644
--- a/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
+++ b/src/main/java/net/minecraft/server/IAsyncTaskHandler.java
@@ -135,6 +135,7 @@ public abstract class IAsyncTaskHandler<R extends Runnable> implements Mailbox<R
@ -105,22 +105,14 @@ index cfe43e882e524b6ab3d9702e81269c97e6b75eba..2632c7c3ec77918be7979f2aa49209e5
r0.run();
} catch (Exception exception) {
+ if (exception.getCause() instanceof ThreadDeath) throw exception; // Paper
IAsyncTaskHandler.LOGGER.fatal("Error executing task on {}", this.bi(), exception);
IAsyncTaskHandler.LOGGER.fatal("Error executing task on {}", this.bh(), exception);
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47b31c8585 100644
index 826db17cdc83833ec93289ee7695171fc136bf8e..cf05c44865b5d3210b50d11ac7413865cc57f1ff 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -144,6 +144,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
private final ResourcePackRepository<ResourcePackLoader> resourcePackRepository;
@Nullable
private ResourcePackSourceFolder resourcePackFolder;
+ public volatile Thread shutdownThread; // Paper
public CommandDispatcher commandDispatcher;
private final CraftingManager craftingManager;
private final TagRegistry tagRegistry;
@@ -176,7 +177,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -160,7 +160,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public boolean serverAutoSave = false; // Paper
public File bukkitDataPackFolder;
public CommandDispatcher vanillaCommandDispatcher;
@ -129,7 +121,16 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
// CraftBukkit end
// Spigot start
public static final int TPS = 20;
@@ -713,6 +714,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -170,6 +170,8 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public final SlackActivityAccountant slackActivityAccountant = new SlackActivityAccountant();
// Spigot end
+ public volatile Thread shutdownThread; // Paper
+
public static <S extends MinecraftServer> S a(Function<Thread, S> function) {
AtomicReference<S> atomicreference = new AtomicReference();
Thread thread = new Thread(() -> {
@@ -738,6 +740,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// CraftBukkit start
private boolean hasStopped = false;
@ -137,7 +138,7 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
private final Object stopLock = new Object();
public final boolean hasStopped() {
synchronized (stopLock) {
@@ -725,10 +727,22 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -750,10 +753,22 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// CraftBukkit start - prevent double stopping on multiple threads
synchronized(stopLock) {
if (hasStopped) return;
@ -161,7 +162,7 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
MinecraftTimings.stopServer(); // Paper
// CraftBukkit start
if (this.server != null) {
@@ -785,7 +799,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -817,7 +832,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.getUserCache().c(false); // Paper
}
// Spigot end
@ -180,15 +181,15 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
}
public String getServerIp() {
@@ -878,6 +903,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -910,6 +936,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
public void run() {
protected void v() {
try {
+ long serverStartTime = SystemUtils.getMonotonicNanos(); // Paper
if (this.init()) {
this.nextTick = SystemUtils.getMonotonicMillis();
this.serverPing.setMOTD(new ChatComponentText(this.motd));
@@ -885,6 +911,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -917,6 +944,18 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.a(this.serverPing);
// Spigot start
@ -207,7 +208,7 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
Arrays.fill( recentTps, 20 );
long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop
@@ -941,6 +979,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -972,6 +1011,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
this.a((CrashReport) null);
}
} catch (Throwable throwable) {
@ -220,7 +221,7 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
MinecraftServer.LOGGER.error("Encountered an unexpected exception", throwable);
// Spigot Start
if ( throwable.getCause() != null )
@@ -972,14 +1016,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1003,14 +1048,14 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
} catch (Throwable throwable1) {
MinecraftServer.LOGGER.error("Exception stopping the server", throwable1);
} finally {
@ -238,7 +239,7 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
}
}
@@ -1035,6 +1079,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@@ -1066,6 +1111,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
@Override
protected TickTask postToMainThread(Runnable runnable) {
@ -251,19 +252,19 @@ index a0e33d42a158defc8b4a72de5d01b9395dca42eb..2c9ae5c46a39639fd9f842df23993a47
return new TickTask(this.ticks, runnable);
}
@@ -1278,6 +1328,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
midTickLoadChunks(); // Paper
} catch (Throwable throwable) {
// Spigot Start
+ if (throwable instanceof ThreadDeath) { throw throwable; } // Paper
CrashReport crashreport;
try {
crashreport = CrashReport.a(throwable, "Exception ticking world");
@@ -1312,6 +1363,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
try {
crashreport = CrashReport.a(throwable, "Exception ticking world");
} catch (Throwable t) {
+ if (throwable instanceof ThreadDeath) { throw (ThreadDeath)throwable; } // Paper
throw new RuntimeException("Error generating crash report", t);
}
// Spigot End
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index ea6b310e8e4741c8bb301e5bc586faca8bea5e06..6bdaaf8daef15cd7c11943254e412e0e2d2898fb 100644
index 9d4c5f32036118bf7c5081c55bea71efd606b8f6..ba100e5c96d5279ab5f30c6e10f3cbd7b6b4443e 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -485,6 +485,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -486,6 +486,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
MutableBoolean mutableboolean = new MutableBoolean();
do {
@ -272,10 +273,10 @@ index ea6b310e8e4741c8bb301e5bc586faca8bea5e06..6bdaaf8daef15cd7c11943254e412e0e
list.stream().map((playerchunk) -> {
CompletableFuture completablefuture;
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 80f1c41062de9251343c3d9be4e076315cdbf88d..4d4912a38ad0bf38a42ac8fed0ad4c1eecaf63a5 100644
index 7a65b4f2cc6f3430bdad9df95b035ff29c8a2700..a212c3bb7c80948cc329f21c3916f52ec02e06bf 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -400,7 +400,7 @@ public abstract class PlayerList {
@@ -430,7 +430,7 @@ public abstract class PlayerList {
cserver.getPluginManager().callEvent(playerQuitEvent);
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
@ -285,22 +286,22 @@ index 80f1c41062de9251343c3d9be4e076315cdbf88d..4d4912a38ad0bf38a42ac8fed0ad4c1e
// Paper start - Remove from collideRule team if needed
diff --git a/src/main/java/net/minecraft/server/SystemUtils.java b/src/main/java/net/minecraft/server/SystemUtils.java
index 20d803ad68ea65fd725d6eb3317b998c1692a7b3..aa399e7f6518ff70f2214161319170b1fc911751 100644
index 3299ac0b0115cb1166c1ee449bd49292e553b7af..dc7a4eabf83d5b74ccde170764dcd1e99f958ee0 100644
--- a/src/main/java/net/minecraft/server/SystemUtils.java
+++ b/src/main/java/net/minecraft/server/SystemUtils.java
@@ -112,6 +112,7 @@ public class SystemUtils {
return SystemUtils.c;
@@ -119,6 +119,7 @@ public class SystemUtils {
return SystemUtils.f;
}
+ public static void shutdownServerThreadPool() { f(); } // Paper - OBFHELPER
public static void f() {
SystemUtils.c.shutdown();
+ public static void shutdownServerThreadPool() { h(); } // Paper - OBFHELPER
public static void h() {
a(SystemUtils.e);
a(SystemUtils.f);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index a52d8a27cee6721c32444d9d2bd81135b7d4b859..bdd0908adb7d3cd5370b43be196c975e6c48a70f 100644
index d2b3e06dda10fc321768301c35f319767796d7d5..91294ff7e86a997cc81f287517b2ff5529fc0a91 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -793,6 +793,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -840,6 +840,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
gameprofilerfiller.exit();
} catch (Throwable throwable) {
@ -308,7 +309,7 @@ index a52d8a27cee6721c32444d9d2bd81135b7d4b859..bdd0908adb7d3cd5370b43be196c975e
// Paper start - Prevent tile entity and entity crashes
String msg = "TileEntity threw exception at " + tileentity.world.getWorld().getName() + ":" + tileentity.position.getX() + "," + tileentity.position.getY() + "," + tileentity.position.getZ();
System.err.println(msg);
@@ -868,6 +869,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -915,6 +916,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
try {
consumer.accept(entity);
} catch (Throwable throwable) {
@ -317,10 +318,10 @@ index a52d8a27cee6721c32444d9d2bd81135b7d4b859..bdd0908adb7d3cd5370b43be196c975e
String msg = "Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX() + "," + entity.locY() + "," + entity.locZ();
System.err.println(msg);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b627180729a24a83ca383f83aee53133ea1b398e..f49193d9d7cd9655fdedf64bebdcf4e1a9b77f2c 100644
index 06b56bd65803bddc634d4984b8da29d910d31ee7..b0ab57ef2e45394905a29444daea1d7b3e866875 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1706,7 +1706,7 @@ public final class CraftServer implements Server {
@@ -1761,7 +1761,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {
@ -330,7 +331,7 @@ index b627180729a24a83ca383f83aee53133ea1b398e..f49193d9d7cd9655fdedf64bebdcf4e1
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index d3463abe89f6e730373cef5e3ac8c0911d0b0963..e913d249d850210c9efba1bb46ce2ce4df013a62 100644
index 5ec16547a20271074d034f7fbcb43e86cb1597e6..429ae482f30eeeab84cc009a9143245e086ce469 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -150,6 +150,37 @@ public class Main {

View File

@ -7,7 +7,7 @@ Prevents pathfinding from spamming failures for things such as
arrow attacks.
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index f06764973feaa29ccbb4731b65372c544dcf3032..dc32107ec320fa54487f24c9d68ff8e5a6dea1bb 100644
index cca6242e38fc286eea810eb8f2e4d1ab5429b9df..e6dc5b9ce1b2f844d84a7cdf9bce030bc8eb568d 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -11,7 +11,7 @@ public abstract class NavigationAbstract {
@ -17,9 +17,9 @@ index f06764973feaa29ccbb4731b65372c544dcf3032..dc32107ec320fa54487f24c9d68ff8e5
- protected PathEntity c;
+ protected PathEntity c; protected final PathEntity getCurrentPath() { return this.c; } // Paper - OBFHELPER
protected double d;
private final AttributeInstance p;
protected int e;
@@ -158,10 +158,30 @@ public abstract class NavigationAbstract {
protected int f;
@@ -162,10 +162,30 @@ public abstract class NavigationAbstract {
return this.a(this.a(d0, d1, d2, 1), d3);
}

View File

@ -8,10 +8,10 @@ is important because we clone chunk data after reading it for safety.
So, reduce the impact of the clone on GC.
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
index 98deaba12ceb25f59d1b56420fb544a64b417ddd..02a2ed1baa3f82d302432b7bc627f3179751f886 100644
index 9c445902e6adc05773497bc4444203ca364e4f5c..f608b35502890650adfc1df35e0794471f57ecbc 100644
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
@@ -31,7 +31,7 @@ public class NBTTagCompound implements NBTBase {
@@ -41,7 +41,7 @@ public class NBTTagCompound implements NBTBase {
if (i > 512) {
throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512");
} else {
@ -20,7 +20,7 @@ index 98deaba12ceb25f59d1b56420fb544a64b417ddd..02a2ed1baa3f82d302432b7bc627f317
byte b0;
@@ -67,7 +67,7 @@ public class NBTTagCompound implements NBTBase {
@@ -77,7 +77,7 @@ public class NBTTagCompound implements NBTBase {
}
public NBTTagCompound() {
@ -29,7 +29,7 @@ index 98deaba12ceb25f59d1b56420fb544a64b417ddd..02a2ed1baa3f82d302432b7bc627f317
}
@Override
@@ -402,9 +402,17 @@ public class NBTTagCompound implements NBTBase {
@@ -409,9 +409,17 @@ public class NBTTagCompound implements NBTBase {
@Override
public NBTTagCompound clone() {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Prevent opening inventories when frozen
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 4e4c0acc6c103c85b7ba2a390a54d3513939d547..49fe2d1a0376e5aa8a5ec00d010e6c834633e7b7 100644
index ec664e43009d0878ac6a2e35ae6b4595eb7aea44..97f03d09d8e7f38b00f407b1268e30a0729d1811 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -380,7 +380,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -423,7 +423,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
containerUpdateDelay = world.paperConfig.containerUpdateTickRate;
}
// Paper end
@ -17,7 +17,7 @@ index 4e4c0acc6c103c85b7ba2a390a54d3513939d547..49fe2d1a0376e5aa8a5ec00d010e6c83
this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper
this.activeContainer = this.defaultContainer;
}
@@ -1170,7 +1170,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -1277,7 +1277,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
} else {
// CraftBukkit start
this.activeContainer = container;
@ -26,7 +26,7 @@ index 4e4c0acc6c103c85b7ba2a390a54d3513939d547..49fe2d1a0376e5aa8a5ec00d010e6c83
// CraftBukkit end
container.addSlotListener(this);
return OptionalInt.of(this.containerCounter);
@@ -1933,7 +1933,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -2071,7 +2071,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
@Override
@ -36,10 +36,10 @@ index 4e4c0acc6c103c85b7ba2a390a54d3513939d547..49fe2d1a0376e5aa8a5ec00d010e6c83
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index a6d75c0e07a25fdb59dde2e3eb2a0213c7112515..a5e9fc90ffae794b9b14468337ce7b091fd0dc35 100644
index 1eac3798acfc8a6859f102250bc8e49ed29d6e21..077d1a0f45c304066fedbb1f9b9a05a2e3331e88 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -350,7 +350,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@@ -317,7 +317,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
String title = container.getBukkitView().getTitle();
@ -48,7 +48,7 @@ index a6d75c0e07a25fdb59dde2e3eb2a0213c7112515..a5e9fc90ffae794b9b14468337ce7b09
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);
}
@@ -420,7 +420,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@@ -387,7 +387,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// Now open the window
Containers<?> windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory());
String title = inventory.getTitle();

View File

@ -7,10 +7,10 @@ Will not run if max entity craming is disabled and
the max collisions per entity is less than or equal to 0
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 4cac47c280a757b09e0b1e3f98c815bb8cd1b3c0..b546537586c3033f696aba9c133490258a9422b2 100644
index e4c7f4c100e1b8d4470da954a3b72f9e0ec5b494..cee156e0847af3187de8a7c9bc0791dff3886b15 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2666,10 +2666,16 @@ public abstract class EntityLiving extends Entity {
@@ -2814,10 +2814,16 @@ public abstract class EntityLiving extends Entity {
protected void doTick() {}
protected void collideNearby() {

View File

@ -1,111 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 2 Apr 2020 02:37:57 -0400
Subject: [PATCH] Optimize Collision to not load chunks
The collision code takes an AABB and generates a cuboid of checks rather
than a cylinder, so at high velocity this can generate a lot of chunk checks.
Treat an unloaded chunk as a collision for entities, and also for players if
the "prevent moving into unloaded chunks" setting is enabled.
If that serting is not enabled, collisions will be ignored for players, since
movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 7434f859f7f9acff0f881ff594c8dffdfa249c76..7fb34a86dc35cb4bf51e1ce5220e56642096fece 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -80,6 +80,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
private CraftEntity bukkitEntity;
PlayerChunkMap.EntityTracker tracker; // Paper
+ boolean collisionLoadChunks = false; // Paper
Throwable addedToWorldStack; // Paper - entity debug
public CraftEntity getBukkitEntity() {
if (bukkitEntity == null) {
diff --git a/src/main/java/net/minecraft/server/ICollisionAccess.java b/src/main/java/net/minecraft/server/ICollisionAccess.java
index f851ed11df14fd9aa8017f44d82fb6cfc3bde345..3eefbf4d5f10b53f930759a0afa5661253b92c60 100644
--- a/src/main/java/net/minecraft/server/ICollisionAccess.java
+++ b/src/main/java/net/minecraft/server/ICollisionAccess.java
@@ -43,7 +43,9 @@ public interface ICollisionAccess extends IBlockAccess {
}
default boolean a(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
+ try { if (entity != null) entity.collisionLoadChunks = true; // Paper
return this.c(entity, axisalignedbb, set).allMatch(VoxelShape::isEmpty);
+ } finally { if (entity != null) entity.collisionLoadChunks = false; } // Paper
}
default Stream<VoxelShape> b(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
@@ -83,19 +85,33 @@ public interface ICollisionAccess extends IBlockAccess {
}
while (cursorposition.a()) {
- int k1 = cursorposition.b();
- int l1 = cursorposition.c();
- int i2 = cursorposition.d();
+ int k1 = cursorposition.b();int x = k1; // Paper
+ int l1 = cursorposition.c();int y = l1; // Paper
+ int i2 = cursorposition.d();int z = i2; // Paper
int j2 = cursorposition.e();
if (j2 != 3) {
- int k2 = k1 >> 4;
- int l2 = i2 >> 4;
- IBlockAccess iblockaccess = ICollisionAccess.this.c(k2, l2);
-
- if (iblockaccess != null) {
- blockposition_mutableblockposition.d(k1, l1, i2);
- IBlockData iblockdata = iblockaccess.getType(blockposition_mutableblockposition);
+ // Paper start - ensure we don't load chunks
+ //int k2 = k1 >> 4;
+ //int l2 = i2 >> 4;
+ boolean far = entity != null && MCUtil.distanceSq(entity.locX(), y, entity.locZ(), x, y, z) > 14;
+ blockposition_mutableblockposition.setValues(x, y, z);
+
+ boolean isRegionLimited = ICollisionAccess.this instanceof RegionLimitedWorldAccess;
+ IBlockData iblockdata = isRegionLimited ? Blocks.VOID_AIR.getBlockData() : ((!far && entity instanceof EntityPlayer) || (entity != null && entity.collisionLoadChunks)
+ ? ICollisionAccess.this.getType(blockposition_mutableblockposition)
+ : ICollisionAccess.this.getTypeIfLoaded(blockposition_mutableblockposition)
+ );
+ if (iblockdata == null) {
+ if (!(entity instanceof EntityPlayer) || entity.world.paperConfig.preventMovingIntoUnloadedChunks) {
+ VoxelShape voxelshape3 = VoxelShapes.of(far ? entity.getBoundingBox() : new AxisAlignedBB(new BlockPosition(x, y, z)));
+ consumer.accept(voxelshape3);
+ return true;
+ }
+ } else {
+ //blockposition_mutableblockposition.d(k1, l1, i2); // moved up
+ //IBlockData iblockdata = iblockaccess.getType(blockposition_mutableblockposition); // moved up
+ // Paper end
if ((j2 != 1 || iblockdata.f()) && (j2 != 2 || iblockdata.getBlock() == Blocks.MOVING_PISTON)) {
VoxelShape voxelshape2 = iblockdata.b((IBlockAccess) ICollisionAccess.this, blockposition_mutableblockposition, voxelshapecollision);
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 088c82c5379b39f8cebd60465e054b97c96eb983..0e9ba6319472f54a1f77a9d2cdfb86d7490f0572 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -677,6 +677,7 @@ public abstract class PlayerList {
entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
// CraftBukkit end
+ worldserver.getChunkProvider().addTicket(TicketType.POST_TELEPORT, new ChunkCoordIntPair(location.getBlockX() >> 4, location.getBlockZ() >> 4), 1, entityplayer.getId()); // Paper
while (avoidSuffocation && !worldserver.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
}
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
index 335142ec0dfad822cfe40877e99dec0f307e1a58..e641d4b8d8b4ac5d539e6d9c0eaf345601e0b499 100644
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
@@ -239,7 +239,8 @@ public final class VoxelShapes {
if (k2 < 3) {
blockposition_mutableblockposition.a(enumaxiscycle1, i2, j2, l1);
- IBlockData iblockdata = iworldreader.getType(blockposition_mutableblockposition);
+ IBlockData iblockdata = iworldreader.getTypeIfLoaded(blockposition_mutableblockposition); // Paper
+ if (iblockdata == null) return 0.0D; // Paper
if ((k2 != 1 || iblockdata.f()) && (k2 != 2 || iblockdata.getBlock() == Blocks.MOVING_PISTON)) {
d0 = iblockdata.b((IBlockAccess) iworldreader, blockposition_mutableblockposition, voxelshapecollision).a(enumdirection_enumaxis2, axisalignedbb.d((double) (-blockposition_mutableblockposition.getX()), (double) (-blockposition_mutableblockposition.getY()), (double) (-blockposition_mutableblockposition.getZ())), d0);

View File

@ -11,10 +11,10 @@ Less crammed entities are likely to show significantly less benefit.
Effectively, this patch optimises crammed entity situations.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe665c24932 100644
index cb24f27bc443880b18ffc36236f6ec7174c9d493..b65ae2d6919a67498d0646c5522735086fec00c1 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -90,6 +90,54 @@ public class Chunk implements IChunkAccess {
@@ -91,6 +91,54 @@ public class Chunk implements IChunkAccess {
private final int[] inventoryEntityCounts = new int[16];
// Paper end
@ -27,7 +27,7 @@ index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe6
+ }
+ }
+
+ public final void getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, List<Entity> into) {
+ public final void getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, List<Entity> into, Predicate<Entity> predicate) {
+ // copied from getEntities
+ int min = MathHelper.floor((axisalignedbb.minY - 2.0D) / 16.0D);
+ int max = MathHelper.floor((axisalignedbb.maxY + 2.0D) / 16.0D);
@ -43,7 +43,7 @@ index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe6
+ Entity entity1 = entities[i];
+ if (entity1.shouldBeRemoved) continue; // Paper
+
+ if (entity1 != entity && entity1.getBoundingBox().intersects(axisalignedbb)) {
+ if (entity1 != entity && entity1.getBoundingBox().intersects(axisalignedbb) && (predicate == null || predicate.test(entity1))) {
+ into.add(entity1);
+
+ if (!(entity1 instanceof EntityEnderDragon)) {
@ -56,7 +56,7 @@ index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe6
+ for (int i1 = 0; i1 < l; ++i1) {
+ EntityComplexPart entitycomplexpart = aentitycomplexpart[i1];
+
+ if (entitycomplexpart != entity && entitycomplexpart.getBoundingBox().intersects(axisalignedbb)) {
+ if (entitycomplexpart != entity && entitycomplexpart.getBoundingBox().intersects(axisalignedbb) && (predicate == null || predicate.test(entitycomplexpart))) {
+ into.add(entitycomplexpart);
+ }
+ }
@ -69,7 +69,7 @@ index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe6
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, BiomeStorage biomestorage, ChunkConverter chunkconverter, TickList<Block> ticklist, TickList<FluidType> ticklist1, long i, @Nullable ChunkSection[] achunksection, @Nullable Consumer<Chunk> consumer) {
this.sections = new ChunkSection[16];
this.e = Maps.newHashMap();
@@ -545,7 +593,7 @@ public class Chunk implements IChunkAccess {
@@ -546,7 +594,7 @@ public class Chunk implements IChunkAccess {
entity.chunkY = k;
entity.chunkZ = this.loc.z;
this.entities.add(entity); // Paper - per chunk entity list
@ -78,7 +78,7 @@ index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe6
// Paper start
if (entity instanceof EntityItem) {
itemCounts[k]++;
@@ -582,7 +630,7 @@ public class Chunk implements IChunkAccess {
@@ -583,7 +631,7 @@ public class Chunk implements IChunkAccess {
entity.entitySlice = null;
entity.inChunk = false;
}
@ -88,10 +88,10 @@ index 74d110874d0a9c1603d6b2d77753179ba49811ea..cf86ce24e12068d6ff7ae43cb1fd6fe6
}
if (entity instanceof EntityItem) {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 7fb34a86dc35cb4bf51e1ce5220e56642096fece..f20f798f0f7bb765ffdab8672f4bf77a60fa52d2 100644
index 8b7f59577416468a89a99954e2a00b3704ffbd40..bf01f4ef7831491ecb29b86f6d459d1e3a767554 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -211,6 +211,40 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -212,6 +212,40 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// CraftBukkit end
@ -106,9 +106,9 @@ index 7fb34a86dc35cb4bf51e1ce5220e56642096fece..f20f798f0f7bb765ffdab8672f4bf77a
+ Boolean hardCollides = cachedOverrides.get(this.getClass());
+ if (hardCollides == null) {
+ try {
+ Object getHardCollisionBoxMethod = Entity.class.getMethod("au");
+ Object getHardCollisionBoxMethod = Entity.class.getMethod("ay");
+ Object getHardCollisionBoxEntityMethod = Entity.class.getMethod("j", Entity.class);
+ if (!this.getClass().getMethod("au").equals(getHardCollisionBoxMethod)) {
+ if (!this.getClass().getMethod("ay").equals(getHardCollisionBoxMethod)) {
+ hardCollides = Boolean.TRUE;
+ } else if (!this.getClass().getMethod("j", Entity.class).equals(getHardCollisionBoxEntityMethod)) {
+ hardCollides = Boolean.TRUE;
@ -133,61 +133,73 @@ index 7fb34a86dc35cb4bf51e1ce5220e56642096fece..f20f798f0f7bb765ffdab8672f4bf77a
this.id = Entity.entityCount.incrementAndGet();
this.passengers = Lists.newArrayList();
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index 5bf99e0028b886a6ba1d2f39f8dc4cd3c9aa0943..aecdaacfc7da560759bc513680d76f55820d5046 100644
index ac12d782539a5f502e8996eb39eb2ddbab46f756..43e3755f0fa75b5f72ec620f3f6647ef6bce38c5 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -847,6 +847,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
@@ -844,6 +844,7 @@ public class EntityEnderDragon extends EntityInsentient implements IMonster {
@Override
public void checkDespawn() {}
+ public final EntityComplexPart[] getComplexParts() { return this.eo(); } // Paper - OBFHELPER
public EntityComplexPart[] eo() {
+ public final EntityComplexPart[] getComplexParts() { return this.eK(); } // Paper - OBFHELPER
public EntityComplexPart[] eK() {
return this.children;
}
diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
index 4157e50e4d99c029759bffcb48a8d645487554c8..5135308fb6137a34ed6fd061f0a210de6de4e81c 100644
index 74d4c28246e7db850e6d993e07a84b2a6ca24ce2..24705eef5514bfb078bea6f87e5457e73cee2d5e 100644
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
@@ -42,17 +42,26 @@ public interface IEntityAccess {
return this.b(oclass, axisalignedbb, IEntitySelector.f);
@@ -53,24 +53,36 @@ public interface IEntityAccess {
return this.b(oclass, axisalignedbb, IEntitySelector.g);
}
+ // Paper start - optimise hard collision
+ /**
+ * Not guaranteed to only return hard colliding entites
+ */
+ default List<Entity> getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb) {
+ default List<Entity> getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<Entity> predicate) {
+ return this.getEntities(entity, axisalignedbb);
+ }
+ // Paper end - optimise hard collision
+
default Stream<VoxelShape> b(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Set<Entity> set) {
default Stream<VoxelShape> c(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<Entity> predicate) {
if (axisalignedbb.a() < 1.0E-7D) {
return Stream.empty();
} else {
AxisAlignedBB axisalignedbb1 = axisalignedbb.g(1.0E-7D);
- Stream<AxisAlignedBB> stream = this.getEntities(entity, axisalignedbb1).stream().filter((entity1) -> { // Paper - decompile fix
+ Stream<AxisAlignedBB> stream = ((entity != null && entity.hardCollides()) ? this.getEntities(entity, axisalignedbb) : this.getHardCollidingEntities(entity, axisalignedbb1)).stream().filter((entity1) -> { // Paper - decompile fix // Paper - optimise hard collision
return !set.contains(entity1);
}).filter((entity1) -> {
return entity == null || !entity.isSameVehicle(entity1);
}).flatMap((entity1) -> {
- return Stream.of(entity1.au(), entity == null ? null : entity.j(entity1));
+ return Stream.of(entity1.au(), entity == null ? null : entity.j(entity1)); // Paper - optimise hard collision - diff on change, these are the methods that only hard colliding entities override
}).filter(Objects::nonNull);
return stream.filter(axisalignedbb1::c).map(VoxelShapes::a);
- return this.getEntities(entity, axisalignedbb1, predicate.and((entity1) -> {
+ // Paper start
+ Predicate<Entity> effectivePredicate = predicate.and((entity1) -> {
return entity == null || !entity.isSameVehicle(entity1);
- })).stream().flatMap((entity1) -> {
+ });
+
+ return ((entity != null && entity.hardCollides()) ? this.getEntities(entity, axisalignedbb, effectivePredicate) : this.getHardCollidingEntities(entity, axisalignedbb1, effectivePredicate)).stream().flatMap((entity1) -> {
if (entity != null) {
- AxisAlignedBB axisalignedbb2 = entity.j(entity1);
+ AxisAlignedBB axisalignedbb2 = entity.j(entity1); // Paper - diff on change, hard collision box method
if (axisalignedbb2 != null && axisalignedbb2.c(axisalignedbb1)) {
return Stream.of(entity1.ay(), axisalignedbb2);
}
}
- return Stream.of(entity1.ay());
+ return Stream.of(entity1.ay()); // Paper - diff on change, hard collision box method
}).filter(Objects::nonNull).map(VoxelShapes::a);
}
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index bdd0908adb7d3cd5370b43be196c975e6c48a70f..1c7955d3ae7ddd1c2d924cec20a91202cf090f40 100644
index 91294ff7e86a997cc81f287517b2ff5529fc0a91..cafa47b90320249f84cd1cc4aca1908a4982bffb 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1179,6 +1179,32 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -1105,6 +1105,32 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
return this.getChunkAt(i, j, ChunkStatus.FULL, false);
}
+ // Paper start - optimise hard collision handling
+ @Override
+ public List<Entity> getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb) {
+ public List<Entity> getHardCollidingEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<Entity> predicate) {
+ // copied from below
+ List<Entity> list = Lists.newArrayList();
+ int i = MathHelper.floor((axisalignedbb.minX - 2.0D) / 16.0D);
@ -195,14 +207,14 @@ index bdd0908adb7d3cd5370b43be196c975e6c48a70f..1c7955d3ae7ddd1c2d924cec20a91202
+ int k = MathHelper.floor((axisalignedbb.minZ - 2.0D) / 16.0D);
+ int l = MathHelper.floor((axisalignedbb.maxZ + 2.0D) / 16.0D);
+
+ ChunkProviderServer chunkProvider = ((ChunkProviderServer)this.chunkProvider);
+ ChunkProviderServer chunkProvider = ((WorldServer)this).getChunkProvider();
+
+ for (int i1 = i; i1 <= j; ++i1) {
+ for (int j1 = k; j1 <= l; ++j1) {
+ Chunk chunk = chunkProvider.getChunkAtIfLoadedMainThread(i1, j1);
+
+ if (chunk != null) {
+ chunk.getHardCollidingEntities(entity, axisalignedbb, list);
+ chunk.getHardCollidingEntities(entity, axisalignedbb, list, predicate);
+ }
+ }
+ }

View File

@ -9,16 +9,16 @@ so inline where possible, and avoid the abstraction of the
Either class.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index b6146330a55665a0365ff7474f1843766e0c0ce1..695d12e1942018be6a9e8c999ba6071b9f778568 100644
index d1f832db33f21f8ba910d2c0c163af78718d298f..91755cd7313d87bae85584dff140acbc6467428f 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -617,27 +617,37 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -618,21 +618,29 @@ public class ChunkProviderServer extends IChunkProvider {
public final boolean isInEntityTickingChunk(Entity entity) { return this.a(entity); } // Paper - OBFHELPER
@Override public boolean a(Entity entity) {
- long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
-
- return this.a(i, PlayerChunk::b);
- return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
+ // Paper start - optimize is ticking ready type functions
+ // entity ticking
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(entity));
@ -28,7 +28,7 @@ index b6146330a55665a0365ff7474f1843766e0c0ce1..695d12e1942018be6a9e8c999ba6071b
public final boolean isEntityTickingChunk(ChunkCoordIntPair chunkcoordintpair) { return this.a(chunkcoordintpair); } // Paper - OBFHELPER
@Override public boolean a(ChunkCoordIntPair chunkcoordintpair) {
- return this.a(chunkcoordintpair.pair(), PlayerChunk::b);
- return this.a(chunkcoordintpair.pair(), (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
+ // Paper start - optimize is ticking ready type functions
+ // is entity ticking ready
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(chunkcoordintpair));
@ -40,7 +40,7 @@ index b6146330a55665a0365ff7474f1843766e0c0ce1..695d12e1942018be6a9e8c999ba6071b
public boolean a(BlockPosition blockposition) {
- long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);
-
- return this.a(i, PlayerChunk::a);
- return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error
+ // Paper start - optimize is ticking ready type functions
+ // is ticking ready
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(blockposition));
@ -48,15 +48,4 @@ index b6146330a55665a0365ff7474f1843766e0c0ce1..695d12e1942018be6a9e8c999ba6071b
+ // Paper end - optimize is ticking ready type functions
}
public boolean b(Entity entity) {
- long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
-
- return this.a(i, PlayerChunk::c);
+ // Paper start - optimize is ticking ready type functions
+ // is full chunk ready
+ PlayerChunk playerChunk = this.getChunk(MCUtil.getCoordinateKey(entity));
+ return playerChunk != null && playerChunk.isFullChunkReady();
+ // Paper end - optimize is ticking ready type functions
}
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {

View File

@ -6,19 +6,19 @@ Subject: [PATCH] Restrict vanilla teleport command to valid locations
Fixes GH-3165, GH-3575
diff --git a/src/main/java/net/minecraft/server/CommandTeleport.java b/src/main/java/net/minecraft/server/CommandTeleport.java
index 3060b4f68b13abe05d31b85bb49690a0b476939f..cc00cd0b44b23c76c627b5d51362a22273f7bac4 100644
index 75c2c7f191f0a9704017ff08766cc920fa8a7270..203373c3bb97d331ff6c6b9e21ae4cbc8b173fe6 100644
--- a/src/main/java/net/minecraft/server/CommandTeleport.java
+++ b/src/main/java/net/minecraft/server/CommandTeleport.java
@@ -116,6 +116,12 @@ public class CommandTeleport {
}
@@ -119,6 +119,12 @@ public class CommandTeleport {
private static void a(CommandListenerWrapper commandlistenerwrapper, Entity entity, WorldServer worldserver, double d0, double d1, double d2, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, float f, float f1, @Nullable CommandTeleport.a commandteleport_a) {
private static void a(CommandListenerWrapper commandlistenerwrapper, Entity entity, WorldServer worldserver, double d0, double d1, double d2, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, float f, float f1, @Nullable CommandTeleport.a commandteleport_a) throws CommandSyntaxException {
BlockPosition blockposition = new BlockPosition(d0, d1, d2);
+ // Paper start - Don't allow teleport command to invalid locations
+ if (d0 <= -30000000 || d2 <= -30000000 || d0 > 30000000 || d2 > 30000000 || d1 > 30000000 || d1 <= -30000000) { // Copy/pasta from BaseBlockPosition#isValidLocation
+ org.bukkit.Bukkit.getLogger().warning("Refused to teleport " + entity.getName() + " to " + d0 + ", " + d1 + ", " + d2);
+ return;
+ }
+ // Paper end
if (entity instanceof EntityPlayer) {
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(d0, d1, d2));
if (!World.k(blockposition)) {
throw CommandTeleport.a.create();

View File

@ -85,20 +85,20 @@ index 0000000000000000000000000000000000000000..b6f4400df3d8ec7e06a996de54f8cabb
+ }
+}
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index c4d433430503e844121f1917c6caf05823af0a34..7df24be46e4471ae0ddad5cded5eef4937fd37a3 100644
index 0bf9de73e800cbbe0553bf491cb1546bb1677b63..e6bf2b5268c03edfb3205f13a963ec1d9388526c 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -35,7 +35,7 @@ public abstract class EntityHuman extends EntityLiving {
private static final Map<EntityPose, EntitySize> b = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.bp).put(EntityPose.SLEEPING, EntityHuman.ap).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
@@ -36,7 +36,7 @@ public abstract class EntityHuman extends EntityLiving {
private static final Map<EntityPose, EntitySize> b = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.bo).put(EntityPose.SLEEPING, EntityHuman.ao).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
private static final DataWatcherObject<Float> c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
private static final DataWatcherObject<Integer> d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
- protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
+ protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); public static DataWatcherObject<Byte> getSkinPartsWatcher() { return bq; } // Paper - OBFHELPER
protected static final DataWatcherObject<Byte> br = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
- protected static final DataWatcherObject<Byte> bp = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
+ protected static final DataWatcherObject<Byte> bp = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a); public static DataWatcherObject<Byte> getSkinPartsWatcher() { return bp; } // Paper - OBFHELPER
protected static final DataWatcherObject<Byte> bq = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
protected static final DataWatcherObject<NBTTagCompound> br = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
protected static final DataWatcherObject<NBTTagCompound> bs = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
protected static final DataWatcherObject<NBTTagCompound> bt = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 49fe2d1a0376e5aa8a5ec00d010e6c834633e7b7..64e00275edf38739fe6e2d79dbcb93243e765678 100644
index 97f03d09d8e7f38b00f407b1268e30a0729d1811..0683e163fa6081d4382b3f4635bc52b646b9dd54 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -2,6 +2,7 @@ package net.minecraft.server;
@ -108,35 +108,39 @@ index 49fe2d1a0376e5aa8a5ec00d010e6c834633e7b7..64e00275edf38739fe6e2d79dbcb9324
+import com.destroystokyo.paper.event.player.PlayerClientOptionsChangeEvent; // Paper
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Either;
import io.netty.util.concurrent.Future;
import com.mojang.serialization.DataResult;
@@ -59,7 +60,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public int lastSentExp = -99999999;
public int invulnerableTicks = 60;
private EnumChatVisibility ch;
- private boolean ci = true;
+ private boolean ci = true; public boolean hasChatColorsEnabled() { return this.ci; } // Paper - OBFHELPER
private long cj = SystemUtils.getMonotonicMillis();
private EnumChatVisibility cf;
- private boolean cg = true;
+ private boolean cg = true; public boolean hasChatColorsEnabled() { return this.cg; } // Paper - OBFHELPER
private long ch = SystemUtils.getMonotonicMillis();
private Entity spectatedEntity;
public boolean worldChangeInvuln;
@@ -1573,6 +1574,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
@@ -1681,6 +1682,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public String locale = null; // CraftBukkit - lowercase // Paper - default to null
public void a(PacketPlayInSettings packetplayinsettings) {
+ new PlayerClientOptionsChangeEvent(getBukkitEntity(), packetplayinsettings.getLocale(), packetplayinsettings.viewDistance, com.destroystokyo.paper.ClientOption.ChatVisibility.valueOf(packetplayinsettings.getChatVisibility().name()), packetplayinsettings.hasChatColorsEnabled(), new com.destroystokyo.paper.PaperSkinParts(packetplayinsettings.getSkinParts()), packetplayinsettings.getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT).callEvent(); // Paper - settings event
// CraftBukkit start
if (getMainHand() != packetplayinsettings.getMainHand()) {
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainHand() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT);
diff --git a/src/main/java/net/minecraft/server/PacketPlayInSettings.java b/src/main/java/net/minecraft/server/PacketPlayInSettings.java
index 8faebf9efed7c3529b151fddf8246e8c77a8b693..4da637138190c9b749d986ac32dddc051931d58f 100644
index dbc3552d50c4129e1844c8a379ab5ba396645f52..be97a0b01b3272e01ece90172f283e3feca10d14 100644
--- a/src/main/java/net/minecraft/server/PacketPlayInSettings.java
+++ b/src/main/java/net/minecraft/server/PacketPlayInSettings.java
@@ -37,18 +37,22 @@ public class PacketPlayInSettings implements Packet<PacketListenerPlayIn> {
packetlistenerplayin.a(this);
}
@@ -4,7 +4,7 @@ import java.io.IOException;
+ public String getLocale() { return b(); } // Paper - OBFHELPER
public String b() {
return this.a;
public class PacketPlayInSettings implements Packet<PacketListenerPlayIn> {
- public String locale;
+ public String locale; public String getLocale() { return this.locale; } // Paper - OBFHELPER
public int viewDistance;
private EnumChatVisibility c;
private boolean d;
@@ -37,14 +37,17 @@ public class PacketPlayInSettings implements Packet<PacketListenerPlayIn> {
packetlistenerplayin.a(this);
}
+ public EnumChatVisibility getChatVisibility() { return d(); } // Paper - OBFHELPER
@ -154,7 +158,7 @@ index 8faebf9efed7c3529b151fddf8246e8c77a8b693..4da637138190c9b749d986ac32dddc05
return this.e;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 71d5ebe8c6ea2d52886c28e0fdc55e5993238709..bd4d5184b607db09c8ff2687ceaf47fb94368a28 100644
index 4bef2d3c8318da57e5721d728953f8d5ac6b0ff6..b28e5abea5d2585d9beff574dd82651e7d20275b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1,5 +1,8 @@
@ -166,15 +170,7 @@ index 71d5ebe8c6ea2d52886c28e0fdc55e5993238709..bd4d5184b607db09c8ff2687ceaf47fb
import com.destroystokyo.paper.Title;
import com.destroystokyo.paper.profile.CraftPlayerProfile;
import com.destroystokyo.paper.profile.PlayerProfile;
@@ -36,6 +39,7 @@ import net.minecraft.server.BlockPosition;
import net.minecraft.server.ChatComponentText;
import net.minecraft.server.Container;
import net.minecraft.server.Entity;
+import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EnumColor;
@@ -1968,6 +1972,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -2008,6 +2011,24 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void setViewDistance(int viewDistance) {
throw new NotImplementedException("Per-Player View Distance APIs need further understanding to properly implement (There are per world view distances though!)"); // TODO
}

View File

@ -25,10 +25,10 @@ This successfully fixed a reoccurring and highly reproduceable crash
for heightmaps.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 695d12e1942018be6a9e8c999ba6071b9f778568..665d83042dab467cddf315fade883fd55ffc8bfd 100644
index 91755cd7313d87bae85584dff140acbc6467428f..0080a0cbe58d1a81c434ef97659428c8bf1ec290 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -1050,6 +1050,7 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -994,6 +994,7 @@ public class ChunkProviderServer extends IChunkProvider {
return super.executeNext() || execChunkTask; // Paper
}
} finally {
@ -37,10 +37,10 @@ index 695d12e1942018be6a9e8c999ba6071b9f778568..665d83042dab467cddf315fade883fd5
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 6bdaaf8daef15cd7c11943254e412e0e2d2898fb..48f858388029e77f710365e73905f8570f1103f5 100644
index ba100e5c96d5279ab5f30c6e10f3cbd7b6b4443e..a44702e805c24fba63ef17534032fc29fb4a2c3f 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -131,6 +131,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -133,6 +133,8 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
};
// CraftBukkit end
@ -49,12 +49,12 @@ index 6bdaaf8daef15cd7c11943254e412e0e2d2898fb..48f858388029e77f710365e73905f857
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<EntityPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@@ -987,7 +989,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -995,7 +997,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return Either.left(chunk);
});
}, (runnable) -> {
- this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, () -> PlayerChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // CraftBukkit - decompile error // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
- this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable));
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, () -> PlayerChunkMap.this.chunkLoadConversionCallbackExecutor.execute(runnable))); // Paper - delay running Chunk post processing until outside of the sorter to prevent a deadlock scenario when post processing causes another chunk request.
});
completablefuture1.thenAcceptAsync((either) -> {

View File

@ -7,11 +7,11 @@ Subject: [PATCH] Don't crash if player is attempted to be removed from
I suspect it deals with teleporting as it uses players current x/y/z
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index 83da76fdc495225b563cecbdb71422aec2b534f3..10e385eb556faff954df28ed0b3ddaceac2b8baa 100644
index d5b50a6a6816421c0443ae36213932b16ed5c797..32d3887e2542c4ebba4a7498167fbe4b497a71ce 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -238,8 +238,8 @@ public abstract class ChunkMapDistance {
long i = sectionposition.u().pair();
long i = sectionposition.r().pair();
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.c.get(i);
- objectset.remove(entityplayer);
@ -19,5 +19,5 @@ index 83da76fdc495225b563cecbdb71422aec2b534f3..10e385eb556faff954df28ed0b3ddace
+ if (objectset != null) objectset.remove(entityplayer); // Paper - some state corruption happens here, don't crash, clean up gracefully.
+ if (objectset == null || objectset.isEmpty()) { // Paper
this.c.remove(i);
this.f.b(i, Integer.MAX_VALUE, false);
this.g.b(i, Integer.MAX_VALUE, false);
this.f.update(i, Integer.MAX_VALUE, false);
this.g.update(i, Integer.MAX_VALUE, false);

View File

@ -5,15 +5,15 @@ Subject: [PATCH] Broadcast join message to console
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 4d4912a38ad0bf38a42ac8fed0ad4c1eecaf63a5..3d6509786cba4307898c4485f6865e3f55ebb13b 100644
index a212c3bb7c80948cc329f21c3916f52ec02e06bf..769f8c147c8104ab21a33abb1471f76f3729f2b2 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -188,9 +188,9 @@ public abstract class PlayerList {
@@ -212,9 +212,9 @@ public abstract class PlayerList {
joinMessage = playerJoinEvent.getJoinMessage();
if (joinMessage != null && joinMessage.length() > 0) {
- for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
- server.getPlayerList().sendAll(new PacketPlayOutChat(line));
- server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b));
- }
+ // Paper start - Removed sendAll for loop and broadcasted to console also
+ server.getPlayerList().sendMessage(CraftChatMessage.fromString(joinMessage));

View File

@ -28,10 +28,10 @@ receives a deterministic result, and should no longer require 1 tick
delays anymore.
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 64e00275edf38739fe6e2d79dbcb93243e765678..a87aa07b17205b52e85f7d082fa4d5169771cbb4 100644
index 0683e163fa6081d4382b3f4635bc52b646b9dd54..b3429f001397ed7cbcdfeb12c8f47e5face209a3 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -100,6 +100,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -104,6 +104,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public double maxHealthCache;
public boolean joining = true;
public boolean sentListPacket = false;
@ -40,22 +40,22 @@ index 64e00275edf38739fe6e2d79dbcb93243e765678..a87aa07b17205b52e85f7d082fa4d516
// CraftBukkit end
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 48f858388029e77f710365e73905f8570f1103f5..2caa53a7e143aae32918ecbefc1bdadcab8d61ed 100644
index a44702e805c24fba63ef17534032fc29fb4a2c3f..ee38ab87ba477e8bf5b739759371439b299f21f3 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -1503,6 +1503,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1534,6 +1534,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
.printStackTrace();
return;
}
+ if (entity instanceof EntityPlayer && ((EntityPlayer) entity).supressTrackerForLogin) return; // Delay adding to tracker until after list packets
// Paper end
if (!(entity instanceof EntityComplexPart)) {
if (!(entity instanceof EntityLightning)) {
EntityTypes<?> entitytypes = entity.getEntityType();
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 3d6509786cba4307898c4485f6865e3f55ebb13b..d9fff5836e6f4b8a14fea1db66c5a89b43b2b952 100644
index 769f8c147c8104ab21a33abb1471f76f3729f2b2..f8c12055330794039347336fe2ab9ab52f413323 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -177,6 +177,12 @@ public abstract class PlayerList {
@@ -201,6 +201,12 @@ public abstract class PlayerList {
this.j.put(entityplayer.getUniqueID(), entityplayer);
// this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below
@ -68,7 +68,7 @@ index 3d6509786cba4307898c4485f6865e3f55ebb13b..d9fff5836e6f4b8a14fea1db66c5a89b
// CraftBukkit start
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
cserver.getPluginManager().callEvent(playerJoinEvent);
@@ -211,6 +217,8 @@ public abstract class PlayerList {
@@ -235,6 +241,8 @@ public abstract class PlayerList {
entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
}
entityplayer.sentListPacket = true;
@ -77,7 +77,7 @@ index 3d6509786cba4307898c4485f6865e3f55ebb13b..d9fff5836e6f4b8a14fea1db66c5a89b
// CraftBukkit end
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
@@ -236,6 +244,11 @@ public abstract class PlayerList {
@@ -260,6 +268,11 @@ public abstract class PlayerList {
playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobeffect));
}
@ -89,7 +89,7 @@ index 3d6509786cba4307898c4485f6865e3f55ebb13b..d9fff5836e6f4b8a14fea1db66c5a89b
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
// CraftBukkit start
@@ -277,6 +290,10 @@ public abstract class PlayerList {
@@ -308,6 +321,10 @@ public abstract class PlayerList {
}
}

View File

@ -4,32 +4,45 @@ Date: Sun, 19 Apr 2020 04:28:29 -0400
Subject: [PATCH] Load Chunks for Login Asynchronously
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 0080a0cbe58d1a81c434ef97659428c8bf1ec290..eebd4c50a7324250d3ebe7060739a71af4243f72 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -604,7 +604,7 @@ public class ChunkProviderServer extends IChunkProvider {
return this.serverThreadQueue.executeNext();
}
- private boolean tickDistanceManager() {
+ public boolean tickDistanceManager() { // Paper - private -> public
boolean flag = this.chunkMapDistance.a(this.playerChunkMap);
boolean flag1 = this.playerChunkMap.b();
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index f20f798f0f7bb765ffdab8672f4bf77a60fa52d2..9eab570e48817e18d10ddde95b3f80f7e4ea4766 100644
index bf01f4ef7831491ecb29b86f6d459d1e3a767554..26cfb843fd54de475190b793d9a206d798d54268 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1384,7 +1384,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -1327,7 +1327,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
this.pitch = MathHelper.a(f1, -90.0F, 90.0F) % 360.0F;
this.lastYaw = this.yaw;
this.lastPitch = this.pitch;
- world.getChunkAt((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4); // CraftBukkit
+ if (valid) world.getChunkAt((int) Math.floor(this.locX) >> 4, (int) Math.floor(this.locZ) >> 4); // CraftBukkit // Paper
- world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit
+ if (valid) world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit // Paper
}
public void setPositionRotation(BlockPosition blockposition, float f, float f1) {
public void c(Vec3D vec3d) {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index a87aa07b17205b52e85f7d082fa4d5169771cbb4..79c2187b7383336e7574709e6d4ad805e557976f 100644
index b3429f001397ed7cbcdfeb12c8f47e5face209a3..c26236ff4ab56506c51d4e215cfe4fb76bed26ed 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -43,6 +43,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
private static final Logger LOGGER = LogManager.getLogger();
public String locale = null; // CraftBukkit - lowercase // Paper - default to null
public PlayerConnection playerConnection;
+ public NetworkManager networkManager; // Paper
public final MinecraftServer server;
public final PlayerInteractManager playerInteractManager;
public final Deque<Integer> removeQueue = new ArrayDeque<>(); // Paper
@@ -101,6 +102,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -105,6 +106,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public boolean joining = true;
public boolean sentListPacket = false;
public boolean supressTrackerForLogin = false; // Paper
@ -38,29 +51,29 @@ index a87aa07b17205b52e85f7d082fa4d5169771cbb4..79c2187b7383336e7574709e6d4ad805
// CraftBukkit end
public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
index f1222fcb2bd52b8781d0f92c94e1472fa7b1e493..28f48f22522ef8c3c66381abcf017f0859b45290 100644
index 8c5c57ecd98a286a4992a36effae95596b37fc8a..28a3040ac9cf705d05ec459a29cd7147770389be 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -66,7 +66,7 @@ public class LoginListener implements PacketLoginInListener {
@@ -65,7 +65,7 @@ public class LoginListener implements PacketLoginInListener {
}
// Paper end
} else if (this.g == LoginListener.EnumProtocolState.DELAY_ACCEPT) {
- EntityPlayer entityplayer = this.server.getPlayerList().a(this.i.getId());
- EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.i.getId());
+ EntityPlayer entityplayer = this.server.getPlayerList().getActivePlayer(this.i.getId()); // Paper
if (entityplayer == null) {
this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
@@ -165,7 +165,7 @@ public class LoginListener implements PacketLoginInListener {
@@ -164,7 +164,7 @@ public class LoginListener implements PacketLoginInListener {
}
this.networkManager.sendPacket(new PacketLoginOutSuccess(this.i));
- EntityPlayer entityplayer = this.server.getPlayerList().a(this.i.getId());
- EntityPlayer entityplayer = this.server.getPlayerList().getPlayer(this.i.getId());
+ EntityPlayer entityplayer = this.server.getPlayerList().getActivePlayer(this.i.getId()); // Paper
if (entityplayer != null) {
this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT;
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 4be93d12dbe12511628fd97af52d5cf78da17eaa..6dd4303c1c211ac4b0bb542ea96cc150581bf8c1 100644
index 651ecb50c2b06ca81cb9a2286d77fd41a17b5140..1099a46aa05f12572100994ea251f0d55c66ef80 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -69,6 +69,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
@ -97,10 +110,10 @@ index 4be93d12dbe12511628fd97af52d5cf78da17eaa..6dd4303c1c211ac4b0bb542ea96cc150
this.minecraftServer.getMethodProfiler().enter("keepAlive");
// Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9f79203a8 100644
index f8c12055330794039347336fe2ab9ab52f413323..e0a95fde93d4a2339831cb8ea0918174e9914e34 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -16,6 +16,7 @@ import java.util.Map;
@@ -18,6 +18,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
@ -108,7 +121,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -52,11 +53,12 @@ public abstract class PlayerList {
@@ -54,11 +55,12 @@ public abstract class PlayerList {
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer server;
public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
@ -122,7 +135,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
// CraftBukkit start
// private final Map<UUID, ServerStatisticManager> o;
// private final Map<UUID, AdvancementDataPlayer> p;
@@ -94,6 +96,11 @@ public abstract class PlayerList {
@@ -97,6 +99,11 @@ public abstract class PlayerList {
}
public void a(NetworkManager networkmanager, EntityPlayer entityplayer) {
@ -134,21 +147,22 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
entityplayer.loginTime = System.currentTimeMillis(); // Paper
GameProfile gameprofile = entityplayer.getProfile();
UserCache usercache = this.server.getUserCache();
@@ -107,7 +114,7 @@ public abstract class PlayerList {
@@ -110,7 +117,7 @@ public abstract class PlayerList {
if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {
NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
- }
+ }String lastKnownName = s; // Paper
if (nbttagcompound == null) entityplayer.moveToSpawn(worldserver); // Paper - only move to spawn on first login, otherwise, stay where you are....
// CraftBukkit end
@@ -160,6 +167,52 @@ public abstract class PlayerList {
if (nbttagcompound != null) {
@@ -184,6 +191,53 @@ public abstract class PlayerList {
entityplayer.B().a(entityplayer);
this.sendScoreboard(worldserver.getScoreboard(), entityplayer);
this.sendScoreboard(worldserver1.getScoreboard(), entityplayer);
this.server.invalidatePingSample();
+ // Paper start - async load spawn in chunk
+ WorldServer finalWorldserver = worldserver;
+ WorldServer finalWorldserver1 = worldserver1;
+ int chunkX = loc.getBlockX() >> 4;
+ int chunkZ = loc.getBlockZ() >> 4;
+ final ChunkCoordIntPair pos = new ChunkCoordIntPair(chunkX, chunkZ);
@ -165,7 +179,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
+ }).thenAccept(chunk -> {
+ playerconnection.playerJoinReady = () -> {
+ postChunkLoadJoin(
+ entityplayer, finalWorldserver, networkmanager, playerconnection,
+ entityplayer, finalWorldserver, finalWorldserver1, networkmanager, playerconnection,
+ nbttagcompound, networkmanager.getSocketAddress().toString(), lastKnownName
+ );
+ //playerChunkMap.chunkDistanceManager.removeTicketAtLevel(TicketType.LOGIN, pos, 31, pos.pair());
@ -186,7 +200,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
+ });
+ }
+
+ private void postChunkLoadJoin(EntityPlayer entityplayer, WorldServer worldserver, NetworkManager networkmanager, PlayerConnection playerconnection, NBTTagCompound nbttagcompound, String s1, String s) {
+ private void postChunkLoadJoin(EntityPlayer entityplayer, WorldServer worldserver, WorldServer worldserver1, NetworkManager networkmanager, PlayerConnection playerconnection, NBTTagCompound nbttagcompound, String s1, String s) {
+ pendingPlayers.remove(entityplayer.getUniqueID(), entityplayer);
+ if (!networkmanager.isConnected()) {
+ return;
@ -196,7 +210,16 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
ChatMessage chatmessage;
if (entityplayer.getProfile().getName().equalsIgnoreCase(s)) {
@@ -218,7 +271,6 @@ public abstract class PlayerList {
@@ -205,7 +259,7 @@ public abstract class PlayerList {
entityplayer.supressTrackerForLogin = true;
worldserver.addPlayerJoin(entityplayer);
this.server.getBossBattleCustomData().a(entityplayer); // see commented out section below worldserver.addPlayerJoin(entityplayer);
- mountSavedVehicle(entityplayer, worldserver, nbttagcompound);
+ mountSavedVehicle(entityplayer, worldserver, worldserver1, nbttagcompound);
// Paper end
// CraftBukkit start
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
@@ -242,7 +296,6 @@ public abstract class PlayerList {
}
entityplayer.sentListPacket = true;
entityplayer.supressTrackerForLogin = false; // Paper
@ -204,15 +227,19 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
// CraftBukkit end
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
@@ -245,6 +297,7 @@ public abstract class PlayerList {
@@ -269,9 +322,10 @@ public abstract class PlayerList {
}
// Paper start - move vehicle into method so it can be called above - short circuit around that code
+ ((WorldServer)entityplayer.world).getChunkProvider().playerChunkMap.addEntity(entityplayer); // track entity now
onPlayerJoinFinish(entityplayer, worldserver, s1);
}
private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver, NBTTagCompound nbttagcompound) {
@@ -390,6 +443,7 @@ public abstract class PlayerList {
- private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver, NBTTagCompound nbttagcompound) {
+ private void mountSavedVehicle(EntityPlayer entityplayer, WorldServer worldserver, WorldServer worldserver1, NBTTagCompound nbttagcompound) {
// Paper end
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
@@ -420,6 +474,7 @@ public abstract class PlayerList {
protected void savePlayerFile(EntityPlayer entityplayer) {
if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
@ -220,7 +247,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
this.playerFileData.save(entityplayer);
ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
@@ -414,7 +468,7 @@ public abstract class PlayerList {
@@ -444,7 +499,7 @@ public abstract class PlayerList {
entityplayer.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game");
@ -229,7 +256,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
if (server.isMainThread()) entityplayer.playerTick(); // SPIGOT-924 // Paper - don't tick during emergency shutdowns (Watchdog)
@@ -466,6 +520,13 @@ public abstract class PlayerList {
@@ -497,6 +552,13 @@ public abstract class PlayerList {
// this.p.remove(uuid);
// CraftBukkit end
}
@ -242,8 +269,8 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
+ // Paper end
// CraftBukkit start
// this.sendAll(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
@@ -483,7 +544,7 @@ public abstract class PlayerList {
// this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
@@ -514,7 +576,7 @@ public abstract class PlayerList {
cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
// CraftBukkit end
@ -252,7 +279,7 @@ index d9fff5836e6f4b8a14fea1db66c5a89b43b2b952..628327e1e39299bbe64dff042d0187a9
}
// CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
@@ -502,6 +563,13 @@ public abstract class PlayerList {
@@ -533,6 +595,13 @@ public abstract class PlayerList {
list.add(entityplayer);
}
}

View File

@ -7,21 +7,21 @@ The code following this has better support for null worlds to move
them back to the world spawn.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 9eab570e48817e18d10ddde95b3f80f7e4ea4766..0a7e4449407104fe6c0ff7d00bd1f32eb074e10a 100644
index 26cfb843fd54de475190b793d9a206d798d54268..7aa95b968af810a7bb4d7dedfacc83219f491e05 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1792,9 +1792,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -1755,9 +1755,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
bworld = server.getWorld(worldName);
}
- if (bworld == null) {
- bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(DimensionManager.OVERWORLD).getWorld();
- bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld();
- }
+ // Paper start - Move player to spawn point if spawn in unloaded world
+ // if (bworld == null) {
+ // bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(DimensionManager.OVERWORLD).getWorld();
+ // }
+ // Paper end
+// if (bworld == null) {
+// bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld();
+// }
+ // Paper end - Move player to spawn point if spawn in unloaded world
spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle());
}

View File

@ -5,14 +5,14 @@ Subject: [PATCH] Add PlayerAttackEntityCooldownResetEvent
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index b546537586c3033f696aba9c133490258a9422b2..ab6576f36e7682d5100f4e9358e76426e4a1c525 100644
index cee156e0847af3187de8a7c9bc0791dff3886b15..d4451116215b0a396fc536fac992e962b3e8a100 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -1690,7 +1690,17 @@ public abstract class EntityLiving extends Entity {
@@ -1820,7 +1820,16 @@ public abstract class EntityLiving extends Entity {
EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
if (damagesource.getEntity() instanceof EntityHuman) {
- ((EntityHuman) damagesource.getEntity()).ey(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
- ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
+ // Paper start - PlayerAttackEntityCooldownResetEvent
+ if (damagesource.getEntity() instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) damagesource.getEntity();
@ -23,7 +23,6 @@ index b546537586c3033f696aba9c133490258a9422b2..ab6576f36e7682d5100f4e9358e76426
+ ((EntityHuman) damagesource.getEntity()).resetCooldown();
+ }
+ // Paper end
+
}
if (event.isCancelled()) {
return false;

View File

@ -14,10 +14,10 @@ Use an ArrayDeque to store this Queue
We make sure to also implement a pattern that is recursion safe too.
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 2caa53a7e143aae32918ecbefc1bdadcab8d61ed..3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb 100644
index ee38ab87ba477e8bf5b739759371439b299f21f3..b55c94788014b8085b45082162866f0210191622 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -110,24 +110,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -112,24 +112,32 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public final CallbackExecutor callbackExecutor = new CallbackExecutor();
public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {

View File

@ -6,14 +6,23 @@ Subject: [PATCH] Don't fire BlockFade on worldgen threads
Caused a deadlock
diff --git a/src/main/java/net/minecraft/server/BlockFire.java b/src/main/java/net/minecraft/server/BlockFire.java
index b41de95a6390910ba8bb21bfa12ab61c85900218..9e501514f30de00d68736d9593582a5e7c8b3cff 100644
index 1e6159f211fb445e45bab3ca1a3bf21750928302..70bcf165b187ba5b3d832f6ad2df87cc51e59bea 100644
--- a/src/main/java/net/minecraft/server/BlockFire.java
+++ b/src/main/java/net/minecraft/server/BlockFire.java
@@ -44,6 +44,7 @@ public class BlockFire extends Block {
@@ -35,6 +35,7 @@ public class BlockFire extends BlockFireAbstract {
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
// CraftBukkit start
+ if (!(generatoraccess instanceof WorldServer)) return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a((IBlockAccess) generatoraccess, blockposition).set(BlockFire.AGE, iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); // Paper - don't fire events in world generation
if (!iblockdata.canPlace(generatoraccess, blockposition)) {
+ if (!(generatoraccess instanceof WorldServer)) return this.canPlace(iblockdata, generatoraccess, blockposition) ? (IBlockData) this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData(); // Paper - don't fire events in world generation
if (!this.canPlace(iblockdata, generatoraccess, blockposition)) {
CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
blockState.setData(Blocks.AIR.getBlockData());
@@ -46,7 +47,7 @@ public class BlockFire extends BlockFireAbstract {
return blockState.getHandle();
}
}
- return this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE));
+ return this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)); // Paper - diff on change, see "don't fire events in world generation"
// CraftBukkit end
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add phantom creative and insomniac controls
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index ea5f306ef57fe5958a554f4bdf866a36d2b185e0..9db76eae1649fe2ce0856ff4bdcb15569bf58d93 100644
index e4821d4c23689aaf51b60c66fc1e6bc7a0b02fd5..5785f24b0646f8dbf3fba0bbc3b3e5b93e02f162 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -670,4 +670,11 @@ public class PaperWorldConfig {
@@ -627,4 +627,11 @@ public class PaperWorldConfig {
private void lightQueueSize() {
lightQueueSize = getInt("light-queue-size", lightQueueSize);
}
@ -21,10 +21,10 @@ index ea5f306ef57fe5958a554f4bdf866a36d2b185e0..9db76eae1649fe2ce0856ff4bdcb1556
+ }
}
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
index 90eeddb1af59126ea7ca19c2cc909da72578fb6c..96b4912c4832bee0337d35cb23e574cd02f64c3b 100644
index 47d82722e15c5b91a86af1a09807ccc37a1b37be..3cb78924daa48c3a0a3e5c9c64ef6e726d79a798 100644
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
@@ -232,6 +232,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -225,6 +225,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) {
@ -33,27 +33,27 @@ index 90eeddb1af59126ea7ca19c2cc909da72578fb6c..96b4912c4832bee0337d35cb23e574cd
return true;
}
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
index a2d1ef3602a1c63d106d10140e18dfdb1d490805..1398c47a2f8b183b65f1553c735c3b183a8bfc9c 100644
index 57bc56cffff87d9b1774cec455af8d1651fb882c..a52dd0c021e264a57a62bde27ea9d2a6a97e2335 100644
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
@@ -23,6 +23,7 @@ public final class IEntitySelector {
public static final Predicate<Entity> f = (entity) -> {
@@ -26,6 +26,7 @@ public final class IEntitySelector {
public static final Predicate<Entity> g = (entity) -> {
return !entity.isSpectator();
};
+ public static Predicate<EntityHuman> isInsomniac = (player) -> MathHelper.clamp(((EntityPlayer) player).getStatisticManager().getStatisticValue(StatisticList.CUSTOM.get(StatisticList.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= 72000; // Paper
public static Predicate<Entity> a(double d0, double d1, double d2, double d3) {
double d4 = d3 * d3;
// Paper start
public static final Predicate<Entity> affectsSpawning = (entity) -> {
diff --git a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
index f488c22ed64a9fa1ce7746942b2a9ff4bc296703..0db431cd6add225304af48a73e1aa732b4c3ae58 100644
index 39c5350373f6a5ad30f41e8886573d6b315924c6..bf4fa17101cb8710d8b8ba8ad43f98b6fe154ae1 100644
--- a/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
+++ b/src/main/java/net/minecraft/server/MobSpawnerPhantom.java
@@ -31,7 +31,7 @@ public class MobSpawnerPhantom {
@@ -32,7 +32,7 @@ public class MobSpawnerPhantom implements MobSpawner {
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
- if (!entityhuman.isSpectator()) {
+ if (!entityhuman.isSpectator() && (!worldserver.paperConfig.phantomIgnoreCreative || !entityhuman.isCreative())) { // Paper
BlockPosition blockposition = new BlockPosition(entityhuman);
BlockPosition blockposition = entityhuman.getChunkCoordinates();
if (!worldserver.worldProvider.f() || blockposition.getY() >= worldserver.getSeaLevel() && worldserver.f(blockposition)) {
if (!worldserver.getDimensionManager().hasSkyLight() || blockposition.getY() >= worldserver.getSeaLevel() && worldserver.f(blockposition)) {

View File

@ -16,10 +16,10 @@ So even if something NEW comes up, it would be impossible to drop the
same item twice because the source was destroyed.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 0a7e4449407104fe6c0ff7d00bd1f32eb074e10a..32daf027a3575d73aeabf9db14a2e0c74e4cc7e6 100644
index 7aa95b968af810a7bb4d7dedfacc83219f491e05..b400b04fcb733110150de800927c602180771cec 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1968,11 +1968,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -1911,11 +1911,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
} else {
// CraftBukkit start - Capture drops for death event
if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
@ -34,20 +34,20 @@ index 0a7e4449407104fe6c0ff7d00bd1f32eb074e10a..32daf027a3575d73aeabf9db14a2e0c7
entityitem.defaultPickupDelay();
// CraftBukkit start
@@ -2635,6 +2636,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -2560,6 +2561,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@Nullable
public Entity teleportTo(DimensionManager dimensionmanager, BlockPosition location) {
public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
// CraftBukkit end
+ // Paper start - fix bad state entities causing dupes
+ if (!isAlive() || !valid) {
+ LOGGER.warn("Illegal Entity Teleport " + this + " to " + dimensionmanager + ":" + location, new Throwable());
+ LOGGER.warn("Illegal Entity Teleport " + this + " to " + worldserver + ":" + location, new Throwable());
+ return null;
+ }
+ // Paper end
if (!this.world.isClientSide && !this.dead) {
if (this.world instanceof WorldServer && !this.dead) {
this.world.getMethodProfiler().enter("changeDimension");
MinecraftServer minecraftserver = this.getMinecraftServer();
@@ -2743,7 +2750,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
// CraftBukkit start
@@ -2663,7 +2670,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
entity.bukkitEntity = this.getBukkitEntity();
if (this instanceof EntityInsentient) {
@ -56,7 +56,7 @@ index 0a7e4449407104fe6c0ff7d00bd1f32eb074e10a..32daf027a3575d73aeabf9db14a2e0c7
}
// CraftBukkit end
}
@@ -2760,7 +2767,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -2684,7 +2691,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public boolean canPortal() {
@ -66,7 +66,7 @@ index 0a7e4449407104fe6c0ff7d00bd1f32eb074e10a..32daf027a3575d73aeabf9db14a2e0c7
public float a(Explosion explosion, IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata, Fluid fluid, float f) {
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index 8ad131e4fc20efc61b938a5f6ab64379da23bf0d..d35a0b2d94e4f52c257375c35f55b5a41c9f2c12 100644
index 51e9f4a6e09474a7489d2872a800308ee3f02e46..250bccee4a27801b41c50d59e93396c696ab6974 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -557,7 +557,7 @@ public class EntityArmorStand extends EntityLiving {
@ -75,7 +75,7 @@ index 8ad131e4fc20efc61b938a5f6ab64379da23bf0d..d35a0b2d94e4f52c257375c35f55b5a4
if (!itemstack.isEmpty()) {
- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe
this.handItems.set(i, ItemStack.a);
this.handItems.set(i, ItemStack.b);
}
}
@@ -565,7 +565,7 @@ public class EntityArmorStand extends EntityLiving {
@ -84,14 +84,14 @@ index 8ad131e4fc20efc61b938a5f6ab64379da23bf0d..d35a0b2d94e4f52c257375c35f55b5a4
if (!itemstack.isEmpty()) {
- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe
this.armorItems.set(i, ItemStack.a);
this.armorItems.set(i, ItemStack.b);
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 5d88a48b4c54c4b2c79804557bd36d1a6c686c89..a4cd6c404c2a8d526c4673695aadd001f2b4516f 100644
index d82b57f4078802acd6b4a45e1f46f7ac9c8ba1d6..3c73d81d143ade511a88d2ab46417c7aa09719d8 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -777,7 +777,8 @@ public class CraftEventFactory {
@@ -775,7 +775,8 @@ public class CraftEventFactory {
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;

View File

@ -10,10 +10,10 @@ Adds CommandRegisteredEvent
- Allows manipulating the CommandNode to add more children/metadata for the client
diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java
index 2414b0a552e5d6fb449bca163add7a9bac39e943..2d512aa4f9ab74dfadff748ba6dd72631eda9fe5 100644
index 1229aaf19de60f1e3ce161b5c3b7ef659d14c018..e59151d01b4710b750366a395e1e5d18caa4726f 100644
--- a/src/main/java/net/minecraft/server/CommandDispatcher.java
+++ b/src/main/java/net/minecraft/server/CommandDispatcher.java
@@ -267,6 +267,7 @@ public class CommandDispatcher {
@@ -268,6 +268,7 @@ public class CommandDispatcher {
bukkit.add(node.getName());
}
// Paper start - Async command map building
@ -21,7 +21,7 @@ index 2414b0a552e5d6fb449bca163add7a9bac39e943..2d512aa4f9ab74dfadff748ba6dd7263
MinecraftServer.getServer().execute(() -> {
runSync(entityplayer, bukkit, rootcommandnode);
});
@@ -274,6 +275,7 @@ public class CommandDispatcher {
@@ -275,6 +276,7 @@ public class CommandDispatcher {
private void runSync(EntityPlayer entityplayer, Collection<String> bukkit, RootCommandNode<ICompletionProvider> rootcommandnode) {
// Paper end - Async command map building
@ -30,19 +30,19 @@ index 2414b0a552e5d6fb449bca163add7a9bac39e943..2d512aa4f9ab74dfadff748ba6dd7263
event.getPlayer().getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/CommandListenerWrapper.java b/src/main/java/net/minecraft/server/CommandListenerWrapper.java
index 0b23a0548d52a30c064d624e39a896a9791aab3b..c988c929f1063b417d10d84b0c13127738f63e20 100644
index 4b6f45501106f49f118a93e5027734cdb7ff2727..fa0f247e51c20ea0e3cbaccbc8dbb2a153d6121f 100644
--- a/src/main/java/net/minecraft/server/CommandListenerWrapper.java
+++ b/src/main/java/net/minecraft/server/CommandListenerWrapper.java
@@ -15,7 +15,7 @@ import java.util.function.BinaryOperator;
@@ -16,7 +16,7 @@ import java.util.function.BinaryOperator;
import java.util.stream.Stream;
import javax.annotation.Nullable;
-public class CommandListenerWrapper implements ICompletionProvider {
+public class CommandListenerWrapper implements ICompletionProvider, com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource { // Paper
public static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player", new Object[0]));
public static final SimpleCommandExceptionType b = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.entity", new Object[0]));
@@ -120,6 +120,25 @@ public class CommandListenerWrapper implements ICompletionProvider {
public static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
public static final SimpleCommandExceptionType b = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.entity"));
@@ -121,6 +121,25 @@ public class CommandListenerWrapper implements ICompletionProvider {
return this.g;
}
@ -69,25 +69,25 @@ index 0b23a0548d52a30c064d624e39a896a9791aab3b..c988c929f1063b417d10d84b0c131277
public boolean hasPermission(int i) {
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 08e087d952edfecd73ad698684b71c09dabbac9e..c3a86d3007c2fdc5d45f628226507b4a1c968ad6 100644
index 1099a46aa05f12572100994ea251f0d55c66ef80..37defd033c3377b1166b8e97bbbf9ef1be25a565 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -581,8 +581,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
ParseResults<CommandListenerWrapper> parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener());
@@ -584,8 +584,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
ParseResults<CommandListenerWrapper> parseresults = this.minecraftServer.getCommandDispatcher().a().parse(stringreader, this.player.getCommandListener());
this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
- if (((Suggestions) suggestions).isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestions)); // CraftBukkit - decompile error
+ // Paper start
+ com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent suggestEvent = new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent(this.getPlayer(), suggestions, buffer);
+ suggestEvent.setCancelled(suggestions.isEmpty());
+ if (!suggestEvent.callEvent()) return;
+ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestEvent.getSuggestions())); // CraftBukkit - decompile error // Paper
+ // Paper end
});
}); // Paper - This needs to be on main
this.minecraftServer.getCommandDispatcher().a().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
- if (suggestions.isEmpty()) return; // CraftBukkit - don't send through empty suggestions - prevents [<args>] from showing for plugins with nothing more to offer
- this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestions));
+ // Paper start
+ com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent suggestEvent = new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent(this.getPlayer(), suggestions, buffer);
+ suggestEvent.setCancelled(suggestions.isEmpty());
+ if (!suggestEvent.callEvent()) return;
+ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), (Suggestions) suggestEvent.getSuggestions())); // CraftBukkit - decompile error // Paper
+ // Paper end
});
});
}
@@ -592,7 +596,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
@@ -594,7 +598,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
builder = builder.createOffset(builder.getInput().lastIndexOf(' ') + 1);
completions.forEach(builder::suggest);
@ -99,7 +99,7 @@ index 08e087d952edfecd73ad698684b71c09dabbac9e..c3a86d3007c2fdc5d45f628226507b4a
+ this.networkManager.sendPacket(new PacketPlayOutTabComplete(packetplayintabcomplete.b(), suggestEvent.getSuggestions()));
}
// Paper end - async tab completion
}
diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
index 5f33c9e52ac51486d4b22a6dcbfac7f46e0412bb..e16ecdea7d27424053b3f21378af054b2f808eca 100644
--- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java

View File

@ -5,12 +5,12 @@ Subject: [PATCH] Villager Restocks API
diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java
index b3462576469f67dca618c54bb35fd53454afcd1f..eeb76bc0298711ac3ea24440a172e812925f875e 100644
index 8d3811ead268635c4b728f5c9b8dd6c9b8ec6124..86b75e31ea1ed9deecae9756c6f838c302dd8df6 100644
--- a/src/main/java/net/minecraft/server/EntityVillager.java
+++ b/src/main/java/net/minecraft/server/EntityVillager.java
@@ -992,4 +992,13 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
return optional.isPresent() && optional1.isPresent() ? i - ((MinecraftSerializableLong) optional.get()).a() < 24000L && i - ((MinecraftSerializableLong) optional1.get()).a() < 36000L : false;
return optional.isPresent() ? i - (Long) optional.get() < 24000L : false;
}
+
+ // Paper start

View File

@ -1,47 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <spottedleaf@spottedleaf.dev>
Date: Mon, 6 Apr 2020 18:06:24 -0700
Subject: [PATCH] Remove streams from MinecraftKey
They produce a lot of garbage.
diff --git a/src/main/java/net/minecraft/server/MinecraftKey.java b/src/main/java/net/minecraft/server/MinecraftKey.java
index 2b271d3e509a5450c9136dced3ad4dc4d65af45a..b1beebf0ed5737c04875bf9138624fb2bd5dff27 100644
--- a/src/main/java/net/minecraft/server/MinecraftKey.java
+++ b/src/main/java/net/minecraft/server/MinecraftKey.java
@@ -125,15 +125,29 @@ public class MinecraftKey implements Comparable<MinecraftKey> {
}
private static boolean c(String s) {
- return s.chars().allMatch((i) -> {
- return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 47 || i == 46;
- });
+ // Paper start - remove streams
+ for (int index = 0, len = s.length(); index < len; ++index) {
+ int i = (int)s.charAt(index);
+ boolean condition = i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 47 || i == 46; // this is copied from the replaced code.
+ if (!condition) {
+ return false;
+ }
+ }
+ return true;
+ // Paper end - remove streams
}
private static boolean d(String s) {
- return s.chars().allMatch((i) -> {
- return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
- });
+ // Paper start - remove streams
+ for (int index = 0, len = s.length(); index < len; ++index) {
+ int i = (int)s.charAt(index);
+ boolean condition = i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46; // this is copied from the replaced code.
+ if (!condition) {
+ return false;
+ }
+ }
+ return true;
+ // Paper end - remove streams
}
public static class a implements JsonDeserializer<MinecraftKey>, JsonSerializer<MinecraftKey> {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Validate PickItem Packet and kick for invalid
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index c3a86d3007c2fdc5d45f628226507b4a1c968ad6..a716f25478ba9731b7bb07f5d80c3655c8190e8b 100644
index 37defd033c3377b1166b8e97bbbf9ef1be25a565..64a948510265b881b2aefdfbdb54ec0d413d2766 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -696,7 +696,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
@@ -697,7 +697,14 @@ public class PlayerConnection implements PacketListenerPlayIn {
@Override
public void a(PacketPlayInPickItem packetplayinpickitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinpickitem, this, this.player.getWorldServer());

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Expose game version
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f49193d9d7cd9655fdedf64bebdcf4e1a9b77f2c..1647c09756ed303a3f3e879e877b5b3de639f843 100644
index b0ab57ef2e45394905a29444daea1d7b3e866875..715186249545ab2af5284ef71ab59e5ebccad8e1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -489,6 +489,13 @@ public final class CraftServer implements Server {
@@ -514,6 +514,13 @@ public final class CraftServer implements Server {
return bukkitVersion;
}

View File

@ -13,10 +13,10 @@ it is triggering a massive movement velocity.
This will ensure that the servers position is synchronized anytime player is teleported.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index a716f25478ba9731b7bb07f5d80c3655c8190e8b..1f9d231fb93e30286205f7a0a4c898a0e153bd95 100644
index 64a948510265b881b2aefdfbdb54ec0d413d2766..383a9bdec4d476bbde5a7c63a9915d2ed4c136a4 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -498,6 +498,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
@@ -501,6 +501,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.o = this.teleportPos.x;
this.p = this.teleportPos.y;
this.q = this.teleportPos.z;
@ -24,7 +24,7 @@ index a716f25478ba9731b7bb07f5d80c3655c8190e8b..1f9d231fb93e30286205f7a0a4c898a0
if (this.player.H()) {
this.player.I();
}
@@ -1277,6 +1278,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
@@ -1299,6 +1300,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.A = this.e;
this.player.setLocation(d0, d1, d2, f, f1);

View File

@ -75,7 +75,7 @@ index 71d2ae2a9c5a05351241b5a313e66ca15b0624ef..232b0023773008c19f19ad4658eb40fc
this.b = new IntArrayList(i1);
this.c = new IntArrayList(i1);
diff --git a/src/main/java/net/minecraft/server/VoxelShapes.java b/src/main/java/net/minecraft/server/VoxelShapes.java
index e641d4b8d8b4ac5d539e6d9c0eaf345601e0b499..4b3e632a8944828189bc8a5dada32913c1929286 100644
index 4acde367542247627574fdeb586fb8c9087eef1a..aeee4f11828e54ff9e873e452e19299822b1ec86 100644
--- a/src/main/java/net/minecraft/server/VoxelShapes.java
+++ b/src/main/java/net/minecraft/server/VoxelShapes.java
@@ -319,9 +319,21 @@ public final class VoxelShapes {

View File

@ -17,10 +17,10 @@ keeping long lived large direct buffers in cache.
Set system properly at server startup if not set already to help protect from this.
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index e913d249d850210c9efba1bb46ce2ce4df013a62..2ea6f5b7da35cbb342e72a00ea70fef667f05d49 100644
index 429ae482f30eeeab84cc009a9143245e086ce469..a61e6561c10b62cc97aab1b4d8befe893c5da09f 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -21,6 +21,7 @@ public class Main {
@@ -20,6 +20,7 @@ public class Main {
public static void main(String[] args) {
// Todo: Installation script

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Implement Mob Goal API
diff --git a/pom.xml b/pom.xml
index 64bd667e8b11263e483364efc3414396819a255c..e4c63bb76cb598545f9d215a8859724d6e7f8b81 100644
index f578acae6fbe1ad7a0c05b96ba489482687ec1df..2b24688310f14b6a9e3fe04fe8b41cd1803b78c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -133,6 +133,13 @@
@ -744,7 +744,7 @@ index 9df0006c1a283f77c4d01d9fce9062fc1c9bbb1f..b3329c6fcd6758a781a51f5ba8f5052a
+ }
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoal.java b/src/main/java/net/minecraft/server/PathfinderGoal.java
index 93009d83f07bdaf7bc424ffb99cbfe716ca0d66d..f1c4ce9e4b83aa966b4ae4dcd6a283e08f8db783 100644
index a85d81186ae92dec72f2cc3a1dcd8c4b7e7ede62..d2aa9a854ea013f24f585c194bd1ddfd8d5410a5 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoal.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoal.java
@@ -10,9 +10,9 @@ public abstract class PathfinderGoal {
@ -780,20 +780,20 @@ index 93009d83f07bdaf7bc424ffb99cbfe716ca0d66d..f1c4ce9e4b83aa966b4ae4dcd6a283e0
this.goalTypes.clear();
this.goalTypes.addAllUnchecked(enumset);
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
index 84d2abbcb90eb09a19fa0922cfc053c74f8c56e4..a68fc11ec668576d1453459666caeacf5fbc49b8 100644
index 22f4fec58fbaab24673dd418700c51671248c510..d3f0327a2a7cdedf3fe8d10df981a9f1cb378d26 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java
@@ -26,7 +26,7 @@ public class PathfinderGoalSelector {
@@ -27,7 +27,7 @@ public class PathfinderGoalSelector {
}
};
private final Map<PathfinderGoal.Type, PathfinderGoalWrapped> c = new EnumMap(PathfinderGoal.Type.class);
- private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet();private Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER
+ private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet();public Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER
private final GameProfilerFiller e;
- private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet(); private Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER
+ private final Set<PathfinderGoalWrapped> d = Sets.newLinkedHashSet(); public final Set<PathfinderGoalWrapped> getTasks() { return d; }// Paper - OBFHELPER // Paper - private -> public
private final Supplier<GameProfilerFiller> e;
private final EnumSet<PathfinderGoal.Type> f = EnumSet.noneOf(PathfinderGoal.Type.class); // Paper unused, but dummy to prevent plugins from crashing as hard. Theyll need to support paper in a special case if this is super important, but really doesn't seem like it would be.
private final OptimizedSmallEnumSet<PathfinderGoal.Type> goalTypes = new OptimizedSmallEnumSet<>(PathfinderGoal.Type.class); // Paper - remove streams from pathfindergoalselector
@@ -37,7 +37,7 @@ public class PathfinderGoalSelector {
this.e = gameprofilerfiller;
@@ -38,7 +38,7 @@ public class PathfinderGoalSelector {
this.e = supplier;
}
- public void a(int i, PathfinderGoal pathfindergoal) {
@ -801,7 +801,7 @@ index 84d2abbcb90eb09a19fa0922cfc053c74f8c56e4..a68fc11ec668576d1453459666caeacf
this.d.add(new PathfinderGoalWrapped(i, pathfindergoal));
}
@@ -60,7 +60,7 @@ public class PathfinderGoalSelector {
@@ -61,7 +61,7 @@ public class PathfinderGoalSelector {
}
// Paper end
@ -810,16 +810,16 @@ index 84d2abbcb90eb09a19fa0922cfc053c74f8c56e4..a68fc11ec668576d1453459666caeacf
// Paper start - remove streams from pathfindergoalselector
for (Iterator<PathfinderGoalWrapped> iterator = this.d.iterator(); iterator.hasNext();) {
PathfinderGoalWrapped goalWrapped = iterator.next();
@@ -154,6 +154,7 @@ public class PathfinderGoalSelector {
this.e.exit();
@@ -157,6 +157,7 @@ public class PathfinderGoalSelector {
gameprofilerfiller.exit();
}
+ public Stream<PathfinderGoalWrapped> getExecutingGoals() {return c();} // Paper - OBFHELPER
public Stream<PathfinderGoalWrapped> c() {
+ public final Stream<PathfinderGoalWrapped> getExecutingGoals() { return d(); } // Paper - OBFHELPER
public Stream<PathfinderGoalWrapped> d() {
return this.d.stream().filter(PathfinderGoalWrapped::g);
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java b/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
index 1b800c558f0988ffc0270b86d1a59ea3bb245116..dee4e2beacb1bbb179f220ed186e873bef718340 100644
index 96f4401044cacf88e8e00b5b18821c105e634fba..112d8bab65bf41263a477c5faa717687fe8a2bc9 100644
--- a/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalWrapped.java
@@ -5,8 +5,8 @@ import javax.annotation.Nullable;
@ -834,10 +834,10 @@ index 1b800c558f0988ffc0270b86d1a59ea3bb245116..dee4e2beacb1bbb179f220ed186e873b
public PathfinderGoalWrapped(int i, PathfinderGoal pathfindergoal) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1647c09756ed303a3f3e879e877b5b3de639f843..b89f99a66fe2ab9ad4c956c38c9e4b1d79716c9c 100644
index 715186249545ab2af5284ef71ab59e5ebccad8e1..7c3a66e5e6c4dece0807cc349a69d79fd1b8c352 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2230,5 +2230,11 @@ public final class CraftServer implements Server {
@@ -2285,5 +2285,11 @@ public final class CraftServer implements Server {
public boolean isStopping() {
return net.minecraft.server.MinecraftServer.getServer().hasStopped();
}

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Use distance map to optimise entity tracker
Use the distance map to find candidate players for tracking.
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 32daf027a3575d73aeabf9db14a2e0c74e4cc7e6..b176dc26d15065aebc91c75e8a96745f589c0b87 100644
index b400b04fcb733110150de800927c602180771cec..d1b5e421e80ed79fec94cbf181d4e6f5515b94e8 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -245,6 +245,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
@@ -246,6 +246,21 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
// Paper end
@ -32,22 +32,34 @@ index 32daf027a3575d73aeabf9db14a2e0c74e4cc7e6..b176dc26d15065aebc91c75e8a96745f
this.id = Entity.entityCount.incrementAndGet();
this.passengers = Lists.newArrayList();
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 3a88c9a67062eb73ad8257ea786efca7e7e99f65..6d3b34ead9cc95dcc1152dffa8c6c4a8c7f1d58b 100644
index 9b89c0c8a3f1dada4e9b2aaeed0b92e56229b7ca..0c46297e6ff229538d77b2f481e4ab13ea14c48e 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -70,6 +70,7 @@ public class EntityTrackerEntry {
this.r = entity.onGround;
@@ -72,6 +72,7 @@ public class EntityTrackerEntry {
this.r = entity.isOnGround();
}
+ public final void tick() { this.a(); } // Paper - OBFHELPER
public void a() {
List<Entity> list = this.tracker.getPassengers();
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index cf05c44865b5d3210b50d11ac7413865cc57f1ff..14a208b3b36f492285c432c591000df1573d31b1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1531,6 +1531,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
}
}
+ public final int applyTrackingRangeScale(int value) { return this.b(i); } // Paper - OBFHELPER
public int b(int i) {
return i;
}
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571fe5f1ebe 100644
index b55c94788014b8085b45082162866f0210191622..38d7cfdbf96679fb2a56c3b36f374831451f34ee 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -143,21 +143,51 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -145,21 +145,55 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper start - distance maps
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<EntityPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
@ -60,6 +72,10 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
+ static final org.spigotmc.TrackingRange.TrackingRangeType[] TRACKING_RANGE_TYPES = org.spigotmc.TrackingRange.TrackingRangeType.values();
+ final com.destroystokyo.paper.util.misc.PlayerAreaMap[] playerEntityTrackerTrackMaps;
+ final int[] entityTrackerTrackRanges;
+
+ private int convertSpigotRangeToVanilla(final int vanilla) {
+ return MinecraftServer.getServer().applyTrackingRangeScale(vanilla);
+ }
+ // Paper end - use distance map to optimise tracker
void addPlayerToDistanceMaps(EntityPlayer player) {
@ -98,10 +114,10 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
+ }
+ // Paper end - use distance map to optimise entity tracker
}
// Paper end
@@ -195,6 +225,44 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.m = new VillagePlace(new File(this.w, "poi"), datafixer, this.world); // Paper
@@ -196,6 +230,45 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.m = new VillagePlace(new File(this.w, "poi"), datafixer, flag, this.world); // Paper
this.setViewDistance(i);
this.playerMobDistanceMap = this.world.paperConfig.perPlayerMobSpawns ? new com.destroystokyo.paper.util.PlayerMobDistanceMap() : null; // Paper
+ // Paper start - use distance map to optimise entity tracker
@ -135,6 +151,7 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
+ default:
+ throw new IllegalStateException("Missing case for enum " + trackingRangeType);
+ }
+ configuredSpigotValue = convertSpigotRangeToVanilla(configuredSpigotValue);
+
+ int trackRange = (configuredSpigotValue >>> 4) + ((configuredSpigotValue & 15) != 0 ? 1 : 0);
+ this.entityTrackerTrackRanges[ordinal] = trackRange;
@ -145,7 +162,7 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
}
public void updatePlayerMobTypeMap(Entity entity) {
@@ -1400,17 +1468,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1431,17 +1504,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
public void movePlayer(EntityPlayer entityplayer) {
@ -164,16 +181,16 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
int i = MathHelper.floor(entityplayer.locX()) >> 4;
int j = MathHelper.floor(entityplayer.locZ()) >> 4;
@@ -1527,7 +1585,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1557,7 +1620,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
this.trackedEntities.put(entity.getId(), playerchunkmap_entitytracker);
- playerchunkmap_entitytracker.track(this.world.getPlayers());
+ playerchunkmap_entitytracker.updatePlayers(entity.getPlayersInTrackRange()); // Paper - don't search all players
if (entity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entity;
entity.tracker = playerchunkmap_entitytracker; // Paper - Fast access to tracker
this.trackedEntities.put(entity.getId(), playerchunkmap_entitytracker);
- playerchunkmap_entitytracker.track(this.world.getPlayers());
+ playerchunkmap_entitytracker.updatePlayers(entity.getPlayersInTrackRange()); // Paper - don't search all players
if (entity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entity;
@@ -1571,7 +1629,37 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1600,7 +1663,37 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
entity.tracker = null; // Paper - We're no longer tracked
}
@ -211,7 +228,7 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
List<EntityPlayer> list = Lists.newArrayList();
List<EntityPlayer> list1 = this.world.getPlayers();
@@ -1639,23 +1727,31 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1668,23 +1761,31 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
PacketDebug.a(this.world, chunk.getPos());
List<Entity> list = Lists.newArrayList();
List<Entity> list1 = Lists.newArrayList();
@ -255,7 +272,7 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
Iterator iterator;
Entity entity1;
@@ -1693,7 +1789,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1722,7 +1823,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public class EntityTracker {
@ -264,7 +281,7 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
private final Entity tracker;
private final int trackingDistance;
private SectionPosition e;
@@ -1710,6 +1806,42 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1739,6 +1840,42 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.e = SectionPosition.a(entity);
}
@ -307,7 +324,7 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
public boolean equals(Object object) {
return object instanceof PlayerChunkMap.EntityTracker ? ((PlayerChunkMap.EntityTracker) object).tracker.getId() == this.tracker.getId() : false;
}
@@ -1806,7 +1938,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1839,7 +1976,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
int j = entity.getEntityType().getChunkRange() * 16;
j = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, j); // Paper
@ -317,10 +334,15 @@ index 3f1a5e48676d1b4b01fbbc25fc9c9cf556cbf0eb..f09bb1329cf993034661fb8cfbf87571
}
}
diff --git a/src/main/java/org/spigotmc/TrackingRange.java b/src/main/java/org/spigotmc/TrackingRange.java
index 03990231a8b6bc6925f054e9033825316abfafcc..2ba1c1b9160e8d24cb338fa9b6b844423119dc73 100644
index 03990231a8b6bc6925f054e9033825316abfafcc..627e9a90b3045602bc540a5f3f031aaf3716c942 100644
--- a/src/main/java/org/spigotmc/TrackingRange.java
+++ b/src/main/java/org/spigotmc/TrackingRange.java
@@ -50,4 +50,43 @@ public class TrackingRange
@@ -46,8 +46,49 @@ public class TrackingRange
return config.miscTrackingRange;
} else
{
- if (entity instanceof EntityEnderDragon) return ((WorldServer)(entity.getWorld())).getChunkProvider().playerChunkMap.getLoadViewDistance(); // Paper - enderdragon is exempt
+ if (entity instanceof EntityEnderDragon) return defaultRange; // Paper - enderdragon is exempt
return config.otherTrackingRange;
}
}
@ -337,8 +359,10 @@ index 03990231a8b6bc6925f054e9033825316abfafcc..2ba1c1b9160e8d24cb338fa9b6b84442
+ switch (entity.activationType) {
+ case RAIDER:
+ case MONSTER:
+ case FLYING_MONSTER:
+ return TrackingRangeType.MONSTER;
+ case WATER:
+ case VILLAGER:
+ case ANIMAL:
+ return TrackingRangeType.ANIMAL;
+ case MISC:

View File

@ -6,15 +6,15 @@ Subject: [PATCH] Optimize isOutsideRange to use distance maps
Use a distance map to find the players in range quickly
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index 10e385eb556faff954df28ed0b3ddaceac2b8baa..ae27942991eeaec77f72b58ab32260a35f86b4a4 100644
index 32d3887e2542c4ebba4a7498167fbe4b497a71ce..7e57a53ec614a2f7d2672edff9d7c0e0dca42377 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -31,7 +31,7 @@ public abstract class ChunkMapDistance {
private final Long2ObjectMap<ObjectSet<EntityPlayer>> c = new Long2ObjectOpenHashMap();
public final Long2ObjectOpenHashMap<ArraySetSorted<Ticket<?>>> tickets = new Long2ObjectOpenHashMap();
private final ChunkMapDistance.a e = new ChunkMapDistance.a();
private final ChunkMapDistance.a ticketLevelTracker = new ChunkMapDistance.a();
- private final ChunkMapDistance.b f = new ChunkMapDistance.b(8);
+ public static final int MOB_SPAWN_RANGE = 8; //private final ChunkMapDistance.b f = new ChunkMapDistance.b(8); // Paper - no longer used
+ public static final int MOB_SPAWN_RANGE = 8; // private final ChunkMapDistance.b f = new ChunkMapDistance.b(8); // Paper - no longer used
private final ChunkMapDistance.c g = new ChunkMapDistance.c(33);
// Paper start use a queue, but still keep unique requirement
public final java.util.Queue<PlayerChunk> pendingChunkUpdates = new java.util.ArrayDeque<PlayerChunk>() {
@ -34,24 +34,24 @@ index 10e385eb556faff954df28ed0b3ddaceac2b8baa..ae27942991eeaec77f72b58ab32260a3
- this.f.a();
+ //this.f.a(); // Paper - no longer used
this.g.a();
int i = Integer.MAX_VALUE - this.e.a(Integer.MAX_VALUE);
int i = Integer.MAX_VALUE - this.ticketLevelTracker.a(Integer.MAX_VALUE);
boolean flag = i != 0;
@@ -230,7 +232,7 @@ public abstract class ChunkMapDistance {
((ObjectSet) this.c.computeIfAbsent(i, (j) -> {
return new ObjectOpenHashSet();
})).add(entityplayer);
- this.f.b(i, 0, true);
+ //this.f.b(i, 0, true); // Paper - no longer used
this.g.b(i, 0, true);
- this.f.update(i, 0, true);
+ //this.f.update(i, 0, true); // Paper - no longer used
this.g.update(i, 0, true);
}
@@ -241,7 +243,7 @@ public abstract class ChunkMapDistance {
if (objectset != null) objectset.remove(entityplayer); // Paper - some state corruption happens here, don't crash, clean up gracefully.
if (objectset == null || objectset.isEmpty()) { // Paper
this.c.remove(i);
- this.f.b(i, Integer.MAX_VALUE, false);
+ //this.f.b(i, Integer.MAX_VALUE, false); // Paper - no longer used
this.g.b(i, Integer.MAX_VALUE, false);
- this.f.update(i, Integer.MAX_VALUE, false);
+ //this.f.update(i, Integer.MAX_VALUE, false); // Paper - no longer used
this.g.update(i, Integer.MAX_VALUE, false);
}
@@ -265,13 +267,17 @@ public abstract class ChunkMapDistance {
@ -77,10 +77,10 @@ index 10e385eb556faff954df28ed0b3ddaceac2b8baa..ae27942991eeaec77f72b58ab32260a3
public String c() {
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 665d83042dab467cddf315fade883fd55ffc8bfd..3089d673a029c493cac756124eb0baa21a8bab7f 100644
index eebd4c50a7324250d3ebe7060739a71af4243f72..a6363b73522f9d27534b6e80f4b3789e84316c49 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -735,6 +735,36 @@ public class ChunkProviderServer extends IChunkProvider {
@@ -728,6 +728,36 @@ public class ChunkProviderServer extends IChunkProvider {
boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !world.getPlayers().isEmpty(); // CraftBukkit
if (!flag) {
@ -116,55 +116,54 @@ index 665d83042dab467cddf315fade883fd55ffc8bfd..3089d673a029c493cac756124eb0baa2
+ // Paper end - optimize isOutisdeRange
this.world.getMethodProfiler().enter("pollingChunks");
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
BlockPosition blockposition = this.world.getSpawn();
@@ -769,15 +799,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.timings.countNaturalMobs.stopTiming(); // Paper - timings
boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit
@@ -757,15 +787,7 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
//List<PlayerChunk> list = Lists.newArrayList(this.playerChunkMap.f()); // Paper
//Collections.shuffle(list); // Paper
- //Paper start - call player naturally spawn event
- int chunkRange = world.spigotConfig.mobSpawnRange;
- chunkRange = (chunkRange > world.spigotConfig.viewDistance) ? (byte) world.spigotConfig.viewDistance : chunkRange;
- chunkRange = Math.min(chunkRange, 8);
- for (EntityPlayer entityPlayer : this.world.players) {
- for (EntityPlayer entityPlayer : this.world.getPlayers()) {
- entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange);
- entityPlayer.playerNaturallySpawnedEvent.callEvent();
- };
- // Paper end
+ // Paper - replaced by above
+ // Paper - moved up
final int[] chunksTicked = {0}; this.playerChunkMap.forEachVisibleChunk((playerchunk) -> { // Paper - safe iterator incase chunk loads, also no wrapping
Optional<Chunk> optional = ((Either) playerchunk.b().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
Optional<Chunk> optional = ((Either) playerchunk.a().getNow(PlayerChunk.UNLOADED_CHUNK)).left();
@@ -791,10 +813,10 @@ public class ChunkProviderServer extends IChunkProvider {
this.world.getMethodProfiler().exit();
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
@@ -781,9 +803,9 @@ public class ChunkProviderServer extends IChunkProvider {
Chunk chunk = (Chunk) optional1.get();
ChunkCoordIntPair chunkcoordintpair = playerchunk.i();
- if (!this.playerChunkMap.isOutsideOfRange(chunkcoordintpair)) {
+ if (!this.playerChunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, false)) { // Paper - optimise isOutsideOfRange
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
- if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
+ if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, true)) { // Spigot // Paper - optimise isOutsideOfRange
SpawnerCreature.a(this.world, chunk, spawnercreature_d, this.allowAnimals, this.allowMonsters, flag2);
}
- if (!this.playerChunkMap.isOutsideOfRange(chunkcoordintpair)) {
+ if (!this.playerChunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, false)) { // Paper - optimise isOutsideOfRange
// Paper end
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
- if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(chunkcoordintpair, true)) { // Spigot
+ if (flag1 && (this.allowMonsters || this.allowAnimals) && this.world.getWorldBorder().isInBounds(chunk.getPos()) && !this.playerChunkMap.isOutsideOfRange(playerchunk, chunkcoordintpair, true)) { // Spigot // Paper - optimise isOutsideOfRange
this.world.getMethodProfiler().enter("spawner");
this.world.timings.mobSpawn.startTiming(); // Spigot
EnumCreatureType[] aenumcreaturetype1 = aenumcreaturetype;
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 79c2187b7383336e7574709e6d4ad805e557976f..0560eca744cb2032bb6a3faf5aeafa95a7a6815e 100644
index c26236ff4ab56506c51d4e215cfe4fb76bed26ed..6c8c697367b2c8504d0467cd58f576afbd3e775f 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -109,6 +109,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -113,6 +113,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<EntityPlayer> cachedSingleHashSet; // Paper
+ double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super((World) worldserver, gameprofile);
playerinteractmanager.player = this;
super(worldserver, worldserver.getSpawn(), gameprofile);
this.spawnDimension = World.OVERWORLD;
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index afc92dd031cdaf725b85c0b301d5a5a21da54720..6980d19f36c18cdbed6679dbdf04afd694e078b6 100644
index 9cb2ff09da0b8832e58eed4d70741853a25c9011..7f660d3c528f5fb4150e4ee8b29913436f125b06 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -44,6 +44,18 @@ public class PlayerChunk {
@@ -43,6 +43,18 @@ public class PlayerChunk {
long lastAutoSaveTime; // Paper - incremental autosave
long inactiveTimeStart; // Paper - incremental autosave
@ -183,7 +182,7 @@ index afc92dd031cdaf725b85c0b301d5a5a21da54720..6980d19f36c18cdbed6679dbdf04afd6
public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) {
this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size());
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
@@ -60,6 +72,7 @@ public class PlayerChunk {
@@ -59,6 +71,7 @@ public class PlayerChunk {
this.n = this.oldTicketLevel;
this.a(i);
this.chunkMap = (PlayerChunkMap)playerchunk_d; // Paper
@ -192,12 +191,12 @@ index afc92dd031cdaf725b85c0b301d5a5a21da54720..6980d19f36c18cdbed6679dbdf04afd6
// Paper start
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4ec54d56b 100644
index 38d7cfdbf96679fb2a56c3b36f374831451f34ee..b55e8f94ef45b526c55bc5ba2a991d933bbc4170 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -153,6 +153,17 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
final com.destroystokyo.paper.util.misc.PlayerAreaMap[] playerEntityTrackerTrackMaps;
final int[] entityTrackerTrackRanges;
@@ -159,6 +159,17 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return MinecraftServer.getServer().applyTrackingRangeScale(vanilla);
}
// Paper end - use distance map to optimise tracker
+ // Paper start - optimise PlayerChunkMap#isOutsideRange
+ // A note about the naming used here:
@ -213,7 +212,7 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
void addPlayerToDistanceMaps(EntityPlayer player) {
int chunkX = MCUtil.getChunkCoordinate(player.locX());
@@ -166,6 +177,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -172,6 +183,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
}
// Paper end - use distance map to optimise entity tracker
@ -223,7 +222,7 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
}
void removePlayerFromDistanceMaps(EntityPlayer player) {
@@ -174,6 +188,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -180,6 +194,10 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.playerEntityTrackerTrackMaps[i].remove(player);
}
// Paper end - use distance map to optimise tracker
@ -234,7 +233,7 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
}
void updateMaps(EntityPlayer player) {
@@ -188,6 +206,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -194,6 +212,9 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, this.getEffectiveViewDistance()));
}
// Paper end - use distance map to optimise entity tracker
@ -242,18 +241,18 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, ChunkMapDistance.MOB_SPAWN_RANGE);
+ // Paper end - optimise PlayerChunkMap#isOutsideRange
}
// Paper end
@@ -220,7 +241,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -225,7 +246,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.mailboxWorldGen = this.p.a(threadedmailbox, false);
this.mailboxMain = this.p.a(mailbox, false);
this.lightEngine = new LightEngineThreaded(ilightaccess, this, this.world.getWorldProvider().f(), threadedmailbox1, this.p.a(threadedmailbox1, false));
this.lightEngine = new LightEngineThreaded(ilightaccess, this, this.world.getDimensionManager().hasSkyLight(), threadedmailbox1, this.p.a(threadedmailbox1, false));
- this.chunkDistanceManager = new PlayerChunkMap.a(executor, iasynctaskhandler);
+ this.chunkDistanceManager = new PlayerChunkMap.a(executor, iasynctaskhandler); this.chunkDistanceManager.chunkMap = this; // Paper
this.l = supplier;
this.m = new VillagePlace(new File(this.w, "poi"), datafixer, this.world); // Paper
this.m = new VillagePlace(new File(this.w, "poi"), datafixer, flag, this.world); // Paper
this.setViewDistance(i);
@@ -263,6 +284,38 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -269,6 +290,38 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.playerEntityTrackerTrackMaps[ordinal] = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets);
}
// Paper end - use distance map to optimise entity tracker
@ -292,7 +291,7 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
}
public void updatePlayerMobTypeMap(Entity entity) {
@@ -282,6 +335,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -288,6 +341,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return entityPlayer.mobCounts[enumCreatureType.ordinal()];
}
@ -300,7 +299,7 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
private static double a(ChunkCoordIntPair chunkcoordintpair, Entity entity) {
double d0 = (double) (chunkcoordintpair.x * 16 + 8);
double d1 = (double) (chunkcoordintpair.z * 16 + 8);
@@ -460,6 +514,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -466,6 +520,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
} else {
if (playerchunk != null) {
playerchunk.a(j);
@ -308,7 +307,7 @@ index f09bb1329cf993034661fb8cfbf87571fe5f1ebe..74b868d7cec0260a10ca7718f48308f4
}
if (playerchunk != null) {
@@ -1397,30 +1452,53 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1433,30 +1488,53 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
return isOutsideOfRange(chunkcoordintpair, false);
}

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Stop copy-on-write operations for updating light data
Causes huge memory allocations + gc issues
diff --git a/src/main/java/net/minecraft/server/LightEngineStorage.java b/src/main/java/net/minecraft/server/LightEngineStorage.java
index a3f919816eb2a742ed09b553995e6508684e5ea5..88277d23c36696fdd5363e41a130c9a443fac2c0 100644
index 916d38cebcbe912153d54a21acbf60bc26db7401..6c7c4e75670a7e08ba10c0231a2510bf985dab6b 100644
--- a/src/main/java/net/minecraft/server/LightEngineStorage.java
+++ b/src/main/java/net/minecraft/server/LightEngineStorage.java
@@ -19,8 +19,8 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
@ -20,7 +20,7 @@ index a3f919816eb2a742ed09b553995e6508684e5ea5..88277d23c36696fdd5363e41a130c9a4
protected final LongSet g = new LongOpenHashSet();
protected final LongSet h = new LongOpenHashSet();
protected final Long2ObjectMap<NibbleArray> i = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap());
@@ -33,8 +33,8 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
@@ -34,8 +34,8 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
this.l = enumskyblock;
this.m = ilightaccess;
this.f = m0;
@ -31,7 +31,7 @@ index a3f919816eb2a742ed09b553995e6508684e5ea5..88277d23c36696fdd5363e41a130c9a4
}
protected boolean g(long i) {
@@ -43,7 +43,15 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
@@ -44,7 +44,15 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
@Nullable
protected NibbleArray a(long i, boolean flag) {
@ -48,7 +48,7 @@ index a3f919816eb2a742ed09b553995e6508684e5ea5..88277d23c36696fdd5363e41a130c9a4
}
@Nullable
@@ -340,10 +348,12 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
@@ -357,10 +365,12 @@ public abstract class LightEngineStorage<M extends LightEngineStorageArray<M>> e
protected void e() {
if (!this.g.isEmpty()) {

View File

@ -23,10 +23,10 @@ index d4ebcf8f66197299256bd6b65710a1488c90ea41..a3b41ce5fc70948d4804659a472cb622
}));
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 9db76eae1649fe2ce0856ff4bdcb15569bf58d93..c3f7717869c86d9ac6395615bceda324aea16b27 100644
index 5785f24b0646f8dbf3fba0bbc3b3e5b93e02f162..0746932a3191669052f15270f5c94efbce0bd0c2 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -677,4 +677,9 @@ public class PaperWorldConfig {
@@ -634,4 +634,9 @@ public class PaperWorldConfig {
phantomIgnoreCreative = getBoolean("phantoms-do-not-spawn-on-creative-players", phantomIgnoreCreative);
phantomOnlyAttackInsomniacs = getBoolean("phantoms-only-attack-insomniacs", phantomOnlyAttackInsomniacs);
}
@ -37,10 +37,10 @@ index 9db76eae1649fe2ce0856ff4bdcb15569bf58d93..c3f7717869c86d9ac6395615bceda324
+ }
}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index cf86ce24e12068d6ff7ae43cb1fd6fe665c24932..c80a55ee53eac128c94d74b78c5641854e974750 100644
index b65ae2d6919a67498d0646c5522735086fec00c1..7f508b9ef616071b1adeef7c00da7f4565ef4ddd 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -245,7 +245,51 @@ public class Chunk implements IChunkAccess {
@@ -246,7 +246,51 @@ public class Chunk implements IChunkAccess {
}
protected void onNeighbourChange(final long bitsetBefore, final long bitsetAfter) {
@ -93,7 +93,7 @@ index cf86ce24e12068d6ff7ae43cb1fd6fe665c24932..c80a55ee53eac128c94d74b78c564185
public final boolean isAnyNeighborsLoaded() {
diff --git a/src/main/java/net/minecraft/server/ChunkMapDistance.java b/src/main/java/net/minecraft/server/ChunkMapDistance.java
index ae27942991eeaec77f72b58ab32260a35f86b4a4..7702fbefa598bce7e6a2d287f7ec36b78a62bff8 100644
index 7e57a53ec614a2f7d2672edff9d7c0e0dca42377..c072f61e8c88eac8335acd660d8ff0e2f9db819e 100644
--- a/src/main/java/net/minecraft/server/ChunkMapDistance.java
+++ b/src/main/java/net/minecraft/server/ChunkMapDistance.java
@@ -262,7 +262,7 @@ public abstract class ChunkMapDistance {
@ -113,25 +113,25 @@ index ae27942991eeaec77f72b58ab32260a35f86b4a4..7702fbefa598bce7e6a2d287f7ec36b7
+ Ticket<?> ticket = new Ticket<>(TicketType.PLAYER, 33, new ChunkCoordIntPair(i)); // Paper - no-tick view distance
if (flag1) {
ChunkMapDistance.this.j.a(ChunkTaskQueueSorter.a(() -> { // CraftBukkit - decompile error
ChunkMapDistance.this.j.a(ChunkTaskQueueSorter.a(() -> {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 0560eca744cb2032bb6a3faf5aeafa95a7a6815e..07a6fc3d88e7d44bfab7f3d6a0eef7dc132ab422 100644
index 6c8c697367b2c8504d0467cd58f576afbd3e775f..55351ee29a724e7680e5ec98afea2c0f365bc6c4 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -111,6 +111,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -115,6 +115,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks
+ boolean needsChunkCenterUpdate; // Paper - no-tick view distance
+
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
super((World) worldserver, gameprofile);
playerinteractmanager.player = this;
super(worldserver, worldserver.getSpawn(), gameprofile);
this.spawnDimension = World.OVERWORLD;
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
index 6980d19f36c18cdbed6679dbdf04afd694e078b6..03fb688fe4bdc19b4bc36b1f1d5b40c61e7bef9b 100644
index 7f660d3c528f5fb4150e4ee8b29913436f125b06..40347212ad1bcf857d5b8ddb0ee6a698e2568201 100644
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
@@ -56,6 +56,18 @@ public class PlayerChunk {
@@ -55,6 +55,18 @@ public class PlayerChunk {
}
// Paper end - optimise isOutsideOfRange
@ -150,7 +150,7 @@ index 6980d19f36c18cdbed6679dbdf04afd694e078b6..03fb688fe4bdc19b4bc36b1f1d5b40c6
public PlayerChunk(ChunkCoordIntPair chunkcoordintpair, int i, LightEngine lightengine, PlayerChunk.c playerchunk_c, PlayerChunk.d playerchunk_d) {
this.statusFutures = new AtomicReferenceArray(PlayerChunk.CHUNK_STATUSES.size());
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
@@ -211,7 +223,7 @@ public class PlayerChunk {
@@ -210,7 +222,7 @@ public class PlayerChunk {
}
public void a(int i, int j, int k) {
@ -159,7 +159,7 @@ index 6980d19f36c18cdbed6679dbdf04afd694e078b6..03fb688fe4bdc19b4bc36b1f1d5b40c6
if (chunk != null) {
this.r |= 1 << (j >> 4);
@@ -231,7 +243,7 @@ public class PlayerChunk {
@@ -230,7 +242,7 @@ public class PlayerChunk {
}
public void a(EnumSkyBlock enumskyblock, int i) {
@ -168,7 +168,7 @@ index 6980d19f36c18cdbed6679dbdf04afd694e078b6..03fb688fe4bdc19b4bc36b1f1d5b40c6
if (chunk != null) {
chunk.setNeedsSaving(true);
@@ -316,9 +328,48 @@ public class PlayerChunk {
@@ -303,9 +315,48 @@ public class PlayerChunk {
}
private void a(Packet<?> packet, boolean flag) {
@ -221,10 +221,10 @@ index 6980d19f36c18cdbed6679dbdf04afd694e078b6..03fb688fe4bdc19b4bc36b1f1d5b40c6
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> a(ChunkStatus chunkstatus, PlayerChunkMap playerchunkmap) {
diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f145202ff7887 100644
index b55e8f94ef45b526c55bc5ba2a991d933bbc4170..6cde6d684f6a3ced1eb2aa554559672e7b0d4947 100644
--- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
@@ -94,7 +94,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -95,7 +95,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private boolean updatingChunksModified;
private final ChunkTaskQueueSorter p;
private final Mailbox<ChunkTaskQueueSorter.a<Runnable>> mailboxWorldGen;
@ -233,7 +233,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
public final WorldLoadListener worldLoadListener;
public final PlayerChunkMap.a chunkDistanceManager; public final PlayerChunkMap.a getChunkMapDistanceManager() { return this.chunkDistanceManager; } // Paper - OBFHELPER
private final AtomicInteger u;
@@ -164,6 +164,22 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -170,6 +170,22 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap; // this map is absent from updateMaps since it's controlled at the start of the chunkproviderserver tick
public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerChunkTickRangeMap;
// Paper end - optimise PlayerChunkMap#isOutsideRange
@ -256,7 +256,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
void addPlayerToDistanceMaps(EntityPlayer player) {
int chunkX = MCUtil.getChunkCoordinate(player.locX());
@@ -180,6 +196,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -186,6 +202,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper start - optimise PlayerChunkMap#isOutsideRange
this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, ChunkMapDistance.MOB_SPAWN_RANGE);
// Paper end - optimise PlayerChunkMap#isOutsideRange
@ -276,7 +276,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
}
void removePlayerFromDistanceMaps(EntityPlayer player) {
@@ -192,6 +221,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -198,6 +227,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.playerMobSpawnMap.remove(player);
this.playerChunkTickRangeMap.remove(player);
// Paper end - optimise PlayerChunkMap#isOutsideRange
@ -288,7 +288,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
}
void updateMaps(EntityPlayer player) {
@@ -209,6 +243,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -215,6 +249,19 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
// Paper start - optimise PlayerChunkMap#isOutsideRange
this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, ChunkMapDistance.MOB_SPAWN_RANGE);
// Paper end - optimise PlayerChunkMap#isOutsideRange
@ -306,9 +306,9 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
+ player.needsChunkCenterUpdate = false;
+ // Paper end - no-tick view distance
}
// Paper end
@@ -316,6 +363,45 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -322,6 +369,45 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
});
// Paper end - optimise PlayerChunkMap#isOutsideRange
@ -354,7 +354,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
}
public void updatePlayerMobTypeMap(Entity entity) {
@@ -1126,15 +1212,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1139,15 +1225,11 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
completablefuture1.thenAcceptAsync((either) -> {
either.mapLeft((chunk) -> {
this.u.getAndIncrement();
@ -367,18 +367,16 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
return Either.left(chunk);
});
}, (runnable) -> {
- this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // CraftBukkit - decompile error // Paper - diff on change, this is the scheduling method copied in Chunk used to schedule chunk broadcasts (on change it needs to be copied again)
- this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable));
+ this.mailboxMain.a(ChunkTaskQueueSorter.a(playerchunk, runnable)); // Paper - diff on change, this is the scheduling method copied in Chunk used to schedule chunk broadcasts (on change it needs to be copied again)
});
return completablefuture1;
}
@@ -1205,32 +1287,38 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
} // Paper
@@ -1243,31 +1325,37 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
- protected void setViewDistance(int i) {
protected void setViewDistance(int i) {
- int j = MathHelper.clamp(i + 1, 3, 33);
+ public final void setViewDistance(int i) { // Paper - public
+ int j = MathHelper.clamp(i + 1, 3, 33); // Paper - diff on change, these make the lower view distance limit 2 and the upper 32
if (j != this.viewDistance) {
@ -426,7 +424,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
protected void sendChunk(EntityPlayer entityplayer, ChunkCoordIntPair chunkcoordintpair, Packet<?>[] apacket, boolean flag, boolean flag1) {
if (entityplayer.world == this.world) {
@@ -1238,7 +1326,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1275,7 +1363,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
PlayerChunk playerchunk = this.getVisibleChunk(chunkcoordintpair.pair());
if (playerchunk != null) {
@ -435,7 +433,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
if (chunk != null) {
this.a(entityplayer, apacket, chunk);
@@ -1500,6 +1588,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1536,6 +1624,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
// Paper end - optimise isOutsideOfRange
@ -443,7 +441,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
private boolean b(EntityPlayer entityplayer) {
return entityplayer.isSpectator() && !this.world.getGameRules().getBoolean(GameRules.SPECTATORS_GENERATE_CHUNKS);
}
@@ -1527,13 +1616,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1563,13 +1652,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.removePlayerFromDistanceMaps(entityplayer); // Paper - distance maps
}
@ -458,7 +456,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
}
@@ -1541,7 +1624,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1577,7 +1660,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
SectionPosition sectionposition = SectionPosition.a((Entity) entityplayer);
entityplayer.a(sectionposition);
@ -467,7 +465,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
return sectionposition;
}
@@ -1586,6 +1669,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1622,6 +1705,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
int k1;
int l1;
@ -475,7 +473,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
if (Math.abs(i1 - i) <= this.viewDistance * 2 && Math.abs(j1 - j) <= this.viewDistance * 2) {
k1 = Math.min(i, i1) - this.viewDistance;
l1 = Math.min(j, j1) - this.viewDistance;
@@ -1623,7 +1707,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1659,7 +1743,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
this.sendChunk(entityplayer, chunkcoordintpair1, new Packet[2], false, true);
}
}
@ -484,7 +482,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
this.updateMaps(entityplayer); // Paper - distance maps
@@ -1631,11 +1715,46 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1667,11 +1751,46 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@Override
public Stream<EntityPlayer> a(ChunkCoordIntPair chunkcoordintpair, boolean flag) {
@ -501,7 +499,7 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
+ return Stream.empty();
+ }
+ // all current cases are inlined so we wont hit this code, it's just in case plugins or future updates use it
+ List<EntityPlayer> players = new ArrayList<>();
+ List<EntityPlayer> players = new java.util.ArrayList<>();
+ Object[] backingSet = inRange.getBackingSet();
+
+ if (flag) { // flag -> border only
@ -535,15 +533,15 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
}
protected void addEntity(Entity entity) {
@@ -1795,6 +1914,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
@@ -1829,6 +1948,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
}
+ final void sendChunk(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) { this.a(entityplayer, apacket, chunk); } // Paper - OBFHELPER
private void a(EntityPlayer entityplayer, Packet<?>[] apacket, Chunk chunk) {
if (apacket[0] == null) {
apacket[0] = new PacketPlayOutMapChunk(chunk, 65535);
@@ -1980,7 +2100,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
apacket[0] = new PacketPlayOutMapChunk(chunk, 65535, true);
@@ -2014,7 +2134,7 @@ public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(this.tracker.chunkX, this.tracker.chunkZ);
PlayerChunk playerchunk = PlayerChunkMap.this.getVisibleChunk(chunkcoordintpair.pair());
@ -553,28 +551,28 @@ index 74b868d7cec0260a10ca7718f48308f4ec54d56b..f832e7cdfc6741a932787f02754f1452
}
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 628327e1e39299bbe64dff042d0187a9f79203a8..74571c1befa60e71e93de8052740a56f7b80e920 100644
index e0a95fde93d4a2339831cb8ea0918174e9914e34..bdee3540b675f8036c5c6a59d6f53057bbdd6a85 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -152,7 +152,7 @@ public abstract class PlayerList {
// CraftBukkit - getType()
@@ -176,7 +176,7 @@ public abstract class PlayerList {
// Spigot - view distance
networkmanager.queueImmunity = true; // Paper
- playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), WorldData.c(worlddata.getSeed()), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getType(), this.getMaxPlayers(), worlddata.getType(), worldserver.spigotConfig.viewDistance, flag1, !flag));
+ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), WorldData.c(worlddata.getSeed()), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getType(), this.getMaxPlayers(), worlddata.getType(), worldserver.getChunkProvider().playerChunkMap.getLoadViewDistance(), flag1, !flag)); // Paper - no-tick view distance
- playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.E(), this.s, worldserver1.getTypeKey(), worldserver1.getDimensionKey(), this.getMaxPlayers(), worldserver.spigotConfig.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld()));
+ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.E(), this.s, worldserver1.getTypeKey(), worldserver1.getDimensionKey(), this.getMaxPlayers(), worldserver1.getChunkProvider().playerChunkMap.getLoadViewDistance(), flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld())); // Paper - no-tick view distance
entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
@@ -776,7 +776,7 @@ public abstract class PlayerList {
WorldData worlddata = worldserver.getWorldData();
entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getType(), WorldData.c(worldserver.getWorldData().getSeed()), worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode()));
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutViewDistance(worldserver.spigotConfig.viewDistance)); // Spigot
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutViewDistance(worldserver.getChunkProvider().playerChunkMap.getLoadViewDistance())); // Paper - no-tick view distance
entityplayer1.spawnIn(worldserver);
@@ -818,7 +818,7 @@ public abstract class PlayerList {
// CraftBukkit start
WorldData worlddata = worldserver1.getWorldData();
entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getTypeKey(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag));
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutViewDistance(worldserver1.spigotConfig.viewDistance)); // Spigot
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutViewDistance(worldserver1.getChunkProvider().playerChunkMap.getLoadViewDistance())); // Spigot // Paper - no-tick view distance
entityplayer1.spawnIn(worldserver1);
entityplayer1.dead = false;
entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch));
@@ -1262,7 +1262,7 @@ public abstract class PlayerList {
entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch));
@@ -1285,7 +1285,7 @@ public abstract class PlayerList {
public void a(int i) {
this.viewDistance = i;
@ -584,10 +582,10 @@ index 628327e1e39299bbe64dff042d0187a9f79203a8..74571c1befa60e71e93de8052740a56f
while (iterator.hasNext()) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 1c7955d3ae7ddd1c2d924cec20a91202cf090f40..7bd3f789b6055d73f3a6c0628652cca241147887 100644
index cafa47b90320249f84cd1cc4aca1908a4982bffb..965b43da38832f37091929d954c2bb7e7fbc7798 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -444,8 +444,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
@@ -502,8 +502,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
this.b(blockposition, iblockdata1, iblockdata2);
}
@ -603,10 +601,10 @@ index 1c7955d3ae7ddd1c2d924cec20a91202cf090f40..7bd3f789b6055d73f3a6c0628652cca2
if (!this.isClientSide && (i & 1) != 0) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 1929aacbe83c401c7254484aa8df62ed1554e3ba..36207acffac3620879afd11bb47e06341a3dabb9 100644
index e044534d3cb47cf1228c5e5fa8920df8264fd0b5..745633509d3f948d46529d5439ec14cd01a05563 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2493,10 +2493,39 @@ public class CraftWorld implements World {
@@ -2496,10 +2496,39 @@ public class CraftWorld implements World {
// Spigot start
@Override
public int getViewDistance() {
@ -648,7 +646,7 @@ index 1929aacbe83c401c7254484aa8df62ed1554e3ba..36207acffac3620879afd11bb47e0634
private final Spigot spigot = new Spigot()
{
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index d873b8cf3aec01b791565c33b252889f99f181f9..f735217e7a99bf8286ea60158f9fe137e84ad75c 100644
index 97af8f8e3c48694c390036bb1455e6d22fcd1c49..901aac23ae2878f4b05e986e8a363b95371ca6c3 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -201,7 +201,7 @@ public class ActivationRange

View File

@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Mariell Hoversholm <proximyst@proximyst.com>
Date: Sun, 19 Apr 2020 12:25:20 +0200
Subject: [PATCH] Allow sleeping players to float
This change lets players who are in their bed have a position which is above
ground for a longer period of time. This is because of the server not setting
their position to the ground/exit location when entering the bed, resulting in
the server believing they're still in the air.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 6dd4303c1c211ac4b0bb542ea96cc150581bf8c1..08e087d952edfecd73ad698684b71c09dabbac9e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -160,7 +160,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
this.player.setLocation(this.l, this.m, this.n, this.player.yaw, this.player.pitch);
++this.e;
this.processedMovePackets = this.receivedMovePackets;
- if (this.B) {
+ if (this.B && !this.player.isSleeping()) { // Paper - #3176 Allow sleeping players to float
if (++this.C > 80) {
PlayerConnection.LOGGER.warn("{} was kicked for floating too long!", this.player.getDisplayName().getString());
this.disconnect(com.destroystokyo.paper.PaperConfig.flyingKickPlayerMessage); // Paper - use configurable kick message