3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-17 00:20:09 +01:00

fix: account for spigot having private PalettedContainer#get(int) (#2910)

Dieser Commit ist enthalten in:
Jordan 2024-09-14 09:47:07 +01:00 committet von GitHub
Ursprung 766a5d6da2
Commit 19370a3549
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
8 geänderte Dateien mit 88 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -15,6 +15,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import net.minecraft.core.Holder;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
@ -179,8 +180,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
biomes[layer] = new Holder[64];
}
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
if (PaperLib.isPaper()) {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
biomes[layer][i] = palettedContainer.get(i); // Only public on paper
}
} else {
try {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = (Holder<Biome>) PaperweightPlatformAdapter.PALETTED_CONTAINER_GET.invoke(i);
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
} else {
LOGGER.error(

Datei anzeigen

@ -123,6 +123,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static Field LEVEL_CHUNK_ENTITIES;
private static Field SERVER_LEVEL_ENTITY_MANAGER;
static final MethodHandle PALETTED_CONTAINER_GET;
static {
final MethodHandles.Lookup lookup = MethodHandles.lookup();
try {
@ -212,6 +214,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} catch (NoSuchFieldException ignored) {
}
POST_CHUNK_REWRITE = chunkRewrite;
Method palettedContaienrGet = PalettedContainer.class.getDeclaredMethod(
Refraction.pickName("get", "a"),
int.class
);
palettedContaienrGet.setAccessible(true);
PALETTED_CONTAINER_GET = lookup.unreflect(palettedContaienrGet);
} catch (RuntimeException | Error e) {
throw e;
} catch (Exception e) {

Datei anzeigen

@ -15,6 +15,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import net.minecraft.core.Holder;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
@ -179,8 +180,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
biomes[layer] = new Holder[64];
}
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
if (PaperLib.isPaper()) {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
biomes[layer][i] = palettedContainer.get(i); // Only public on paper
}
} else {
try {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = (Holder<Biome>) PaperweightPlatformAdapter.PALETTED_CONTAINER_GET.invoke(i);
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
} else {
LOGGER.error(

Datei anzeigen

@ -123,6 +123,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static Field LEVEL_CHUNK_ENTITIES;
private static Field SERVER_LEVEL_ENTITY_MANAGER;
static final MethodHandle PALETTED_CONTAINER_GET;
static {
final MethodHandles.Lookup lookup = MethodHandles.lookup();
try {
@ -212,6 +214,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} catch (NoSuchFieldException ignored) {
}
POST_CHUNK_REWRITE = chunkRewrite;
Method palettedContaienrGet = PalettedContainer.class.getDeclaredMethod(
Refraction.pickName("get", "a"),
int.class
);
palettedContaienrGet.setAccessible(true);
PALETTED_CONTAINER_GET = lookup.unreflect(palettedContaienrGet);
} catch (RuntimeException | Error e) {
throw e;
} catch (Exception e) {

Datei anzeigen

@ -15,6 +15,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import net.minecraft.core.Holder;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.level.ServerLevel;
@ -180,8 +181,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
biomes[layer] = new Holder[64];
}
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
if (PaperLib.isPaper()) {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
biomes[layer][i] = palettedContainer.get(i); // Only public on paper
}
} else {
try {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = (Holder<Biome>) PaperweightPlatformAdapter.PALETTED_CONTAINER_GET.invoke(i);
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
} else {
LOGGER.error(

Datei anzeigen

@ -121,6 +121,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static Field LEVEL_CHUNK_ENTITIES;
private static Field SERVER_LEVEL_ENTITY_MANAGER;
static final MethodHandle PALETTED_CONTAINER_GET;
static {
final MethodHandles.Lookup lookup = MethodHandles.lookup();
try {
@ -210,6 +212,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
} catch (NoSuchFieldException ignored) {
}
POST_CHUNK_REWRITE = chunkRewrite;
Method palettedContaienrGet = PalettedContainer.class.getDeclaredMethod(
Refraction.pickName("get", "a"),
int.class
);
palettedContaienrGet.setAccessible(true);
PALETTED_CONTAINER_GET = lookup.unreflect(palettedContaienrGet);
} catch (RuntimeException | Error e) {
throw e;
} catch (Exception e) {

Datei anzeigen

@ -15,6 +15,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import io.papermc.lib.PaperLib;
import net.minecraft.core.Holder;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.level.ServerLevel;
@ -180,8 +181,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
biomes[layer] = new Holder[64];
}
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
if (PaperLib.isPaper()) {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = palettedContainer.get(i);
biomes[layer][i] = palettedContainer.get(i); // Only public on paper
}
} else {
try {
for (int i = 0; i < 64; i++) {
biomes[layer][i] = (Holder<Biome>) PaperweightPlatformAdapter.PALETTED_CONTAINER_GET.invoke(i);
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
} else {
LOGGER.error(

Datei anzeigen

@ -119,6 +119,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
private static Method PAPER_CHUNK_GEN_ALL_ENTITIES;
private static Field SERVER_LEVEL_ENTITY_MANAGER;
static final MethodHandle PALETTED_CONTAINER_GET;
static {
final MethodHandles.Lookup lookup = MethodHandles.lookup();
try {
@ -195,6 +197,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
SERVER_LEVEL_ENTITY_MANAGER = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "N"));
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
}
Method palettedContaienrGet = PalettedContainer.class.getDeclaredMethod(
Refraction.pickName("get", "a"),
int.class
);
palettedContaienrGet.setAccessible(true);
PALETTED_CONTAINER_GET = lookup.unreflect(palettedContaienrGet);
} catch (RuntimeException | Error e) {
throw e;
} catch (Exception e) {