Skip to content

Commit 41d294e

Browse files
Support 1.21.1 (#2877)
* chore: add support for 1.21.1 * chore: remove old chunk system references in 1.21 adapter (paper) * chore: re-word exception message
1 parent 4578719 commit 41d294e

File tree

6 files changed

+20
-47
lines changed

6 files changed

+20
-47
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ allprojects {
8383
}
8484

8585
applyCommonConfiguration()
86-
val supportedVersions = listOf("1.19.4", "1.20", "1.20.4", "1.20.5", "1.20.6", "1.21")
86+
val supportedVersions = listOf("1.19.4", "1.20", "1.20.4", "1.20.5", "1.20.6", "1.21", "1.21.1")
8787

8888
tasks {
8989
supportedVersions.forEach {

buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ dependencies {
2424
implementation(gradleApi())
2525
implementation("org.ajoberstar.grgit:grgit-gradle:5.2.2")
2626
implementation("com.github.johnrengelman:shadow:8.1.1")
27-
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.1")
27+
implementation("io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.2")
2828
constraints {
2929
val asmVersion = "[9.7,)"
3030
implementation("org.ow2.asm:asm:$asmVersion") {

worldedit-bukkit/adapters/adapter-1_21/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
}
1212

1313
dependencies {
14-
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.21-R0.1-SNAPSHOT/
15-
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.21-R0.1-20240629.091304-42")
14+
// url=https://repo.papermc.io/service/rest/repository/browse/maven-public/io/papermc/paper/dev-bundle/1.21.1-R0.1-SNAPSHOT/
15+
the<PaperweightUserDependenciesExtension>().paperDevBundle("1.21.1-R0.1-20240810.223713-4")
1616
compileOnly(libs.paperlib)
1717
}

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ public PaperweightAdapter() throws NoSuchFieldException, NoSuchMethodException {
195195
CraftServer.class.cast(Bukkit.getServer());
196196

197197
int dataVersion = CraftMagicNumbers.INSTANCE.getDataVersion();
198-
if (dataVersion != 3953) {
199-
throw new UnsupportedClassVersionError("Not 1.21!");
198+
if (dataVersion != 3953 && dataVersion != 3955) {
199+
throw new UnsupportedClassVersionError("Not 1.21(.1)!");
200200
}
201201

202202
serverWorldsField = CraftServer.class.getDeclaredField("worlds");

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,14 @@ public IBatchProcessor getTickingPostProcessor() {
624624
}
625625

626626
private boolean wasAccessibleSinceLastSave(ChunkHolder holder) {
627-
if (!PaperLib.isPaper() || !PaperweightPlatformAdapter.POST_CHUNK_REWRITE) {
628-
try {
629-
return (boolean) CHUNK_HOLDER_WAS_ACCESSIBLE_SINCE_LAST_SAVE.invoke(holder);
630-
} catch (IllegalAccessException | InvocationTargetException ignored) {
631-
// fall-through
632-
}
627+
if (PaperLib.isPaper()) { // Papers new chunk system has no related replacement - therefor we assume true.
628+
return true;
629+
}
630+
try {
631+
return (boolean) CHUNK_HOLDER_WAS_ACCESSIBLE_SINCE_LAST_SAVE.invoke(holder);
632+
} catch (IllegalAccessException | InvocationTargetException ignored) {
633+
return false;
633634
}
634-
// Papers new chunk system has no related replacement - therefor we assume true.
635-
return true;
636635
}
637636

638637
}

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightPlatformAdapter.java

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices;
44
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager;
5-
import com.destroystokyo.paper.util.maplist.EntityList;
65
import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter;
76
import com.fastasyncworldedit.bukkit.adapter.DelegateSemaphore;
87
import com.fastasyncworldedit.bukkit.adapter.NMSAdapter;
@@ -117,9 +116,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
117116

118117
private static final Logger LOGGER = LogManagerCompat.getLogger();
119118

120-
static final boolean POST_CHUNK_REWRITE;
121119
private static Method PAPER_CHUNK_GEN_ALL_ENTITIES;
122-
private static Field LEVEL_CHUNK_ENTITIES;
123120
private static Field SERVER_LEVEL_ENTITY_MANAGER;
124121

125122
static {
@@ -189,28 +186,15 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
189186
fieldRemove = BlockEntity.class.getDeclaredField(Refraction.pickName("remove", "p"));
190187
fieldRemove.setAccessible(true);
191188

192-
boolean chunkRewrite;
193189
try {
194190
Level.class.getDeclaredMethod("moonrise$getEntityLookup");
195-
chunkRewrite = true;
196191
PAPER_CHUNK_GEN_ALL_ENTITIES = ChunkEntitySlices.class.getDeclaredMethod("getAllEntities");
197192
PAPER_CHUNK_GEN_ALL_ENTITIES.setAccessible(true);
198193
} catch (NoSuchMethodException ignored) {
199-
chunkRewrite = false;
200-
}
201-
try {
202-
// Paper - Pre-Chunk-Update
203-
LEVEL_CHUNK_ENTITIES = LevelChunk.class.getDeclaredField("entities");
204-
LEVEL_CHUNK_ENTITIES.setAccessible(true);
205-
} catch (NoSuchFieldException ignored) {
206-
}
207-
try {
208194
// Non-Paper
209195
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "N"));
210196
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
211-
} catch (NoSuchFieldException ignored) {
212197
}
213-
POST_CHUNK_REWRITE = chunkRewrite;
214198
} catch (RuntimeException | Error e) {
215199
throw e;
216200
} catch (Exception e) {
@@ -657,32 +641,22 @@ static void removeBeacon(BlockEntity beacon, LevelChunk levelChunk) {
657641
}
658642

659643
static List<Entity> getEntities(LevelChunk chunk) {
660-
ExceptionCollector<RuntimeException> collector = new ExceptionCollector<>();
661644
if (PaperLib.isPaper()) {
662-
if (POST_CHUNK_REWRITE) {
663-
try {
664-
//noinspection unchecked
665-
return (List<Entity>) PAPER_CHUNK_GEN_ALL_ENTITIES.invoke(chunk.level.moonrise$getEntityLookup().getChunk(chunk.locX, chunk.locZ));
666-
} catch (IllegalAccessException | InvocationTargetException e) {
667-
throw new RuntimeException("Failed to lookup entities [POST_CHUNK_REWRITE=true]", e);
668-
}
669-
}
670645
try {
671-
EntityList entityList = (EntityList) LEVEL_CHUNK_ENTITIES.get(chunk);
672-
return List.of(entityList.getRawData());
673-
} catch (IllegalAccessException e) {
674-
collector.add(new RuntimeException("Failed to lookup entities [POST_CHUNK_REWRITE=false]", e));
675-
// fall through
646+
//noinspection unchecked
647+
return (List<Entity>) PAPER_CHUNK_GEN_ALL_ENTITIES.invoke(chunk.level
648+
.moonrise$getEntityLookup()
649+
.getChunk(chunk.locX, chunk.locZ));
650+
} catch (IllegalAccessException | InvocationTargetException e) {
651+
throw new RuntimeException("Failed to lookup entities [PAPER=true]", e);
676652
}
677653
}
678654
try {
679655
//noinspection unchecked
680656
return ((PersistentEntitySectionManager<Entity>) (SERVER_LEVEL_ENTITY_MANAGER.get(chunk.level))).getEntities(chunk.getPos());
681657
} catch (IllegalAccessException e) {
682-
collector.add(new RuntimeException("Failed to lookup entities [PAPER=false]", e));
658+
throw new RuntimeException("Failed to lookup entities [PAPER=false]", e);
683659
}
684-
collector.throwIfPresent();
685-
return List.of();
686660
}
687661

688662
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {

0 commit comments

Comments
 (0)