Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 09:20:08 +01:00
Upstream changes, use correct list of cached block changes
Dieser Commit ist enthalten in:
Ursprung
ef9c2c0bd3
Commit
a2c0498b0c
@ -296,11 +296,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
private static Block getBlockFromType(BlockType blockType) {
|
private static Block getBlockFromType(BlockType blockType) {
|
||||||
|
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item getItemFromType(ItemType itemType) {
|
private static Item getItemFromType(ItemType itemType) {
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -468,7 +468,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();
|
||||||
|
|
||||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
CompoundBinaryTag nativeTag = state.getNbt();
|
CompoundBinaryTag nativeTag = state.getNbt();
|
||||||
@ -575,7 +575,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||||
item.getAmount()
|
item.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||||
@ -859,7 +859,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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()));
|
||||||
@ -867,7 +867,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@ 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.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;
|
||||||
@ -103,4 +105,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(),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ 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) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||||
baseItemStack.getAmount()
|
baseItemStack.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||||
@ -532,7 +532,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(() -> {
|
||||||
@ -547,10 +547,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;
|
||||||
@ -568,7 +565,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;
|
||||||
}
|
}
|
||||||
@ -719,7 +716,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
.getServer()
|
.getServer()
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(BIOME);
|
.registryOrThrow(BIOME);
|
||||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||||
Biome biome = registry.get(resourceLocation);
|
Biome biome = registry.get(resourceLocation);
|
||||||
return registry.getId(biome);
|
return registry.getId(biome);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.util.MathMan;
|
|||||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||||
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;
|
||||||
@ -46,6 +47,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.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
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;
|
||||||
@ -59,7 +61,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
|
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
|
||||||
import sun.misc.Unsafe;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -99,6 +100,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldNonEmptyBlockCount;
|
private static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -141,6 +144,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "f"));
|
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "f"));
|
||||||
fieldNonEmptyBlockCount.setAccessible(true);
|
fieldNonEmptyBlockCount.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"
|
||||||
@ -687,6 +693,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
|
||||||
|
@ -297,11 +297,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
private static Block getBlockFromType(BlockType blockType) {
|
private static Block getBlockFromType(BlockType blockType) {
|
||||||
|
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item getItemFromType(ItemType itemType) {
|
private static Item getItemFromType(ItemType itemType) {
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -501,7 +501,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();
|
||||||
|
|
||||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
CompoundBinaryTag nativeTag = state.getNbt();
|
CompoundBinaryTag nativeTag = state.getNbt();
|
||||||
@ -619,7 +619,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||||
item.getAmount()
|
item.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||||
@ -905,7 +905,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()));
|
||||||
@ -913,7 +913,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@ 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.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;
|
||||||
@ -103,4 +105,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(),
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ 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) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||||
baseItemStack.getAmount()
|
baseItemStack.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||||
@ -533,7 +533,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(() -> {
|
||||||
@ -548,10 +548,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;
|
||||||
@ -569,7 +566,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;
|
||||||
}
|
}
|
||||||
@ -720,7 +717,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
.getServer()
|
.getServer()
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(BIOME);
|
.registryOrThrow(BIOME);
|
||||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||||
Biome biome = registry.get(resourceLocation);
|
Biome biome = registry.get(resourceLocation);
|
||||||
return registry.getId(biome);
|
return registry.getId(biome);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.util.MathMan;
|
|||||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||||
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;
|
||||||
@ -47,6 +48,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;
|
||||||
@ -61,7 +63,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
|
||||||
import sun.misc.Unsafe;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -103,6 +104,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldNonEmptyBlockCount;
|
private static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
|
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 +154,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||||
fieldNonEmptyBlockCount.setAccessible(true);
|
fieldNonEmptyBlockCount.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"
|
||||||
@ -701,6 +707,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
|
||||||
|
@ -294,11 +294,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
private static Block getBlockFromType(BlockType blockType) {
|
private static Block getBlockFromType(BlockType blockType) {
|
||||||
|
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item getItemFromType(ItemType itemType) {
|
private static Item getItemFromType(ItemType itemType) {
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -468,7 +468,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();
|
||||||
|
|
||||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
CompoundBinaryTag nativeTag = state.getNbt();
|
CompoundBinaryTag nativeTag = state.getNbt();
|
||||||
@ -575,7 +575,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||||
item.getAmount()
|
item.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||||
@ -860,7 +860,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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()));
|
||||||
@ -868,7 +868,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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
|
||||||
|
@ -497,7 +497,7 @@ 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) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||||
baseItemStack.getAmount()
|
baseItemStack.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||||
@ -536,7 +536,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(() -> {
|
||||||
@ -551,10 +551,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;
|
||||||
@ -572,7 +569,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;
|
||||||
}
|
}
|
||||||
@ -725,7 +722,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
.getServer()
|
.getServer()
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(BIOME);
|
.registryOrThrow(BIOME);
|
||||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||||
Biome biome = registry.get(resourceLocation);
|
Biome biome = registry.get(resourceLocation);
|
||||||
return registry.getId(biome);
|
return registry.getId(biome);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.util.MathMan;
|
|||||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||||
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.ChunkStatus;
|
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||||
@ -58,7 +60,6 @@ import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.CraftChunk;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftChunk;
|
||||||
import sun.misc.Unsafe;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -100,6 +101,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldNonEmptyBlockCount;
|
private static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -145,6 +148,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||||
fieldNonEmptyBlockCount.setAccessible(true);
|
fieldNonEmptyBlockCount.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"
|
||||||
@ -674,6 +680,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
|
||||||
|
@ -148,6 +148,7 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.spigotmc.SpigotConfig;
|
import org.spigotmc.SpigotConfig;
|
||||||
import org.spigotmc.WatchdogThread;
|
import org.spigotmc.WatchdogThread;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -169,7 +170,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
@ -294,11 +294,11 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
private static Block getBlockFromType(BlockType blockType) {
|
private static Block getBlockFromType(BlockType blockType) {
|
||||||
|
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(blockType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item getItemFromType(ItemType itemType) {
|
private static Item getItemFromType(ItemType itemType) {
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.getId()));
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(itemType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -468,7 +468,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();
|
||||||
|
|
||||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
CompoundBinaryTag nativeTag = state.getNbt();
|
CompoundBinaryTag nativeTag = state.getNbt();
|
||||||
@ -575,7 +575,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
@Override
|
@Override
|
||||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().getId())),
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||||
item.getAmount()
|
item.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData())));
|
||||||
@ -860,7 +860,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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()));
|
||||||
@ -868,7 +868,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
|
|
||||||
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
|
||||||
|
@ -497,7 +497,7 @@ 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) {
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM)
|
||||||
.get(ResourceLocation.tryParse(baseItemStack.getType().getId())),
|
.get(ResourceLocation.tryParse(baseItemStack.getType().id())),
|
||||||
baseItemStack.getAmount()
|
baseItemStack.getAmount()
|
||||||
);
|
);
|
||||||
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
stack.setTag(((net.minecraft.nbt.CompoundTag) fromNative(baseItemStack.getNbtData())));
|
||||||
@ -536,7 +536,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(() -> {
|
||||||
@ -549,19 +549,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
|
||||||
}
|
}
|
||||||
@ -572,7 +569,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;
|
||||||
}
|
}
|
||||||
@ -725,7 +722,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
.getServer()
|
.getServer()
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(BIOME);
|
.registryOrThrow(BIOME);
|
||||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||||
Biome biome = registry.get(resourceLocation);
|
Biome biome = registry.get(resourceLocation);
|
||||||
return registry.getId(biome);
|
return registry.getId(biome);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import com.fastasyncworldedit.core.util.MathMan;
|
|||||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||||
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.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 fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldNonEmptyBlockCount;
|
private static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -144,6 +148,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||||
fieldNonEmptyBlockCount.setAccessible(true);
|
fieldNonEmptyBlockCount.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"
|
||||||
@ -673,6 +680,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
|
||||||
|
@ -142,6 +142,7 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.spigotmc.SpigotConfig;
|
import org.spigotmc.SpigotConfig;
|
||||||
import org.spigotmc.WatchdogThread;
|
import org.spigotmc.WatchdogThread;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -163,7 +164,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
@ -291,12 +291,12 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
private static Block getBlockFromType(BlockType blockType) {
|
private static Block getBlockFromType(BlockType blockType) {
|
||||||
|
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.BLOCK).get(ResourceLocation.tryParse(
|
||||||
blockType.getId()));
|
blockType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Item getItemFromType(ItemType itemType) {
|
private static Item getItemFromType(ItemType itemType) {
|
||||||
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(
|
return DedicatedServer.getServer().registryAccess().registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(
|
||||||
itemType.getId()));
|
itemType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -470,7 +470,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();
|
||||||
|
|
||||||
Entity createdEntity = createEntityFromId(state.getType().getId(), craftWorld.getHandle());
|
Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle());
|
||||||
|
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
CompoundBinaryTag nativeTag = state.getNbt();
|
CompoundBinaryTag nativeTag = state.getNbt();
|
||||||
@ -598,7 +598,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
|
|||||||
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
public org.bukkit.inventory.ItemStack adapt(BaseItemStack item) {
|
||||||
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(item.getType().getId())),
|
registryAccess.registryOrThrow(Registries.ITEM).get(ResourceLocation.tryParse(item.getType().id())),
|
||||||
item.getAmount()
|
item.getAmount()
|
||||||
);
|
);
|
||||||
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData());
|
final CompoundTag nbt = (net.minecraft.nbt.CompoundTag) fromNative(item.getNbtData());
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import com.fastasyncworldedit.core.util.TaskManager;
|
|||||||
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.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
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;
|
||||||
@ -57,8 +57,8 @@ import com.sk89q.worldedit.world.registry.BlockMaterial;
|
|||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.SectionPos;
|
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.core.SectionPos;
|
||||||
import net.minecraft.core.WritableRegistry;
|
import net.minecraft.core.WritableRegistry;
|
||||||
import net.minecraft.core.component.DataComponentPatch;
|
import net.minecraft.core.component.DataComponentPatch;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
@ -505,7 +505,7 @@ 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().getId())),
|
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());
|
||||||
@ -550,7 +550,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(() -> {
|
||||||
@ -565,10 +565,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;
|
||||||
@ -586,7 +583,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;
|
||||||
}
|
}
|
||||||
@ -746,7 +743,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
|
|||||||
.getServer()
|
.getServer()
|
||||||
.registryAccess()
|
.registryAccess()
|
||||||
.registryOrThrow(BIOME);
|
.registryOrThrow(BIOME);
|
||||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.getId());
|
ResourceLocation resourceLocation = ResourceLocation.tryParse(biomeType.id());
|
||||||
Biome biome = registry.get(resourceLocation);
|
Biome biome = registry.get(resourceLocation);
|
||||||
return registry.getId(biome);
|
return registry.getId(biome);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import com.fastasyncworldedit.core.math.BitArrayUnstretched;
|
|||||||
import com.fastasyncworldedit.core.util.MathMan;
|
import com.fastasyncworldedit.core.util.MathMan;
|
||||||
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
import com.fastasyncworldedit.core.util.ReflectionUtils;
|
||||||
import com.fastasyncworldedit.core.util.TaskManager;
|
import com.fastasyncworldedit.core.util.TaskManager;
|
||||||
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 +44,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;
|
||||||
@ -76,7 +77,6 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -99,6 +99,8 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
private static final Field fieldTickingBlockCount;
|
private static final Field fieldTickingBlockCount;
|
||||||
private static final Field fieldNonEmptyBlockCount;
|
private static final Field fieldNonEmptyBlockCount;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -144,6 +146,9 @@ public final class PaperweightPlatformAdapter extends NMSAdapter {
|
|||||||
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
fieldNonEmptyBlockCount = LevelChunkSection.class.getDeclaredField(Refraction.pickName("nonEmptyBlockCount", "e"));
|
||||||
fieldNonEmptyBlockCount.setAccessible(true);
|
fieldNonEmptyBlockCount.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"
|
||||||
@ -671,6 +676,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
|
||||||
|
@ -166,10 +166,10 @@ public interface IBukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
default Material adapt(ItemType itemType) {
|
default Material adapt(ItemType itemType) {
|
||||||
checkNotNull(itemType);
|
checkNotNull(itemType);
|
||||||
if (!itemType.getId().startsWith("minecraft:")) {
|
if (!itemType.id().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||||
}
|
}
|
||||||
return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
|
return Material.getMaterial(itemType.id().substring(10).toUpperCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,10 +180,10 @@ public interface IBukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
default Material adapt(BlockType blockType) {
|
default Material adapt(BlockType blockType) {
|
||||||
checkNotNull(blockType);
|
checkNotNull(blockType);
|
||||||
if (!blockType.getId().startsWith("minecraft:")) {
|
if (!blockType.id().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||||
}
|
}
|
||||||
String id = blockType.getId().substring(10).toUpperCase(Locale.ROOT);
|
String id = blockType.id().substring(10).toUpperCase(Locale.ROOT);
|
||||||
return Material.getMaterial(id);
|
return Material.getMaterial(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,11 +293,11 @@ public interface IBukkitAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default Biome adapt(BiomeType biomeType) {
|
default Biome adapt(BiomeType biomeType) {
|
||||||
if (!biomeType.getId().startsWith("minecraft:")) {
|
if (!biomeType.id().startsWith("minecraft:")) {
|
||||||
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
|
return Biome.valueOf(biomeType.id().substring(10).toUpperCase(Locale.ROOT));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
|||||||
@Override
|
@Override
|
||||||
public Component getRichName(BiomeType biomeType) {
|
public Component getRichName(BiomeType biomeType) {
|
||||||
return TranslatableComponent.of(
|
return TranslatableComponent.of(
|
||||||
TranslationManager.makeTranslationKey("biome", biomeType.getId())
|
TranslationManager.makeTranslationKey("biome", biomeType.id())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
final PlayerInventory inv = player.getInventory();
|
final PlayerInventory inv = player.getInventory();
|
||||||
ItemStack newItem = BukkitAdapter.adapt(itemStack);
|
ItemStack newItem = BukkitAdapter.adapt(itemStack);
|
||||||
TaskManager.taskManager().sync(() -> {
|
TaskManager.taskManager().sync(() -> {
|
||||||
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
if (itemStack.getType().id().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
||||||
inv.remove(newItem);
|
inv.remove(newItem);
|
||||||
}
|
}
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
final ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
@ -267,7 +267,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameMode(GameMode gameMode) {
|
public void setGameMode(GameMode gameMode) {
|
||||||
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT)));
|
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.id().toUpperCase(Locale.ROOT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -230,7 +230,7 @@ public class BukkitServerInterface extends AbstractPlatform implements MultiUser
|
|||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return "intellectualsites:bukkit";
|
return "intellectualsites:bukkit";
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
@ -226,7 +226,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
return getWorld().getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class CLIBlockRegistry extends BundledBlockRegistry {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||||
Map<String, FileRegistries.BlockProperty> properties =
|
Map<String, FileRegistries.BlockProperty> properties =
|
||||||
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.getId()).properties;
|
CLIWorldEdit.inst.getFileRegistries().getDataFile().blocks.get(blockType.id()).properties;
|
||||||
Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform =
|
Maps.EntryTransformer<String, FileRegistries.BlockProperty, Property<?>> entryTransform =
|
||||||
(key, value) -> createProperty(value.type, key, value.values);
|
(key, value) -> createProperty(value.type, key, value.values);
|
||||||
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));
|
return ImmutableMap.copyOf(Maps.transformEntries(properties, entryTransform));
|
||||||
|
@ -115,7 +115,7 @@ class CLIPlatform extends AbstractPlatform {
|
|||||||
@Override
|
@Override
|
||||||
public World matchWorld(World world) {
|
public World matchWorld(World world) {
|
||||||
return this.worlds.stream()
|
return this.worlds.stream()
|
||||||
.filter(w -> w.getId().equals(world.getId()))
|
.filter(w -> w.id().equals(world.id()))
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld
|
|||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <B extends BlockStateHolder<B>> B checkBlock(B block) {
|
private <B extends BlockStateHolder<B>> B checkBlock(B block) {
|
||||||
if (blockedBlocks != null) {
|
if (blockedBlocks != null) {
|
||||||
if (blockedBlocks.contains(block.getBlockType().getId())) {
|
if (blockedBlocks.contains(block.getBlockType().id())) {
|
||||||
return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty
|
return (B) (block instanceof BlockState ? RESERVED : RESERVED.toBaseBlock()); // set to reserved/empty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IB
|
|||||||
}
|
}
|
||||||
BlockState state = BlockTypesCache.states[block];
|
BlockState state = BlockTypesCache.states[block];
|
||||||
if (blockedBlocks != null) {
|
if (blockedBlocks != null) {
|
||||||
if (blockedBlocks.contains(state.getBlockType().getId())) {
|
if (blockedBlocks.contains(state.getBlockType().id())) {
|
||||||
blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
blocks[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
|
public boolean setBiome(BlockVector3 position, BiomeType newBiome) {
|
||||||
BiomeType oldBiome = this.getBiome(position);
|
BiomeType oldBiome = this.getBiome(position);
|
||||||
if (!oldBiome.getId().equals(newBiome.getId())) {
|
if (!oldBiome.id().equals(newBiome.id())) {
|
||||||
this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome);
|
this.changeSet.addBiomeChange(position.x(), position.y(), position.z(), oldBiome, newBiome);
|
||||||
return getExtent().setBiome(position, newBiome);
|
return getExtent().setBiome(position, newBiome);
|
||||||
} else {
|
} else {
|
||||||
@ -121,7 +121,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
|
public boolean setBiome(int x, int y, int z, BiomeType newBiome) {
|
||||||
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
|
BiomeType oldBiome = this.getBiome(mutable.setComponents(x, y, z));
|
||||||
if (!oldBiome.getId().equals(newBiome.getId())) {
|
if (!oldBiome.id().equals(newBiome.id())) {
|
||||||
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
|
this.changeSet.addBiomeChange(x, y, z, oldBiome, newBiome);
|
||||||
return getExtent().setBiome(x, y, z, newBiome);
|
return getExtent().setBiome(x, y, z, newBiome);
|
||||||
} else {
|
} else {
|
||||||
|
@ -237,7 +237,7 @@ public class FastSchematicWriter implements ClipboardWriter {
|
|||||||
if (!brokenEntities) {
|
if (!brokenEntities) {
|
||||||
loc = loc.setPosition(loc.add(min.toVector3()));
|
loc = loc.setPosition(loc.add(min.toVector3()));
|
||||||
}
|
}
|
||||||
values.put("Id", new StringTag(state.getType().getId()));
|
values.put("Id", new StringTag(state.getType().id()));
|
||||||
values.put("Pos", writeVector(loc));
|
values.put("Pos", writeVector(loc));
|
||||||
values.put("Rotation", writeRotation(entity.getLocation()));
|
values.put("Rotation", writeRotation(entity.getLocation()));
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ public class FastSchematicWriter implements ClipboardWriter {
|
|||||||
for (int i = 0; i < paletteList.size(); i++) {
|
for (int i = 0; i < paletteList.size(); i++) {
|
||||||
int ordinal = paletteList.get(i);
|
int ordinal = paletteList.get(i);
|
||||||
BiomeType state = BiomeTypes.get(ordinal);
|
BiomeType state = BiomeTypes.get(ordinal);
|
||||||
out12.writeNamedTag(state.getId(), i);
|
out12.writeNamedTag(state.id(), i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
|
|
||||||
indexes.put(combined, (Integer) palette.size());
|
indexes.put(combined, (Integer) palette.size());
|
||||||
HashMap<String, Object> paletteEntry = new HashMap<>();
|
HashMap<String, Object> paletteEntry = new HashMap<>();
|
||||||
paletteEntry.put("Name", type.getId());
|
paletteEntry.put("Name", type.id());
|
||||||
if (block.getInternalId() != type.getInternalId()) {
|
if (block.getInternalId() != type.getInternalId()) {
|
||||||
Map<String, Object> properties = null;
|
Map<String, Object> properties = null;
|
||||||
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
|
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
|
||||||
@ -239,7 +239,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
|
|||||||
Map<String, Tag> nbtMap = nbt.getValue();
|
Map<String, Tag> nbtMap = nbt.getValue();
|
||||||
// Replace rotation data
|
// Replace rotation data
|
||||||
nbtMap.put("Rotation", writeRotation(entity.getLocation()));
|
nbtMap.put("Rotation", writeRotation(entity.getLocation()));
|
||||||
nbtMap.put("id", new StringTag(state.getType().getId()));
|
nbtMap.put("id", new StringTag(state.getType().id()));
|
||||||
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt);
|
Map<String, Object> entityMap = FaweCache.INSTANCE.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt);
|
||||||
entities.add(entityMap);
|
entities.add(entityMap);
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
int lightLevel = iChunk.getEmittedLight(node.x() & 15, node.y(), node.z() & 15);
|
int lightLevel = iChunk.getEmittedLight(node.x() & 15, node.y(), node.z() & 15);
|
||||||
BlockState state = this.queue.getBlock(node.x(), node.y(), node.z());
|
BlockState state = this.queue.getBlock(node.x(), node.y(), node.z());
|
||||||
String id = state.getBlockType().getId().toLowerCase(Locale.ROOT);
|
String id = state.getBlockType().id().toLowerCase(Locale.ROOT);
|
||||||
if (lightLevel <= 1) {
|
if (lightLevel <= 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairEast(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break east;
|
break east;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x + 1, y, z, currentLight, queue, visited);
|
||||||
break east;
|
break east;
|
||||||
}
|
}
|
||||||
@ -449,7 +449,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairWest(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break west;
|
break west;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x - 1, y, z, currentLight, queue, visited);
|
||||||
break west;
|
break west;
|
||||||
}
|
}
|
||||||
@ -502,7 +502,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairSouth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break south;
|
break south;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x, y, z + 1, currentLight, queue, visited);
|
||||||
break south;
|
break south;
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
if (!(checkStairNorth(state) && isStairOrTrueTop(state, top) && isSlabOrTrueValue(state, top ? "top" : "bottom"))) {
|
||||||
break north;
|
break north;
|
||||||
}
|
}
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited);
|
this.computeSpreadBlockLight(x, y, z - 1, currentLight, queue, visited);
|
||||||
break north;
|
break north;
|
||||||
}
|
}
|
||||||
@ -707,7 +707,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairNorth(BlockState state) {
|
private boolean checkStairNorth(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -725,7 +725,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairSouth(BlockState state) {
|
private boolean checkStairSouth(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -743,7 +743,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairEast(BlockState state) {
|
private boolean checkStairEast(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -761,7 +761,7 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStairWest(BlockState state) {
|
private boolean checkStairWest(BlockState state) {
|
||||||
if (!state.getBlockType().getId().toLowerCase(Locale.ROOT).contains("stair")) {
|
if (!state.getBlockType().id().toLowerCase(Locale.ROOT).contains("stair")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Direction direction = getStairDir(state);
|
Direction direction = getStairDir(state);
|
||||||
@ -787,11 +787,11 @@ public class NMSRelighter implements Relighter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStairOrTrueTop(BlockState state, boolean top) {
|
private boolean isStairOrTrueTop(BlockState state, boolean top) {
|
||||||
return !state.getBlockType().getId().contains("stair") || state.getState(stairHalf).equals("top") == top;
|
return !state.getBlockType().id().contains("stair") || state.getState(stairHalf).equals("top") == top;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSlabOrTrueValue(BlockState state, String value) {
|
private boolean isSlabOrTrueValue(BlockState state, String value) {
|
||||||
return !state.getBlockType().getId().contains("slab") || state.getState(slabHalf).equals(value);
|
return !state.getBlockType().id().contains("slab") || state.getState(slabHalf).equals(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeRemoveBlockLight(
|
private void computeRemoveBlockLight(
|
||||||
|
@ -236,7 +236,7 @@ public class CavesGen extends GenBase {
|
|||||||
BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
BlockState material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||||
BlockState materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
BlockState materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||||
BlockType blockType = material.getBlockType();
|
BlockType blockType = material.getBlockType();
|
||||||
switch (blockType.getId()) {
|
switch (blockType.id()) {
|
||||||
case "minecraft:mycelium", "minecraft:grass_block" -> grassFound = true;
|
case "minecraft:mycelium", "minecraft:grass_block" -> grassFound = true;
|
||||||
}
|
}
|
||||||
if (this.isSuitableBlock(material, materialAbove)) {
|
if (this.isSuitableBlock(material, materialAbove)) {
|
||||||
@ -277,7 +277,7 @@ public class CavesGen extends GenBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
|
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
|
||||||
return switch (material.getBlockType().getId()) {
|
return switch (material.getBlockType().id()) {
|
||||||
case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false;
|
case "minecraft:air", "minecraft:cave_air", "minecraft:void_air", "minecraft:water", "minecraft:lava", "minecraft:bedrock" -> false;
|
||||||
default -> true;
|
default -> true;
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@ public abstract class ABlockMask extends AbstractExtentMask {
|
|||||||
List<BlockState> all = type.getAllStates();
|
List<BlockState> all = type.getAllStates();
|
||||||
hasAll = all.stream().map(this::test).reduce(true, (a, b) -> a && b);
|
hasAll = all.stream().map(this::test).reduce(true, (a, b) -> a && b);
|
||||||
if (hasAll) {
|
if (hasAll) {
|
||||||
strings.add(type.getId());
|
strings.add(type.id());
|
||||||
} else {
|
} else {
|
||||||
for (BlockState state : all) {
|
for (BlockState state : all) {
|
||||||
if (test(state)) {
|
if (test(state)) {
|
||||||
|
@ -183,7 +183,7 @@ public class BlockMaskBuilder {
|
|||||||
builders = new ArrayList<>();
|
builders = new ArrayList<>();
|
||||||
Pattern pattern = Pattern.compile("(minecraft:)?" + regex);
|
Pattern pattern = Pattern.compile("(minecraft:)?" + regex);
|
||||||
for (BlockType type : BlockTypesCache.values) {
|
for (BlockType type : BlockTypesCache.values) {
|
||||||
if (pattern.matcher(type.getId()).find()) {
|
if (pattern.matcher(type.id()).find()) {
|
||||||
blockTypeList.add(type);
|
blockTypeList.add(type);
|
||||||
builders.add(new FuzzyStateAllowingBuilder(type));
|
builders.add(new FuzzyStateAllowingBuilder(type));
|
||||||
add(type);
|
add(type);
|
||||||
@ -284,7 +284,7 @@ public class BlockMaskBuilder {
|
|||||||
} else {
|
} else {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
for (BlockType myType : BlockTypesCache.values) {
|
for (BlockType myType : BlockTypesCache.values) {
|
||||||
if (myType.getId().matches("(minecraft:)?" + input)) {
|
if (myType.id().matches("(minecraft:)?" + input)) {
|
||||||
add(myType);
|
add(myType);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ public class BlockMaskBuilder {
|
|||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
"Property %s cannot be applied to block type %s",
|
"Property %s cannot be applied to block type %s",
|
||||||
property.getName(),
|
property.getName(),
|
||||||
type.getId()
|
type.id()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
masked.computeIfAbsent(property, k -> new ArrayList<>()).add(index);
|
masked.computeIfAbsent(property, k -> new ArrayList<>()).add(index);
|
||||||
|
@ -79,7 +79,7 @@ public class TypeSwapPattern extends AbstractExtentPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BlockState getNewBlock(BlockState existing) {
|
private BlockState getNewBlock(BlockState existing) {
|
||||||
String oldId = existing.getBlockType().getId();
|
String oldId = existing.getBlockType().id();
|
||||||
String newId = oldId;
|
String newId = oldId;
|
||||||
if (inputPattern != null) {
|
if (inputPattern != null) {
|
||||||
newId = inputPattern.matcher(oldId).replaceAll(outputString);
|
newId = inputPattern.matcher(oldId).replaceAll(outputString);
|
||||||
|
@ -444,7 +444,7 @@ public class MainUtil {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
public static CompoundTag setEntityInfo(@Nonnull CompoundTag tag, @Nonnull Entity entity) {
|
public static CompoundTag setEntityInfo(@Nonnull CompoundTag tag, @Nonnull Entity entity) {
|
||||||
Map<String, Tag> map = new HashMap<>(tag.getValue());
|
Map<String, Tag> map = new HashMap<>(tag.getValue());
|
||||||
map.put("Id", new StringTag(entity.getState().getType().getId()));
|
map.put("Id", new StringTag(entity.getState().getType().id()));
|
||||||
ListTag pos = (ListTag) map.get("Pos");
|
ListTag pos = (ListTag) map.get("Pos");
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
|
@ -929,10 +929,10 @@ public class TextureUtil implements TextureHolder {
|
|||||||
}.getType();
|
}.getType();
|
||||||
|
|
||||||
for (BlockType blockType : BlockTypesCache.values) {
|
for (BlockType blockType : BlockTypesCache.values) {
|
||||||
if (!blockType.getMaterial().isFullCube() || blockType.getId().toLowerCase().contains("shulker")) {
|
if (!blockType.getMaterial().isFullCube() || blockType.id().toLowerCase().contains("shulker")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (blockType.getId().toLowerCase(Locale.ROOT)) {
|
switch (blockType.id().toLowerCase(Locale.ROOT)) {
|
||||||
case "slime_block":
|
case "slime_block":
|
||||||
case "honey_block":
|
case "honey_block":
|
||||||
case "mob_spawner":
|
case "mob_spawner":
|
||||||
@ -940,7 +940,7 @@ public class TextureUtil implements TextureHolder {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int combined = blockType.getInternalId();
|
int combined = blockType.getInternalId();
|
||||||
String id = blockType.getId();
|
String id = blockType.id();
|
||||||
String[] split = id.split(":", 2);
|
String[] split = id.split(":", 2);
|
||||||
String name = split.length == 1 ? id : split[1];
|
String name = split.length == 1 ? id : split[1];
|
||||||
String nameSpace = split.length == 1 ? "" : split[0];
|
String nameSpace = split.length == 1 ? "" : split[0];
|
||||||
|
@ -196,7 +196,7 @@ public abstract class LocalConfiguration {
|
|||||||
BlockTypes.BEDROCK
|
BlockTypes.BEDROCK
|
||||||
FAWE end*/
|
FAWE end*/
|
||||||
);
|
);
|
||||||
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
|
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::id).toArray(String[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -277,7 +277,7 @@ public abstract class LocalConfiguration {
|
|||||||
id = Integer.parseInt(splitter[0]);
|
id = Integer.parseInt(splitter[0]);
|
||||||
data = Byte.parseByte(splitter[1]);
|
data = Byte.parseByte(splitter[1]);
|
||||||
}
|
}
|
||||||
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
|
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).id();
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1879,7 +1879,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
* @return item id of wand item, or {@code null}
|
* @return item id of wand item, or {@code null}
|
||||||
*/
|
*/
|
||||||
public String getWandItem() {
|
public String getWandItem() {
|
||||||
return wandItem.getId();
|
return wandItem.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1888,7 +1888,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
* @return item id of nav wand item, or {@code null}
|
* @return item id of nav wand item, or {@code null}
|
||||||
*/
|
*/
|
||||||
public String getNavWandItem() {
|
public String getNavWandItem() {
|
||||||
return navWandItem.getId();
|
return navWandItem.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,7 +128,7 @@ public class BaseItem implements NbtValued {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getType().getId() + nbtString;
|
return getType().id() + nbtString;
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ public class BiomeCommands {
|
|||||||
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
|
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
|
||||||
BiomeType.REGISTRY.values().stream()
|
BiomeType.REGISTRY.values().stream()
|
||||||
.map(biomeType -> TextComponent.builder()
|
.map(biomeType -> TextComponent.builder()
|
||||||
.append(biomeType.getId())
|
.append(biomeType.id())
|
||||||
.append(" (")
|
.append(" (")
|
||||||
.append(biomeRegistry.getRichName(biomeType))
|
.append(biomeRegistry.getRichName(biomeType))
|
||||||
.append(")")
|
.append(")")
|
||||||
@ -166,7 +166,7 @@ public class BiomeCommands {
|
|||||||
|
|
||||||
List<Component> components = biomes.stream().map(biome ->
|
List<Component> components = biomes.stream().map(biome ->
|
||||||
biomeRegistry.getRichName(biome).hoverEvent(
|
biomeRegistry.getRichName(biome).hoverEvent(
|
||||||
HoverEvent.showText(TextComponent.of(biome.getId()))
|
HoverEvent.showText(TextComponent.of(biome.id()))
|
||||||
)
|
)
|
||||||
).collect(Collectors.toList());
|
).collect(Collectors.toList());
|
||||||
actor.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
|
actor.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));
|
||||||
|
@ -349,7 +349,7 @@ public class GeneralCommands {
|
|||||||
if (world == null) {
|
if (world == null) {
|
||||||
actor.print(Caption.of("worldedit.world.remove"));
|
actor.print(Caption.of("worldedit.world.remove"));
|
||||||
} else {
|
} else {
|
||||||
actor.print(Caption.of("worldedit.world.set", TextComponent.of(world.getId())));
|
actor.print(Caption.of("worldedit.world.set", TextComponent.of(world.id())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +641,7 @@ public class GeneralCommands {
|
|||||||
if (itemsOnly && searchType.hasBlockType()) {
|
if (itemsOnly && searchType.hasBlockType()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final String id = searchType.getId();
|
final String id = searchType.id();
|
||||||
if (id.contains(idMatch)) {
|
if (id.contains(idMatch)) {
|
||||||
Component name = searchType.getRichName();
|
Component name = searchType.getRichName();
|
||||||
results.put(id, TextComponent.builder()
|
results.put(id, TextComponent.builder()
|
||||||
|
@ -832,7 +832,7 @@ public class SelectionCommands {
|
|||||||
toolTip = TextComponent.of(state.getAsString());
|
toolTip = TextComponent.of(state.getAsString());
|
||||||
blockName = blockName.append(TextComponent.of("*"));
|
blockName = blockName.append(TextComponent.of("*"));
|
||||||
} else {
|
} else {
|
||||||
toolTip = TextComponent.of(blockType.getId());
|
toolTip = TextComponent.of(blockType.id());
|
||||||
}
|
}
|
||||||
blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip));
|
blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip));
|
||||||
line.append(blockName);
|
line.append(blockName);
|
||||||
|
@ -65,7 +65,7 @@ public class WorldConverter implements ArgumentConverter<World> {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getSuggestions(String input, InjectedValueAccess context) {
|
public List<String> getSuggestions(String input, InjectedValueAccess context) {
|
||||||
return getWorlds()
|
return getWorlds()
|
||||||
.map(World::getId)
|
.map(World::id)
|
||||||
.filter(world -> world.startsWith(input))
|
.filter(world -> world.startsWith(input))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ public class WorldConverter implements ArgumentConverter<World> {
|
|||||||
@Override
|
@Override
|
||||||
public ConversionResult<World> convert(String s, InjectedValueAccess injectedValueAccess) {
|
public ConversionResult<World> convert(String s, InjectedValueAccess injectedValueAccess) {
|
||||||
World result = getWorlds()
|
World result = getWorlds()
|
||||||
.filter(world -> world.getId().equals(s))
|
.filter(world -> world.id().equals(s))
|
||||||
.findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
return result == null
|
return result == null
|
||||||
? FailedConversion.from(new IllegalArgumentException(
|
? FailedConversion.from(new IllegalArgumentException(
|
||||||
|
@ -66,7 +66,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
|
|
||||||
if (!config.allowedDataCycleBlocks.isEmpty()
|
if (!config.allowedDataCycleBlocks.isEmpty()
|
||||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||||
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) {
|
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().id())) {
|
||||||
player.print(Caption.of("worldedit.tool.data-cycler.block-not-permitted"));
|
player.print(Caption.of("worldedit.tool.data-cycler.block-not-permitted"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -135,42 +135,42 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
private String woolMapper(String string) {
|
private String woolMapper(String string) {
|
||||||
switch (string.toLowerCase(Locale.ROOT)) {
|
switch (string.toLowerCase(Locale.ROOT)) {
|
||||||
case "white":
|
case "white":
|
||||||
return BlockTypes.WHITE_WOOL.getId();
|
return BlockTypes.WHITE_WOOL.id();
|
||||||
case "black":
|
case "black":
|
||||||
return BlockTypes.BLACK_WOOL.getId();
|
return BlockTypes.BLACK_WOOL.id();
|
||||||
case "blue":
|
case "blue":
|
||||||
return BlockTypes.BLUE_WOOL.getId();
|
return BlockTypes.BLUE_WOOL.id();
|
||||||
case "brown":
|
case "brown":
|
||||||
return BlockTypes.BROWN_WOOL.getId();
|
return BlockTypes.BROWN_WOOL.id();
|
||||||
case "cyan":
|
case "cyan":
|
||||||
return BlockTypes.CYAN_WOOL.getId();
|
return BlockTypes.CYAN_WOOL.id();
|
||||||
case "gray":
|
case "gray":
|
||||||
case "grey":
|
case "grey":
|
||||||
return BlockTypes.GRAY_WOOL.getId();
|
return BlockTypes.GRAY_WOOL.id();
|
||||||
case "green":
|
case "green":
|
||||||
return BlockTypes.GREEN_WOOL.getId();
|
return BlockTypes.GREEN_WOOL.id();
|
||||||
case "light_blue":
|
case "light_blue":
|
||||||
case "lightblue":
|
case "lightblue":
|
||||||
return BlockTypes.LIGHT_BLUE_WOOL.getId();
|
return BlockTypes.LIGHT_BLUE_WOOL.id();
|
||||||
case "light_gray":
|
case "light_gray":
|
||||||
case "light_grey":
|
case "light_grey":
|
||||||
case "lightgray":
|
case "lightgray":
|
||||||
case "lightgrey":
|
case "lightgrey":
|
||||||
return BlockTypes.LIGHT_GRAY_WOOL.getId();
|
return BlockTypes.LIGHT_GRAY_WOOL.id();
|
||||||
case "lime":
|
case "lime":
|
||||||
return BlockTypes.LIME_WOOL.getId();
|
return BlockTypes.LIME_WOOL.id();
|
||||||
case "magenta":
|
case "magenta":
|
||||||
return BlockTypes.MAGENTA_WOOL.getId();
|
return BlockTypes.MAGENTA_WOOL.id();
|
||||||
case "orange":
|
case "orange":
|
||||||
return BlockTypes.ORANGE_WOOL.getId();
|
return BlockTypes.ORANGE_WOOL.id();
|
||||||
case "pink":
|
case "pink":
|
||||||
return BlockTypes.PINK_WOOL.getId();
|
return BlockTypes.PINK_WOOL.id();
|
||||||
case "purple":
|
case "purple":
|
||||||
return BlockTypes.PURPLE_WOOL.getId();
|
return BlockTypes.PURPLE_WOOL.id();
|
||||||
case "yellow":
|
case "yellow":
|
||||||
return BlockTypes.YELLOW_WOOL.getId();
|
return BlockTypes.YELLOW_WOOL.id();
|
||||||
case "red":
|
case "red":
|
||||||
return BlockTypes.RED_WOOL.getId();
|
return BlockTypes.RED_WOOL.id();
|
||||||
default:
|
default:
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
if (input.indexOf('[') == -1 && input.indexOf(']') == -1) {
|
if (input.indexOf('[') == -1 && input.indexOf(']') == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!type.getId().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) {
|
if (!type.id().equalsIgnoreCase(input.substring(0, input.indexOf('[')))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String[] properties = input.substring(input.indexOf('[') + 1, input.indexOf(']')).split(",");
|
String[] properties = input.substring(input.indexOf('[') + 1, input.indexOf(']')).split(",");
|
||||||
@ -249,10 +249,10 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
throw new NoMatchException(Caption.of(
|
throw new NoMatchException(Caption.of(
|
||||||
"worldedit.error.parser.unknown-property",
|
"worldedit.error.parser.unknown-property",
|
||||||
TextComponent.of(parts[0]),
|
TextComponent.of(parts[0]),
|
||||||
TextComponent.of(type.getId())
|
TextComponent.of(type.id())
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId());
|
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.id());
|
||||||
}
|
}
|
||||||
return Maps.newHashMap();
|
return Maps.newHashMap();
|
||||||
}
|
}
|
||||||
@ -516,20 +516,20 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
//FAWE start - per-limit disallowed blocks
|
//FAWE start - per-limit disallowed blocks
|
||||||
if (actor != null) {
|
if (actor != null) {
|
||||||
if (!actor.hasPermission("worldedit.anyblock")
|
if (!actor.hasPermission("worldedit.anyblock")
|
||||||
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
|
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.id().toLowerCase(Locale.ROOT))) {
|
||||||
throw new DisallowedUsageException(Caption.of(
|
throw new DisallowedUsageException(Caption.of(
|
||||||
"worldedit.error.disallowed-block",
|
"worldedit.error.disallowed-block",
|
||||||
TextComponent.of(blockType.getId())
|
TextComponent.of(blockType.id())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
FaweLimit limit = actor.getLimit();
|
FaweLimit limit = actor.getLimit();
|
||||||
if (!limit.isUnlimited()) {
|
if (!limit.isUnlimited()) {
|
||||||
// No need to account for blocked states/properties as it will simply return false in the equality check
|
// No need to account for blocked states/properties as it will simply return false in the equality check
|
||||||
// during contains.
|
// during contains.
|
||||||
if (limit.DISALLOWED_BLOCKS.contains(blockType.getId().toLowerCase(Locale.ROOT))) {
|
if (limit.DISALLOWED_BLOCKS.contains(blockType.id().toLowerCase(Locale.ROOT))) {
|
||||||
throw new DisallowedUsageException(Caption.of(
|
throw new DisallowedUsageException(Caption.of(
|
||||||
"fawe.error.limit.disallowed-block",
|
"fawe.error.limit.disallowed-block",
|
||||||
TextComponent.of(blockType.getId())
|
TextComponent.of(blockType.id())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -559,14 +559,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
if (ent == null) {
|
if (ent == null) {
|
||||||
throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
|
throw new NoMatchException(Caption.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
|
||||||
}
|
}
|
||||||
mobName = ent.getId();
|
mobName = ent.id();
|
||||||
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
||||||
throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
|
throw new NoMatchException(Caption.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
|
||||||
}
|
}
|
||||||
return validate(context, new MobSpawnerBlock(state, mobName));
|
return validate(context, new MobSpawnerBlock(state, mobName));
|
||||||
} else {
|
} else {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
|
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.id()));
|
||||||
}
|
}
|
||||||
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
||||||
// allow setting type/player/rotation
|
// allow setting type/player/rotation
|
||||||
|
@ -71,7 +71,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> implements
|
|||||||
|
|
||||||
Set<BlockType> blocks = category.getAll();
|
Set<BlockType> blocks = category.getAll();
|
||||||
if (blocks.isEmpty()) {
|
if (blocks.isEmpty()) {
|
||||||
throw new InputParseException(Caption.of("worldedit.error.empty-tag", TextComponent.of(category.getId())));
|
throw new InputParseException(Caption.of("worldedit.error.empty-tag", TextComponent.of(category.id())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyState) {
|
if (anyState) {
|
||||||
|
@ -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;
|
||||||
@ -233,7 +232,7 @@ public interface Platform extends Keyed {
|
|||||||
*/
|
*/
|
||||||
@NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {})
|
@NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {})
|
||||||
@Override
|
@Override
|
||||||
default String getId() {
|
default String id() {
|
||||||
return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_");
|
return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable, Fl
|
|||||||
if (pasteEntities) {
|
if (pasteEntities) {
|
||||||
for (Entity entity : this.getEntities()) {
|
for (Entity entity : this.getEntities()) {
|
||||||
// skip players on pasting schematic
|
// skip players on pasting schematic
|
||||||
if (entity.getState() != null && entity.getState().getType().getId()
|
if (entity.getState() != null && entity.getState().getType().id()
|
||||||
.equals("minecraft:player")) {
|
.equals("minecraft:player")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
BlockVector3 pt = BlockVector3.at(x0, min.y(), z0);
|
BlockVector3 pt = BlockVector3.at(x0, min.y(), z0);
|
||||||
BiomeType biome = clipboard.getBiome(pt);
|
BiomeType biome = clipboard.getBiome(pt);
|
||||||
|
|
||||||
String biomeKey = biome.getId();
|
String biomeKey = biome.id();
|
||||||
int biomeId;
|
int biomeId;
|
||||||
if (palette.containsKey(biomeKey)) {
|
if (palette.containsKey(biomeKey)) {
|
||||||
biomeId = palette.get(biomeKey);
|
biomeId = palette.get(biomeKey);
|
||||||
@ -262,7 +262,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
|||||||
values.putAll(rawData.getValue());
|
values.putAll(rawData.getValue());
|
||||||
}
|
}
|
||||||
values.remove("id");
|
values.remove("id");
|
||||||
values.put("Id", new StringTag(state.getType().getId()));
|
values.put("Id", new StringTag(state.getType().id()));
|
||||||
final Location location = e.getLocation();
|
final Location location = e.getLocation();
|
||||||
values.put("Pos", writeVector(location.toVector()));
|
values.put("Pos", writeVector(location.toVector()));
|
||||||
values.put("Rotation", writeRotation(location));
|
values.put("Rotation", writeRotation(location));
|
||||||
|
@ -84,7 +84,7 @@ public class FlowerPotCompatibilityHandler implements NBTCompatibilityHandler {
|
|||||||
} else {
|
} else {
|
||||||
BlockState plantedWithData = LegacyMapper.getInstance().getBlockFromLegacy(newId, data);
|
BlockState plantedWithData = LegacyMapper.getInstance().getBlockFromLegacy(newId, data);
|
||||||
if (plantedWithData != null) {
|
if (plantedWithData != null) {
|
||||||
plantedName = plantedWithData.getBlockType().getId().substring(10); // remove "minecraft:"
|
plantedName = plantedWithData.getBlockType().id().substring(10); // remove "minecraft:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plantedName != null) {
|
if (plantedName != null) {
|
||||||
|
@ -29,7 +29,7 @@ public class Pre13HangingCompatibilityHandler implements EntityNBTCompatibilityH
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAffectedEntity(EntityType type, CompoundTag tag) {
|
public boolean isAffectedEntity(EntityType type, CompoundTag tag) {
|
||||||
if (!type.getId().startsWith("minecraft:")) {
|
if (!type.id().startsWith("minecraft:")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean hasLegacyDirection = tag.containsKey("Dir") || tag.containsKey("Direction");
|
boolean hasLegacyDirection = tag.containsKey("Dir") || tag.containsKey("Direction");
|
||||||
|
@ -441,7 +441,7 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
if (Settings.settings().ENABLED_COMPONENTS.DEBUG) {
|
if (Settings.settings().ENABLED_COMPONENTS.DEBUG) {
|
||||||
LOGGER.warn(String.format(
|
LOGGER.warn(String.format(
|
||||||
"Index outside direction array length found for block:{%s} property:{%s}",
|
"Index outside direction array length found for block:{%s} property:{%s}",
|
||||||
state.getBlockType().getId(),
|
state.getBlockType().id(),
|
||||||
property.getName()
|
property.getName()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class SnowSimulator implements LayerFunction {
|
|||||||
if (!above.getBlockType().getMaterial().isAir() && (!stack || above.getBlockType() != BlockTypes.SNOW)) {
|
if (!above.getBlockType().getMaterial().isAir() && (!stack || above.getBlockType() != BlockTypes.SNOW)) {
|
||||||
return false;
|
return false;
|
||||||
//FAWE start
|
//FAWE start
|
||||||
} else if (!block.getBlockType().getId().toLowerCase(Locale.ROOT).contains("ice") && this.extent.getEmittedLight(
|
} else if (!block.getBlockType().id().toLowerCase(Locale.ROOT).contains("ice") && this.extent.getEmittedLight(
|
||||||
abovePosition) > 10) {
|
abovePosition) > 10) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!block.getBlockType().getMaterial().isFullCube()) {
|
} else if (!block.getBlockType().getMaterial().isFullCube()) {
|
||||||
@ -132,7 +132,7 @@ public class SnowSimulator implements LayerFunction {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
} else if (!block.getBlockType().getId().toLowerCase(Locale.ROOT).contains("ice") && block
|
} else if (!block.getBlockType().id().toLowerCase(Locale.ROOT).contains("ice") && block
|
||||||
.getBlockType()
|
.getBlockType()
|
||||||
.getMaterial()
|
.getMaterial()
|
||||||
.isTranslucent()) {
|
.isTranslucent()) {
|
||||||
|
@ -165,7 +165,7 @@ public class ServerCUIHandler {
|
|||||||
structureTag.putString("mode", "SAVE");
|
structureTag.putString("mode", "SAVE");
|
||||||
structureTag.putByte("ignoreEntities", (byte) 1);
|
structureTag.putByte("ignoreEntities", (byte) 1);
|
||||||
structureTag.putByte("showboundingbox", (byte) 1);
|
structureTag.putByte("showboundingbox", (byte) 1);
|
||||||
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.getId());
|
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.id());
|
||||||
|
|
||||||
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build());
|
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build());
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
@ -36,7 +36,7 @@ public abstract class Category<T extends Keyed> implements RegistryItem {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String getId() {
|
public final String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public abstract class Category<T extends Keyed> implements RegistryItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,6 @@ public interface Keyed {
|
|||||||
*
|
*
|
||||||
* @return an id
|
* @return an id
|
||||||
*/
|
*/
|
||||||
String getId();
|
String id();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
|||||||
registerHelp = getBool("register-help", registerHelp);
|
registerHelp = getBool("register-help", registerHelp);
|
||||||
wandItem = getString("wand-item", wandItem).toLowerCase(Locale.ROOT);
|
wandItem = getString("wand-item", wandItem).toLowerCase(Locale.ROOT);
|
||||||
try {
|
try {
|
||||||
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
|
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).id();
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
|
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
|
||||||
@ -124,7 +124,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
|
|||||||
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
|
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
|
||||||
navigationWand = getString("nav-wand-item", navigationWand).toLowerCase(Locale.ROOT);
|
navigationWand = getString("nav-wand-item", navigationWand).toLowerCase(Locale.ROOT);
|
||||||
try {
|
try {
|
||||||
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId();
|
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).id();
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);
|
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);
|
||||||
|
@ -78,7 +78,7 @@ public class NullWorld extends AbstractWorld {
|
|||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default String getId() {
|
default String id() {
|
||||||
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
return getName().replace(" ", "_").toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ public class BiomeType implements RegistryItem, Keyed, BiomePattern {
|
|||||||
* @return The id
|
* @return The id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -291,7 +291,7 @@ public final class BiomeTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BiomeType register(final BiomeType biome) {
|
public static BiomeType register(final BiomeType biome) {
|
||||||
return BiomeType.REGISTRY.register(biome.getId(), biome);
|
return BiomeType.REGISTRY.register(biome.id(), biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiomeType getLegacy(int legacyId) {
|
public static BiomeType getLegacy(int legacyId) {
|
||||||
|
@ -154,7 +154,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
|||||||
String input = key.toString();
|
String input = key.toString();
|
||||||
throw new SuggestInputParseException(Caption.of("fawe.error.invalid-block-type", TextComponent.of(input)), () -> Stream.of(
|
throw new SuggestInputParseException(Caption.of("fawe.error.invalid-block-type", TextComponent.of(input)), () -> Stream.of(
|
||||||
BlockTypesCache.values)
|
BlockTypesCache.values)
|
||||||
.map(BlockType::getId)
|
.map(BlockType::id)
|
||||||
.filter(id -> StringMan.blockStateMatches(input, id))
|
.filter(id -> StringMan.blockStateMatches(input, id))
|
||||||
.sorted(StringMan.blockStateComparator(input))
|
.sorted(StringMan.blockStateComparator(input))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
|
@ -204,14 +204,14 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
|||||||
|
|
||||||
default String getAsString() {
|
default String getAsString() {
|
||||||
if (getStates().isEmpty()) {
|
if (getStates().isEmpty()) {
|
||||||
return this.getBlockType().getId();
|
return this.getBlockType().id();
|
||||||
} else {
|
} else {
|
||||||
String properties = getStates().entrySet().stream()
|
String properties = getStates().entrySet().stream()
|
||||||
.map(entry -> entry.getKey().getName()
|
.map(entry -> entry.getKey().getName()
|
||||||
+ "="
|
+ "="
|
||||||
+ entry.getValue().toString().toLowerCase(Locale.ROOT))
|
+ entry.getValue().toString().toLowerCase(Locale.ROOT))
|
||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
return this.getBlockType().getId() + "[" + properties + "]";
|
return this.getBlockType().id() + "[" + properties + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class BlockType implements Keyed, Pattern {
|
|||||||
* @return The id
|
* @return The id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,13 +135,13 @@ public class BlockType implements Keyed, Pattern {
|
|||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
String id = getId();
|
String id = id();
|
||||||
int i = id.indexOf(':');
|
int i = id.indexOf(':');
|
||||||
return i == -1 ? "minecraft" : id.substring(0, i);
|
return i == -1 ? "minecraft" : id.substring(0, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResource() {
|
public String getResource() {
|
||||||
String id = getId();
|
String id = id();
|
||||||
return id.substring(id.indexOf(':') + 1);
|
return id.substring(id.indexOf(':') + 1);
|
||||||
}
|
}
|
||||||
//FAWE end
|
//FAWE end
|
||||||
@ -156,7 +156,7 @@ public class BlockType implements Keyed, Pattern {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
String name = this.name.getValue();
|
String name = this.name.getValue();
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ public class BlockType implements Keyed, Pattern {
|
|||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
"Attempted to load blockstate with id {} of type {} outside of state ordinals length. Using default state.",
|
"Attempted to load blockstate with id {} of type {} outside of state ordinals length. Using default state.",
|
||||||
propertyId,
|
propertyId,
|
||||||
getId()
|
id()
|
||||||
);
|
);
|
||||||
return settings.defaultState;
|
return settings.defaultState;
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ public class BlockType implements Keyed, Pattern {
|
|||||||
LOGGER.error(
|
LOGGER.error(
|
||||||
"Attempted to load blockstate with ordinal {} of type {} outside of states length. Using default state. Using default state.",
|
"Attempted to load blockstate with ordinal {} of type {} outside of states length. Using default state. Using default state.",
|
||||||
ordinal,
|
ordinal,
|
||||||
getId()
|
id()
|
||||||
);
|
);
|
||||||
return settings.defaultState;
|
return settings.defaultState;
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ public class BlockType implements Keyed, Pattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start
|
//FAWE start
|
||||||
|
@ -2235,8 +2235,8 @@ public final class BlockTypes {
|
|||||||
|
|
||||||
throw new SuggestInputParseException(Caption.of("fawe.error.invalid-block-type", TextComponent.of(input)), () -> Stream.of(
|
throw new SuggestInputParseException(Caption.of("fawe.error.invalid-block-type", TextComponent.of(input)), () -> Stream.of(
|
||||||
BlockTypesCache.values)
|
BlockTypesCache.values)
|
||||||
.filter(b -> StringMan.blockStateMatches(inputLower, b.getId()))
|
.filter(b -> StringMan.blockStateMatches(inputLower, b.id()))
|
||||||
.map(BlockType::getId)
|
.map(BlockType::id)
|
||||||
.sorted(StringMan.blockStateComparator(inputLower))
|
.sorted(StringMan.blockStateComparator(inputLower))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
|
@ -125,7 +125,7 @@ public class AnvilChunk13 implements Chunk {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new InvalidFormatException("Invalid block state for " + blockState
|
throw new InvalidFormatException("Invalid block state for " + blockState
|
||||||
.getBlockType()
|
.getBlockType()
|
||||||
.getId() + ", " + property.getName() + ": " + value);
|
.id() + ", " + property.getName() + ": " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public class AnvilChunk17 implements Chunk {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new InvalidFormatException("Invalid block state for " + blockState
|
throw new InvalidFormatException("Invalid block state for " + blockState
|
||||||
.getBlockType()
|
.getBlockType()
|
||||||
.getId() + ", " + property.getName() + ": " + value);
|
.id() + ", " + property.getName() + ": " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ public class AnvilChunk18 implements Chunk {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new InvalidFormatException("Invalid block state for " + blockState
|
throw new InvalidFormatException("Invalid block state for " + blockState
|
||||||
.getBlockType()
|
.getBlockType()
|
||||||
.getId() + ", " + property.getName() + ": " + value);
|
.id() + ", " + property.getName() + ": " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class EntityType implements RegistryItem, Keyed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ public class EntityType implements RegistryItem, Keyed {
|
|||||||
* @return The name, or ID
|
* @return The name, or ID
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -37,7 +37,7 @@ public final class FluidCategories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FluidCategory register(final FluidCategory tag) {
|
public static FluidCategory register(final FluidCategory tag) {
|
||||||
return FluidCategory.REGISTRY.register(tag.getId(), tag);
|
return FluidCategory.REGISTRY.register(tag.id(), tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -45,7 +45,7 @@ public class FluidType implements RegistryItem, Keyed {
|
|||||||
* @return The id
|
* @return The id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class FluidType implements RegistryItem, Keyed {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,7 +40,7 @@ public final class FluidTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FluidType register(final FluidType fluid) {
|
public static FluidType register(final FluidType fluid) {
|
||||||
return FluidType.REGISTRY.register(fluid.getId(), fluid);
|
return FluidType.REGISTRY.register(fluid.id(), fluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -33,7 +33,7 @@ public class GameMode implements Keyed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,12 +43,12 @@ public class GameMode implements Keyed {
|
|||||||
* @return The name, or ID
|
* @return The name, or ID
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public final class GameModes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GameMode register(final GameMode gameMode) {
|
public static GameMode register(final GameMode gameMode) {
|
||||||
return GameMode.REGISTRY.register(gameMode.getId(), gameMode);
|
return GameMode.REGISTRY.register(gameMode.id(), gameMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -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}
|
||||||
*
|
*
|
||||||
|
@ -49,7 +49,7 @@ public class ItemType implements RegistryItem, Keyed {
|
|||||||
.getRegistries().getItemRegistry().getName(this),
|
.getRegistries().getItemRegistry().getName(this),
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
return name.isEmpty() ? getId() : name;
|
return name.isEmpty() ? id() : name;
|
||||||
});
|
});
|
||||||
@SuppressWarnings("this-escape")
|
@SuppressWarnings("this-escape")
|
||||||
private transient final LazyReference<Component> richName = LazyReference.from(() ->
|
private transient final LazyReference<Component> richName = LazyReference.from(() ->
|
||||||
@ -76,7 +76,7 @@ public class ItemType implements RegistryItem, Keyed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ public class ItemType implements RegistryItem, Keyed {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,7 @@ public class BundledBlockRegistry implements BlockRegistry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getRichName(BlockType blockType) {
|
public Component getRichName(BlockType blockType) {
|
||||||
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
|
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.id());
|
||||||
if (blockEntry != null) {
|
if (blockEntry != null) {
|
||||||
// This is more likely to be "right", but not translated
|
// This is more likely to be "right", but not translated
|
||||||
// Some vanilla MC blocks have overrides so we need this name here
|
// Some vanilla MC blocks have overrides so we need this name here
|
||||||
@ -50,7 +50,7 @@ public class BundledBlockRegistry implements BlockRegistry {
|
|||||||
return TextComponent.of(blockEntry.localizedName);
|
return TextComponent.of(blockEntry.localizedName);
|
||||||
}
|
}
|
||||||
return Caption.of(
|
return Caption.of(
|
||||||
TranslationManager.makeTranslationKey("block", blockType.getId())
|
TranslationManager.makeTranslationKey("block", blockType.id())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,14 +60,14 @@ public class BundledBlockRegistry implements BlockRegistry {
|
|||||||
// dumb_intellij.jpg - Ok??
|
// dumb_intellij.jpg - Ok??
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String getName(BlockType blockType) {
|
public String getName(BlockType blockType) {
|
||||||
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
|
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.id());
|
||||||
return blockEntry != null ? blockEntry.localizedName : null;
|
return blockEntry != null ? blockEntry.localizedName : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockMaterial getMaterial(BlockType blockType) {
|
public BlockMaterial getMaterial(BlockType blockType) {
|
||||||
return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(blockType.getId()));
|
return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(blockType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -34,7 +34,7 @@ import javax.annotation.Nullable;
|
|||||||
public class BundledItemRegistry implements ItemRegistry {
|
public class BundledItemRegistry implements ItemRegistry {
|
||||||
|
|
||||||
private BundledItemData.ItemEntry getEntryById(ItemType itemType) {
|
private BundledItemData.ItemEntry getEntryById(ItemType itemType) {
|
||||||
return BundledItemData.getInstance().findById(itemType.getId());
|
return BundledItemData.getInstance().findById(itemType.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +48,7 @@ public class BundledItemRegistry implements ItemRegistry {
|
|||||||
return TextComponent.of(itemEntry.localizedName);
|
return TextComponent.of(itemEntry.localizedName);
|
||||||
}
|
}
|
||||||
return Caption.of(
|
return Caption.of(
|
||||||
TranslationManager.makeTranslationKey("item", itemType.getId())
|
TranslationManager.makeTranslationKey("item", itemType.id())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class BundledItemRegistry implements ItemRegistry {
|
|||||||
if (itemEntry != null) {
|
if (itemEntry != null) {
|
||||||
String localized = itemEntry.localizedName;
|
String localized = itemEntry.localizedName;
|
||||||
if (localized.equals("Air")) {
|
if (localized.equals("Air")) {
|
||||||
String id = itemType.getId();
|
String id = itemType.id();
|
||||||
int c = id.indexOf(':');
|
int c = id.indexOf(':');
|
||||||
return c < 0 ? id : id.substring(c + 1);
|
return c < 0 ? id : id.substring(c + 1);
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class BundledItemRegistry implements ItemRegistry {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ItemMaterial getMaterial(ItemType itemType) {
|
public ItemMaterial getMaterial(ItemType itemType) {
|
||||||
return new PassthroughItemMaterial(BundledItemData.getInstance().getMaterialById(itemType.getId()));
|
return new PassthroughItemMaterial(BundledItemData.getInstance().getMaterialById(itemType.id()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public interface CategoryRegistry<T extends Keyed> {
|
|||||||
Set<T> getCategorisedByName(String category);
|
Set<T> getCategorisedByName(String category);
|
||||||
|
|
||||||
default Set<T> getAll(final Category<T> category) {
|
default Set<T> getAll(final Category<T> category) {
|
||||||
return getCategorisedByName(category.getId());
|
return getCategorisedByName(category.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class NullBiomeRegistry implements BiomeRegistry {
|
|||||||
@Override
|
@Override
|
||||||
public Component getRichName(BiomeType biomeType) {
|
public Component getRichName(BiomeType biomeType) {
|
||||||
return Caption.of(
|
return Caption.of(
|
||||||
TranslationManager.makeTranslationKey("biome", biomeType.getId())
|
TranslationManager.makeTranslationKey("biome", biomeType.id())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class WeatherType implements Keyed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String id() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,12 +43,12 @@ public class WeatherType implements Keyed {
|
|||||||
* @return The name, or ID
|
* @return The name, or ID
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getId();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ public final class WeatherTypes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static WeatherType register(WeatherType weather) {
|
public static WeatherType register(WeatherType weather) {
|
||||||
return WeatherType.REGISTRY.register(weather.getId(), weather);
|
return WeatherType.REGISTRY.register(weather.id(), weather);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren