Skip to content

Commit

Permalink
[ci skip] Add more identifying patch comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Jan 21, 2024
1 parent f7dd304 commit 98e6d20
Show file tree
Hide file tree
Showing 66 changed files with 315 additions and 355 deletions.
12 changes: 2 additions & 10 deletions patches/api/0345-Add-GameEvent-tags.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ Subject: [PATCH] Add GameEvent tags


diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java
index 31bdecf8cbea40129a568c1761f27fa1ae0f535a..35d52539f264202d50d70e6aaab4678571dc8ad2 100644
index 31bdecf8cbea40129a568c1761f27fa1ae0f535a..741c34b74811666c3b38e9d6fbb74b0a7bc64699 100644
--- a/src/main/java/org/bukkit/Tag.java
+++ b/src/main/java/org/bukkit/Tag.java
@@ -968,6 +968,7 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla tag representing entities which are dismounted when underwater.
*/
Tag<EntityType> ENTITY_TYPES_DISMOUNTS_UNDERWATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("dismounts_underwater"), EntityType.class);
+
/**
* Vanilla tag representing entities which are not controlled by their mount.
*/
@@ -985,6 +986,25 @@ public interface Tag<T extends Keyed> extends Keyed {
@@ -985,6 +985,25 @@ public interface Tag<T extends Keyed> extends Keyed {
*/
Tag<EntityType> ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class);

Expand Down
4 changes: 2 additions & 2 deletions patches/api/0446-add-missing-Experimental-annotations.patch
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,10 @@ index 72ea6ddd00eed73459d700d657929f83ba1ca7ee..bb1b6bc9349af6dec369420035e86092
ITEM_CHORUS_FRUIT_TELEPORT("item.chorus_fruit.teleport"),
ITEM_CROP_PLANT("item.crop.plant"),
diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java
index 35d52539f264202d50d70e6aaab4678571dc8ad2..8b584130c039ba915f28dc87f13c2538f26134f2 100644
index 741c34b74811666c3b38e9d6fbb74b0a7bc64699..1137a21afa0283fa3d391415e98171e3c160aa1f 100644
--- a/src/main/java/org/bukkit/Tag.java
+++ b/src/main/java/org/bukkit/Tag.java
@@ -976,14 +976,17 @@ public interface Tag<T extends Keyed> extends Keyed {
@@ -975,14 +975,17 @@ public interface Tag<T extends Keyed> extends Keyed {
/**
* Vanilla tag representing entities which deflect arrows.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 6 Apr 2019 10:16:48 -0400
Subject: [PATCH] Optimize Captured TileEntity Lookup
Subject: [PATCH] Optimize Captured BlockEntity Lookup

upstream was doing a containsKey/get pattern, and always doing it at that.
that scenario is only even valid if were in the middle of a block place.
Expand All @@ -10,7 +10,7 @@ Optimize to check if the captured list even has values in it, and also to
just do a get call since the value can never be null.

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index b10c93cbcf264a3e13d48f30a2c09ae5568a510e..3fdec0ff323ac94517f1ab9a13764a8959148127 100644
index b10c93cbcf264a3e13d48f30a2c09ae5568a510e..c8b2399c55c8ea4fcb953202c0ea74d95b47c359 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -998,9 +998,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
Expand All @@ -19,12 +19,12 @@ index b10c93cbcf264a3e13d48f30a2c09ae5568a510e..3fdec0ff323ac94517f1ab9a13764a89
public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) {
- if (this.capturedTileEntities.containsKey(blockposition)) {
- return this.capturedTileEntities.get(blockposition);
+ // Paper start - Optimize capturedTileEntities lookup
+ // Paper start - Perf: Optimize capturedTileEntities lookup
+ net.minecraft.world.level.block.entity.BlockEntity blockEntity;
+ if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) {
+ return blockEntity;
}
+ // Paper end
+ // Paper end - Perf: Optimize capturedTileEntities lookup
// CraftBukkit end
return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system
}
4 changes: 2 additions & 2 deletions patches/server/0302-Mob-Spawner-API-Enhancements.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public net.minecraft.world.level.BaseSpawner delay(Lnet/minecraft/world/level/Le
public net.minecraft.world.level.BaseSpawner setNextSpawnData(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/SpawnData;)V

diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index 231674f1483ad71630ac71ba92efc50f94a5659b..0578ac12d92f9af0b0113587db9351b4a41bedd5 100644
index 231674f1483ad71630ac71ba92efc50f94a5659b..3b48d50bd3727647dc2d73cccc3fbd8a4f649715 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -235,7 +235,13 @@ public abstract class BaseSpawner {
Expand Down Expand Up @@ -64,7 +64,7 @@ index 231674f1483ad71630ac71ba92efc50f94a5659b..0578ac12d92f9af0b0113587db9351b4
+
+ nbt.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay));
+ nbt.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay));
+ // Paper nbt
+ // Paper end
nbt.putShort("SpawnCount", (short) this.spawnCount);
nbt.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities);
nbt.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,49 @@ Subject: [PATCH] Configurable Keep Spawn Loaded range per world
This lets you disable it for some worlds and lower it for others.

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f317b9fdb2bfbae9babd64d4801f190042fc1867..6407af497c719d0f6a4446192bed622af34d6bc6 100644
index f317b9fdb2bfbae9babd64d4801f190042fc1867..1d069e33f64463e96199fa336336ffc44e3ed10e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -768,30 +768,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

// CraftBukkit start
public void prepareLevels(ChunkProgressListener worldloadlistener, ServerLevel worldserver) {
+ ServerChunkCache chunkproviderserver = worldserver.getChunkSource(); // Paper
+ ServerChunkCache chunkproviderserver = worldserver.getChunkSource(); // Paper - Configurable Keep Spawn Loaded range per world
// WorldServer worldserver = this.overworld();
this.forceTicks = true;
// CraftBukkit end
+ if (worldserver.getWorld().getKeepSpawnInMemory()) { // Paper
+ if (worldserver.getWorld().getKeepSpawnInMemory()) { // Paper - Configurable Keep Spawn Loaded range per world

MinecraftServer.LOGGER.info("Preparing start region for dimension {}", worldserver.dimension().location());
BlockPos blockposition = worldserver.getSharedSpawnPos();

worldloadlistener.updateSpawnPos(new ChunkPos(blockposition));
- ServerChunkCache chunkproviderserver = worldserver.getChunkSource();
+ //ChunkProviderServer chunkproviderserver = worldserver.getChunkProvider(); // Paper - move up
+ //ChunkProviderServer chunkproviderserver = worldserver.getChunkProvider(); // Paper - Configurable Keep Spawn Loaded range per world; move up

this.nextTickTimeNanos = Util.getNanos();
- // CraftBukkit start
- if (worldserver.getWorld().getKeepSpawnInMemory()) {
- chunkproviderserver.addRegionTicket(TicketType.START, new ChunkPos(blockposition), 11, Unit.INSTANCE);
-
- while (chunkproviderserver.getTickingGenerated() != 441) {
- // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.executeModerately();
- }
- }
+ // Paper start - configurable spawn reason
+ // Paper start - Configurable Keep Spawn Loaded range per world
+ int radiusBlocks = worldserver.paperConfig().spawn.keepSpawnLoadedRange * 16;
+ int radiusChunks = radiusBlocks / 16 + ((radiusBlocks & 15) != 0 ? 1 : 0);
+ int totalChunks = ((radiusChunks) * 2 + 1);
+ totalChunks *= totalChunks;
+ worldloadlistener.setChunkRadius(radiusBlocks / 16);
+

- while (chunkproviderserver.getTickingGenerated() != 441) {
- // this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
- this.executeModerately();
- }
- }
+ worldserver.addTicketsForSpawn(radiusBlocks, blockposition);
+ // Paper end
+ // Paper end - Configurable Keep Spawn Loaded range per world

// this.nextTickTimeNanos = SystemUtils.getNanos() + MinecraftServer.PREPARE_LEVELS_DEFAULT_DELAY_NANOS;
this.executeModerately();
// Iterator iterator = this.levels.values().iterator();
+ }
+ } // Paper - Configurable Keep Spawn Loaded range per world

if (true) {
ServerLevel worldserver1 = worldserver;
Expand All @@ -58,19 +57,19 @@ index f317b9fdb2bfbae9babd64d4801f190042fc1867..6407af497c719d0f6a4446192bed622a
this.executeModerately();
// CraftBukkit end
- worldloadlistener.stop();
+ if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper
+ if (worldserver.getWorld().getKeepSpawnInMemory()) worldloadlistener.stop(); // Paper - Configurable Keep Spawn Loaded range per world
// CraftBukkit start
// this.updateMobSpawningFlags();
worldserver.setSpawnSettings(this.isSpawningMonsters(), this.isSpawningAnimals());
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 43424a9d8e985f4965b4d101f7fee398e3d1f52c..978f0f20c3aceb1c6f967c2bec3d010e344aad0c 100644
index 43424a9d8e985f4965b4d101f7fee398e3d1f52c..e8d54a421bb743844c031a4e43965e5873f79995 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1897,12 +1897,84 @@ public class ServerLevel extends Level implements WorldGenLevel {
return ((MapIndex) this.getServer().overworld().getDataStorage().computeIfAbsent(MapIndex.factory(), "idcounts")).getFreeAuxValueForMap();
}

+ // Paper start - helper function for configurable spawn radius
+ // Paper start - Configurable Keep Spawn Loaded range per world
+ public void addTicketsForSpawn(int radiusInBlocks, BlockPos spawn) {
+ // In order to respect vanilla behavior, which is ensuring everything but the spawn border can tick, we add tickets
+ // with level 31 for the non-border spawn chunks
Expand Down Expand Up @@ -135,11 +134,11 @@ index 43424a9d8e985f4965b4d101f7fee398e3d1f52c..978f0f20c3aceb1c6f967c2bec3d010e
+ chunkproviderserver.removeRegionTicket(TicketType.START, new ChunkPos(spawn.offset(-radiusInBlocks, 0, z)), 1, Unit.INSTANCE); // level 32
+ }
+ }
+ // Paper end
+ // Paper end - Configurable Keep Spawn Loaded range per world
+
public void setDefaultSpawnPos(BlockPos pos, float angle) {
- ChunkPos chunkcoordintpair = new ChunkPos(new BlockPos(this.levelData.getXSpawn(), 0, this.levelData.getZSpawn()));
+ // Paper - configurable spawn radius
+ // Paper start - Configurable Keep Spawn Loaded range per world

This comment has been minimized.

Copy link
@Lulu13022002

Lulu13022002 Jan 21, 2024

Contributor

There's no paper end comment to this start

+ BlockPos prevSpawn = this.getSharedSpawnPos();
+ //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c()));

Expand All @@ -155,18 +154,18 @@ index 43424a9d8e985f4965b4d101f7fee398e3d1f52c..978f0f20c3aceb1c6f967c2bec3d010e
}

diff --git a/src/main/java/net/minecraft/server/level/progress/ChunkProgressListener.java b/src/main/java/net/minecraft/server/level/progress/ChunkProgressListener.java
index 1b565b2809c2d367e21971c5154f35c9763995e6..b0f899835ded29aff108d1674bf4a1a6c89693db 100644
index 1b565b2809c2d367e21971c5154f35c9763995e6..4792eaa30464f4c4ca7f2d6cf20f734beed81f23 100644
--- a/src/main/java/net/minecraft/server/level/progress/ChunkProgressListener.java
+++ b/src/main/java/net/minecraft/server/level/progress/ChunkProgressListener.java
@@ -12,4 +12,6 @@ public interface ChunkProgressListener {
void start();

void stop();
+
+ void setChunkRadius(int radius); // Paper - allow changing chunk radius
+ void setChunkRadius(int radius); // Paper - Configurable Keep Spawn Loaded range per world
}
diff --git a/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java b/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java
index 4d2348df25410a0b5364eec066880326d6667dad..b9176ec634ed806dda6ce84b8978803111462428 100644
index 4d2348df25410a0b5364eec066880326d6667dad..3754cda7e7731935893359d84f3ae06157a347c6 100644
--- a/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java
+++ b/src/main/java/net/minecraft/server/level/progress/LoggerChunkProgressListener.java
@@ -11,12 +11,19 @@ import org.slf4j.Logger;
Expand All @@ -180,13 +179,13 @@ index 4d2348df25410a0b5364eec066880326d6667dad..b9176ec634ed806dda6ce84b89788031
private long nextTickTime = Long.MAX_VALUE;

public LoggerChunkProgressListener(int radius) {
+ // Paper start - Allow changing radius later for configurable spawn patch
+ // Paper start - Configurable Keep Spawn Loaded range per world
+ this.setChunkRadius(radius); // Move to method
+ }
+
+ @Override
+ public void setChunkRadius(int radius) {
+ // Paper end
+ // Paper end - Configurable Keep Spawn Loaded range per world
int i = radius * 2 + 1;
this.maxCount = i * i;
}
Expand Down
40 changes: 6 additions & 34 deletions patches/server/0307-Allow-Saving-of-Oversized-Chunks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ this fix, as the data will remain in the oversized file. Once the server returns
to a jar with this fix, the data will be restored.

diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
index 2a7f17726a161ddbcd0397fb4332de6980199c38..72dacdc271325c814fb43cd6daaf3a209801ffda 100644
index 2a7f17726a161ddbcd0397fb4332de6980199c38..69ed808ca5fbfb9191d0818bb0f1c839d11d9d11 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -18,8 +18,11 @@ import java.nio.file.LinkOption;
Expand Down Expand Up @@ -71,7 +71,7 @@ index 2a7f17726a161ddbcd0397fb4332de6980199c38..72dacdc271325c814fb43cd6daaf3a20

+ // Paper start
+ private final byte[] oversized = new byte[1024];
+ private int oversizedCount = 0;
+ private int oversizedCount;
+
+ private synchronized void initOversizedState() throws IOException {
+ Path metaFile = getOversizedMetaFile();
Expand Down Expand Up @@ -141,10 +141,10 @@ index 2a7f17726a161ddbcd0397fb4332de6980199c38..72dacdc271325c814fb43cd6daaf3a20

private final ChunkPos pos;
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index 465ad0bae446a20e941e8f2dbf2d85f2627482b9..2ab7060f5c9a54bc7beb819f381a202c977f0a80 100644
index 465ad0bae446a20e941e8f2dbf2d85f2627482b9..affd43308ac565066cefa799238e46b75a28b270 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -121,6 +121,71 @@ public class RegionFileStorage implements AutoCloseable {
@@ -121,6 +121,43 @@ public class RegionFileStorage implements AutoCloseable {
}
}

Expand All @@ -153,22 +153,6 @@ index 465ad0bae446a20e941e8f2dbf2d85f2627482b9..2ab7060f5c9a54bc7beb819f381a202c
+ org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed.");
+ }
+
+ private static final int DEFAULT_SIZE_THRESHOLD = 1024 * 8;
+ private static final int OVERZEALOUS_TOTAL_THRESHOLD = 1024 * 64;
+ private static final int OVERZEALOUS_THRESHOLD = 1024;
+ private static int SIZE_THRESHOLD = DEFAULT_SIZE_THRESHOLD;
+ private static void resetFilterThresholds() {
+ SIZE_THRESHOLD = Math.max(1024 * 4, Integer.getInteger("Paper.FilterThreshhold", DEFAULT_SIZE_THRESHOLD));
+ }
+ static {
+ resetFilterThresholds();
+ }
+
+ static boolean isOverzealous() {
+ return SIZE_THRESHOLD == OVERZEALOUS_THRESHOLD;
+ }
+
+
+ private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException {
+ synchronized (regionfile) {
+ try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
Expand Down Expand Up @@ -199,24 +183,12 @@ index 465ad0bae446a20e941e8f2dbf2d85f2627482b9..2ab7060f5c9a54bc7beb819f381a202c
+ level.put(key, levelList);
+ }
+ }
+
+ private static int getNBTSize(net.minecraft.nbt.Tag nbtBase) {
+ DataOutputStream test = new DataOutputStream(new org.apache.commons.io.output.NullOutputStream());
+ try {
+ nbtBase.write(test);
+ return test.size();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return 0;
+ }
+ }
+
+ // Paper end
+
@Nullable
public CompoundTag read(ChunkPos pos) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -132,6 +197,12 @@ public class RegionFileStorage implements AutoCloseable {
@@ -132,6 +169,12 @@ public class RegionFileStorage implements AutoCloseable {
try { // Paper
DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos);

Expand All @@ -229,7 +201,7 @@ index 465ad0bae446a20e941e8f2dbf2d85f2627482b9..2ab7060f5c9a54bc7beb819f381a202c
CompoundTag nbttagcompound;
label43:
{
@@ -218,6 +289,7 @@ public class RegionFileStorage implements AutoCloseable {
@@ -218,6 +261,7 @@ public class RegionFileStorage implements AutoCloseable {

try {
NbtIo.write(nbt, (DataOutput) dataoutputstream);
Expand Down
Loading

0 comments on commit 98e6d20

Please sign in to comment.