Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-16 16:10:07 +01:00
refactor: apply final/abstract to various fawe extent classes (#2615)
* refactor: apply final/abstract to various fawe extent classes * Remove forremoval as targets v3
Dieser Commit ist enthalten in:
Ursprung
986d351519
Commit
de49924c85
@ -9,7 +9,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
public final class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final int dx;
|
||||
private final int dy;
|
||||
|
@ -29,7 +29,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DisallowedBlocksExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
public final class DisallowedBlocksExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
|
||||
private static final BlockState RESERVED = BlockTypes.__RESERVED__.getDefaultState();
|
||||
private final Set<PropertyRemap<?>> remaps;
|
||||
|
@ -4,7 +4,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ExtentHeightCacher extends PassthroughExtent {
|
||||
public final class ExtentHeightCacher extends PassthroughExtent {
|
||||
|
||||
private transient int cacheBotX = Integer.MIN_VALUE;
|
||||
private transient int cacheBotZ = Integer.MIN_VALUE;
|
||||
|
@ -12,7 +12,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class HeightBoundExtent extends FaweRegionExtent {
|
||||
public final class HeightBoundExtent extends FaweRegionExtent {
|
||||
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
@ -26,7 +26,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Stores changes to a {@link ChangeSet}.
|
||||
*/
|
||||
public class HistoryExtent extends AbstractDelegateExtent {
|
||||
public final class HistoryExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private AbstractChangeSet changeSet;
|
||||
|
@ -40,7 +40,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class LimitExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
public final class LimitExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
|
||||
private final FaweLimit limit;
|
||||
private final boolean[] faweExceptionReasonsUsed = new boolean[FaweException.Type.values().length];
|
||||
|
@ -8,7 +8,7 @@ import com.fastasyncworldedit.core.util.WEManager;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
public class MemoryCheckingExtent extends PassthroughExtent {
|
||||
public final class MemoryCheckingExtent extends PassthroughExtent {
|
||||
|
||||
private final Actor actor;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class MultiRegionExtent extends FaweRegionExtent {
|
||||
public final class MultiRegionExtent extends FaweRegionExtent {
|
||||
|
||||
@Nullable
|
||||
private final RegionIntersection intersection;
|
||||
|
@ -40,7 +40,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
//todo This should be removed in favor of com.sk89q.worldedit.extent.NullExtent
|
||||
public class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
public final class NullExtent extends FaweRegionExtent implements IBatchProcessor {
|
||||
|
||||
private final FaweException reason;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class PassthroughExtent extends AbstractDelegateExtent {
|
||||
public abstract class PassthroughExtent extends AbstractDelegateExtent {
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
|
@ -11,7 +11,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class PositionTransformExtent extends ResettableExtent {
|
||||
public final class PositionTransformExtent extends ResettableExtent {
|
||||
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private transient BlockVector3 min;
|
||||
|
@ -18,7 +18,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
public final class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final FaweLimit limit;
|
||||
private final Extent extent;
|
||||
|
@ -14,7 +14,7 @@ import java.lang.reflect.Field;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class ResettableExtent extends AbstractDelegateExtent implements Serializable {
|
||||
public abstract class ResettableExtent extends AbstractDelegateExtent implements Serializable {
|
||||
|
||||
public ResettableExtent(Extent parent) {
|
||||
super(parent);
|
||||
|
@ -11,7 +11,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class SingleRegionExtent extends FaweRegionExtent {
|
||||
public final class SingleRegionExtent extends FaweRegionExtent {
|
||||
|
||||
private final Region region;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class SlowExtent extends AbstractDelegateExtent {
|
||||
public final class SlowExtent extends AbstractDelegateExtent {
|
||||
|
||||
private final long THRESHOLD = 50 * 1000000; // 1 tick
|
||||
private final long nanos;
|
||||
|
@ -9,7 +9,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class SourceMaskExtent extends TemporalExtent {
|
||||
public final class SourceMaskExtent extends TemporalExtent {
|
||||
|
||||
private Mask mask;
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StripNBTExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
public final class StripNBTExtent extends AbstractDelegateExtent implements IBatchProcessor {
|
||||
|
||||
private final Set<String> strip;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import java.util.function.Supplier;
|
||||
/**
|
||||
* An extent that delegates actions to another extent that may change at any time.
|
||||
*/
|
||||
public class SupplyingExtent extends PassthroughExtent {
|
||||
public final class SupplyingExtent extends PassthroughExtent {
|
||||
|
||||
private final Supplier<Extent> extentSupplier;
|
||||
|
||||
|
@ -8,7 +8,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class TemporalExtent extends PassthroughExtent {
|
||||
public abstract class TemporalExtent extends PassthroughExtent {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
|
@ -1,120 +0,0 @@
|
||||
package com.fastasyncworldedit.core.extent;
|
||||
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.fastasyncworldedit.core.math.MutableVector3;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
/**
|
||||
* @deprecated Unused internal, will be removed in v3
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2.9.2")
|
||||
public class TransformExtent extends BlockTransformExtent {
|
||||
|
||||
private final MutableVector3 mutable1 = new MutableVector3();
|
||||
private final MutableBlockVector3 mutable2 = new MutableBlockVector3();
|
||||
private BlockVector3 min;
|
||||
|
||||
public TransformExtent(Extent parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResettableExtent setExtent(Extent extent) {
|
||||
min = null;
|
||||
return super.setExtent(extent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
BlockVector3 pos1 = getPos(super.getMinimumPoint());
|
||||
BlockVector3 pos2 = getPos(super.getMaximumPoint());
|
||||
return pos1.getMinimum(pos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
BlockVector3 pos1 = getPos(super.getMinimumPoint());
|
||||
BlockVector3 pos2 = getPos(super.getMaximumPoint());
|
||||
return pos1.getMaximum(pos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrigin(BlockVector3 pos) {
|
||||
this.min = pos;
|
||||
}
|
||||
|
||||
public BlockVector3 getPos(BlockVector3 pos) {
|
||||
if (min == null) {
|
||||
min = pos;
|
||||
}
|
||||
mutable1.mutX(pos.x() - min.x());
|
||||
mutable1.mutY(pos.y() - min.y());
|
||||
mutable1.mutZ(pos.z() - min.z());
|
||||
Vector3 tmp = getTransform().apply(mutable1);
|
||||
mutable2.mutX(tmp.x() + min.x());
|
||||
mutable2.mutY(tmp.y() + min.y());
|
||||
mutable2.mutZ(tmp.z() + min.z());
|
||||
return mutable2;
|
||||
}
|
||||
|
||||
public BlockVector3 getPos(int x, int y, int z) {
|
||||
if (min == null) {
|
||||
min = BlockVector3.at(x, y, z);
|
||||
}
|
||||
mutable1.mutX(x - min.x());
|
||||
mutable1.mutY(y - min.y());
|
||||
mutable1.mutZ(z - min.z());
|
||||
Vector3 tmp = getTransform().apply(mutable1);
|
||||
mutable2.mutX(tmp.x() + min.x());
|
||||
mutable2.mutY(tmp.y() + min.y());
|
||||
mutable2.mutZ(tmp.z() + min.z());
|
||||
return tmp.toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
BlockVector3 p = getPos(x, y, z);
|
||||
return transform(super.getBlock(p.x(), p.y(), p.z()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return transform(super.getFullBlock(getPos(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiomeType(int x, int y, int z) {
|
||||
BlockVector3 p = getPos(x, y, z);
|
||||
return super.getBiomeType(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block)
|
||||
throws WorldEditException {
|
||||
return super.setBlock(getPos(x, y, z), transformInverse(block));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 location, B block)
|
||||
throws WorldEditException {
|
||||
return super.setBlock(getPos(location), transformInverse(block));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
BlockVector3 p = getPos(x, y, z);
|
||||
return super.setBiome(p.x(), p.y(), p.z(), biome);
|
||||
}
|
||||
|
||||
}
|
@ -45,7 +45,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class ParallelQueueExtent extends PassthroughExtent {
|
||||
public final class ParallelQueueExtent extends PassthroughExtent {
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
private static final ThreadLocal<Extent> extents = new ThreadLocal<>();
|
||||
|
@ -43,7 +43,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* This queue is reusable {@link #init(Extent, IChunkCache, IChunkCache)}
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> {
|
||||
public final class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> {
|
||||
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren