mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 12:36:40 +00:00
@ -117,27 +117,6 @@ public class FaweAPI {
|
||||
// return parser != null;
|
||||
// }
|
||||
|
||||
public static <T> T getParser(Class<T> parserClass) {
|
||||
try {
|
||||
Field field = AbstractFactory.class.getDeclaredField("parsers");
|
||||
field.setAccessible(true);
|
||||
ArrayList<InputParser> parsers = new ArrayList<>();
|
||||
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getMaskFactory()));
|
||||
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getBlockFactory()));
|
||||
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getItemFactory()));
|
||||
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getPatternFactory()));
|
||||
for (InputParser parser : parsers) {
|
||||
if (parserClass.isAssignableFrom(parser.getClass())) {
|
||||
return (T) parser;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* You can either use a IQueueExtent or an EditSession to change blocks<br>
|
||||
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
|
||||
|
@ -50,7 +50,7 @@ public class AsyncPreloader implements Preloader, Runnable {
|
||||
MutablePair<World, Set<BlockVector2>> existing = cancelAndGet(player);
|
||||
try {
|
||||
Region region = session.getSelection(world);
|
||||
if (!(region instanceof CuboidRegion) || region.getArea() > 50466816) {
|
||||
if (!(region instanceof CuboidRegion) || region.getVolume() > 50466816) {
|
||||
// TOO LARGE or NOT CUBOID
|
||||
return;
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
}
|
||||
for (int y = 255; y > 0; y--) {
|
||||
for (RelightSkyEntry chunk : chunks) { // Propogate skylight
|
||||
for (RelightSkyEntry chunk : chunks) { // Propagate skylight
|
||||
int layer = y >> 4;
|
||||
byte[] mask = chunk.mask;
|
||||
if ((y & 15) == 15 && chunk.fix[layer] != SkipReason.NONE) {
|
||||
@ -596,7 +596,7 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
}
|
||||
|
||||
private class RelightSkyEntry implements Comparable {
|
||||
private class RelightSkyEntry implements Comparable<RelightSkyEntry> {
|
||||
public final int x;
|
||||
public final int z;
|
||||
public final byte[] mask;
|
||||
@ -625,18 +625,17 @@ public class NMSRelighter implements Relighter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
RelightSkyEntry other = (RelightSkyEntry) o;
|
||||
if (other.x < x) {
|
||||
public int compareTo(RelightSkyEntry o) {
|
||||
if (o.x < x) {
|
||||
return 1;
|
||||
}
|
||||
if (other.x > x) {
|
||||
if (o.x > x) {
|
||||
return -1;
|
||||
}
|
||||
if (other.z < z) {
|
||||
if (o.z < z) {
|
||||
return 1;
|
||||
}
|
||||
if (other.z > z) {
|
||||
if (o.z > z) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -52,7 +52,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public List<? extends Entity> getEntities(Region region) {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
try {
|
||||
return getExtent().getEntities(region);
|
||||
} catch (FaweException e) {
|
||||
@ -223,8 +223,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public void addCaves(Region region) throws WorldEditException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
getExtent().addCaves(region);
|
||||
} catch (FaweException e) {
|
||||
@ -236,8 +236,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public void generate(Region region, GenBase gen) throws WorldEditException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
getExtent().generate(region, gen);
|
||||
} catch (FaweException e) {
|
||||
@ -249,8 +249,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
getExtent().addSchems(region, mask, clipboards, rarity, rotate);
|
||||
} catch (FaweException e) {
|
||||
@ -262,8 +262,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
getExtent().spawnResource(region, gen, rarity, frequency);
|
||||
} catch (FaweException e) {
|
||||
@ -275,8 +275,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
||||
} catch (FaweException e) {
|
||||
@ -288,8 +288,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public void addOres(Region region, Mask mask) throws WorldEditException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
getExtent().addOres(region, mask);
|
||||
} catch (FaweException e) {
|
||||
@ -301,7 +301,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
try {
|
||||
return getExtent().getBlockDistribution(region);
|
||||
} catch (FaweException e) {
|
||||
@ -314,7 +314,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
try {
|
||||
return getExtent().getBlockDistributionWithData(region);
|
||||
} catch (FaweException e) {
|
||||
@ -327,7 +327,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
try {
|
||||
return getExtent().countBlocks(region, searchBlocks);
|
||||
} catch (FaweException e) {
|
||||
@ -340,7 +340,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int countBlocks(Region region, Mask searchMask) {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
try {
|
||||
return getExtent().countBlocks(region, searchMask);
|
||||
} catch (FaweException e) {
|
||||
@ -353,7 +353,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().setBlocks(region, block);
|
||||
} catch (FaweException e) {
|
||||
@ -366,7 +366,7 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().setBlocks(region, pattern);
|
||||
} catch (FaweException e) {
|
||||
@ -379,8 +379,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().replaceBlocks(region, filter, replacement);
|
||||
} catch (FaweException e) {
|
||||
@ -393,8 +393,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().replaceBlocks(region, filter, pattern);
|
||||
} catch (FaweException e) {
|
||||
@ -407,8 +407,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().replaceBlocks(region, mask, pattern);
|
||||
} catch (FaweException e) {
|
||||
@ -421,8 +421,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().center(region, pattern);
|
||||
} catch (FaweException e) {
|
||||
@ -448,8 +448,8 @@ public class LimitExtent extends PassthroughExtent {
|
||||
|
||||
@Override
|
||||
public <T extends Filter> T apply(Region region, T filter, boolean full) {
|
||||
limit.THROW_MAX_CHECKS(region.getArea());
|
||||
limit.THROW_MAX_CHANGES(region.getArea());
|
||||
limit.THROW_MAX_CHECKS(region.getVolume());
|
||||
limit.THROW_MAX_CHANGES(region.getVolume());
|
||||
try {
|
||||
return getExtent().apply(region, filter, full);
|
||||
} catch (FaweException e) {
|
||||
|
@ -151,10 +151,6 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
||||
return forkJoinPoolPrimary.submit(call);
|
||||
}
|
||||
|
||||
public <T> Future<T> sync(Runnable run, T value) {
|
||||
return sync(run, value, syncTasks);
|
||||
}
|
||||
|
||||
public <T> Future<T> sync(Runnable run) {
|
||||
return sync(run, syncTasks);
|
||||
}
|
||||
|
@ -1,22 +1,3 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.boydti.fawe.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
@ -1,22 +1,3 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* 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 Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.boydti.fawe.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
@ -9,6 +9,10 @@ public class XAxisMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private transient int layer = -1;
|
||||
|
||||
public XAxisMask(Extent extent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
if (layer == -1) {
|
||||
|
@ -9,6 +9,9 @@ public class YAxisMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private transient int layer = -1;
|
||||
|
||||
public YAxisMask(Extent extent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
if (layer == -1) {
|
||||
|
@ -9,6 +9,9 @@ public class ZAxisMask extends AbstractMask implements ResettableMask {
|
||||
|
||||
private transient int layer = -1;
|
||||
|
||||
public ZAxisMask(Extent extent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
if (layer == -1) {
|
||||
|
@ -162,6 +162,9 @@ public class FaweLimit {
|
||||
public void THROW_MAX_CHANGES(int amt) {
|
||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
public void THROW_MAX_CHANGES(long amt) {
|
||||
if ((MAX_CHANGES -= amt) <= 0) throw FaweCache.MAX_CHANGES;
|
||||
}
|
||||
|
||||
public void THROW_MAX_FAILS(int amt) {
|
||||
if ((MAX_FAILS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||
@ -171,6 +174,10 @@ public class FaweLimit {
|
||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
|
||||
public void THROW_MAX_CHECKS(long amt) {
|
||||
if ((MAX_CHECKS -= amt) <= 0) throw FaweCache.MAX_CHECKS;
|
||||
}
|
||||
|
||||
public void THROW_MAX_ITERATIONS(int amt) {
|
||||
if ((MAX_ITERATIONS -= amt) <= 0) throw FaweCache.MAX_ITERATIONS;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.boydti.fawe.object;
|
||||
|
||||
public final class IntTriple {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
public IntTriple(int x, int y, int z) {
|
||||
this.x = x;
|
||||
|
@ -1,8 +0,0 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface Lazy<T> extends Supplier<T> {
|
||||
Supplier<T> init();
|
||||
public default T get() { return init().get(); }
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class RunnableVal2<T, U> implements Runnable, BiConsumer<T, U> {
|
||||
public T value1;
|
||||
public U value2;
|
||||
|
||||
public RunnableVal2() {
|
||||
}
|
||||
|
||||
public RunnableVal2(T value1, U value2) {
|
||||
this.value1 = value1;
|
||||
this.value2 = value2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
run(this.value1, this.value2);
|
||||
}
|
||||
|
||||
public abstract void run(T value1, U value2);
|
||||
|
||||
public RunnableVal2<T, U> runAndGet(T value1, U value2) {
|
||||
run(value1, value2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(T t, U u) {
|
||||
run(t, u);
|
||||
}
|
||||
}
|
@ -93,7 +93,7 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
||||
}
|
||||
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMapLoc.entrySet()) {
|
||||
IntTriple key = entry.getKey();
|
||||
setTile(getIndex(key.x, key.y, key.z), entry.getValue());
|
||||
setTile(getIndex(key.getX(), key.getY(), key.getZ()), entry.getValue());
|
||||
}
|
||||
nbtMapLoc.clear();
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
nbt = null;
|
||||
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
|
||||
IntTriple key = entry.getKey();
|
||||
int index = getIndex(key.x, key.y, key.z);
|
||||
int index = getIndex(key.getX(), key.getY(), key.getZ());
|
||||
if (index == i) {
|
||||
nbt = entry.getValue();
|
||||
break;
|
||||
|
@ -200,7 +200,7 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
|
||||
nbt = null;
|
||||
for (Map.Entry<IntTriple, CompoundTag> entry : nbtMap.entrySet()) {
|
||||
IntTriple trio = entry.getKey();
|
||||
int index = getIndex(trio.x, trio.y, trio.z);
|
||||
int index = getIndex(trio.getX(), trio.getY(), trio.getZ());
|
||||
if (index == i) {
|
||||
nbt = entry.getValue();
|
||||
break;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -14,7 +15,7 @@ public class AdjacentAnyMask extends AbstractMask implements ResettableMask {
|
||||
private final CachedMask mask;
|
||||
private final MutableBlockVector3 mutable;
|
||||
|
||||
public AdjacentAnyMask(Mask mask) {
|
||||
public AdjacentAnyMask(AbstractExtentMask mask) {
|
||||
this.mask = CachedMask.cache(mask);
|
||||
mutable = new MutableBlockVector3();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.object.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -11,7 +12,7 @@ public class SurfaceMask extends AdjacentAnyMask {
|
||||
super(getMask(extent));
|
||||
}
|
||||
|
||||
public static Mask getMask(Extent extent) {
|
||||
public static AbstractExtentMask getMask(Extent extent) {
|
||||
return new BlockMaskBuilder()
|
||||
.addTypes(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR)
|
||||
.addAll(b -> !b.getMaterial().isMovementBlocker())
|
||||
|
@ -87,14 +87,12 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) {
|
||||
int size = this.region.getArea();
|
||||
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")"));
|
||||
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getVolume() + ")"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) {
|
||||
int size = this.region.getArea();
|
||||
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")"));
|
||||
player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getVolume() + ")"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,8 +99,8 @@ public abstract class DFSVisitor implements Operation {
|
||||
// mutable2.mutY(from.getY() + direction.y);
|
||||
// mutable2.mutZ(from.getZ() + direction.z);
|
||||
BlockVector3 bv2 = BlockVector3
|
||||
.at(from.getX() + direction.x, from.getY() + direction.y,
|
||||
from.getZ() + direction.z);
|
||||
.at(from.getX() + direction.getX(), from.getY() + direction.getY(),
|
||||
from.getZ() + direction.getZ());
|
||||
if (isVisitable(bv, bv2)) {
|
||||
Node adjacent = new Node(bv2.getBlockX(), bv2.getBlockY(), bv2.getBlockZ());
|
||||
if (!adjacent.equals(current.from)) {
|
||||
|
@ -5,29 +5,17 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.IBatchProcessor;
|
||||
import com.boydti.fawe.beta.IQueueChunk;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.implementation.lighting.NMSRelighter;
|
||||
import com.boydti.fawe.beta.implementation.lighting.NullRelighter;
|
||||
import com.boydti.fawe.beta.implementation.lighting.Relighter;
|
||||
import com.boydti.fawe.beta.implementation.processors.LimitProcessor;
|
||||
import com.boydti.fawe.beta.implementation.queue.ParallelQueueExtent;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.HistoryExtent;
|
||||
import com.boydti.fawe.object.NullChangeSet;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RelightMode;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
import com.boydti.fawe.object.changeset.AbstractChangeSet;
|
||||
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
|
||||
import com.boydti.fawe.object.changeset.DiskStorageHistory;
|
||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||
import com.boydti.fawe.object.extent.MultiRegionExtent;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
||||
import com.boydti.fawe.object.extent.SlowExtent;
|
||||
import com.boydti.fawe.object.extent.StripNBTExtent;
|
||||
import com.boydti.fawe.object.extent.*;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
@ -4,6 +4,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ExtentTraverser<T extends Extent> {
|
||||
@ -48,21 +49,8 @@ public class ExtentTraverser<T extends Extent> {
|
||||
return last;
|
||||
}
|
||||
|
||||
public boolean insert(T extent) {
|
||||
try {
|
||||
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
field.set(extent, field.get(root));
|
||||
field.set(root, extent);
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public <U> U findAndGet(Class<U> clazz) {
|
||||
ExtentTraverser<Extent> traverser = find( clazz);
|
||||
ExtentTraverser<Extent> traverser = find(clazz);
|
||||
return (traverser != null) ? (U) traverser.get() : null;
|
||||
}
|
||||
|
||||
|
@ -1,92 +1,51 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.FaweInputStream;
|
||||
import com.boydti.fawe.object.FaweOutputStream;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.changeset.FaweStreamChangeSet;
|
||||
import com.boydti.fawe.object.io.AbstractDelegateOutputStream;
|
||||
import com.github.luben.zstd.ZstdInputStream;
|
||||
import com.github.luben.zstd.ZstdOutputStream;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.DoubleTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import java.awt.Graphics2D;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
|
||||
import net.jpountz.lz4.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.*;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.util.zip.*;
|
||||
|
||||
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FastDecompressor;
|
||||
import net.jpountz.lz4.LZ4InputStream;
|
||||
import net.jpountz.lz4.LZ4Utils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import static java.lang.System.arraycopy;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public class MainUtil {
|
||||
|
||||
@ -112,22 +71,22 @@ public class MainUtil {
|
||||
|
||||
public static long getTotalSize(Path path) {
|
||||
final AtomicLong size = new AtomicLong(0);
|
||||
traverse(path, new RunnableVal2<Path, BasicFileAttributes>() {
|
||||
traverse(path, new RunnableVal<BasicFileAttributes>() {
|
||||
@Override
|
||||
public void run(Path path, BasicFileAttributes attrs) {
|
||||
public void run(BasicFileAttributes attrs) {
|
||||
size.addAndGet(attrs.size());
|
||||
}
|
||||
});
|
||||
return size.get();
|
||||
}
|
||||
|
||||
public static void traverse(Path path, final BiConsumer<Path, BasicFileAttributes> onEach) {
|
||||
public static void traverse(Path path, final Consumer<BasicFileAttributes> onEach) {
|
||||
try {
|
||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult
|
||||
visitFile(Path file, BasicFileAttributes attrs) {
|
||||
onEach.accept(file, attrs);
|
||||
onEach.accept(attrs);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@ -169,7 +128,7 @@ public class MainUtil {
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
public static void forEachFile(Path path, final RunnableVal2<Path, BasicFileAttributes> onEach, Comparator<File> comparator) {
|
||||
public static void forEachFile(Path path, final RunnableVal<BasicFileAttributes> onEach, Comparator<File> comparator) {
|
||||
File dir = path.toFile();
|
||||
if (!dir.exists()) return;
|
||||
File[] files = path.toFile().listFiles();
|
||||
@ -178,7 +137,7 @@ public class MainUtil {
|
||||
Path filePath = file.toPath();
|
||||
try {
|
||||
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
|
||||
onEach.run(file.toPath(), attr);
|
||||
onEach.run(attr);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import com.boydti.fawe.object.mask.ResettableMask;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
|
||||
@ -38,6 +40,18 @@ public class MaskTraverser {
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
}
|
||||
if (mask instanceof MaskIntersection) {
|
||||
MaskIntersection mask1 = (MaskIntersection) mask;
|
||||
try {
|
||||
Field field = mask1.getClass().getDeclaredField("masks");
|
||||
field.setAccessible(true);
|
||||
Collection<Mask> masks = (Collection<Mask>) field.get(mask);
|
||||
for (Mask next : masks) {
|
||||
reset(next, newExtent);
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException ignored) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
Field field = current.getDeclaredField("mask");
|
||||
field.setAccessible(true);
|
||||
|
@ -1,27 +0,0 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class RegionCacheUtil {
|
||||
public RegionCacheUtil() {
|
||||
|
||||
}
|
||||
|
||||
public void cache(Region region) {
|
||||
Iterator<BlockVector3> iter = region.iterator();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -33,15 +33,9 @@ public class WEManager {
|
||||
|
||||
public void cancelEditSafe(AbstractDelegateExtent parent, FaweException reason) throws FaweException {
|
||||
log.warn("CancelEditSafe was hit. Please ignore this message.");
|
||||
try {
|
||||
final Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
Extent currentExtent = parent.getExtent();
|
||||
if (!(currentExtent instanceof NullExtent)) {
|
||||
field.set(parent, new NullExtent((Extent) field.get(parent), reason));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Extent currentExtent = parent.getExtent();
|
||||
if (!(currentExtent instanceof NullExtent)) {
|
||||
parent.extent = new NullExtent(parent.extent, reason);
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
Reference in New Issue
Block a user