diff --git a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java index ad15f9de8..4d27d0706 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R2/PaperweightAdapter.java @@ -947,7 +947,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter 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(); WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this); return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z())); @@ -956,7 +956,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter configuredFeature = serverLevel .registryAccess() .registryOrThrow(Registries.CONFIGURED_FEATURE) - .get(ResourceLocation.tryParse(feature.getId())); + .get(ResourceLocation.tryParse(feature.id())); FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel); Map placed = TaskManager.taskManager().sync(() -> { @@ -559,10 +559,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter craftBlockState - )); + return new HashMap<>(populator.getLevel().capturedBlockStates); } finally { serverLevel.captureBlockStates = false; serverLevel.captureTreeGeneration = false; @@ -580,7 +577,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter getStatePropertiesCodec( + net.minecraft.world.level.block.state.BlockState state + ) throws IllegalAccessException { + return (MapCodec) fieldPropertiesCodec.get(state); + } + record FakeIdMapBlock(int size) implements IdMap { @Override diff --git a/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R3/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R3/PaperweightAdapter.java index 8799e3ae9..5ed967f32 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R3/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_20_R3/PaperweightAdapter.java @@ -946,7 +946,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter 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(); WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this); return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z())); @@ -955,7 +955,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter configuredFeature = serverLevel .registryAccess() .registryOrThrow(Registries.CONFIGURED_FEATURE) - .get(ResourceLocation.tryParse(feature.getId())); + .get(ResourceLocation.tryParse(feature.id())); FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel); Map placed = TaskManager.taskManager().sync(() -> { @@ -557,19 +557,16 @@ public final class PaperweightFaweAdapter extends FaweAdapter craftBlockState - )); + return new HashMap<>(populator.getLevel().capturedBlockStates); } finally { serverLevel.captureBlockStates = false; serverLevel.captureTreeGeneration = false; serverLevel.capturedBlockStates.clear(); } }); - return placeFeatureIntoSession(editSession, populator, placed); //FAWE end } @@ -580,7 +577,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter getStatePropertiesCodec( + net.minecraft.world.level.block.state.BlockState state + ) throws IllegalAccessException { + return (MapCodec) fieldPropertiesCodec.get(state); + } + record FakeIdMapBlock(int size) implements IdMap { @Override diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java index 5fc5c72d6..0d5121e18 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext.fawe/v1_20_R4/PaperweightAdapter.java @@ -970,7 +970,8 @@ public final class PaperweightAdapter implements BukkitImplAdapter 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(); WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this); return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z())); @@ -979,7 +980,10 @@ public final class PaperweightAdapter implements BukkitImplAdapter, 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); + } + } diff --git a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java index 08ec760ab..f6f119cf6 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java @@ -558,7 +558,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter configuredFeature = serverLevel .registryAccess() .registryOrThrow(Registries.CONFIGURED_FEATURE) - .get(ResourceLocation.tryParse(feature.getId())); + .get(ResourceLocation.tryParse(feature.id())); FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel); Map placed = TaskManager.taskManager().sync(() -> { @@ -573,10 +573,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter craftBlockState - )); + return new HashMap<>(populator.getLevel().capturedBlockStates); } finally { serverLevel.captureBlockStates = false; serverLevel.captureTreeGeneration = false; @@ -594,7 +591,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter getStatePropertiesCodec( + net.minecraft.world.level.block.state.BlockState state + ) throws IllegalAccessException { + return (MapCodec) fieldPropertiesCodec.get(state); + } + record FakeIdMapBlock(int size) implements IdMap { @Override diff --git a/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java index bfdfc3950..aae9cc3cf 100644 --- a/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/v1_21_R1/PaperweightAdapter.java @@ -510,23 +510,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter { - loadedEntity.absMoveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - return loadedEntity; - }); + Entity createdEntity = createEntityFromId(state.getType().id(), craftWorld.getHandle()); if (createdEntity != null) { worldServer.addFreshEntityWithPassengers(createdEntity, SpawnReason.CUSTOM); @@ -977,7 +961,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter 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(); WorldGenLevel proxyLevel = PaperweightServerLevelDelegateProxy.newInstance(session, originalWorld, this); return k != null && k.place(proxyLevel, chunkManager.getGenerator(), random, new BlockPos(pt.x(), pt.y(), pt.z())); @@ -986,7 +970,7 @@ public final class PaperweightAdapter implements BukkitImplAdapter, 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); + } + } diff --git a/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java index c19be3415..4e12f0088 100644 --- a/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java @@ -513,7 +513,8 @@ public final class PaperweightFaweAdapter extends FaweAdapter configuredFeature = serverLevel .registryAccess() .registryOrThrow(Registries.CONFIGURED_FEATURE) - .get(ResourceLocation.tryParse(feature.getId())); + .get(ResourceLocation.tryParse(feature.id())); FaweBlockStateListPopulator populator = new FaweBlockStateListPopulator(serverLevel); Map placed = TaskManager.taskManager().sync(() -> { @@ -573,10 +574,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter craftBlockState - )); + return new HashMap<>(populator.getLevel().capturedBlockStates); } finally { serverLevel.captureBlockStates = false; serverLevel.captureTreeGeneration = false; @@ -595,7 +593,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter getStatePropertiesCodec( + net.minecraft.world.level.block.state.BlockState state + ) throws IllegalAccessException { + return (MapCodec) fieldPropertiesCodec.get(state); + } + record FakeIdMapBlock(int size) implements IdMap { @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java index 472dce93c..0361ea3ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Platform.java @@ -23,7 +23,6 @@ import com.fastasyncworldedit.core.extent.processor.lighting.Relighter; import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory; import com.fastasyncworldedit.core.queue.IBatchProcessor; import com.sk89q.worldedit.LocalConfiguration; -import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility; import com.sk89q.worldedit.registry.Keyed; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/Pre13HangingCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/Pre13HangingCompatibilityHandler.java index f0bea016f..8a72489f1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/Pre13HangingCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/Pre13HangingCompatibilityHandler.java @@ -29,7 +29,7 @@ public class Pre13HangingCompatibilityHandler implements EntityNBTCompatibilityH @Override public LinCompoundTag updateNbt(EntityType type, LinCompoundTag tag) { - if (!type.getId().startsWith("minecraft:")) { + if (!type.id().startsWith("minecraft:")) { return tag; } Direction newDirection; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java index 9b3d54027..34e843f8f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java @@ -131,7 +131,9 @@ public class AnvilChunk13 implements Chunk { try { blockState = getBlockStateWith(blockState, property, value); } catch (IllegalArgumentException e) { - throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().id() + ", " + property.getName() + ": " + value); + throw new InvalidFormatException("Invalid block state for " + blockState + .getBlockType() + .id() + ", " + property.getName() + ": " + value); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java index c5736bfd5..79ffa8b7a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk18.java @@ -105,7 +105,9 @@ public class AnvilChunk18 implements Chunk { try { blockState = getBlockStateWith(blockState, property, value); } catch (IllegalArgumentException e) { - throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().getId() + ", " + property.getName() + ": " + value); + throw new InvalidFormatException("Invalid block state for " + blockState + .getBlockType() + .id() + ", " + property.getName() + ": " + value); } } } @@ -197,9 +199,9 @@ public class AnvilChunk18 implements Chunk { @Override public BaseBlock getBlock(BlockVector3 position) throws DataException { - int x = position.getX() - rootX * 16; - int y = position.getY(); - int z = position.getZ() - rootZ * 16; + int x = position.x() - rootX * 16; + int y = position.y(); + int z = position.z() - rootZ * 16; int section = y >> 4; int yIndex = y & 0x0F; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java index bc5126d31..48c61a01c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/ConfiguredFeatureType.java @@ -24,26 +24,17 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.registry.NamespacedRegistry; -public class ConfiguredFeatureType implements Keyed { +public record ConfiguredFeatureType(String id) implements Keyed { + public static final NamespacedRegistry 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 public String toString() { return this.id; } //FAWE start + /** * Place this feature into an {@link EditSession} * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/StructureType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/StructureType.java index 0713735d7..06fef05f8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/StructureType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/generation/StructureType.java @@ -24,26 +24,17 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.registry.Keyed; import com.sk89q.worldedit.registry.NamespacedRegistry; -public class StructureType implements Keyed { +public record StructureType(String id) implements Keyed { + public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("structure type"); - private final String id; - - public StructureType(String id) { - this.id = id; - } - - @Override - public String getId() { - return this.id; - } - @Override public String toString() { return this.id; } //FAWE start + /** * Place this structure into an {@link EditSession} *