mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Move to BinaryTags where appropriate in adapters
This commit is contained in:
parent
48e2953910
commit
f38859237a
@ -56,6 +56,7 @@ import com.sk89q.worldedit.registry.state.IntegerProperty;
|
|||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.SideEffect;
|
import com.sk89q.worldedit.util.SideEffect;
|
||||||
|
import com.sk89q.worldedit.util.concurrency.LazyReference;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.util.io.file.SafeFiles;
|
import com.sk89q.worldedit.util.io.file.SafeFiles;
|
||||||
@ -171,11 +172,11 @@ import static com.google.common.base.Preconditions.checkState;
|
|||||||
|
|
||||||
public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft.nbt.Tag> {
|
public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft.nbt.Tag> {
|
||||||
|
|
||||||
private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
private final Logger LOGGER = Logger.getLogger(getClass().getCanonicalName());
|
||||||
|
|
||||||
private final Field serverWorldsField;
|
private final Field worldsField;
|
||||||
private final Method getChunkFutureMethod;
|
private final Method getChunkFutureMainThreadMethod;
|
||||||
private final Field chunkProviderExecutorField;
|
private final Field mainThreadProcessorField;
|
||||||
private final Watchdog watchdog;
|
private final Watchdog watchdog;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -191,18 +192,18 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
throw new UnsupportedClassVersionError("Not 1.17.1!");
|
throw new UnsupportedClassVersionError("Not 1.17.1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
serverWorldsField = CraftServer.class.getDeclaredField("worlds");
|
worldsField = CraftServer.class.getDeclaredField("worlds");
|
||||||
serverWorldsField.setAccessible(true);
|
worldsField.setAccessible(true);
|
||||||
|
|
||||||
getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod("getChunkFutureMainThread",
|
getChunkFutureMainThreadMethod = ServerChunkCache.class.getDeclaredMethod("getChunkFutureMainThread",
|
||||||
int.class, int.class, ChunkStatus.class, boolean.class
|
int.class, int.class, ChunkStatus.class, boolean.class
|
||||||
);
|
);
|
||||||
getChunkFutureMethod.setAccessible(true);
|
getChunkFutureMainThreadMethod.setAccessible(true);
|
||||||
|
|
||||||
chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField(
|
mainThreadProcessorField = ServerChunkCache.class.getDeclaredField(
|
||||||
Refraction.pickName("mainThreadProcessor", "h")
|
Refraction.pickName("mainThreadProcessor", "h")
|
||||||
);
|
);
|
||||||
chunkProviderExecutorField.setAccessible(true);
|
mainThreadProcessorField.setAccessible(true);
|
||||||
|
|
||||||
new PaperweightDataConverters(CraftMagicNumbers.INSTANCE.getDataVersion(), this).build(ForkJoinPool.commonPool());
|
new PaperweightDataConverters(CraftMagicNumbers.INSTANCE.getDataVersion(), this).build(ForkJoinPool.commonPool());
|
||||||
|
|
||||||
@ -435,7 +436,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||||
readEntityIntoTag(mcEntity, tag);
|
readEntityIntoTag(mcEntity, tag);
|
||||||
return new BaseEntity(com.sk89q.worldedit.world.entity.EntityTypes.get(id), (CompoundTag) toNative(tag));
|
return new BaseEntity(
|
||||||
|
com.sk89q.worldedit.world.entity.EntityTypes.get(id),
|
||||||
|
LazyReference.from(() -> (CompoundBinaryTag) toNativeBinary(tag))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -667,7 +671,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) serverWorldsField.get(Bukkit.getServer());
|
Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) worldsField.get(Bukkit.getServer());
|
||||||
map.remove("worldeditregentempworld");
|
map.remove("worldeditregentempworld");
|
||||||
} catch (IllegalAccessException ignored) {
|
} catch (IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
@ -740,7 +744,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
List<CompletableFuture<ChunkAccess>> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
|
List<CompletableFuture<ChunkAccess>> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
|
||||||
BlockableEventLoop<Runnable> executor;
|
BlockableEventLoop<Runnable> executor;
|
||||||
try {
|
try {
|
||||||
executor = (BlockableEventLoop<Runnable>) chunkProviderExecutorField.get(serverWorld.getChunkSource());
|
executor = (BlockableEventLoop<Runnable>) mainThreadProcessorField.get(serverWorld.getChunkSource());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new IllegalStateException("Couldn't get executor for chunk loading.", e);
|
throw new IllegalStateException("Couldn't get executor for chunk loading.", e);
|
||||||
}
|
}
|
||||||
@ -801,7 +805,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
chunkLoadings.add(
|
chunkLoadings.add(
|
||||||
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
|
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
|
||||||
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true))
|
getChunkFutureMainThreadMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true))
|
||||||
.thenApply(either -> either.left().orElse(null))
|
.thenApply(either -> either.left().orElse(null))
|
||||||
);
|
);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
@ -893,7 +897,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
try {
|
try {
|
||||||
return toNativeList((net.minecraft.nbt.ListTag) foreign);
|
return toNativeList((net.minecraft.nbt.ListTag) foreign);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
|
LOGGER.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
|
||||||
return ListBinaryTag.empty();
|
return ListBinaryTag.empty();
|
||||||
}
|
}
|
||||||
} else if (foreign instanceof net.minecraft.nbt.LongTag) {
|
} else if (foreign instanceof net.minecraft.nbt.LongTag) {
|
||||||
@ -1012,7 +1016,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
WatchdogThread.tick();
|
WatchdogThread.tick();
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
logger.log(Level.WARNING, "Failed to tick watchdog", e);
|
LOGGER.log(Level.WARNING, "Failed to tick watchdog", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -40,6 +38,9 @@ import com.sk89q.worldedit.util.SideEffect;
|
|||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
|
import com.sk89q.worldedit.util.nbt.BinaryTag;
|
||||||
|
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
|
||||||
|
import com.sk89q.worldedit.util.nbt.StringBinaryTag;
|
||||||
import com.sk89q.worldedit.world.RegenOptions;
|
import com.sk89q.worldedit.world.RegenOptions;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -274,9 +275,8 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
// Read the NBT data
|
// Read the NBT data
|
||||||
BlockEntity blockEntity = chunk.getBlockEntity(blockPos, LevelChunk.EntityCreationType.CHECK);
|
BlockEntity blockEntity = chunk.getBlockEntity(blockPos, LevelChunk.EntityCreationType.CHECK);
|
||||||
if (blockEntity != null) {
|
if (blockEntity != null) {
|
||||||
//TODO 1.18 recheck logic, I may skipped loading - NMF
|
|
||||||
net.minecraft.nbt.CompoundTag tag = blockEntity.save(new net.minecraft.nbt.CompoundTag());
|
net.minecraft.nbt.CompoundTag tag = blockEntity.save(new net.minecraft.nbt.CompoundTag());
|
||||||
return state.toBaseBlock((CompoundTag) toNative(tag));
|
return state.toBaseBlock((CompoundBinaryTag) toNativeBinary(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
|
|
||||||
levelChunk.removeBlockEntity(blockPos); // Force delete the old tile entity
|
levelChunk.removeBlockEntity(blockPos); // Force delete the old tile entity
|
||||||
|
|
||||||
CompoundTag compoundTag = state instanceof BaseBlock ? state.getNbtData() : null;
|
CompoundBinaryTag compoundTag = state instanceof BaseBlock ? state.getNbt() : null;
|
||||||
if (compoundTag != null || existing instanceof TileEntityBlock) {
|
if (compoundTag != null || existing instanceof TileEntityBlock) {
|
||||||
level.setBlock(blockPos, blockState, 0);
|
level.setBlock(blockPos, blockState, 0);
|
||||||
// remove tile
|
// remove tile
|
||||||
@ -317,7 +317,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
// though we do not do this on the Forge version
|
// though we do not do this on the Forge version
|
||||||
BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
||||||
if (blockEntity != null) {
|
if (blockEntity != null) {
|
||||||
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNative(compoundTag);
|
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNativeBinary(compoundTag);
|
||||||
tag.put("x", IntTag.valueOf(x));
|
tag.put("x", IntTag.valueOf(x));
|
||||||
tag.put("y", IntTag.valueOf(y));
|
tag.put("y", IntTag.valueOf(y));
|
||||||
tag.put("z", IntTag.valueOf(z));
|
tag.put("z", IntTag.valueOf(z));
|
||||||
@ -361,14 +361,15 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
|
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
|
||||||
Supplier<CompoundTag> saveTag = () -> {
|
Supplier<CompoundBinaryTag> saveTag = () -> {
|
||||||
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
|
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
|
||||||
readEntityIntoTag(mcEntity, minecraftTag);
|
readEntityIntoTag(mcEntity, minecraftTag);
|
||||||
//add Id for AbstractChangeSet to work
|
//add Id for AbstractChangeSet to work
|
||||||
final CompoundTag tag = (CompoundTag) toNative(minecraftTag);
|
final CompoundBinaryTag tag = (CompoundBinaryTag) toNative(minecraftTag);
|
||||||
final Map<String, Tag> tags = new HashMap<>(tag.getValue());
|
final Map<String, BinaryTag> tags = new HashMap<>();
|
||||||
tags.put("Id", new StringTag(id));
|
tag.keySet().forEach(key -> tags.put(key, tag.get(key)));
|
||||||
return new CompoundTag(tags);
|
tags.put("Id", StringBinaryTag.of(id));
|
||||||
|
return CompoundBinaryTag.from(tags);
|
||||||
};
|
};
|
||||||
return new LazyBaseEntity(type, saveTag);
|
return new LazyBaseEntity(type, saveTag);
|
||||||
} else {
|
} else {
|
||||||
@ -541,7 +542,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
Registry.ITEM.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
Registry.ITEM.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
||||||
baseItemStack.getAmount()
|
baseItemStack.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNativeBinary(baseItemStack.getNbt())));
|
||||||
return CraftItemStack.asCraftMirror(stack);
|
return CraftItemStack.asCraftMirror(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,7 +604,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
|
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
|
||||||
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
|
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
|
||||||
final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
|
final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
|
||||||
weStack.setNbtData(((CompoundTag) toNative(nmsStack.getTag())));
|
weStack.setNbt(((CompoundBinaryTag) toNativeBinary(nmsStack.getTag())));
|
||||||
return weStack;
|
return weStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final long fieldLockOffset;
|
private static final long fieldLockOffset;
|
||||||
|
|
||||||
private static final Field fieldGameEventDispatcherSections;
|
private static final Field fieldGameEventDispatcherSections;
|
||||||
private static final MethodHandle methodremoveTickingBlockEntity;
|
private static final MethodHandle methodremoveBlockEntityTicker;
|
||||||
|
|
||||||
private static final Field fieldRemove;
|
private static final Field fieldRemove;
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
), BlockPos.class
|
), BlockPos.class
|
||||||
);
|
);
|
||||||
removeBlockEntityTicker.setAccessible(true);
|
removeBlockEntityTicker.setAccessible(true);
|
||||||
methodremoveTickingBlockEntity = MethodHandles.lookup().unreflect(removeBlockEntityTicker);
|
methodremoveBlockEntityTicker = MethodHandles.lookup().unreflect(removeBlockEntityTicker);
|
||||||
|
|
||||||
fieldRemove = BlockEntity.class.getDeclaredField(Refraction.pickName("remove", "p"));
|
fieldRemove = BlockEntity.class.getDeclaredField(Refraction.pickName("remove", "p"));
|
||||||
fieldRemove.setAccessible(true);
|
fieldRemove.setAccessible(true);
|
||||||
@ -440,7 +440,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldRemove.set(beacon, true);
|
fieldRemove.set(beacon, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
methodremoveTickingBlockEntity.invoke(levelChunk, beacon.getBlockPos());
|
methodremoveBlockEntityTicker.invoke(levelChunk, beacon.getBlockPos());
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -90,13 +90,13 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||||
|
|
||||||
private static final Field serverWorldsField;
|
private static final Field worldsField;
|
||||||
private static final Field worldPaperConfigField;
|
private static final Field paperConfigField;
|
||||||
private static final Field flatBedrockField;
|
private static final Field generateFlatBedrockField;
|
||||||
private static final Field generatorSettingFlatField;
|
private static final Field generatorSettingFlatField;
|
||||||
private static final Field generatorSettingBaseSupplierField;
|
private static final Field generatorSettingBaseSupplierField;
|
||||||
private static final Field delegateField;
|
private static final Field delegateField;
|
||||||
private static final Field chunkProviderField;
|
private static final Field chunkSourceField;
|
||||||
|
|
||||||
//list of chunk stati in correct order without FULL
|
//list of chunk stati in correct order without FULL
|
||||||
private static final Map<ChunkStatus, Concurrency> chunkStati = new LinkedHashMap<>();
|
private static final Map<ChunkStatus, Concurrency> chunkStati = new LinkedHashMap<>();
|
||||||
@ -125,8 +125,8 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
chunkStati.put(ChunkStatus.HEIGHTMAPS, Concurrency.FULL); // heightmaps: radius 0
|
chunkStati.put(ChunkStatus.HEIGHTMAPS, Concurrency.FULL); // heightmaps: radius 0
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serverWorldsField = CraftServer.class.getDeclaredField("worlds");
|
worldsField = CraftServer.class.getDeclaredField("worlds");
|
||||||
serverWorldsField.setAccessible(true);
|
worldsField.setAccessible(true);
|
||||||
|
|
||||||
Field tmpPaperConfigField;
|
Field tmpPaperConfigField;
|
||||||
Field tmpFlatBedrockField;
|
Field tmpFlatBedrockField;
|
||||||
@ -140,8 +140,8 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
tmpPaperConfigField = null;
|
tmpPaperConfigField = null;
|
||||||
tmpFlatBedrockField = null;
|
tmpFlatBedrockField = null;
|
||||||
}
|
}
|
||||||
worldPaperConfigField = tmpPaperConfigField;
|
paperConfigField = tmpPaperConfigField;
|
||||||
flatBedrockField = tmpFlatBedrockField;
|
generateFlatBedrockField = tmpFlatBedrockField;
|
||||||
|
|
||||||
generatorSettingBaseSupplierField = NoiseBasedChunkGenerator.class.getDeclaredField(Refraction.pickName(
|
generatorSettingBaseSupplierField = NoiseBasedChunkGenerator.class.getDeclaredField(Refraction.pickName(
|
||||||
"settings", "g"));
|
"settings", "g"));
|
||||||
@ -153,8 +153,8 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
delegateField = CustomChunkGenerator.class.getDeclaredField("delegate");
|
delegateField = CustomChunkGenerator.class.getDeclaredField("delegate");
|
||||||
delegateField.setAccessible(true);
|
delegateField.setAccessible(true);
|
||||||
|
|
||||||
chunkProviderField = ServerLevel.class.getDeclaredField(Refraction.pickName("chunkSource", "C"));
|
chunkSourceField = ServerLevel.class.getDeclaredField(Refraction.pickName("chunkSource", "C"));
|
||||||
chunkProviderField.setAccessible(true);
|
chunkSourceField.setAccessible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -187,9 +187,9 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
}
|
}
|
||||||
|
|
||||||
//flat bedrock? (only on paper)
|
//flat bedrock? (only on paper)
|
||||||
if (worldPaperConfigField != null) {
|
if (paperConfigField != null) {
|
||||||
try {
|
try {
|
||||||
generateFlatBedrock = flatBedrockField.getBoolean(worldPaperConfigField.get(originalServerWorld));
|
generateFlatBedrock = generateFlatBedrockField.getBoolean(paperConfigField.get(originalServerWorld));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,8 +270,8 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
freshWorld.noSave = true;
|
freshWorld.noSave = true;
|
||||||
removeWorldFromWorldsMap();
|
removeWorldFromWorldsMap();
|
||||||
newWorldData.checkName(originalServerWorld.serverLevelData.getLevelName()); //rename to original world name
|
newWorldData.checkName(originalServerWorld.serverLevelData.getLevelName()); //rename to original world name
|
||||||
if (worldPaperConfigField != null) {
|
if (paperConfigField != null) {
|
||||||
worldPaperConfigField.set(freshWorld, originalServerWorld.paperConfig);
|
paperConfigField.set(freshWorld, originalServerWorld.paperConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
//generator
|
//generator
|
||||||
@ -319,7 +319,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReflectionUtils.unsafeSet(chunkProviderField, freshWorld, freshChunkProvider);
|
ReflectionUtils.unsafeSet(chunkSourceField, freshWorld, freshChunkProvider);
|
||||||
//let's start then
|
//let's start then
|
||||||
structureManager = server.getStructureManager();
|
structureManager = server.getStructureManager();
|
||||||
threadedLevelLightEngine = freshChunkProvider.getLightEngine();
|
threadedLevelLightEngine = freshChunkProvider.getLightEngine();
|
||||||
@ -405,7 +405,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
private void removeWorldFromWorldsMap() {
|
private void removeWorldFromWorldsMap() {
|
||||||
Fawe.instance().getQueueHandler().sync(() -> {
|
Fawe.instance().getQueueHandler().sync(() -> {
|
||||||
try {
|
try {
|
||||||
Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) serverWorldsField.get(Bukkit.getServer());
|
Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) worldsField.get(Bukkit.getServer());
|
||||||
map.remove("worldeditregentempworld");
|
map.remove("worldeditregentempworld");
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -30,7 +30,6 @@ import com.mojang.datafixers.util.Either;
|
|||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.Dynamic;
|
import com.mojang.serialization.Dynamic;
|
||||||
import com.mojang.serialization.Lifecycle;
|
import com.mojang.serialization.Lifecycle;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -55,6 +54,7 @@ import com.sk89q.worldedit.registry.state.IntegerProperty;
|
|||||||
import com.sk89q.worldedit.registry.state.Property;
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.SideEffect;
|
import com.sk89q.worldedit.util.SideEffect;
|
||||||
|
import com.sk89q.worldedit.util.concurrency.LazyReference;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.util.io.file.SafeFiles;
|
import com.sk89q.worldedit.util.io.file.SafeFiles;
|
||||||
@ -172,11 +172,11 @@ import static com.google.common.base.Preconditions.checkState;
|
|||||||
|
|
||||||
public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft.nbt.Tag> {
|
public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft.nbt.Tag> {
|
||||||
|
|
||||||
private final Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
private final Logger LOGGER = Logger.getLogger(getClass().getCanonicalName());
|
||||||
|
|
||||||
private final Field serverWorldsField;
|
private final Field worldsField;
|
||||||
private final Method getChunkFutureMethod;
|
private final Method getChunkFutureMainThreadMethod;
|
||||||
private final Field chunkProviderExecutorField;
|
private final Field mainThreadProcessorField;
|
||||||
private final Watchdog watchdog;
|
private final Watchdog watchdog;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -192,19 +192,19 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
throw new UnsupportedClassVersionError("Not 1.18 or 1.18.1!");
|
throw new UnsupportedClassVersionError("Not 1.18 or 1.18.1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
serverWorldsField = CraftServer.class.getDeclaredField("worlds");
|
worldsField = CraftServer.class.getDeclaredField("worlds");
|
||||||
serverWorldsField.setAccessible(true);
|
worldsField.setAccessible(true);
|
||||||
|
|
||||||
getChunkFutureMethod = ServerChunkCache.class.getDeclaredMethod(
|
getChunkFutureMainThreadMethod = ServerChunkCache.class.getDeclaredMethod(
|
||||||
Refraction.pickName("getChunkFutureMainThread", "c"),
|
Refraction.pickName("getChunkFutureMainThread", "c"),
|
||||||
int.class, int.class, ChunkStatus.class, boolean.class
|
int.class, int.class, ChunkStatus.class, boolean.class
|
||||||
);
|
);
|
||||||
getChunkFutureMethod.setAccessible(true);
|
getChunkFutureMainThreadMethod.setAccessible(true);
|
||||||
|
|
||||||
chunkProviderExecutorField = ServerChunkCache.class.getDeclaredField(
|
mainThreadProcessorField = ServerChunkCache.class.getDeclaredField(
|
||||||
Refraction.pickName("mainThreadProcessor", "h")
|
Refraction.pickName("mainThreadProcessor", "h")
|
||||||
);
|
);
|
||||||
chunkProviderExecutorField.setAccessible(true);
|
mainThreadProcessorField.setAccessible(true);
|
||||||
|
|
||||||
new PaperweightDataConverters(CraftMagicNumbers.INSTANCE.getDataVersion(), this).build(ForkJoinPool.commonPool());
|
new PaperweightDataConverters(CraftMagicNumbers.INSTANCE.getDataVersion(), this).build(ForkJoinPool.commonPool());
|
||||||
|
|
||||||
@ -427,7 +427,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
|
||||||
readEntityIntoTag(mcEntity, tag);
|
readEntityIntoTag(mcEntity, tag);
|
||||||
return new BaseEntity(com.sk89q.worldedit.world.entity.EntityTypes.get(id), (CompoundTag) toNative(tag));
|
return new BaseEntity(
|
||||||
|
com.sk89q.worldedit.world.entity.EntityTypes.get(id),
|
||||||
|
LazyReference.from(() -> (CompoundBinaryTag) toNativeBinary(tag))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -442,9 +445,9 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
CompoundTag nativeTag = state.getNbtData();
|
CompoundBinaryTag nativeTag = state.getNbt();
|
||||||
if (nativeTag != null) {
|
if (nativeTag != null) {
|
||||||
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNative(nativeTag);
|
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNativeBinary(nativeTag);
|
||||||
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
|
||||||
tag.remove(name);
|
tag.remove(name);
|
||||||
}
|
}
|
||||||
@ -546,7 +549,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
|
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
|
||||||
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
|
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
|
||||||
final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
|
final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
|
||||||
weStack.setNbtData(((CompoundTag) toNative(nmsStack.getTag())));
|
weStack.setNbt(((CompoundBinaryTag) toNativeBinary(nmsStack.getTag())));
|
||||||
return weStack;
|
return weStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,7 +668,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) serverWorldsField.get(Bukkit.getServer());
|
Map<String, org.bukkit.World> map = (Map<String, org.bukkit.World>) worldsField.get(Bukkit.getServer());
|
||||||
map.remove("worldeditregentempworld");
|
map.remove("worldeditregentempworld");
|
||||||
} catch (IllegalAccessException ignored) {
|
} catch (IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
@ -738,7 +741,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
List<CompletableFuture<ChunkAccess>> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
|
List<CompletableFuture<ChunkAccess>> chunkLoadings = submitChunkLoadTasks(region, serverWorld);
|
||||||
BlockableEventLoop<Runnable> executor;
|
BlockableEventLoop<Runnable> executor;
|
||||||
try {
|
try {
|
||||||
executor = (BlockableEventLoop<Runnable>) chunkProviderExecutorField.get(serverWorld.getChunkSource());
|
executor = (BlockableEventLoop<Runnable>) mainThreadProcessorField.get(serverWorld.getChunkSource());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new IllegalStateException("Couldn't get executor for chunk loading.", e);
|
throw new IllegalStateException("Couldn't get executor for chunk loading.", e);
|
||||||
}
|
}
|
||||||
@ -797,7 +800,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
chunkLoadings.add(
|
chunkLoadings.add(
|
||||||
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
|
((CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>)
|
||||||
getChunkFutureMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true))
|
getChunkFutureMainThreadMethod.invoke(chunkManager, chunk.getX(), chunk.getZ(), ChunkStatus.FEATURES, true))
|
||||||
.thenApply(either -> either.left().orElse(null))
|
.thenApply(either -> either.left().orElse(null))
|
||||||
);
|
);
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
@ -889,7 +892,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
try {
|
try {
|
||||||
return toNativeList((net.minecraft.nbt.ListTag) foreign);
|
return toNativeList((net.minecraft.nbt.ListTag) foreign);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
|
LOGGER.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
|
||||||
return ListBinaryTag.empty();
|
return ListBinaryTag.empty();
|
||||||
}
|
}
|
||||||
} else if (foreign instanceof net.minecraft.nbt.LongTag) {
|
} else if (foreign instanceof net.minecraft.nbt.LongTag) {
|
||||||
@ -1008,7 +1011,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
WatchdogThread.tick();
|
WatchdogThread.tick();
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
logger.log(Level.WARNING, "Failed to tick watchdog", e);
|
LOGGER.log(Level.WARNING, "Failed to tick watchdog", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_18_R1;
|
||||||
|
|
||||||
import ca.spottedleaf.starlight.common.light.StarLightEngine;
|
|
||||||
import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter;
|
import com.fastasyncworldedit.bukkit.adapter.CachedBukkitAdapter;
|
||||||
import com.fastasyncworldedit.bukkit.adapter.IDelegateBukkitImplAdapter;
|
import com.fastasyncworldedit.bukkit.adapter.IDelegateBukkitImplAdapter;
|
||||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||||
@ -12,8 +11,6 @@ import com.fastasyncworldedit.core.queue.implementation.packet.ChunkPacket;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
@ -41,6 +38,9 @@ import com.sk89q.worldedit.util.SideEffect;
|
|||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
|
import com.sk89q.worldedit.util.nbt.BinaryTag;
|
||||||
|
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
|
||||||
|
import com.sk89q.worldedit.util.nbt.StringBinaryTag;
|
||||||
import com.sk89q.worldedit.world.RegenOptions;
|
import com.sk89q.worldedit.world.RegenOptions;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
@ -275,7 +275,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
BlockEntity blockEntity = chunk.getBlockEntity(blockPos, LevelChunk.EntityCreationType.CHECK);
|
BlockEntity blockEntity = chunk.getBlockEntity(blockPos, LevelChunk.EntityCreationType.CHECK);
|
||||||
if (blockEntity != null) {
|
if (blockEntity != null) {
|
||||||
net.minecraft.nbt.CompoundTag tag = blockEntity.saveWithId();
|
net.minecraft.nbt.CompoundTag tag = blockEntity.saveWithId();
|
||||||
return state.toBaseBlock((CompoundTag) toNative(tag));
|
return state.toBaseBlock((CompoundBinaryTag) toNativeBinary(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
|
|
||||||
levelChunk.removeBlockEntity(blockPos); // Force delete the old tile entity
|
levelChunk.removeBlockEntity(blockPos); // Force delete the old tile entity
|
||||||
|
|
||||||
CompoundTag compoundTag = state instanceof BaseBlock ? state.getNbtData() : null;
|
CompoundBinaryTag compoundTag = state instanceof BaseBlock ? state.getNbt() : null;
|
||||||
if (compoundTag != null || existing instanceof TileEntityBlock) {
|
if (compoundTag != null || existing instanceof TileEntityBlock) {
|
||||||
level.setBlock(blockPos, blockState, 0);
|
level.setBlock(blockPos, blockState, 0);
|
||||||
// remove tile
|
// remove tile
|
||||||
@ -317,7 +317,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
// though we do not do this on the Forge version
|
// though we do not do this on the Forge version
|
||||||
BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
BlockEntity blockEntity = level.getBlockEntity(blockPos);
|
||||||
if (blockEntity != null) {
|
if (blockEntity != null) {
|
||||||
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNative(compoundTag);
|
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) fromNativeBinary(compoundTag);
|
||||||
tag.put("x", IntTag.valueOf(x));
|
tag.put("x", IntTag.valueOf(x));
|
||||||
tag.put("y", IntTag.valueOf(y));
|
tag.put("y", IntTag.valueOf(y));
|
||||||
tag.put("z", IntTag.valueOf(z));
|
tag.put("z", IntTag.valueOf(z));
|
||||||
@ -356,14 +356,15 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
if (id != null) {
|
if (id != null) {
|
||||||
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
|
EntityType type = com.sk89q.worldedit.world.entity.EntityTypes.get(id);
|
||||||
//TODO 1.18 be a CBT ?
|
//TODO 1.18 be a CBT ?
|
||||||
Supplier<CompoundTag> saveTag = () -> {
|
Supplier<CompoundBinaryTag> saveTag = () -> {
|
||||||
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
|
final net.minecraft.nbt.CompoundTag minecraftTag = new net.minecraft.nbt.CompoundTag();
|
||||||
readEntityIntoTag(mcEntity, minecraftTag);
|
readEntityIntoTag(mcEntity, minecraftTag);
|
||||||
//add Id for AbstractChangeSet to work
|
//add Id for AbstractChangeSet to work
|
||||||
final CompoundTag tag = (CompoundTag) toNative(minecraftTag);
|
final CompoundBinaryTag tag = (CompoundBinaryTag) toNativeBinary(minecraftTag);
|
||||||
final Map<String, Tag> tags = new HashMap<>(tag.getValue());
|
final Map<String, BinaryTag> tags = new HashMap<>();
|
||||||
tags.put("Id", new StringTag(id));
|
tag.keySet().forEach(key -> tags.put(key, tag.get(key)));
|
||||||
return new CompoundTag(tags);
|
tags.put("Id", StringBinaryTag.of(id));
|
||||||
|
return CompoundBinaryTag.from(tags);
|
||||||
};
|
};
|
||||||
return new LazyBaseEntity(type, saveTag);
|
return new LazyBaseEntity(type, saveTag);
|
||||||
} else {
|
} else {
|
||||||
@ -598,7 +599,7 @@ public final class PaperweightFaweAdapter extends CachedBukkitAdapter implements
|
|||||||
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
|
public BaseItemStack adapt(org.bukkit.inventory.ItemStack itemStack) {
|
||||||
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
|
final ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack);
|
||||||
final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
|
final BaseItemStack weStack = new BaseItemStack(BukkitAdapter.asItemType(itemStack.getType()), itemStack.getAmount());
|
||||||
weStack.setNbtData(((CompoundTag) toNative(nmsStack.getTag())));
|
weStack.setNbt(((CompoundBinaryTag) toNativeBinary(nmsStack.getTag())));
|
||||||
return weStack;
|
return weStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
public static final Field fieldPalette;
|
public static final Field fieldPalette;
|
||||||
|
|
||||||
|
|
||||||
public static final Field fieldTickingFluidContent;
|
public static final Field fieldTickingFluidCount;
|
||||||
public static final Field fieldTickingBlockCount;
|
public static final Field fieldTickingBlockCount;
|
||||||
public static final Field fieldNonEmptyBlockCount;
|
public static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
@ -114,14 +114,13 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
dataConstructor = dataClazz.getDeclaredConstructors()[0];
|
dataConstructor = dataClazz.getDeclaredConstructors()[0];
|
||||||
dataConstructor.setAccessible(true);
|
dataConstructor.setAccessible(true);
|
||||||
|
|
||||||
//TODO FIXME 1.18
|
|
||||||
fieldStorage = dataClazz.getDeclaredField(Refraction.pickName("storage", "b"));
|
fieldStorage = dataClazz.getDeclaredField(Refraction.pickName("storage", "b"));
|
||||||
fieldStorage.setAccessible(true);
|
fieldStorage.setAccessible(true);
|
||||||
fieldPalette = dataClazz.getDeclaredField(Refraction.pickName("palette", "c"));
|
fieldPalette = dataClazz.getDeclaredField(Refraction.pickName("palette", "c"));
|
||||||
fieldPalette.setAccessible(true);
|
fieldPalette.setAccessible(true);
|
||||||
|
|
||||||
fieldTickingFluidContent = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingFluidCount", "h"));
|
fieldTickingFluidCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingFluidCount", "h"));
|
||||||
fieldTickingFluidContent.setAccessible(true);
|
fieldTickingFluidCount.setAccessible(true);
|
||||||
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "g"));
|
fieldTickingBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("tickingBlockCount", "g"));
|
||||||
fieldTickingBlockCount.setAccessible(true);
|
fieldTickingBlockCount.setAccessible(true);
|
||||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "f"));
|
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "f"));
|
||||||
@ -544,7 +543,7 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
|
|
||||||
public static void setCount(final int tickingBlockCount, final int nonEmptyBlockCount, final LevelChunkSection section) throws
|
public static void setCount(final int tickingBlockCount, final int nonEmptyBlockCount, final LevelChunkSection section) throws
|
||||||
IllegalAccessException {
|
IllegalAccessException {
|
||||||
fieldTickingFluidContent.setShort(section, (short) 0); // TODO FIXME
|
fieldTickingFluidCount.setShort(section, (short) 0); // TODO FIXME
|
||||||
fieldTickingBlockCount.setShort(section, (short) tickingBlockCount);
|
fieldTickingBlockCount.setShort(section, (short) tickingBlockCount);
|
||||||
fieldNonEmptyBlockCount.setShort(section, (short) nonEmptyBlockCount);
|
fieldNonEmptyBlockCount.setShort(section, (short) nonEmptyBlockCount);
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,12 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||||
|
|
||||||
private static final Field serverWorldsField;
|
private static final Field serverWorldsField;
|
||||||
private static final Field worldPaperConfigField;
|
private static final Field paperConfigField;
|
||||||
private static final Field flatBedrockField;
|
private static final Field flatBedrockField;
|
||||||
private static final Field generatorSettingFlatField;
|
private static final Field generatorSettingFlatField;
|
||||||
private static final Field generatorSettingBaseSupplierField;
|
private static final Field generatorSettingBaseSupplierField;
|
||||||
private static final Field delegateField;
|
private static final Field delegateField;
|
||||||
private static final Field chunkProviderField;
|
private static final Field chunkSourceField;
|
||||||
|
|
||||||
//list of chunk stati in correct order without FULL
|
//list of chunk stati in correct order without FULL
|
||||||
private static final Map<ChunkStatus, Concurrency> chunkStati = new LinkedHashMap<>();
|
private static final Map<ChunkStatus, Concurrency> chunkStati = new LinkedHashMap<>();
|
||||||
@ -123,7 +123,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
tmpPaperConfigField = null;
|
tmpPaperConfigField = null;
|
||||||
tmpFlatBedrockField = null;
|
tmpFlatBedrockField = null;
|
||||||
}
|
}
|
||||||
worldPaperConfigField = tmpPaperConfigField;
|
paperConfigField = tmpPaperConfigField;
|
||||||
flatBedrockField = tmpFlatBedrockField;
|
flatBedrockField = tmpFlatBedrockField;
|
||||||
|
|
||||||
generatorSettingBaseSupplierField = NoiseBasedChunkGenerator.class.getDeclaredField(Refraction.pickName(
|
generatorSettingBaseSupplierField = NoiseBasedChunkGenerator.class.getDeclaredField(Refraction.pickName(
|
||||||
@ -136,8 +136,8 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
delegateField = CustomChunkGenerator.class.getDeclaredField("delegate");
|
delegateField = CustomChunkGenerator.class.getDeclaredField("delegate");
|
||||||
delegateField.setAccessible(true);
|
delegateField.setAccessible(true);
|
||||||
|
|
||||||
chunkProviderField = ServerLevel.class.getDeclaredField(Refraction.pickName("chunkSource", "L"));
|
chunkSourceField = ServerLevel.class.getDeclaredField(Refraction.pickName("chunkSource", "L"));
|
||||||
chunkProviderField.setAccessible(true);
|
chunkSourceField.setAccessible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -170,9 +170,9 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
}
|
}
|
||||||
|
|
||||||
//flat bedrock? (only on paper)
|
//flat bedrock? (only on paper)
|
||||||
if (worldPaperConfigField != null) {
|
if (paperConfigField != null) {
|
||||||
try {
|
try {
|
||||||
generateFlatBedrock = flatBedrockField.getBoolean(worldPaperConfigField.get(originalServerWorld));
|
generateFlatBedrock = flatBedrockField.getBoolean(paperConfigField.get(originalServerWorld));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,8 +254,8 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
freshWorld.noSave = true;
|
freshWorld.noSave = true;
|
||||||
removeWorldFromWorldsMap();
|
removeWorldFromWorldsMap();
|
||||||
newWorldData.checkName(originalServerWorld.serverLevelData.getLevelName()); //rename to original world name
|
newWorldData.checkName(originalServerWorld.serverLevelData.getLevelName()); //rename to original world name
|
||||||
if (worldPaperConfigField != null) {
|
if (paperConfigField != null) {
|
||||||
worldPaperConfigField.set(freshWorld, originalServerWorld.paperConfig);
|
paperConfigField.set(freshWorld, originalServerWorld.paperConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
//generator
|
//generator
|
||||||
@ -302,7 +302,7 @@ public class PaperweightRegen extends Regenerator<ChunkAccess, ProtoChunk, Level
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReflectionUtils.unsafeSet(chunkProviderField, freshWorld, freshChunkProvider);
|
ReflectionUtils.unsafeSet(chunkSourceField, freshWorld, freshChunkProvider);
|
||||||
//let's start then
|
//let's start then
|
||||||
structureManager = server.getStructureManager();
|
structureManager = server.getStructureManager();
|
||||||
threadedLevelLightEngine = freshChunkProvider.getLightEngine();
|
threadedLevelLightEngine = freshChunkProvider.getLightEngine();
|
||||||
|
@ -4,6 +4,7 @@ import com.fastasyncworldedit.core.Fawe;
|
|||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -11,26 +12,26 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public class LazyBaseEntity extends BaseEntity {
|
public class LazyBaseEntity extends BaseEntity {
|
||||||
|
|
||||||
private Supplier<CompoundTag> saveTag;
|
private Supplier<CompoundBinaryTag> saveTag;
|
||||||
|
|
||||||
public LazyBaseEntity(EntityType type, Supplier<CompoundTag> saveTag) {
|
public LazyBaseEntity(EntityType type, Supplier<CompoundBinaryTag> saveTag) {
|
||||||
super(type);
|
super(type);
|
||||||
this.saveTag = saveTag;
|
this.saveTag = saveTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundBinaryTag getNbt() {
|
||||||
Supplier<CompoundTag> tmp = saveTag;
|
Supplier<CompoundBinaryTag> tmp = saveTag;
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
saveTag = null;
|
saveTag = null;
|
||||||
if (Fawe.isMainThread()) {
|
if (Fawe.isMainThread()) {
|
||||||
setNbtData(tmp.get());
|
setNbt(tmp.get());
|
||||||
} else {
|
} else {
|
||||||
setNbtData(TaskManager.taskManager().sync(tmp));
|
setNbt(TaskManager.taskManager().sync(tmp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.getNbtData();
|
return super.getNbt();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user