mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
fix: account for spigot having private PalettedContainer#get(int) (#2910)
This commit is contained in:
parent
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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
@ -179,8 +180,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
|||||||
biomes[layer] = new Holder[64];
|
biomes[layer] = new Holder[64];
|
||||||
}
|
}
|
||||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||||
for (int i = 0; i < 64; i++) {
|
if (PaperLib.isPaper()) {
|
||||||
biomes[layer][i] = palettedContainer.get(i);
|
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 {
|
} else {
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
|
@ -123,6 +123,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static Field LEVEL_CHUNK_ENTITIES;
|
private static Field LEVEL_CHUNK_ENTITIES;
|
||||||
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
||||||
|
|
||||||
|
static final MethodHandle PALETTED_CONTAINER_GET;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||||
try {
|
try {
|
||||||
@ -212,6 +214,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
} catch (NoSuchFieldException ignored) {
|
} catch (NoSuchFieldException ignored) {
|
||||||
}
|
}
|
||||||
POST_CHUNK_REWRITE = chunkRewrite;
|
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) {
|
} catch (RuntimeException | Error e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception 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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
@ -179,8 +180,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
|||||||
biomes[layer] = new Holder[64];
|
biomes[layer] = new Holder[64];
|
||||||
}
|
}
|
||||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||||
for (int i = 0; i < 64; i++) {
|
if (PaperLib.isPaper()) {
|
||||||
biomes[layer][i] = palettedContainer.get(i);
|
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 {
|
} else {
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
|
@ -123,6 +123,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static Field LEVEL_CHUNK_ENTITIES;
|
private static Field LEVEL_CHUNK_ENTITIES;
|
||||||
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
||||||
|
|
||||||
|
static final MethodHandle PALETTED_CONTAINER_GET;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||||
try {
|
try {
|
||||||
@ -212,6 +214,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
} catch (NoSuchFieldException ignored) {
|
} catch (NoSuchFieldException ignored) {
|
||||||
}
|
}
|
||||||
POST_CHUNK_REWRITE = chunkRewrite;
|
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) {
|
} catch (RuntimeException | Error e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception 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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@ -180,8 +181,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
|||||||
biomes[layer] = new Holder[64];
|
biomes[layer] = new Holder[64];
|
||||||
}
|
}
|
||||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||||
for (int i = 0; i < 64; i++) {
|
if (PaperLib.isPaper()) {
|
||||||
biomes[layer][i] = palettedContainer.get(i);
|
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 {
|
} else {
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
|
@ -121,6 +121,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static Field LEVEL_CHUNK_ENTITIES;
|
private static Field LEVEL_CHUNK_ENTITIES;
|
||||||
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
||||||
|
|
||||||
|
static final MethodHandle PALETTED_CONTAINER_GET;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||||
try {
|
try {
|
||||||
@ -210,6 +212,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
} catch (NoSuchFieldException ignored) {
|
} catch (NoSuchFieldException ignored) {
|
||||||
}
|
}
|
||||||
POST_CHUNK_REWRITE = chunkRewrite;
|
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) {
|
} catch (RuntimeException | Error e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception 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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@ -180,8 +181,18 @@ public class PaperweightGetBlocks_Copy implements IChunkGet {
|
|||||||
biomes[layer] = new Holder[64];
|
biomes[layer] = new Holder[64];
|
||||||
}
|
}
|
||||||
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
if (biomeData instanceof PalettedContainer<Holder<Biome>> palettedContainer) {
|
||||||
for (int i = 0; i < 64; i++) {
|
if (PaperLib.isPaper()) {
|
||||||
biomes[layer][i] = palettedContainer.get(i);
|
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 {
|
} else {
|
||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
|
@ -119,6 +119,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static Method PAPER_CHUNK_GEN_ALL_ENTITIES;
|
private static Method PAPER_CHUNK_GEN_ALL_ENTITIES;
|
||||||
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
private static Field SERVER_LEVEL_ENTITY_MANAGER;
|
||||||
|
|
||||||
|
static final MethodHandle PALETTED_CONTAINER_GET;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||||
try {
|
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 = ServerLevel.class.getDeclaredField(Refraction.pickName("entityManager", "N"));
|
||||||
SERVER_LEVEL_ENTITY_MANAGER.setAccessible(true);
|
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) {
|
} catch (RuntimeException | Error e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user