Compare commits

..

6 Commits

Author SHA1 Message Date
MrHua269
27a2e2a129 Fix wrong end portal teleport position 2024-12-15 15:36:38 +08:00
MrHua269
3b9b3813b4 Fix extension name parsing again *
Jesus what careless I am()
2024-12-15 14:01:21 +08:00
MrHua269
9b4a6d60ac Fix extension name parsing again 2024-12-15 13:49:22 +08:00
MrHua269
6055cc7367 Fix extension name parsing 2024-12-15 13:26:16 +08:00
MrHua269
9edeb2a539 Remove dot* in argument option of EnumRegionFormat 2024-12-15 13:14:20 +08:00
MrHua269
207f96891a Fix missing replaces 2024-12-15 13:04:52 +08:00
2 changed files with 67 additions and 37 deletions

View File

@@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..d92f1d549c7e01daa6b5bba7d405e462
+}
diff --git a/src/main/java/abomination/LinearRegionFile.java b/src/main/java/abomination/LinearRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..192572f2672b9afb8c593dbf96ba95225bf985dc
index 0000000000000000000000000000000000000000..4a8a71686dddfc6b0c27882d1f73b92c96f6173e
--- /dev/null
+++ b/src/main/java/abomination/LinearRegionFile.java
@@ -0,0 +1,666 @@
@@ -108,7 +108,7 @@ index 0000000000000000000000000000000000000000..192572f2672b9afb8c593dbf96ba9522
+
+// LinearRegionFile_implementation_version_0_5byXymb
+// Just gonna use this string to inform other forks about updates ;-)
+public class LinearRegionFile extends Thread implements IRegionFile{
+public class LinearRegionFile implements IRegionFile{
+ private static final long SUPERBLOCK = 0xc3ff13183cca9d9aL;
+ private static final byte VERSION = 3;
+ private static final int HEADER_SIZE = 27;
@@ -834,7 +834,7 @@ index 0000000000000000000000000000000000000000..60546260cd1d535cc596485de2ced48b
+}
diff --git a/src/main/java/me/earthme/luminol/utils/EnumRegionFormat.java b/src/main/java/me/earthme/luminol/utils/EnumRegionFormat.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8e9ebd95312e94a07dc18c3435471810f0b5b2a
index 0000000000000000000000000000000000000000..73b4f9b5f608322839cf1e37fbf1d3a147247c60
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/utils/EnumRegionFormat.java
@@ -0,0 +1,40 @@
@@ -846,8 +846,8 @@ index 0000000000000000000000000000000000000000..f8e9ebd95312e94a07dc18c343547181
+import org.jetbrains.annotations.Nullable;
+
+public enum EnumRegionFormat {
+ MCA("mca", ".mca" , (info) -> new RegionFile(info.info(), info.filePath(), info.folder(), info.sync())),
+ LINEAR_V2("linear_v2", ".linear" ,(info) -> new LinearRegionFile(info.info(), info.filePath(), info.folder(), info.sync(), RegionFormatConfig.linearCompressionLevel));
+ MCA("mca", "mca" , (info) -> new RegionFile(info.info(), info.filePath(), info.folder(), info.sync())),
+ LINEAR_V2("linear_v2", "linear" ,(info) -> new LinearRegionFile(info.info(), info.filePath(), info.folder(), info.sync(), RegionFormatConfig.linearCompressionLevel));
+
+ private final String name;
+ private final String argument;
@@ -919,7 +919,7 @@ index 8cc0c01a19fc71753d7c3ed4fa7e9992aaf93b5a..88be8a6232bc3311cc0bdb7c697f7a78
this.stopPart2();
}
diff --git a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
index 622d0cbe023774d92d212f242b60b96317720835..b34b2519a2abccd1d60edb7a89cb080541df18d0 100644
index 622d0cbe023774d92d212f242b60b96317720835..9b4b01a741e8779f4ea06b0fd801ce243e179910 100644
--- a/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/src/main/java/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -75,7 +75,7 @@ public class WorldUpgrader implements AutoCloseable {
@@ -940,6 +940,33 @@ index 622d0cbe023774d92d212f242b60b96317720835..b34b2519a2abccd1d60edb7a89cb0805
});
if (afile == null) {
@@ -419,7 +419,7 @@ public class WorldUpgrader implements AutoCloseable {
List<ChunkPos> list1 = Lists.newArrayList();
try {
- RegionFile regionfile = new RegionFile(key, file.toPath(), regionDirectory, true);
+ abomination.IRegionFile regionfile = net.minecraft.world.level.chunk.storage.RegionFileStorage.createNew(key, file.toPath(), regionDirectory, true);
try {
for (int i1 = 0; i1 < 32; ++i1) {
@@ -482,7 +482,7 @@ public class WorldUpgrader implements AutoCloseable {
protected abstract boolean tryProcessOnePosition(T storage, ChunkPos chunkPos, ResourceKey<Level> worldKey);
- private void onFileFinished(RegionFile regionFile) {
+ private void onFileFinished(abomination.IRegionFile regionFile) {
if (WorldUpgrader.this.recreateRegionFiles) {
if (this.previousWriteFuture != null) {
this.previousWriteFuture.join();
@@ -507,7 +507,7 @@ public class WorldUpgrader implements AutoCloseable {
}
}
- static record FileToUpgrade(RegionFile file, List<ChunkPos> chunksToUpgrade) {
+ static record FileToUpgrade(abomination.IRegionFile file, List<ChunkPos> chunksToUpgrade) {
}
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 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc38b513f8 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
@@ -1003,7 +1030,7 @@ index 16f07007a0f73ec0c6f421c9b082518e87e8cc7b..fc69834e18e0860750d878e1361722fc
}
// Paper end - rewrite chunk system
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 e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9fcf450d0c 100644
index e40665cead218502b44dd49051a53326ed94f061..a25e1bfd74b7ec9d6fcc3fe7c4369bc20b33a0da 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
@@ -23,7 +23,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -1015,7 +1042,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
private final RegionStorageInfo info;
private final Path folder;
private final boolean sync;
@@ -33,8 +33,33 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -33,8 +33,27 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
private static final int MAX_NON_EXISTING_CACHE = 1024 * 4;
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet();
private static String getRegionFileName(final int chunkX, final int chunkZ) {
@@ -1023,34 +1050,28 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
+ return "r." + (chunkX >> REGION_SHIFT) + "." + (chunkZ >> REGION_SHIFT) + getExtensionName(); // Luminol - Configurable region file format
}
+ // Luminol start - Configurable region file format
+ protected abomination.IRegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
+ public static abomination.IRegionFile createNew(RegionStorageInfo info, Path filePath, Path folder, boolean sync) throws IOException{
+ final me.earthme.luminol.utils.EnumRegionFormat regionFormat = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormat;
+ final String fullFileName = filePath.getFileName().toString();
+ final String argument;
+ final String[] fullNameSplit = fullFileName.split("\\.");
+ final String extensionName = fullNameSplit[fullNameSplit.length - 1];
+
+ int lastDotIndex = fullFileName.lastIndexOf(".");
+ if (lastDotIndex != -1 && lastDotIndex < fullFileName.length() - 1) {
+ argument = fullFileName.substring(lastDotIndex + 1);
+ }else {
+ throw new IOException("Invalid region file name: " + fullFileName);
+ }
+
+ if (!regionFormat.getArgument().equalsIgnoreCase(argument)) {
+ net.minecraft.server.MinecraftServer.setFatalException(new RuntimeException("Invalid region file format: " + argument + " expected " + regionFormat.getArgument()));
+ throw new IOException("Invalid region file format: ." + argument + " expected " + regionFormat.getArgument());
+ if (!regionFormat.getArgument().equalsIgnoreCase(extensionName)) {
+ net.minecraft.server.MinecraftServer.setFatalException(new RuntimeException("Invalid region file format: " + extensionName + " expected " + regionFormat.getArgument()));
+ throw new IOException("Invalid region file format: " + extensionName + " expected " + regionFormat.getArgument());
+ }
+
+ return regionFormat.getCreator().create(new me.earthme.luminol.utils.RegionCreatorInfo(info, filePath, folder, sync));
+ }
+
+ public static String getExtensionName() {
+ return me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormat.getArgument();
+ return "." + me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormat.getArgument();
+ }
+ // Luminol end
private boolean doesRegionFilePossiblyExist(final long position) {
synchronized (this.nonExistingRegionFiles) {
@@ -68,15 +93,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -68,15 +87,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
@Override
@@ -1069,7 +1090,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
if (ret != null) {
return ret;
}
@@ -100,7 +125,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -100,7 +119,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
FileUtil.createDirectoriesSafe(this.folder);
@@ -1078,7 +1099,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
this.regionCache.putAndMoveToFirst(key, ret);
@@ -119,7 +144,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -119,7 +138,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -1087,7 +1108,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
// (and, the regionfile parameter is unused for writing until the write call)
@@ -153,7 +178,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -153,7 +172,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
) throws IOException {
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
@@ -1096,7 +1117,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
if (regionFile != null) {
regionFile.clear(pos);
} // else: didn't exist
@@ -168,7 +193,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -168,7 +187,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.ReadData moonrise$readData(
final int chunkX, final int chunkZ
) throws IOException {
@@ -1105,7 +1126,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
@@ -221,7 +246,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -221,7 +240,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@Nullable
public static ChunkPos getRegionFileCoordinates(Path file) {
String fileName = file.getFileName().toString();
@@ -1114,7 +1135,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
return null;
}
@@ -250,12 +275,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -250,12 +269,12 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
// Paper start - rewrite chunk system
@@ -1129,7 +1150,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
// Paper start - rewrite chunk system
if (existingOnly) {
return this.moonrise$getRegionFileIfExists(chunkcoordintpair.x, chunkcoordintpair.z);
@@ -263,7 +288,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -263,7 +282,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
synchronized (this) {
final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.z >> REGION_SHIFT);
@@ -1138,7 +1159,16 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
if (ret != null) {
return ret;
}
@@ -292,7 +317,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -278,7 +297,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
FileUtil.createDirectoriesSafe(this.folder);
- ret = new RegionFile(this.info, regionPath, this.folder, this.sync);
+ ret = this.createNew(this.info, regionPath, this.folder, this.sync);
this.regionCache.putAndMoveToFirst(key, ret);
@@ -292,7 +311,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
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.");
}
@@ -1147,7 +1177,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
@@ -327,7 +352,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -327,7 +346,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@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
@@ -1156,7 +1186,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
if (regionfile == null) {
return null;
}
@@ -391,7 +416,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -391,7 +410,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -1165,7 +1195,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
if (regionfile == null) {
return;
}
@@ -421,7 +446,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -421,7 +440,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - rewrite chunk system - public
@@ -1174,7 +1204,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
// Paper start - rewrite chunk system
if (regionfile == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -465,7 +490,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -465,7 +484,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -1183,7 +1213,7 @@ index e40665cead218502b44dd49051a53326ed94f061..aa6603b11b5ee42f118e202141772c9f
try {
regionFile.close();
} catch (final IOException ex) {
@@ -482,7 +507,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -482,7 +501,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Kaiiju Vanilla end portal teleportation
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 4fdbdd1c5c937c20026afe555fa1c8371b4eaa16..bd3f0c807c36ecfb8a89a0ca68ffa0c3640b7423 100644
index 4fdbdd1c5c937c20026afe555fa1c8371b4eaa16..64e081f993c2c844f83af227380b8a957eaabad4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -114,6 +114,7 @@ import net.minecraft.world.level.block.Rotation;
@@ -33,7 +33,7 @@ index 4fdbdd1c5c937c20026afe555fa1c8371b4eaa16..bd3f0c807c36ecfb8a89a0ca68ffa0c3
portalInfoCompletable.complete(
new net.minecraft.world.level.portal.TeleportTransition(
- destination, Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f,
+ destination, Vec3.atBottomCenterOf(targetPos.below()), this.getDeltaMovement(), 90.0f, 0.0f, // Kaiiju - Vanilla end teleportation
+ destination, finalPos, this.getDeltaMovement(), 90.0f, 0.0f, // Kaiiju - Vanilla end teleportation
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
)