Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
fix: account for spigot having private PalettedContainer#get(int) (#2910)
Dieser Commit ist enthalten in:
Ursprung
766a5d6da2
Commit
19370a3549
@ -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) {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
if (PaperLib.isPaper()) {
|
||||
for (int i = 0; i < 64; 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(
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
if (PaperLib.isPaper()) {
|
||||
for (int i = 0; i < 64; 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(
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
if (PaperLib.isPaper()) {
|
||||
for (int i = 0; i < 64; 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(
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
biomes[layer][i] = palettedContainer.get(i);
|
||||
if (PaperLib.isPaper()) {
|
||||
for (int i = 0; i < 64; 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(
|
||||
|
@ -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) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren