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 7726563bc..d2491f596 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 @@ -333,6 +333,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."); @@ -346,6 +348,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 8c99a3f6e..08df308e1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -4019,6 +4019,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); @@ -4031,6 +4033,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 478a0b778..7c4f9c12e 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); - } - -}