Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-19 17:30:08 +01:00
Minor refactor, add various javadocs
Dieser Commit ist enthalten in:
Ursprung
9fc0a456bf
Commit
45aaade039
@ -4,7 +4,7 @@ import com.fastasyncworldedit.bukkit.adapter.FaweAdapter;
|
||||
import com.fastasyncworldedit.bukkit.adapter.NMSRelighterFactory;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
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.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_19_R3;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
||||
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
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.core.FaweCache;
|
||||
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.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v1_20_R1;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.PlacementStateProcessor;
|
||||
import com.fastasyncworldedit.core.extent.processor.PlacementStateProcessor;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
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.core.FaweCache;
|
||||
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.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.extent.Extent;
|
||||
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.core.FaweCache;
|
||||
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.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.extent.Extent;
|
||||
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.core.FaweCache;
|
||||
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.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.wrappers.WorldWrapper;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.fastasyncworldedit.bukkit.util.MinecraftVersion;
|
||||
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.queue.IBatchProcessor;
|
||||
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.NMSRelighterFactory;
|
||||
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.queue.IBatchProcessor;
|
||||
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.processor.ProcessorScope;
|
||||
import com.fastasyncworldedit.core.function.mask.AdjacentAny2DMask;
|
||||
import com.fastasyncworldedit.core.math.BlockVector3ChunkMap;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
@ -37,6 +36,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
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 {
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 mask Mask of blocks to perform updates on
|
||||
@ -208,7 +212,13 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
|
||||
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++) {
|
||||
int blockZ = processChunkZ + z;
|
||||
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.math.BlockVector3;
|
||||
|
||||
/**
|
||||
* Mask that tests adjacency only in 2D/the same y-level
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
public class Adjacent2DMask extends AbstractMask {
|
||||
|
||||
private final int min;
|
||||
@ -12,6 +17,14 @@ public class Adjacent2DMask extends AbstractMask {
|
||||
private final Mask mask;
|
||||
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) {
|
||||
this.mask = mask;
|
||||
this.min = requiredMin;
|
||||
|
@ -8,17 +8,32 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
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 {
|
||||
|
||||
private final Mask mask;
|
||||
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) {
|
||||
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) {
|
||||
this.mask = cache ? CachedMask.cache(mask) : mask;
|
||||
mutable = new MutableBlockVector3();
|
||||
@ -41,11 +56,20 @@ public class AdjacentAny2DMask extends AbstractMask {
|
||||
return mask.test(mutable.setComponents(x, y, z - 1));
|
||||
}
|
||||
|
||||
public boolean test(Extent extent, BlockVector3 v) {
|
||||
AbstractExtentMask extentMask = (AbstractExtentMask) mask;
|
||||
int x = v.x();
|
||||
int y = v.y();
|
||||
int z = v.z();
|
||||
/**
|
||||
* Test this mask for the given extent
|
||||
*
|
||||
* @param extent extent to test in
|
||||
* @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))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -421,6 +421,8 @@ public final class EditSessionBuilder {
|
||||
|
||||
/**
|
||||
* Set the side effects to be used with this edit
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
public EditSessionBuilder setSideEffectSet(@Nullable SideEffectSet sideEffectSet) {
|
||||
this.sideEffectSet = sideEffectSet;
|
||||
@ -748,6 +750,8 @@ public final class EditSessionBuilder {
|
||||
|
||||
/**
|
||||
* Get the SideEffectSet that will be used
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
public SideEffectSet getSideEffectSet() {
|
||||
return sideEffectSet;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
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.RelighterFactory;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
|
@ -142,6 +142,11 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
return types[block.getInternalId()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a block state against this block type mask
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
public <B extends BlockStateHolder<B>> boolean test(B blockStateHolder) {
|
||||
return types[blockStateHolder.getBlockType().getInternalId()];
|
||||
}
|
||||
|
@ -359,6 +359,12 @@ public enum Direction {
|
||||
}
|
||||
|
||||
//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) {
|
||||
Set<Direction> directions = new HashSet<>();
|
||||
for (Property<?> property : state.getBlockType().getProperties()) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren