Update Paper

This commit is contained in:
Spottedleaf 2023-12-23 06:03:14 -08:00
parent cd713b8ea2
commit 9a389a1a5e
5 changed files with 52 additions and 80 deletions

View File

@ -2,7 +2,7 @@ group=dev.folia
version=1.20.4-R0.1-SNAPSHOT
mcVersion=1.20.4
paperRef=e3140fb70e818b9e3fd7becbb9842e7f24847bb5
paperRef=1e7dd72f15a1d13b43792367193547c656a16ab6
org.gradle.caching=true
org.gradle.parallel=true

View File

@ -8806,10 +8806,10 @@ index e08f4e39db4ee3fed62e37364d17dcc5c5683504..7e92e14cdb9f3d895550991b2ea154a6
}
}
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
index 5d4c5cc8eb06f2e6c31df6cbb98ea642b2264d49..0f74d6d64437150ad8f154354162f6ffe0532180 100644
index ee0331a6bc40cdde08d926fd8eb1dc642630c2e5..feea642338c7fdd96d9c4d2ea5564f1c3743195c 100644
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -1650,7 +1650,7 @@ public final class CollisionUtil {
@@ -1623,7 +1623,7 @@ public final class CollisionUtil {
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
@ -12837,7 +12837,7 @@ index 55f96545d6db95e3e657502a7910d96fded1113e..b39dd5a11a34407244666d8b9c1e775d
public String getDebugStatus() {
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7 100644
index 44ada45d9bf2d9b48e5de1c3cb1a855902f3884b..a21cc9c7d5981c742f379affe9c1ef4dcb0fa1e1 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -58,73 +58,42 @@ public class ServerChunkCache extends ChunkSource {
@ -12987,37 +12987,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
if (!this.level.isDebug()) {
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
@@ -520,9 +471,9 @@ public class ServerChunkCache extends ChunkSource {
// Paper start - optimise chunk tick iteration
ChunkMap playerChunkMap = this.chunkMap;
- for (ServerPlayer player : this.level.players) {
+ for (ServerPlayer player : this.level.getLocalPlayers()) { // Folia - region threading
if (!player.affectsSpawning || player.isSpectator()) {
- playerChunkMap.playerMobSpawnMap.remove(player);
+ regionizedWorldData.mobSpawnMap.remove(player); // Folia - region threading
player.playerNaturallySpawnedEvent = null;
player.lastEntitySpawnRadiusSquared = -1.0;
continue;
@@ -538,7 +489,7 @@ public class ServerChunkCache extends ChunkSource {
com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
event.callEvent();
if (event.isCancelled() || event.getSpawnRadius() < 0) {
- playerChunkMap.playerMobSpawnMap.remove(player);
+ regionizedWorldData.mobSpawnMap.remove(player); // Folia - region threading
player.playerNaturallySpawnedEvent = null;
player.lastEntitySpawnRadiusSquared = -1.0;
continue;
@@ -548,7 +499,7 @@ public class ServerChunkCache extends ChunkSource {
int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX());
int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ());
- playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
+ regionizedWorldData.mobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range); // Folia - region threading
player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
player.playerNaturallySpawnedEvent = event;
}
@@ -563,7 +514,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -530,7 +481,7 @@ public class ServerChunkCache extends ChunkSource {
NaturalSpawner.SpawnState spawnercreature_d; // moved down
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
// re-set mob counts
@ -13026,7 +12996,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
// Paper start - per player mob spawning backoff
for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
player.mobCounts[ii] = 0;
@@ -576,21 +527,21 @@ public class ServerChunkCache extends ChunkSource {
@@ -543,22 +494,22 @@ public class ServerChunkCache extends ChunkSource {
}
// Paper end - per player mob spawning backoff
}
@ -13046,6 +13016,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
+ boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.getLocalPlayers().isEmpty(); // CraftBukkit // Folia - region threadin
// Paper start - optimise chunk tick iteration
ChunkMap playerChunkMap = this.chunkMap;
- for (ServerPlayer player : this.level.players) {
+ for (ServerPlayer player : this.level.getLocalPlayers()) { // Folia - region threading
if (!player.affectsSpawning || player.isSpectator()) {
@ -13054,7 +13025,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
player.playerNaturallySpawnedEvent = null;
player.lastEntitySpawnRadiusSquared = -1.0;
continue;
@@ -606,7 +557,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -574,7 +525,7 @@ public class ServerChunkCache extends ChunkSource {
com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange);
event.callEvent();
if (event.isCancelled() || event.getSpawnRadius() < 0) {
@ -13063,7 +13034,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
player.playerNaturallySpawnedEvent = null;
player.lastEntitySpawnRadiusSquared = -1.0;
continue;
@@ -616,23 +567,23 @@ public class ServerChunkCache extends ChunkSource {
@@ -584,13 +535,13 @@ public class ServerChunkCache extends ChunkSource {
int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX());
int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ());
@ -13076,9 +13047,10 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
int l = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
- boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
+ boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getRedstoneGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit // Folia - region threading
// Paper - optimise chunk tick iteration
int chunksTicked = 0; // Paper
// Paper start - optimise chunk tick iteration
@@ -598,10 +549,10 @@ public class ServerChunkCache extends ChunkSource {
io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = this.chunkMap.getNearbyPlayers(); // Paper - optimise chunk tick iteration
Iterator<LevelChunk> chunkIterator;
if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) {
@ -13092,7 +13064,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
while (chunkIterator.hasNext()) {
shuffled.add(chunkIterator.next());
}
@@ -702,17 +653,21 @@ public class ServerChunkCache extends ChunkSource {
@@ -671,17 +622,21 @@ public class ServerChunkCache extends ChunkSource {
// Paper - optimise chunk tick iteration
this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing
// Paper start - optimise chunk tick iteration
@ -13122,7 +13094,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
// Paper end - optimise chunk tick iteration
this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing
// Paper - optimise chunk tick iteration
@@ -775,14 +730,19 @@ public class ServerChunkCache extends ChunkSource {
@@ -744,14 +699,19 @@ public class ServerChunkCache extends ChunkSource {
@Override
public void onLightUpdate(LightLayer type, SectionPos pos) {
@ -13144,7 +13116,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
}
public <T> void addRegionTicket(TicketType<T> ticketType, ChunkPos pos, int radius, T argument) {
@@ -854,7 +814,8 @@ public class ServerChunkCache extends ChunkSource {
@@ -823,7 +783,8 @@ public class ServerChunkCache extends ChunkSource {
@Nullable
@VisibleForDebug
public NaturalSpawner.SpawnState getLastSpawnState() {
@ -13154,7 +13126,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
}
public void removeTicketsOnClosing() {
@@ -887,8 +848,43 @@ public class ServerChunkCache extends ChunkSource {
@@ -856,8 +817,43 @@ public class ServerChunkCache extends ChunkSource {
return ServerChunkCache.this.mainThread;
}
@ -13198,7 +13170,7 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..a363c9d74d2a50a3bb3c3e323f7cf921
ServerChunkCache.this.level.getProfiler().incrementCounter("runTask");
super.doRunTask(task);
}
@@ -896,10 +892,15 @@ public class ServerChunkCache extends ChunkSource {
@@ -865,10 +861,15 @@ public class ServerChunkCache extends ChunkSource {
@Override
// CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
public boolean pollTask() {
@ -14255,7 +14227,7 @@ index b78a9628a88f2a495ef6de74446a02a14d41a1f6..72af30b281f2bb1dd4beee746a1b3f7b
for (ServerPlayer player : ServerLevel.this.players) {
player.getBukkitEntity().onEntityRemove(entity);
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 8efbbd379244e3ed54d4aba199037cc20ccd096a..c66815bd2a13554aec7176258f8fae542d668d3f 100644
index d1f20a8a3ccea1f074624163eb96da023142a459..08176ffc089fd20f64f98690d0f383f6d91aaf53 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -191,7 +191,7 @@ import org.bukkit.inventory.MainHand;
@ -16390,7 +16362,7 @@ index ea27b46eec01bda427653335f922ccd068cffcb5..e551d3b875eab6851b75041f418c9a08
return blockToFallLocation(blockState);
} else {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2d27baf83 100644
index 0c46a4aeafd03fbbfd590b0362d41bf2b1d5ca74..8f9e9936400d00e001f8791e9bc8213d898f6073 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -167,7 +167,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@ -16411,7 +16383,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper
public @Nullable Throwable addedToWorldStack; // Paper - entity debug
@@ -536,6 +536,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -535,6 +535,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.teleportTo(worldserver, null);
}
// Paper end - make end portalling safe
@ -16437,7 +16409,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
public boolean isLegacyTrackingEntity = false;
@@ -543,28 +562,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -542,28 +561,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.isLegacyTrackingEntity = isLegacyTrackingEntity;
}
@ -16467,7 +16439,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
// Paper end - optimise entity tracking
public Entity(EntityType<?> type, Level world) {
@@ -808,6 +806,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -807,6 +805,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// CraftBukkit start
public void postTick() {
@ -16480,7 +16452,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
// No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
if (!(this instanceof ServerPlayer) && this.isAlive()) { // Paper - don't attempt to teleport dead entities
this.handleNetherPortal();
@@ -830,7 +834,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -829,7 +833,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@ -16489,7 +16461,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -939,11 +943,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -938,11 +942,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// This will be called every single tick the entity is in lava, so don't throw an event
this.setSecondsOnFire(15, false);
}
@ -16503,7 +16475,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
// CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
}
@@ -1088,8 +1092,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1087,8 +1091,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} else {
this.wasOnFire = this.isOnFire();
if (movementType == MoverType.PISTON) {
@ -16514,7 +16486,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
movement = this.limitPistonMovement(movement);
if (movement.equals(Vec3.ZERO)) {
return;
@@ -3001,7 +3005,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2996,7 +3000,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.passengers = ImmutableList.copyOf(list);
}
@ -16523,7 +16495,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
}
}
@@ -3050,7 +3054,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3045,7 +3049,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
entity.boardingCooldown = 60;
@ -16532,7 +16504,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
}
return true; // CraftBukkit
}
@@ -3330,6 +3334,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3325,6 +3329,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@Nullable
public PlayerTeam getTeam() {
@ -16544,7 +16516,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
}
@@ -3445,9 +3454,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3440,9 +3449,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (this.fireImmune()) {
return;
}
@ -16556,7 +16528,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
return;
}
// CraftBukkit end
@@ -3620,6 +3629,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3615,6 +3624,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.portalEntrancePos = original.portalEntrancePos;
}
@ -17332,7 +17304,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
@Nullable
public Entity changeDimension(ServerLevel destination) {
// CraftBukkit start
@@ -3628,6 +4406,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3623,6 +4401,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@Nullable
public Entity teleportTo(ServerLevel worldserver, Vec3 location) {
@ -17344,7 +17316,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
// CraftBukkit end
// Paper start - fix bad state entities causing dupes
if (!this.isAlive() || !this.valid) {
@@ -3720,6 +4503,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3715,6 +4498,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
}
@ -17357,7 +17329,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
protected void removeAfterChangingDimensions() {
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
}
@@ -4657,7 +5446,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4652,7 +5441,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
}
// Paper end - fix MC-4
@ -17367,7 +17339,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
synchronized (this.posLock) { // Paper
this.position = new Vec3(x, y, z);
} // Paper
@@ -4678,7 +5468,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4673,7 +5463,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// Paper start - never allow AABB to become desynced from position
// hanging has its own special logic
@ -17376,7 +17348,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
this.setBoundingBox(this.makeBoundingBox());
}
// Paper end
@@ -4765,6 +5555,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4760,6 +5550,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return this.removalReason != null;
}
@ -17389,7 +17361,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
@Nullable
public Entity.RemovalReason getRemovalReason() {
return this.removalReason;
@@ -4780,6 +5576,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4775,6 +5571,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
// Paper end - rewrite chunk system
final boolean alreadyRemoved = this.removalReason != null;
@ -17399,7 +17371,7 @@ index 9abe817ae202edaa2d88cd59ae5c7db0b1c634be..9f38cec134dfd476d0a8d56b628238d2
if (this.removalReason == null) {
this.removalReason = reason;
}
@@ -4802,6 +5601,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4797,6 +5596,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.removalReason = null;
}

View File

@ -29,10 +29,10 @@ index 41bf71d116ffc5431586ce54abba7f8def6c1dcf..519da6886613b8460e989767b1a21e31
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9f38cec134dfd476d0a8d56b628238d2d27baf83..65ae803da6fa395c9ad031460fc76077da62aeec 100644
index 8f9e9936400d00e001f8791e9bc8213d898f6073..34724fd847a99349f13a6690d1abe27647bc80ca 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2918,6 +2918,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2913,6 +2913,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@ -40,7 +40,7 @@ index 9f38cec134dfd476d0a8d56b628238d2d27baf83..65ae803da6fa395c9ad031460fc76077
// CraftBukkit start
if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity());
@@ -2939,6 +2940,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2934,6 +2935,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (event.isCancelled()) {
return false;
}
@ -48,7 +48,7 @@ index 9f38cec134dfd476d0a8d56b628238d2d27baf83..65ae803da6fa395c9ad031460fc76077
// Spigot end
if (this.isPassenger()) {
this.stopRiding();
@@ -3017,6 +3019,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3012,6 +3014,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
@ -56,7 +56,7 @@ index 9f38cec134dfd476d0a8d56b628238d2d27baf83..65ae803da6fa395c9ad031460fc76077
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -3044,6 +3047,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3039,6 +3042,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (event.isCancelled()) {
return false;
}

View File

@ -9,7 +9,7 @@ data deserialization and is racey even in Vanilla. But in Folia,
some accesses may throw and as such we need to fix this directly.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index c66815bd2a13554aec7176258f8fae542d668d3f..a22173984c418e648ae5308de26fbd5f9cbe6973 100644
index 08176ffc089fd20f64f98690d0f383f6d91aaf53..0b27e7ffdc6b61b8e64afc253a8470c1ad8791dd 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -644,7 +644,7 @@ public class ServerPlayer extends Player {

View File

@ -1518,7 +1518,7 @@ index f640a0b8742a8362401f91a9a0f8fbb31885dca0..50597a8b45bbd7dcc40b361da78358d9
// Folia end - region threading - replace entity tracking ticking
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180ee846c51 100644
index a21cc9c7d5981c742f379affe9c1ef4dcb0fa1e1..88db5ada13329a5fe0d0fb652d2c8a8d561649e8 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -434,16 +434,23 @@ public class ServerChunkCache extends ChunkSource {
@ -1553,7 +1553,7 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
//long i = this.level.getGameTime(); // Folia - region threading
long j = 1; // Folia - region threading
@@ -512,6 +520,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -479,6 +487,7 @@ public class ServerChunkCache extends ChunkSource {
// Paper start - per player mob spawning
int naturalSpawnChunkCount = k;
NaturalSpawner.SpawnState spawnercreature_d; // moved down
@ -1561,7 +1561,7 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
// re-set mob counts
for (ServerPlayer player : this.level.getLocalPlayers()) { // Folia - region threading
@@ -531,6 +540,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -498,6 +507,7 @@ public class ServerChunkCache extends ChunkSource {
} else {
spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, regionizedWorldData.getLoadedEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); // Folia - region threading - note: function only cares about loaded entities, doesn't need all
}
@ -1569,7 +1569,7 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
// Paper end
this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings
@@ -592,6 +602,9 @@ public class ServerChunkCache extends ChunkSource {
@@ -561,6 +571,9 @@ public class ServerChunkCache extends ChunkSource {
}
try {
// Paper end - optimise chunk tick iteration
@ -1577,9 +1577,9 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
+ long randomChunkCount = 0L; // Folia - profiler
+ profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.SPAWN_AND_RANDOM_TICK); try { // Folia - profiler
while (chunkIterator.hasNext()) {
LevelChunk chunk1 = chunkIterator.next(); // Paper - optimise chunk tick iteration
ChunkPos chunkcoordintpair = chunk1.getPos();
@@ -623,15 +636,20 @@ public class ServerChunkCache extends ChunkSource {
LevelChunk chunk1 = chunkIterator.next();
// Paper end - optimise chunk tick iteration
@@ -592,15 +605,20 @@ public class ServerChunkCache extends ChunkSource {
// Paper end - optimise chunk tick iteration
chunk1.incrementInhabitedTime(j);
if (spawn && flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration
@ -1600,7 +1600,7 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
// Paper start - optimise chunk tick iteration
} finally {
if (chunkIterator instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) {
@@ -643,9 +661,11 @@ public class ServerChunkCache extends ChunkSource {
@@ -612,9 +630,11 @@ public class ServerChunkCache extends ChunkSource {
gameprofilerfiller.popPush("customSpawners");
if (flag) {
@ -1612,7 +1612,7 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
}
}
@@ -655,6 +675,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -624,6 +644,7 @@ public class ServerChunkCache extends ChunkSource {
// Paper start - optimise chunk tick iteration
// Folia start - region threading
if (!this.level.needsChangeBroadcasting.isEmpty()) {
@ -1620,7 +1620,7 @@ index a363c9d74d2a50a3bb3c3e323f7cf921c50bbff7..d248c0492a34c11fb96c9dd6f0a3d180
for (Iterator<ChunkHolder> iterator = this.level.needsChangeBroadcasting.iterator(); iterator.hasNext();) {
ChunkHolder holder = iterator.next();
if (!io.papermc.paper.util.TickThread.isTickThreadFor(holder.newChunkHolder.world, holder.pos)) {
@@ -666,6 +687,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -635,6 +656,7 @@ public class ServerChunkCache extends ChunkSource {
iterator.remove();
}
}