Skip to content

Commit 2d6e82e

Browse files
authored
Change world storage layout to be closer to vanilla & implement migration (#13736)
1 parent 33a9258 commit 2d6e82e

39 files changed

+1572
-605
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ jobs:
115115
116116
- name: Create Paperclip Jar
117117
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
118-
run: ./gradlew createMojmapPaperclipJar --stacktrace
118+
run: ./gradlew createPaperclipJar --stacktrace
119119

120120
- name: Upload Paperclip Jar
121121
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
122122
uses: actions/upload-artifact@v4
123123
with:
124124
name: paper-${{ fromJSON(steps.determine.outputs.result).pr }}
125-
path: paper-server/build/libs/paper-paperclip-*-mojmap.jar
125+
path: paper-server/build/libs/paper-paperclip-*.jar
126126

127127
- name: Publish Artifacts
128128
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ nbactions.xml
2020
bin/
2121
dist/
2222
manifest.mf
23+
__pycache__/
2324

2425
# Mac filesystem dust
2526
.DS_Store/

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mcVersion=26.1
66
apiVersion=26.1
77

88
# Set to true while updating Minecraft version
9-
updatingMinecraft=true
9+
updatingMinecraft=false
1010

1111
org.gradle.configuration-cache=true
1212
org.gradle.caching=true

paper-api/src/main/java/org/bukkit/Server.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.File;
66
import java.io.Serializable;
77
import java.net.InetAddress;
8+
import java.nio.file.Path;
89
import java.util.Collection;
910
import java.util.Collections;
1011
import java.util.Iterator;
@@ -1565,7 +1566,6 @@ default int broadcast(net.kyori.adventure.text.@NotNull Component message) {
15651566
@NotNull
15661567
public ConsoleCommandSender getConsoleSender();
15671568

1568-
// Paper start
15691569
/**
15701570
* Creates a special {@link CommandSender} which redirects command feedback (in the form of chat messages) to the
15711571
* specified listener. The returned sender will have the same effective permissions as {@link #getConsoleSender()}.
@@ -1575,16 +1575,31 @@ default int broadcast(net.kyori.adventure.text.@NotNull Component message) {
15751575
*/
15761576
@NotNull
15771577
public CommandSender createCommandSender(final @NotNull java.util.function.Consumer<? super net.kyori.adventure.text.Component> feedback);
1578-
// Paper end
15791578

15801579
/**
1581-
* Gets the folder that contains all the various {@link World}s.
1580+
* Gets the folder that contains {@link #getLevelDirectory()}.
1581+
*
1582+
* <p>This is usually the server's current working directory
1583+
* but can be overridden using command line flags (i.e. {@code --universe} or {@code --world-container}).</p>
15821584
*
1583-
* @return folder that contains all worlds
1585+
* @return folder that contains the level directory
15841586
*/
1587+
@ApiStatus.Obsolete
15851588
@NotNull
15861589
public File getWorldContainer();
15871590

1591+
/**
1592+
* Gets the level directory.
1593+
*
1594+
* <p>This is the {@code ./world} directory in a fresh default server. Contains player data, dimensions, datapacks,
1595+
* and other world data.</p>
1596+
*
1597+
* @return the level directory
1598+
*/
1599+
@ApiStatus.Experimental
1600+
@NotNull
1601+
Path getLevelDirectory();
1602+
15881603
/**
15891604
* Gets every player that has ever played on this server.
15901605
* <p>

paper-api/src/main/java/org/bukkit/WorldCreator.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ public class WorldCreator {
3131
* @param name Name of the world that will be created
3232
*/
3333
public WorldCreator(@NotNull String name) {
34-
// Paper start
35-
this(name, getWorldKey(name));
34+
this(name, defaultWorldKey(name));
3635
}
3736

38-
private static NamespacedKey getWorldKey(String name) {
37+
private static NamespacedKey defaultWorldKey(String name) {
3938
final String mainLevelName = Bukkit.getUnsafe().getMainLevelName();
4039
if (name.equals(mainLevelName)) {
4140
return NamespacedKey.minecraft("overworld");
@@ -58,6 +57,9 @@ public WorldCreator(@NotNull String levelName, @NotNull NamespacedKey worldKey)
5857
if (levelName == null || worldKey == null) {
5958
throw new IllegalArgumentException("World name and key cannot be null");
6059
}
60+
if (!worldKey.equals(defaultWorldKey(levelName))) {
61+
throw new UnsupportedOperationException("Custom world keys not yet implemented");
62+
}
6163
this.name = levelName;
6264
this.seed = (new Random()).nextLong();
6365
this.key = worldKey;
@@ -104,7 +106,6 @@ public static WorldCreator ofNameAndKey(@NotNull String levelName, @NotNull Name
104106
public static WorldCreator ofKey(@NotNull NamespacedKey worldKey) {
105107
return new WorldCreator(worldKey);
106108
}
107-
// Paper end
108109

109110
/**
110111
* Copies the options from the specified world
@@ -589,7 +590,6 @@ public static BiomeProvider getBiomeProviderForName(@NotNull String world, @Null
589590
return result;
590591
}
591592

592-
// Paper start - keep spawn loaded tristate
593593
/**
594594
* Returns the current intent to keep the world loaded, @see {@link WorldCreator#keepSpawnLoaded(net.kyori.adventure.util.TriState)}
595595
*
@@ -615,5 +615,4 @@ public net.kyori.adventure.util.TriState keepSpawnLoaded() {
615615
public WorldCreator keepSpawnLoaded(@NotNull net.kyori.adventure.util.TriState keepSpawnLoaded) {
616616
return this;
617617
}
618-
// Paper end - keep spawn loaded tristate
619618
}

paper-server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ paperweight {
2323
gitFilePatches = false
2424

2525
updatingMinecraft {
26-
oldPaperCommit = "7e80cef5198561d0db53406127e5b8bc7af51577"
26+
// oldPaperCommit = "7e80cef5198561d0db53406127e5b8bc7af51577"
2727
}
2828
}
2929

paper-server/patches/features/0002-Allow-Saving-of-Oversized-Chunks.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ index 728ec122b7af090427cc7511a168336d539835a1..a60a417432cab517fd2fbfd4447c7cb7
119119
+ // Paper end
120120
}
121121
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
122-
index 7c6f16fa3de0d344202ec456c648aaebf24a69ca..6b265cc308a14846c9ef3c96aa5daf06e246b8a8 100644
122+
index 4473503da2459016859b2d72ecd7825df23f4be4..76f83dfa2acbd0840718a022102d820bf65ac1be 100644
123123
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
124124
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
125-
@@ -48,6 +48,43 @@ public final class RegionFileStorage implements AutoCloseable {
125+
@@ -49,6 +49,43 @@ public final class RegionFileStorage implements AutoCloseable {
126126
}
127127
}
128128

@@ -166,7 +166,7 @@ index 7c6f16fa3de0d344202ec456c648aaebf24a69ca..6b265cc308a14846c9ef3c96aa5daf06
166166
public @Nullable CompoundTag read(final ChunkPos pos) throws IOException {
167167
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
168168
RegionFile region = this.getRegionFile(pos, true);
169-
@@ -55,6 +92,12 @@ public final class RegionFileStorage implements AutoCloseable {
169+
@@ -56,6 +93,12 @@ public final class RegionFileStorage implements AutoCloseable {
170170
return null;
171171
}
172172
// CraftBukkit end
@@ -179,7 +179,7 @@ index 7c6f16fa3de0d344202ec456c648aaebf24a69ca..6b265cc308a14846c9ef3c96aa5daf06
179179

180180
CompoundTag var4;
181181
try (DataInputStream regionChunkInputStream = region.getChunkDataInputStream(pos)) {
182-
@@ -91,6 +134,7 @@ public final class RegionFileStorage implements AutoCloseable {
182+
@@ -92,6 +135,7 @@ public final class RegionFileStorage implements AutoCloseable {
183183
} else {
184184
try (DataOutputStream output = region.getChunkDataOutputStream(pos)) {
185185
NbtIo.write(value, output);

paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,18 @@ index 0000000000000000000000000000000000000000..c18823746ab2edcab536cb1589b7720e
354354
+ }
355355
+}
356356
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
357-
index 4f31c92c8c3b2757a4103a1b2a0ae158117eebd1..43c47bdd2fdb7731eec5301e20f923d0703a36fc 100644
357+
index 71446ef19c560f67d22697941973326e2b81bb60..6ea8d1c04afdaf2136dfd5fb3ab1899e8e62fc70 100644
358358
--- a/net/minecraft/server/level/ServerLevel.java
359359
+++ b/net/minecraft/server/level/ServerLevel.java
360-
@@ -591,6 +591,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
360+
@@ -599,6 +599,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
361361
profiler.pop();
362362
}
363363

364364
+ io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
365365
this.entityTickList
366366
.forEach(
367367
entity -> {
368-
@@ -1064,12 +1065,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
368+
@@ -1072,12 +1073,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
369369
entity.totalEntityAge++; // Paper - age-like counter for all entities
370370
profiler.push(entity.typeHolder()::getRegisteredName);
371371
profiler.incrementCounter("tickNonPassenger");
@@ -382,7 +382,7 @@ index 4f31c92c8c3b2757a4103a1b2a0ae158117eebd1..43c47bdd2fdb7731eec5301e20f923d0
382382
}
383383
// Paper start - log detailed entity tick information
384384
} finally {
385-
@@ -1080,7 +1084,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
385+
@@ -1088,7 +1092,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
386386
// Paper end - log detailed entity tick information
387387
}
388388

@@ -391,7 +391,7 @@ index 4f31c92c8c3b2757a4103a1b2a0ae158117eebd1..43c47bdd2fdb7731eec5301e20f923d0
391391
if (entity.isRemoved() || entity.getVehicle() != vehicle) {
392392
entity.stopRiding();
393393
} else if (entity instanceof Player || this.entityTickList.contains(entity)) {
394-
@@ -1090,12 +1094,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
394+
@@ -1098,12 +1102,21 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
395395
ProfilerFiller profiler = Profiler.get();
396396
profiler.push(entity.typeHolder()::getRegisteredName);
397397
profiler.incrementCounter("tickPassenger");
@@ -462,7 +462,7 @@ index 6309a615ba2525437758b1fe39c43060ec42d6f8..677b0cadec2270537d868aac7d0acaf7
462462
public void tick() {
463463
super.tick();
464464
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
465-
index 931a886ab969009c1dc672e3108a0e65f888e0f4..83602c8ee3e2d6064fea66a915f427ffe1584b5a 100644
465+
index a480a35b23f38680598cb428bd09b7d1db07af6e..9ea33286ac0d4691dbc6b607a18b6688ca1724e9 100644
466466
--- a/net/minecraft/world/entity/Entity.java
467467
+++ b/net/minecraft/world/entity/Entity.java
468468
@@ -426,6 +426,15 @@ public abstract class Entity
@@ -521,7 +521,7 @@ index 931a886ab969009c1dc672e3108a0e65f888e0f4..83602c8ee3e2d6064fea66a915f427ff
521521
delta = this.maybeBackOffFromEdge(delta, moverType);
522522
Vec3 movement = this.collide(delta);
523523
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
524-
index e0e6c0f1ab9609fb64db4dfd436414d7ce12dd12..cbcef6d9d4113e318237df4501839d6870042c8d 100644
524+
index 9d579b7f17dc38c9e92447ea27ec71a8967a9964..30d518454e7a48b42242184203ab583b19b3e770 100644
525525
--- a/net/minecraft/world/entity/LivingEntity.java
526526
+++ b/net/minecraft/world/entity/LivingEntity.java
527527
@@ -3385,6 +3385,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -540,7 +540,7 @@ index e0e6c0f1ab9609fb64db4dfd436414d7ce12dd12..cbcef6d9d4113e318237df4501839d68
540540
public void tick() {
541541
super.tick();
542542
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
543-
index dab431458aa93349a9f09e8e3502a8b8b11a1653..2c7efcc76da5c2d1596bd15128fa27d77acc152d 100644
543+
index c7c53ef16e104ebc48aeb8719783fb4c45d39fc2..90eaa775dc134041647618c3b965334a9bb9fd3b 100644
544544
--- a/net/minecraft/world/entity/Mob.java
545545
+++ b/net/minecraft/world/entity/Mob.java
546546
@@ -211,6 +211,19 @@ public abstract class Mob extends LivingEntity implements Targeting, EquipmentUs
@@ -673,7 +673,7 @@ index a4f719c1b1b6a8920068ed8969a9e780420eade1..3791ffa6a14a1b2304780382e19f0e38
673673
public void tick() {
674674
if (this.getItem().isEmpty()) {
675675
diff --git a/net/minecraft/world/entity/npc/villager/Villager.java b/net/minecraft/world/entity/npc/villager/Villager.java
676-
index e7df6fb302abc958608090e84052eccb3190ed95..df50e6ac986cd388f02d405186f2855e42638eac 100644
676+
index a80e6a23cf29cb44943339101f15565dbc19af1f..f481fd661440f77c98940cbde4a8b95818e4a22c 100644
677677
--- a/net/minecraft/world/entity/npc/villager/Villager.java
678678
+++ b/net/minecraft/world/entity/npc/villager/Villager.java
679679
@@ -244,11 +244,35 @@ public class Villager extends AbstractVillager implements VillagerDataHolder, Re
@@ -816,7 +816,7 @@ index 3a590d4dc980a2912e9cc043d8c8db4cf9d60803..06ab7c48b18c03af494ab10fc2b584ce
816816
+
817817
}
818818
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
819-
index 8c5725b83a82b4297aecebc5220e9b3160746923..ad39c0822f757216d817934ba18440c228dc6be3 100644
819+
index 16ca35249e2248500073bb2b12447d2a0e545b95..00be50d2b8de3b5084c14c2e02eaf97f76ed5e49 100644
820820
--- a/net/minecraft/world/level/Level.java
821821
+++ b/net/minecraft/world/level/Level.java
822822
@@ -153,6 +153,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {

paper-server/patches/features/0014-Add-Alternate-Current-redstone-implementation.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,18 +2326,18 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9
23262326
+ }
23272327
+}
23282328
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
2329-
index 43c47bdd2fdb7731eec5301e20f923d0703a36fc..75068c07d1892882a85e27e30da8ac9906cf16e7 100644
2329+
index 6ea8d1c04afdaf2136dfd5fb3ab1899e8e62fc70..59ccc7a7c3a93a69e78061d4c091705658f38f48 100644
23302330
--- a/net/minecraft/server/level/ServerLevel.java
23312331
+++ b/net/minecraft/server/level/ServerLevel.java
23322332
@@ -232,6 +232,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
2333-
public final net.minecraft.world.level.storage.LevelDataAndDimensions.WorldDataAndGenSettings worldDataAndGenSettings;
2333+
public final WorldGenSettings worldGenSettings;
23342334
public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
23352335
public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent
23362336
+ private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current)
23372337

23382338
@Override
23392339
public @Nullable LevelChunk getChunkIfLoaded(int x, int z) {
2340-
@@ -2434,6 +2435,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
2340+
@@ -2432,6 +2433,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
23412341
return this.debugSynchronizers;
23422342
}
23432343

@@ -2352,10 +2352,10 @@ index 43c47bdd2fdb7731eec5301e20f923d0703a36fc..75068c07d1892882a85e27e30da8ac99
23522352
return toLevel.dimension() != Level.NETHER || this.getGameRules().get(GameRules.ALLOW_ENTERING_NETHER_USING_PORTALS);
23532353
}
23542354
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
2355-
index ad39c0822f757216d817934ba18440c228dc6be3..52e870443337adbd7a573cbc49a0b094a84a905d 100644
2355+
index 00be50d2b8de3b5084c14c2e02eaf97f76ed5e49..f56bf11ef2202b78635951f511f468231fd7e13a 100644
23562356
--- a/net/minecraft/world/level/Level.java
23572357
+++ b/net/minecraft/world/level/Level.java
2358-
@@ -1446,6 +1446,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
2358+
@@ -1447,6 +1447,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
23592359
return this.palettedContainerFactory;
23602360
}
23612361

paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)