fix: Fixes NoSuchMethodException in NMS-Spawners for new 1.20.4 builds

Affects EpicAnchors/EpicSpawners
This commit is contained in:
Christian Koop 2024-03-18 19:06:14 +01:00
parent 9f6f8fb660
commit 374856719c
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3

View File

@ -45,7 +45,15 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
this.setNextSpawnDataMethod.setAccessible(true);
}
this.getOrCreateNextSpawnDataMethod = this.spawner.getClass().getSuperclass().getDeclaredMethod("b", Level.class, RandomSource.class, BlockPos.class);
// Spigot mappings changed again mid-nms-version :<
Method getOrCreateNextSpawnDataMethodLocal;
try {
getOrCreateNextSpawnDataMethodLocal = this.spawner.getClass().getSuperclass().getDeclaredMethod("a", Level.class, RandomSource.class, BlockPos.class);
} catch (NoSuchMethodException ex) {
getOrCreateNextSpawnDataMethodLocal = this.spawner.getClass().getSuperclass().getDeclaredMethod("b", Level.class, RandomSource.class, BlockPos.class);
}
this.getOrCreateNextSpawnDataMethod = getOrCreateNextSpawnDataMethodLocal;
if (!this.getOrCreateNextSpawnDataMethod.canAccess(this.spawner)) {
this.getOrCreateNextSpawnDataMethod.setAccessible(true);
}