Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-17 00:20:09 +01:00
Upstream changes, use correct list of cached block changes
Dieser Commit ist enthalten in:
Ursprung
4906dfa347
Commit
7c1c92d6db
@ -947,7 +947,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.getId()));
|
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.id()));
|
||||||
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
||||||
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
||||||
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
||||||
@ -956,7 +956,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.getId()));
|
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import net.minecraft.world.entity.Entity;
|
|||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeManager;
|
import net.minecraft.world.level.biome.BiomeManager;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.border.WorldBorder;
|
import net.minecraft.world.level.border.WorldBorder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
@ -121,7 +122,22 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlockState(final BlockPos pos) {
|
public BlockState getBlockState(final BlockPos pos) {
|
||||||
return world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
try {
|
||||||
|
state = new BlockState(
|
||||||
|
state.getBlock(),
|
||||||
|
state.getValues(),
|
||||||
|
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public boolean is(Block block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -544,7 +544,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
||||||
.get(ResourceLocation.tryParse(feature.getId()));
|
.get(ResourceLocation.tryParse(feature.id()));
|
||||||
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
||||||
|
|
||||||
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
||||||
@ -559,10 +559,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
)) {
|
)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return populator.getList().stream().collect(Collectors.toMap(
|
return new HashMap<>(populator.getLevel().capturedBlockStates);
|
||||||
CraftBlockState::getPosition,
|
|
||||||
craftBlockState -> craftBlockState
|
|
||||||
));
|
|
||||||
} finally {
|
} finally {
|
||||||
serverLevel.captureBlockStates = false;
|
serverLevel.captureBlockStates = false;
|
||||||
serverLevel.captureTreeGeneration = false;
|
serverLevel.captureTreeGeneration = false;
|
||||||
@ -580,7 +577,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
Structure k = serverLevel
|
Structure k = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.STRUCTURE)
|
.registryOrThrow(Registries.STRUCTURE)
|
||||||
.get(ResourceLocation.tryParse(type.getId()));
|
.get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.math.IntPair;
|
|||||||
import com.fastasyncworldedit.core.util.MathMan;
|
import com.fastasyncworldedit.core.util.MathMan;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||||
@ -45,6 +46,7 @@ import net.minecraft.world.level.biome.Biome;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.StateHolder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||||
@ -99,6 +101,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingFluidCount;
|
private static final Field fieldTickingFluidCount;
|
||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
|
|
||||||
|
private static final Field fieldPropertiesCodec;
|
||||||
|
|
||||||
private static final MethodHandle methodGetVisibleChunk;
|
private static final MethodHandle methodGetVisibleChunk;
|
||||||
|
|
||||||
private static final Field fieldThreadingDetector;
|
private static final Field fieldThreadingDetector;
|
||||||
@ -154,6 +158,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldBiomes = tmpFieldBiomes;
|
fieldBiomes = tmpFieldBiomes;
|
||||||
fieldBiomes.setAccessible(true);
|
fieldBiomes.setAccessible(true);
|
||||||
|
|
||||||
|
fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
|
||||||
|
fieldPropertiesCodec.setAccessible(true);
|
||||||
|
|
||||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||||
"getVisibleChunkIfPresent",
|
"getVisibleChunkIfPresent",
|
||||||
"b"
|
"b"
|
||||||
@ -705,6 +712,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
|
||||||
|
net.minecraft.world.level.block.state.BlockState state
|
||||||
|
) throws IllegalAccessException {
|
||||||
|
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
|
||||||
|
}
|
||||||
|
|
||||||
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -946,7 +946,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.getId()));
|
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.id()));
|
||||||
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
||||||
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
||||||
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
||||||
@ -955,7 +955,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.getId()));
|
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import net.minecraft.world.entity.Entity;
|
|||||||
import net.minecraft.world.flag.FeatureFlagSet;
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeManager;
|
import net.minecraft.world.level.biome.BiomeManager;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.border.WorldBorder;
|
import net.minecraft.world.level.border.WorldBorder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
@ -121,7 +122,22 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlockState(final BlockPos pos) {
|
public BlockState getBlockState(final BlockPos pos) {
|
||||||
return world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
try {
|
||||||
|
state = new BlockState(
|
||||||
|
state.getBlock(),
|
||||||
|
state.getValues(),
|
||||||
|
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public boolean is(Block block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -544,7 +544,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
||||||
.get(ResourceLocation.tryParse(feature.getId()));
|
.get(ResourceLocation.tryParse(feature.id()));
|
||||||
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
||||||
|
|
||||||
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
||||||
@ -557,19 +557,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
serverLevel.random,
|
serverLevel.random,
|
||||||
new BlockPos(pt.x(), pt.y(), pt.z())
|
new BlockPos(pt.x(), pt.y(), pt.z())
|
||||||
)) {
|
)) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return populator.getList().stream().collect(Collectors.toMap(
|
return new HashMap<>(populator.getLevel().capturedBlockStates);
|
||||||
CraftBlockState::getPosition,
|
|
||||||
craftBlockState -> craftBlockState
|
|
||||||
));
|
|
||||||
} finally {
|
} finally {
|
||||||
serverLevel.captureBlockStates = false;
|
serverLevel.captureBlockStates = false;
|
||||||
serverLevel.captureTreeGeneration = false;
|
serverLevel.captureTreeGeneration = false;
|
||||||
serverLevel.capturedBlockStates.clear();
|
serverLevel.capturedBlockStates.clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return placeFeatureIntoSession(editSession, populator, placed);
|
return placeFeatureIntoSession(editSession, populator, placed);
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
@ -580,7 +577,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
Structure k = serverLevel
|
Structure k = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.STRUCTURE)
|
.registryOrThrow(Registries.STRUCTURE)
|
||||||
.get(ResourceLocation.tryParse(type.getId()));
|
.get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.math.IntPair;
|
|||||||
import com.fastasyncworldedit.core.util.MathMan;
|
import com.fastasyncworldedit.core.util.MathMan;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||||
@ -45,6 +46,7 @@ import net.minecraft.world.level.biome.Biome;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.StateHolder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||||
@ -100,6 +102,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldBiomes;
|
private static final Field fieldBiomes;
|
||||||
|
|
||||||
|
private static final Field fieldPropertiesCodec;
|
||||||
|
|
||||||
private static final MethodHandle methodGetVisibleChunk;
|
private static final MethodHandle methodGetVisibleChunk;
|
||||||
|
|
||||||
private static final Field fieldThreadingDetector;
|
private static final Field fieldThreadingDetector;
|
||||||
@ -154,6 +158,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldBiomes = tmpFieldBiomes;
|
fieldBiomes = tmpFieldBiomes;
|
||||||
fieldBiomes.setAccessible(true);
|
fieldBiomes.setAccessible(true);
|
||||||
|
|
||||||
|
fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
|
||||||
|
fieldPropertiesCodec.setAccessible(true);
|
||||||
|
|
||||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||||
"getVisibleChunkIfPresent",
|
"getVisibleChunkIfPresent",
|
||||||
"b"
|
"b"
|
||||||
@ -705,6 +712,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
|
||||||
|
net.minecraft.world.level.block.state.BlockState state
|
||||||
|
) throws IllegalAccessException {
|
||||||
|
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
|
||||||
|
}
|
||||||
|
|
||||||
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -970,7 +970,8 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.getId()));
|
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(
|
||||||
|
ResourceLocation.tryParse(type.id()));
|
||||||
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
||||||
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
||||||
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
||||||
@ -979,7 +980,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.getId()));
|
Structure k = originalWorld
|
||||||
|
.registryAccess()
|
||||||
|
.registryOrThrow(Registries.STRUCTURE)
|
||||||
|
.get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.flag.FeatureFlagSet;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeManager;
|
import net.minecraft.world.level.biome.BiomeManager;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import net.minecraft.world.level.border.WorldBorder;
|
import net.minecraft.world.level.border.WorldBorder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkSource;
|
import net.minecraft.world.level.chunk.ChunkSource;
|
||||||
@ -66,6 +71,11 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
|
|||||||
return world.getSeaLevel();
|
return world.getSeaLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureFlagSet enabledFeatures() {
|
||||||
|
return world.enabledFeatures();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getShade(final Direction direction, final boolean shaded) {
|
public float getShade(final Direction direction, final boolean shaded) {
|
||||||
return world.getShade(direction, shaded);
|
return world.getShade(direction, shaded);
|
||||||
@ -97,4 +107,44 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
|
|||||||
return world.getWorldBorder();
|
return world.getWorldBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final BlockPos pos, final BlockState state, final int flags, final int maxUpdateDepth) {
|
||||||
|
return world.setBlock(pos, state, flags, maxUpdateDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeBlock(final BlockPos pos, final boolean move) {
|
||||||
|
return world.removeBlock(pos, move);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean destroyBlock(final BlockPos pos, final boolean drop, final Entity breakingEntity, final int maxUpdateDepth) {
|
||||||
|
return world.destroyBlock(pos, drop, breakingEntity, maxUpdateDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockState(final BlockPos pos) {
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
try {
|
||||||
|
state = new BlockState(
|
||||||
|
state.getBlock(),
|
||||||
|
(Reference2ObjectArrayMap<Property<?>, Comparable<?>>) state.getValues(),
|
||||||
|
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public boolean is(Block block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final BlockPos pos, final BlockState state, final int flags) {
|
||||||
|
return world.setBlock(pos, state, flags);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -558,7 +558,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
||||||
.get(ResourceLocation.tryParse(feature.getId()));
|
.get(ResourceLocation.tryParse(feature.id()));
|
||||||
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
||||||
|
|
||||||
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
||||||
@ -573,10 +573,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
)) {
|
)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return populator.getList().stream().collect(Collectors.toMap(
|
return new HashMap<>(populator.getLevel().capturedBlockStates);
|
||||||
CraftBlockState::getPosition,
|
|
||||||
craftBlockState -> craftBlockState
|
|
||||||
));
|
|
||||||
} finally {
|
} finally {
|
||||||
serverLevel.captureBlockStates = false;
|
serverLevel.captureBlockStates = false;
|
||||||
serverLevel.captureTreeGeneration = false;
|
serverLevel.captureTreeGeneration = false;
|
||||||
@ -594,7 +591,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
Structure k = serverLevel
|
Structure k = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.STRUCTURE)
|
.registryOrThrow(Registries.STRUCTURE)
|
||||||
.get(ResourceLocation.tryParse(type.getId()));
|
.get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.math.IntPair;
|
|||||||
import com.fastasyncworldedit.core.util.MathMan;
|
import com.fastasyncworldedit.core.util.MathMan;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||||
@ -45,6 +46,7 @@ import net.minecraft.world.level.biome.Biome;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.StateHolder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||||
import net.minecraft.world.level.chunk.HashMapPalette;
|
import net.minecraft.world.level.chunk.HashMapPalette;
|
||||||
@ -100,6 +102,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldBiomes;
|
private static final Field fieldBiomes;
|
||||||
|
|
||||||
|
private static final Field fieldPropertiesCodec;
|
||||||
|
|
||||||
private static final MethodHandle methodGetVisibleChunk;
|
private static final MethodHandle methodGetVisibleChunk;
|
||||||
|
|
||||||
private static final Field fieldThreadingDetector;
|
private static final Field fieldThreadingDetector;
|
||||||
@ -154,6 +158,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldBiomes = tmpFieldBiomes;
|
fieldBiomes = tmpFieldBiomes;
|
||||||
fieldBiomes.setAccessible(true);
|
fieldBiomes.setAccessible(true);
|
||||||
|
|
||||||
|
fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
|
||||||
|
fieldPropertiesCodec.setAccessible(true);
|
||||||
|
|
||||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||||
"getVisibleChunkIfPresent",
|
"getVisibleChunkIfPresent",
|
||||||
"b"
|
"b"
|
||||||
@ -705,6 +712,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
|
||||||
|
net.minecraft.world.level.block.state.BlockState state
|
||||||
|
) throws IllegalAccessException {
|
||||||
|
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
|
||||||
|
}
|
||||||
|
|
||||||
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -510,23 +510,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
CraftWorld craftWorld = ((CraftWorld) location.getWorld());
|
||||||
ServerLevel worldServer = craftWorld.getHandle();
|
ServerLevel worldServer = craftWorld.getHandle();
|
||||||
|
|
||||||
String entityId = state.getType().id();
|
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||||
|
|
||||||
LinCompoundTag nativeTag = state.getNbt();
|
|
||||||
net.minecraft.nbt.CompoundTag tag;
|
|
||||||
if (nativeTag != null) {
|
|
||||||
tag = (net.minecraft.nbt.CompoundTag) fromNativeLin(nativeTag);
|
|
||||||
removeUnwantedEntityTagsRecursively(tag);
|
|
||||||
} else {
|
|
||||||
tag = new net.minecraft.nbt.CompoundTag();
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.putString("id", entityId);
|
|
||||||
|
|
||||||
Entity createdEntity = EntityType.loadEntityRecursive(tag, craftWorld.getHandle(), (loadedEntity) -> {
|
|
||||||
loadedEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
|
||||||
return loadedEntity;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
worldServer.addFreshEntityWithPassengers(createdEntity, SpawnReason.CUSTOM);
|
worldServer.addFreshEntityWithPassengers(createdEntity, SpawnReason.CUSTOM);
|
||||||
@ -977,7 +961,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateFeature(ConfiguredFeatureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.getId()));
|
ConfiguredFeature<?, ?> k = originalWorld.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).get(ResourceLocation.tryParse(type.id()));
|
||||||
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
ServerChunkCache chunkManager = originalWorld.getChunkSource();
|
||||||
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this);
|
||||||
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z()));
|
||||||
@ -986,7 +970,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
public boolean generateStructure(StructureType type, World world, EditSession session, BlockVector3 pt) {
|
||||||
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
ServerLevel originalWorld = ((CraftWorld) world).getHandle();
|
||||||
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.getId()));
|
Structure k = originalWorld.registryAccess().registryOrThrow(Registries.STRUCTURE).get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.biome.Biome;
|
import net.minecraft.world.level.biome.Biome;
|
||||||
import net.minecraft.world.level.biome.BiomeManager;
|
import net.minecraft.world.level.biome.BiomeManager;
|
||||||
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.properties.Property;
|
||||||
import net.minecraft.world.level.border.WorldBorder;
|
import net.minecraft.world.level.border.WorldBorder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.ChunkSource;
|
import net.minecraft.world.level.chunk.ChunkSource;
|
||||||
@ -97,4 +101,44 @@ public class FaweBlockStateListPopulator extends BlockStateListPopulator {
|
|||||||
return world.getWorldBorder();
|
return world.getWorldBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final BlockPos pos, final BlockState state, final int flags, final int maxUpdateDepth) {
|
||||||
|
return world.setBlock(pos, state, flags, maxUpdateDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeBlock(final BlockPos pos, final boolean move) {
|
||||||
|
return world.removeBlock(pos, move);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean destroyBlock(final BlockPos pos, final boolean drop, final Entity breakingEntity, final int maxUpdateDepth) {
|
||||||
|
return world.destroyBlock(pos, drop, breakingEntity, maxUpdateDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockState(final BlockPos pos) {
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
try {
|
||||||
|
state = new BlockState(
|
||||||
|
state.getBlock(),
|
||||||
|
(Reference2ObjectArrayMap<Property<?>, Comparable<?>>) state.getValues(),
|
||||||
|
PaperweightPlatformAdapter.getStatePropertiesCodec(state)
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public boolean is(Block block) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final BlockPos pos, final BlockState state, final int flags) {
|
||||||
|
return world.setBlock(pos, state, flags);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,8 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
public org.bukkit.inventory.ItemStack adapt(BaseItemStack baseItemStack) {
|
||||||
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
|
final RegistryAccess.Frozen registryAccess = DedicatedServer.getServer().registryAccess();
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||||
|
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||||
baseItemStack.getAmount()
|
baseItemStack.getAmount()
|
||||||
);
|
);
|
||||||
final net.minecraft.nbt.CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData());
|
final net.minecraft.nbt.CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData());
|
||||||
@ -558,7 +559,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
ConfiguredFeature<?, ?> configuredFeature = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
.registryOrThrow(Registries.CONFIGURED_FEATURE)
|
||||||
.get(ResourceLocation.tryParse(feature.getId()));
|
.get(ResourceLocation.tryParse(feature.id()));
|
||||||
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel);
|
||||||
|
|
||||||
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
Map<BlockPos, CraftBlockState> placed = TaskManager.taskManager().sync(() -> {
|
||||||
@ -573,10 +574,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
)) {
|
)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return populator.getList().stream().collect(Collectors.toMap(
|
return new HashMap<>(populator.getLevel().capturedBlockStates);
|
||||||
CraftBlockState::getPosition,
|
|
||||||
craftBlockState -> craftBlockState
|
|
||||||
));
|
|
||||||
} finally {
|
} finally {
|
||||||
serverLevel.captureBlockStates = false;
|
serverLevel.captureBlockStates = false;
|
||||||
serverLevel.captureTreeGeneration = false;
|
serverLevel.captureTreeGeneration = false;
|
||||||
@ -595,7 +593,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
Structure k = serverLevel
|
Structure k = serverLevel
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(Registries.STRUCTURE)
|
.registryOrThrow(Registries.STRUCTURE)
|
||||||
.get(ResourceLocation.tryParse(type.getId()));
|
.get(ResourceLocation.tryParse(type.id()));
|
||||||
if (k == null) {
|
if (k == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import com.fastasyncworldedit.core.math.IntPair;
|
|||||||
import com.fastasyncworldedit.core.util.MathMan;
|
import com.fastasyncworldedit.core.util.MathMan;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
import com.sk89q.worldedit.bukkit.adapter.Refraction;
|
||||||
@ -44,6 +45,7 @@ import net.minecraft.world.level.biome.Biome;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.StateHolder;
|
||||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||||
import net.minecraft.world.level.chunk.HashMapPalette;
|
import net.minecraft.world.level.chunk.HashMapPalette;
|
||||||
@ -99,6 +101,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldBiomes;
|
private static final Field fieldBiomes;
|
||||||
|
|
||||||
|
private static final Field fieldPropertiesCodec;
|
||||||
|
|
||||||
private static final MethodHandle methodGetVisibleChunk;
|
private static final MethodHandle methodGetVisibleChunk;
|
||||||
|
|
||||||
private static final Field fieldThreadingDetector;
|
private static final Field fieldThreadingDetector;
|
||||||
@ -151,6 +155,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldBiomes = tmpFieldBiomes;
|
fieldBiomes = tmpFieldBiomes;
|
||||||
fieldBiomes.setAccessible(true);
|
fieldBiomes.setAccessible(true);
|
||||||
|
|
||||||
|
fieldPropertiesCodec = StateHolder.class.getDeclaredField(Refraction.pickName("propertiesCodec", "f"));
|
||||||
|
fieldPropertiesCodec.setAccessible(true);
|
||||||
|
|
||||||
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
Method getVisibleChunkIfPresent = ChunkMap.class.getDeclaredMethod(Refraction.pickName(
|
||||||
"getVisibleChunkIfPresent",
|
"getVisibleChunkIfPresent",
|
||||||
"b"
|
"b"
|
||||||
@ -679,6 +686,12 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MapCodec<net.minecraft.world.level.block.state.BlockState> getStatePropertiesCodec(
|
||||||
|
net.minecraft.world.level.block.state.BlockState state
|
||||||
|
) throws IllegalAccessException {
|
||||||
|
return (MapCodec<net.minecraft.world.level.block.state.BlockState>) fieldPropertiesCodec.get(state);
|
||||||
|
}
|
||||||
|
|
||||||
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
record FakeIdMapBlock(int size) implements IdMap<net.minecraft.world.level.block.state.BlockState> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,6 @@ import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
|
|||||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
|
||||||
import com.sk89q.worldedit.registry.Keyed;
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
|
@ -29,7 +29,7 @@ public class Pre13HangingCompatibilityHandler implements EntityNBTCompatibilityH
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinCompoundTag updateNbt(EntityType type, LinCompoundTag tag) {
|
public LinCompoundTag updateNbt(EntityType type, LinCompoundTag tag) {
|
||||||
if (!type.getId().startsWith("minecraft:")) {
|
if (!type.id().startsWith("minecraft:")) {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
Direction newDirection;
|
Direction newDirection;
|
||||||
|
@ -131,7 +131,9 @@ public class AnvilChunk13 implements Chunk {
|
|||||||
try {
|
try {
|
||||||
blockState = getBlockStateWith(blockState, property, value);
|
blockState = getBlockStateWith(blockState, property, value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().id() + ", " + property.getName() + ": " + value);
|
throw new InvalidFormatException("Invalid block state for " + blockState
|
||||||
|
.getBlockType()
|
||||||
|
.id() + ", " + property.getName() + ": " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,9 @@ public class AnvilChunk18 implements Chunk {
|
|||||||
try {
|
try {
|
||||||
blockState = getBlockStateWith(blockState, property, value);
|
blockState = getBlockStateWith(blockState, property, value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().getId() + ", " + property.getName() + ": " + value);
|
throw new InvalidFormatException("Invalid block state for " + blockState
|
||||||
|
.getBlockType()
|
||||||
|
.id() + ", " + property.getName() + ": " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,9 +199,9 @@ public class AnvilChunk18 implements Chunk {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(BlockVector3 position) throws DataException {
|
public BaseBlock getBlock(BlockVector3 position) throws DataException {
|
||||||
int x = position.getX() - rootX * 16;
|
int x = position.x() - rootX * 16;
|
||||||
int y = position.getY();
|
int y = position.y();
|
||||||
int z = position.getZ() - rootZ * 16;
|
int z = position.z() - rootZ * 16;
|
||||||
|
|
||||||
int section = y >> 4;
|
int section = y >> 4;
|
||||||
int yIndex = y & 0x0F;
|
int yIndex = y & 0x0F;
|
||||||
|
@ -24,26 +24,17 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.registry.Keyed;
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
|
|
||||||
public class ConfiguredFeatureType implements Keyed {
|
public record ConfiguredFeatureType(String id) implements Keyed {
|
||||||
|
|
||||||
public static final NamespacedRegistry<ConfiguredFeatureType> REGISTRY = new NamespacedRegistry<>("configured feature type");
|
public static final NamespacedRegistry<ConfiguredFeatureType> REGISTRY = new NamespacedRegistry<>("configured feature type");
|
||||||
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
public ConfiguredFeatureType(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place this feature into an {@link EditSession}
|
* Place this feature into an {@link EditSession}
|
||||||
*
|
*
|
||||||
|
@ -24,26 +24,17 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.registry.Keyed;
|
import com.sk89q.worldedit.registry.Keyed;
|
||||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||||
|
|
||||||
public class StructureType implements Keyed {
|
public record StructureType(String id) implements Keyed {
|
||||||
|
|
||||||
public static final NamespacedRegistry<StructureType> REGISTRY = new NamespacedRegistry<>("structure type");
|
public static final NamespacedRegistry<StructureType> REGISTRY = new NamespacedRegistry<>("structure type");
|
||||||
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
public StructureType(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place this structure into an {@link EditSession}
|
* Place this structure into an {@link EditSession}
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren