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 31f4736e0..fcdc144e9 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 @@ -137,6 +137,7 @@ import org.bukkit.generator.ChunkGenerator; import org.spigotmc.SpigotConfig; import org.spigotmc.WatchdogThread; +import javax.annotation.Nullable; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -158,7 +159,6 @@ import java.util.concurrent.ExecutionException; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; diff --git a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightFaweAdapter.java b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightFaweAdapter.java index d1bc6b0cf..d949cf430 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightFaweAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightFaweAdapter.java @@ -21,7 +21,6 @@ import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; -import com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightServerLevelDelegateProxy; import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2.nbt.PaperweightLazyCompoundTag; import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2.regen.PaperweightRegen; import com.sk89q.worldedit.entity.BaseEntity; @@ -74,7 +73,6 @@ import net.minecraft.util.StringRepresentable; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -103,7 +101,6 @@ import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_20_R2.util.CraftNamespacedKey; import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; import java.lang.ref.WeakReference; @@ -111,7 +108,6 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -120,7 +116,6 @@ import java.util.Map; import java.util.Objects; import java.util.OptionalInt; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java index f27d2eb4c..aa2f5529f 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java @@ -291,6 +291,8 @@ public interface BukkitImplAdapter extends IBukkitAdapter { * @param session The EditSession * @param pt The location * @return If it succeeded + * + * @since TODO */ default boolean generateFeature(ConfiguredFeatureType feature, World world, EditSession session, BlockVector3 pt) { throw new UnsupportedOperationException("This adapter does not support generating features."); @@ -304,6 +306,8 @@ public interface BukkitImplAdapter extends IBukkitAdapter { * @param session The EditSession * @param pt The location * @return If it succeeded + * + * @since TODO */ default boolean generateStructure(StructureType feature, World world, EditSession session, BlockVector3 pt) { throw new UnsupportedOperationException("This adapter does not support generating features."); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/StructurePlacer.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/StructurePlacer.java index 99720f65d..798e74aea 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/StructurePlacer.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/command/tool/StructurePlacer.java @@ -17,7 +17,7 @@ import com.sk89q.worldedit.world.generation.StructureType; import javax.annotation.Nullable; /** - * Places a feature + * Places a structure * * @since TODO */ diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/StructureGenerator.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/StructureGenerator.java index 537a6c83b..c99677126 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/StructureGenerator.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/function/generator/StructureGenerator.java @@ -6,6 +6,11 @@ import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.generation.StructureType; +/** + * Generate a structure at the given location + * + * @since TODO + */ public class StructureGenerator implements RegionFunction { private final StructureType structureType; @@ -16,6 +21,8 @@ public class StructureGenerator implements RegionFunction { * * @param editSession the edit session * @param structureType the structure type + * + * @since TODO */ public StructureGenerator(EditSession editSession, StructureType structureType) { this.editSession = editSession; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index f9b71dc6d..36c4e62df 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -4026,6 +4026,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @param feature feature to generate * @param position position to generate at * @return blocks affected + * + * @since TODO */ public int generateFeature(ConfiguredFeatureType feature, BlockVector3 position) { feature.place(this, position); @@ -4038,6 +4040,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @param structure structure to generate * @param position position to generate at * @return blocks affected + * + * @since TODO */ public int generateStructure(StructureType structure, BlockVector3 position) { structure.place(this, position); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FeatureGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FeatureGenerator.java index 6c49138db..f01a588db 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FeatureGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FeatureGenerator.java @@ -26,8 +26,9 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.generation.ConfiguredFeatureType; /** - * Generates forests by searching for the ground starting from the given upper Y - * coordinate for every column given. + * Generate a feature at the given location + * + * @since TODO */ public class FeatureGenerator implements RegionFunction { @@ -39,6 +40,8 @@ public class FeatureGenerator implements RegionFunction { * * @param editSession the edit session * @param featureType the feature type + * + * @since TODO */ public FeatureGenerator(EditSession editSession, ConfiguredFeatureType featureType) { this.editSession = editSession; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java index 925788b57..221c0de8d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java @@ -320,6 +320,8 @@ public interface World extends Extent, Keyed, IChunkCache { * @param editSession The {@link EditSession} * @param position The position * @return True if the generation was successful + * + * @since TODO */ default boolean generateStructure(StructureType type, EditSession editSession, BlockVector3 position) { return false; @@ -332,6 +334,8 @@ public interface World extends Extent, Keyed, IChunkCache { * @param editSession The {@link EditSession} * @param position The position * @return True if the generation was successful + * + * @since TODO */ default boolean generateFeature(ConfiguredFeatureType type, EditSession editSession, BlockVector3 position) { return false; diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricServerLevelDelegateProxy.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricServerLevelDelegateProxy.java deleted file mode 100644 index 07ee8d81c..000000000 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/internal/FabricServerLevelDelegateProxy.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.fabric.internal; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.fabric.FabricAdapter; -import com.sk89q.worldedit.world.block.BlockTypes; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.Nullable; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.Arrays; - -public class FabricServerLevelDelegateProxy implements InvocationHandler { - - private final EditSession editSession; - private final ServerLevel serverLevel; - - private FabricServerLevelDelegateProxy(EditSession editSession, ServerLevel serverLevel) { - this.editSession = editSession; - this.serverLevel = serverLevel; - } - - public static WorldGenLevel newInstance(EditSession editSession, ServerLevel serverLevel) { - return (WorldGenLevel) Proxy.newProxyInstance( - serverLevel.getClass().getClassLoader(), - serverLevel.getClass().getInterfaces(), - new FabricServerLevelDelegateProxy(editSession, serverLevel) - ); - } - - @Nullable - private BlockEntity getBlockEntity(BlockPos blockPos) { - BlockEntity tileEntity = this.serverLevel.getChunkAt(blockPos).getBlockEntity(blockPos); - if (tileEntity == null) { - return null; - } - BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos)); - newEntity.load(NBTConverter.toNative(this.editSession.getFullBlock(FabricAdapter.adapt(blockPos)).getNbtReference().getValue())); - - return newEntity; - } - - private BlockState getBlockState(BlockPos blockPos) { - return FabricAdapter.adapt(this.editSession.getBlock(FabricAdapter.adapt(blockPos))); - } - - private boolean setBlock(BlockPos blockPos, BlockState blockState) { - try { - return editSession.setBlock(FabricAdapter.adapt(blockPos), FabricAdapter.adapt(blockState)); - } catch (MaxChangedBlocksException e) { - throw new RuntimeException(e); - } - } - - private boolean removeBlock(BlockPos blockPos, boolean bl) { - try { - return editSession.setBlock(FabricAdapter.adapt(blockPos), BlockTypes.AIR.getDefaultState()); - } catch (MaxChangedBlocksException e) { - throw new RuntimeException(e); - } - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - switch (method.getName()) { - case "getBlockState", "method_8320" -> { - if (args.length == 1 && args[0] instanceof BlockPos blockPos) { - return getBlockState(blockPos); - } - } - case "getBlockEntity", "method_8321" -> { - if (args.length == 1 && args[0] instanceof BlockPos blockPos) { - return getBlockEntity(blockPos); - } - } - case "setBlock", "method_8652" -> { - if (args.length >= 2 && args[0] instanceof BlockPos blockPos && args[1] instanceof BlockState blockState) { - return setBlock(blockPos, blockState); - } - } - case "removeBlock", "destroyBlock", "method_8650", "method_8651" -> { - if (args.length >= 2 && args[0] instanceof BlockPos blockPos && args[1] instanceof Boolean bl) { - return removeBlock(blockPos, bl); - } - } - default -> { } - } - - return method.invoke(this.serverLevel, args); - } - -} diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeServerLevelDelegateProxy.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeServerLevelDelegateProxy.java deleted file mode 100644 index ff9e64d4e..000000000 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/internal/ForgeServerLevelDelegateProxy.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.forge.internal; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.forge.ForgeAdapter; -import com.sk89q.worldedit.world.block.BlockTypes; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.WorldGenLevel; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.Nullable; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.Arrays; - -public class ForgeServerLevelDelegateProxy implements InvocationHandler { - - private final EditSession editSession; - private final ServerLevel serverLevel; - - private ForgeServerLevelDelegateProxy(EditSession editSession, ServerLevel serverLevel) { - this.editSession = editSession; - this.serverLevel = serverLevel; - } - - public static WorldGenLevel newInstance(EditSession editSession, ServerLevel serverLevel) { - return (WorldGenLevel) Proxy.newProxyInstance( - serverLevel.getClass().getClassLoader(), - serverLevel.getClass().getInterfaces(), - new ForgeServerLevelDelegateProxy(editSession, serverLevel) - ); - } - - @Nullable - private BlockEntity getBlockEntity(BlockPos blockPos) { - BlockEntity tileEntity = this.serverLevel.getChunkAt(blockPos).getBlockEntity(blockPos); - if (tileEntity == null) { - return null; - } - BlockEntity newEntity = tileEntity.getType().create(blockPos, getBlockState(blockPos)); - newEntity.load(NBTConverter.toNative(this.editSession.getFullBlock(ForgeAdapter.adapt(blockPos)).getNbtReference().getValue())); - - return newEntity; - } - - private BlockState getBlockState(BlockPos blockPos) { - return ForgeAdapter.adapt(this.editSession.getBlock(ForgeAdapter.adapt(blockPos))); - } - - private boolean setBlock(BlockPos blockPos, BlockState blockState) { - try { - return editSession.setBlock(ForgeAdapter.adapt(blockPos), ForgeAdapter.adapt(blockState)); - } catch (MaxChangedBlocksException e) { - throw new RuntimeException(e); - } - } - - private boolean removeBlock(BlockPos blockPos, boolean bl) { - try { - return editSession.setBlock(ForgeAdapter.adapt(blockPos), BlockTypes.AIR.getDefaultState()); - } catch (MaxChangedBlocksException e) { - throw new RuntimeException(e); - } - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - switch (method.getName()) { - case "getBlockState", "m_8055_" -> { - if (args.length == 1 && args[0] instanceof BlockPos blockPos) { - return getBlockState(blockPos); - } - } - case "getBlockEntity", "m_7702_" -> { - if (args.length == 1 && args[0] instanceof BlockPos blockPos) { - return getBlockEntity(blockPos); - } - } - case "setBlock", "m_7731_" -> { - if (args.length >= 2 && args[0] instanceof BlockPos blockPos && args[1] instanceof BlockState blockState) { - return setBlock(blockPos, blockState); - } - } - case "removeBlock", "destroyBlock", "m_7471_", "m_7740_" -> { - if (args.length >= 2 && args[0] instanceof BlockPos blockPos && args[1] instanceof Boolean bl) { - return removeBlock(blockPos, bl); - } - } - default -> { } - } - - return method.invoke(this.serverLevel, args); - } - -}