Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-17 00:20:09 +01:00
Minor refactor, add various javadocs
Dieser Commit ist enthalten in:
Ursprung
dc8841d3e1
Commit
db249e6b05
@ -4,7 +4,7 @@ import com.fastasyncworldedit.bukkit.adapter.FaweAdapter;
|
|||||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||||
import com.fastasyncworldedit.core.FaweCache;
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||||
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
||||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R2;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
|
@ -4,7 +4,7 @@ import com.fastasyncworldedit.bukkit.adapter.FaweAdapter;
|
|||||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||||
import com.fastasyncworldedit.core.FaweCache;
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||||
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
||||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R3;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
|
@ -4,7 +4,7 @@ import com.fastasyncworldedit.bukkit.adapter.FaweAdapter;
|
|||||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||||
import com.fastasyncworldedit.core.FaweCache;
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||||
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
||||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R4;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
|
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
@ -4,7 +4,7 @@ import com.fastasyncworldedit.bukkit.adapter.FaweAdapter;
|
|||||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||||
import com.fastasyncworldedit.core.FaweCache;
|
import com.fastasyncworldedit.core.FaweCache;
|
||||||
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
import com.fastasyncworldedit.core.entity.LazyBaseEntity;
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||||
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
import com.fastasyncworldedit.core.nbt.FaweCompoundTag;
|
||||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;
|
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_21_R1;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
|
import com.fastasyncworldedit.core.wrappers.WorldWrapper;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.fastasyncworldedit.bukkit.util.MinecraftVersion;
|
import com.fastasyncworldedit.bukkit.util.MinecraftVersion;
|
||||||
import com.fastasyncworldedit.core.configuration.Settings;
|
import com.fastasyncworldedit.core.configuration.Settings;
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
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.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
@ -23,7 +23,7 @@ import com.fastasyncworldedit.bukkit.FaweBukkit;
|
|||||||
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
|
import com.fastasyncworldedit.bukkit.adapter.IBukkitAdapter;
|
||||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||||
import com.fastasyncworldedit.core.Fawe;
|
import com.fastasyncworldedit.core.Fawe;
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
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.fastasyncworldedit.core.queue.IChunkGet;
|
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.fastasyncworldedit.core.extent;
|
package com.fastasyncworldedit.core.extent.processor;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.filter.block.FilterBlock;
|
import com.fastasyncworldedit.core.extent.filter.block.FilterBlock;
|
||||||
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
|
||||||
import com.fastasyncworldedit.core.function.mask.AdjacentAny2DMask;
|
import com.fastasyncworldedit.core.function.mask.AdjacentAny2DMask;
|
||||||
import com.fastasyncworldedit.core.math.BlockVector3ChunkMap;
|
import com.fastasyncworldedit.core.math.BlockVector3ChunkMap;
|
||||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||||
@ -37,6 +36,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processor/pattern that uses Minecraft internal methods to determine the shape of blocks, e.g. stairs and fences
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public abstract class PlacementStateProcessor extends AbstractDelegateExtent implements IBatchProcessor, Pattern {
|
public abstract class PlacementStateProcessor extends AbstractDelegateExtent implements IBatchProcessor, Pattern {
|
||||||
|
|
||||||
private static final Direction[] NESW = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
private static final Direction[] NESW = new Direction[]{Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST};
|
||||||
@ -62,7 +66,7 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
|
|||||||
private int processChunkZ;
|
private int processChunkZ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process/extent/pattern for performing block updates, e.g. stair shape and glass pane connections
|
* Processor/pattern for performing block updates, e.g. stair shape and glass pane connections
|
||||||
*
|
*
|
||||||
* @param extent Extent to use
|
* @param extent Extent to use
|
||||||
* @param mask Mask of blocks to perform updates on
|
* @param mask Mask of blocks to perform updates on
|
||||||
@ -208,7 +212,13 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
|
|||||||
return processChunkSet;
|
return processChunkSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndPerformUpdate(Map<BlockVector3, CompoundTag> setTiles, char[] set, int index, int blockY, boolean firstPass) {
|
private void checkAndPerformUpdate(
|
||||||
|
Map<BlockVector3, CompoundTag> setTiles,
|
||||||
|
char[] set,
|
||||||
|
int index,
|
||||||
|
int blockY,
|
||||||
|
boolean firstPass
|
||||||
|
) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
int blockZ = processChunkZ + z;
|
int blockZ = processChunkZ + z;
|
||||||
for (int x = 0; x < 16; x++, index++) {
|
for (int x = 0; x < 16; x++, index++) {
|
@ -5,6 +5,11 @@ import com.sk89q.worldedit.function.mask.AbstractMask;
|
|||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mask that tests adjacency only in 2D/the same y-level
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public class Adjacent2DMask extends AbstractMask {
|
public class Adjacent2DMask extends AbstractMask {
|
||||||
|
|
||||||
private final int min;
|
private final int min;
|
||||||
@ -12,6 +17,14 @@ public class Adjacent2DMask extends AbstractMask {
|
|||||||
private final Mask mask;
|
private final Mask mask;
|
||||||
private final MutableBlockVector3 vector;
|
private final MutableBlockVector3 vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mask that tests adjacency only in 2D/the same y-level
|
||||||
|
*
|
||||||
|
* @param mask Mask required to be adjacent
|
||||||
|
* @param requiredMin Minimum number of positive adjacency matches required
|
||||||
|
* @param requiredMax Maximum number of positive adjacency matches required
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public Adjacent2DMask(Mask mask, int requiredMin, int requiredMax) {
|
public Adjacent2DMask(Mask mask, int requiredMin, int requiredMax) {
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
this.min = requiredMin;
|
this.min = requiredMin;
|
||||||
|
@ -8,17 +8,32 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just an optimized version of the Adjacent Mask for single adjacency.
|
* Optimized version of {@link Adjacent2DMask} for testing for any single adjacency
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
public class AdjacentAny2DMask extends AbstractMask {
|
public class AdjacentAny2DMask extends AbstractMask {
|
||||||
|
|
||||||
private final Mask mask;
|
private final Mask mask;
|
||||||
private final MutableBlockVector3 mutable;
|
private final MutableBlockVector3 mutable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimized version of {@link Adjacent2DMask} for testing for any single adjacency. Caches results of the adjacent mask
|
||||||
|
*
|
||||||
|
* @param mask Mask required to be adjacent
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public AdjacentAny2DMask(Mask mask) {
|
public AdjacentAny2DMask(Mask mask) {
|
||||||
this(mask, true);
|
this(mask, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimized version of {@link Adjacent2DMask} for testing for any single adjacency
|
||||||
|
*
|
||||||
|
* @param mask Mask required to be adjacent
|
||||||
|
* @param cache If the result of the adjacency mask should be cached
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public AdjacentAny2DMask(Mask mask, boolean cache) {
|
public AdjacentAny2DMask(Mask mask, boolean cache) {
|
||||||
this.mask = cache ? CachedMask.cache(mask) : mask;
|
this.mask = cache ? CachedMask.cache(mask) : mask;
|
||||||
mutable = new MutableBlockVector3();
|
mutable = new MutableBlockVector3();
|
||||||
@ -41,11 +56,20 @@ public class AdjacentAny2DMask extends AbstractMask {
|
|||||||
return mask.test(mutable.setComponents(x, y, z - 1));
|
return mask.test(mutable.setComponents(x, y, z - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean test(Extent extent, BlockVector3 v) {
|
/**
|
||||||
AbstractExtentMask extentMask = (AbstractExtentMask) mask;
|
* Test this mask for the given extent
|
||||||
int x = v.x();
|
*
|
||||||
int y = v.y();
|
* @param extent extent to test in
|
||||||
int z = v.z();
|
* @param position position to test at
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public boolean test(Extent extent, BlockVector3 position) {
|
||||||
|
if (!(mask instanceof AbstractExtentMask extentMask)) {
|
||||||
|
throw new UnsupportedOperationException("Adjacency mask must inherit from AbstractExtentMask");
|
||||||
|
}
|
||||||
|
int x = position.x();
|
||||||
|
int y = position.y();
|
||||||
|
int z = position.z();
|
||||||
if (extentMask.test(extent, mutable.setComponents(x + 1, y, z))) {
|
if (extentMask.test(extent, mutable.setComponents(x + 1, y, z))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -421,6 +421,8 @@ public final class EditSessionBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the side effects to be used with this edit
|
* Set the side effects to be used with this edit
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
public EditSessionBuilder setSideEffectSet(@Nullable SideEffectSet sideEffectSet) {
|
public EditSessionBuilder setSideEffectSet(@Nullable SideEffectSet sideEffectSet) {
|
||||||
this.sideEffectSet = sideEffectSet;
|
this.sideEffectSet = sideEffectSet;
|
||||||
@ -752,6 +754,8 @@ public final class EditSessionBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the SideEffectSet that will be used
|
* Get the SideEffectSet that will be used
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
public SideEffectSet getSideEffectSet() {
|
public SideEffectSet getSideEffectSet() {
|
||||||
return sideEffectSet;
|
return sideEffectSet;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.platform;
|
package com.sk89q.worldedit.extension.platform;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||||
import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
|
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;
|
||||||
|
@ -142,6 +142,11 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
return types[block.getInternalId()];
|
return types[block.getInternalId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a block state against this block type mask
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public <B extends BlockStateHolder<B>> boolean test(B blockStateHolder) {
|
public <B extends BlockStateHolder<B>> boolean test(B blockStateHolder) {
|
||||||
return types[blockStateHolder.getBlockType().getInternalId()];
|
return types[blockStateHolder.getBlockType().getInternalId()];
|
||||||
}
|
}
|
||||||
|
@ -359,6 +359,12 @@ public enum Direction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//FAWE start - utility methods for block states
|
//FAWE start - utility methods for block states
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the directions associated with the given block state, e.g. the connections a fence makes or the direction stairs face
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
public static EnumSet<Direction> getDirections(BlockState state) {
|
public static EnumSet<Direction> getDirections(BlockState state) {
|
||||||
Set<Direction> directions = new HashSet<>();
|
Set<Direction> directions = new HashSet<>();
|
||||||
for (Property<?> property : state.getBlockType().getProperties()) {
|
for (Property<?> property : state.getBlockType().getProperties()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren