Update to 1.20 (#2276)

* Towards 1.20

* Init bukkit

* Update YAML to 2.0

* Fixes for 1.20 adapters

* Update obfuscated field names

* Remove getHandle workaround

* entityManager is obfuscated

* Update paperweight

* [ci-skip] Add 1.20 to modrinth task

---------

Co-authored-by: Phillipp Glanz <p.glanz@madfix.me>
Co-authored-by: SirYwell <hannesgreule@outlook.de>
This commit is contained in:
Alexander Brandes
2023-06-09 12:53:42 +02:00
committed by GitHub
parent 152d870cdb
commit e7876c4eba
38 changed files with 9038 additions and 47 deletions

View File

@ -11,6 +11,6 @@ repositories {
}
dependencies {
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.19.4-R0.1-20230601.025018-99")
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.19.4-R0.1-20230608.201059-104")
compileOnly("io.papermc:paperlib")
}

View File

@ -109,12 +109,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static final MethodHandle methodRemoveGameEventListener;
private static final MethodHandle methodremoveTickingBlockEntity;
/*
* This is a workaround for the changes from https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1fddefce1cdce44010927b888432bf70c0e88cde#src/main/java/org/bukkit/craftbukkit/CraftChunk.java
* and is only needed to support 1.19.4 versions before *and* after this change.
*/
private static final MethodHandle CRAFT_CHUNK_GET_HANDLE;
private static final Field fieldRemove;
static final boolean POST_CHUNK_REWRITE;
@ -220,20 +214,6 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} catch (Exception e) {
throw new RuntimeException(e);
}
MethodHandle craftChunkGetHandle;
final MethodType type = methodType(LevelChunk.class);
try {
craftChunkGetHandle = lookup.findVirtual(CraftChunk.class, "getHandle", type);
} catch (NoSuchMethodException | IllegalAccessException e) {
try {
final MethodType newType = methodType(ChunkAccess.class, ChunkStatus.class);
craftChunkGetHandle = lookup.findVirtual(CraftChunk.class, "getHandle", newType);
craftChunkGetHandle = MethodHandles.insertArguments(craftChunkGetHandle, 1, ChunkStatus.FULL);
} catch (NoSuchMethodException | IllegalAccessException ex) {
throw new RuntimeException(ex);
}
}
CRAFT_CHUNK_GET_HANDLE = craftChunkGetHandle;
}
static boolean setSectionAtomic(
@ -309,7 +289,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
try {
CraftChunk chunk = (CraftChunk) future.get();
addTicket(serverLevel, chunkX, chunkZ);
return (LevelChunk) CRAFT_CHUNK_GET_HANDLE.invoke(chunk);
return (LevelChunk) chunk.getHandle(ChunkStatus.FULL);
} catch (Throwable e) {
e.printStackTrace();
}