Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 02:50:05 +01:00
Many upstream changes. Should be non-breaking
Dieser Commit ist enthalten in:
Ursprung
c672bcfddd
Commit
a1c15e1c39
@ -7,7 +7,6 @@ import com.boydti.fawe.regions.general.CuboidRegionFilter;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@ -65,4 +64,4 @@ public class WorldGuardFilter extends CuboidRegionFilter {
|
||||
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
|
||||
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class WorldguardFlag extends BukkitMaskManager implements Listener {
|
||||
final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
final RegionManager manager = container.get(fp.getWorld());
|
||||
|
||||
return new FaweMask(new ManagerRegion(manager, localplayer), null) {
|
||||
return new FaweMask(new ManagerRegion(manager, localplayer)) {
|
||||
@Override
|
||||
public boolean isValid(FawePlayer player, MaskType type) {
|
||||
// We rely on the region mask instead of this
|
||||
|
@ -2,20 +2,20 @@ package com.boydti.fawe.bukkit.util;
|
||||
|
||||
import com.boydti.fawe.bukkit.v0.BukkitQueue_0;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
private final Class<?> classCraftItemStack;
|
||||
private final Method methodAsNMSCopy;
|
||||
private final Class<?> classNMSItem;
|
||||
private final Method methodGetTag;
|
||||
private final Method methodHasTag;
|
||||
private final Method methodSetTag;
|
||||
@ -25,8 +25,8 @@ public class ItemUtil {
|
||||
private SoftReference<Int2ObjectOpenHashMap<WeakReference<Tag>>> hashToNMSTag = new SoftReference(new Int2ObjectOpenHashMap<>());
|
||||
|
||||
public ItemUtil() throws Exception {
|
||||
this.classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
|
||||
this.classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
|
||||
Class<?> classCraftItemStack = BukkitReflectionUtils.getCbClass("inventory.CraftItemStack");
|
||||
Class<?> classNMSItem = BukkitReflectionUtils.getNmsClass("ItemStack");
|
||||
this.methodAsNMSCopy = ReflectionUtils.setAccessible(classCraftItemStack.getDeclaredMethod("asNMSCopy", ItemStack.class));
|
||||
this.methodHasTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("hasTag"));
|
||||
this.methodGetTag = ReflectionUtils.setAccessible(classNMSItem.getDeclaredMethod("getTag"));
|
||||
|
@ -11,20 +11,12 @@ import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
@ -33,6 +25,14 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> {
|
||||
|
||||
private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker()
|
||||
@ -78,15 +78,6 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
}
|
||||
|
||||
private static Class<?> classRegionFileCache;
|
||||
private static Class<?> classRegionFile;
|
||||
private static Class<?> classCraftChunk;
|
||||
private static Class<?> classCraftWorld;
|
||||
private static Class<?> classNMSChunk;
|
||||
private static Class<?> classNMSWorld;
|
||||
private static Class<?> classChunkProviderServer;
|
||||
private static Class<?> classIChunkLoader;
|
||||
private static Class<?> classChunkRegionLoader;
|
||||
private static Class<?> classIChunkProvider;
|
||||
private static Method methodGetHandleChunk;
|
||||
private static Method methodGetHandleWorld;
|
||||
private static Method methodFlush;
|
||||
@ -100,15 +91,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
try {
|
||||
BukkitReflectionUtils.init();
|
||||
classRegionFileCache = BukkitReflectionUtils.getNmsClass("RegionFileCache");
|
||||
classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
|
||||
classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
|
||||
classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
|
||||
classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
|
||||
classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
|
||||
classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
|
||||
classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
|
||||
classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
|
||||
classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
|
||||
Class<?> classRegionFile = BukkitReflectionUtils.getNmsClass("RegionFile");
|
||||
Class<?> classCraftChunk = BukkitReflectionUtils.getCbClass("CraftChunk");
|
||||
Class<?> classNMSChunk = BukkitReflectionUtils.getNmsClass("Chunk");
|
||||
Class<?> classCraftWorld = BukkitReflectionUtils.getCbClass("CraftWorld");
|
||||
Class<?> classNMSWorld = BukkitReflectionUtils.getNmsClass("World");
|
||||
Class<?> classChunkProviderServer = BukkitReflectionUtils.getNmsClass("ChunkProviderServer");
|
||||
Class<?> classIChunkProvider = BukkitReflectionUtils.getNmsClass("IChunkProvider");
|
||||
Class<?> classIChunkLoader = BukkitReflectionUtils.getNmsClass("IChunkLoader");
|
||||
Class<?> classChunkRegionLoader = BukkitReflectionUtils.getNmsClass("ChunkRegionLoader");
|
||||
|
||||
methodGetHandleChunk = ReflectionUtils.setAccessible(classCraftChunk.getDeclaredMethod("getHandle"));
|
||||
methodGetHandleWorld = ReflectionUtils.setAccessible(classCraftWorld.getDeclaredMethod("getHandle"));
|
||||
@ -289,15 +280,15 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
private ChunkSnapshot tryGetSnasphot(Chunk chunk) {
|
||||
try {
|
||||
return chunk.getChunkSnapshot(false, true, false);
|
||||
} catch (Throwable ignore) {
|
||||
Throwable cause = ignore;
|
||||
} catch (Throwable throwable) {
|
||||
Throwable cause = throwable;
|
||||
while (cause.getCause() != null) {
|
||||
cause = cause.getCause();
|
||||
}
|
||||
if (cause instanceof IllegalStateException) {
|
||||
return null;
|
||||
}
|
||||
throw ignore;
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,8 +382,8 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
if (disableResult != null) {
|
||||
try {
|
||||
fieldNeighbors.set(disableResult[0], disableResult[1]);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ import com.boydti.fawe.object.brush.visualization.VisualChunk;
|
||||
import com.boydti.fawe.object.visitor.FaweChunkVisitor;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
@ -62,24 +62,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
final static Field fieldNonEmptyBlockCount;
|
||||
final static Field fieldSection;
|
||||
final static Field fieldLiquidCount;
|
||||
private final static Field fieldEmittedLight;
|
||||
private final static Field fieldSkyLight;
|
||||
|
||||
|
||||
// protected final static Field fieldBiomes;
|
||||
|
||||
private final static Field fieldChunkGenerator;
|
||||
private final static Field fieldSeed;
|
||||
// protected final static Field fieldBiomeCache;
|
||||
// protected final static Field fieldBiomes2;
|
||||
private final static Field fieldGenLayer1;
|
||||
private final static Field fieldGenLayer2;
|
||||
private final static Field fieldSave;
|
||||
// protected final static MutableGenLayer genLayer;
|
||||
private final static ChunkSection emptySection;
|
||||
|
||||
// protected static final Method methodResize;
|
||||
|
||||
private final static Field fieldDirtyCount;
|
||||
private final static Field fieldDirtyBits;
|
||||
|
||||
@ -89,12 +73,8 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
Arrays.fill(emptySection.getSkyLightArray().asBytes(), (byte) 255);
|
||||
fieldSection = ChunkSection.class.getDeclaredField("blockIds");
|
||||
fieldLiquidCount = ChunkSection.class.getDeclaredField("e");
|
||||
fieldEmittedLight = ChunkSection.class.getDeclaredField("emittedLight");
|
||||
fieldSkyLight = ChunkSection.class.getDeclaredField("skyLight");
|
||||
fieldSection.setAccessible(true);
|
||||
fieldLiquidCount.setAccessible(true);
|
||||
fieldEmittedLight.setAccessible(true);
|
||||
fieldSkyLight.setAccessible(true);
|
||||
|
||||
fieldFluidCount = ChunkSection.class.getDeclaredField("e");
|
||||
fieldTickingBlockCount = ChunkSection.class.getDeclaredField("tickingBlockCount");
|
||||
@ -103,25 +83,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
fieldTickingBlockCount.setAccessible(true);
|
||||
fieldNonEmptyBlockCount.setAccessible(true);
|
||||
|
||||
//fieldBiomes = ChunkProviderGenerate.class.getDeclaredField("D"); // *
|
||||
//fieldBiomes.setAccessible(true);
|
||||
|
||||
fieldChunkGenerator = ChunkProviderServer.class.getDeclaredField("chunkGenerator");
|
||||
fieldChunkGenerator.setAccessible(true);
|
||||
fieldSeed = WorldData.class.getDeclaredField("e");
|
||||
fieldSeed.setAccessible(true);
|
||||
|
||||
// fieldBiomeCache = WorldChunkManager.class.getDeclaredField("d"); // *
|
||||
// fieldBiomeCache.setAccessible(true);
|
||||
// fieldBiomes2 = WorldChunkManager.class.getDeclaredField("e"); // *
|
||||
// fieldBiomes2.setAccessible(true);
|
||||
fieldGenLayer1 = WorldChunkManager.class.getDeclaredField("b") ;
|
||||
fieldGenLayer2 = WorldChunkManager.class.getDeclaredField("c") ;
|
||||
fieldGenLayer1.setAccessible(true);
|
||||
fieldGenLayer2.setAccessible(true);
|
||||
|
||||
fieldSave = ReflectionUtils.setAccessible(net.minecraft.server.v1_13_R2.Chunk.class.getDeclaredField("s")); //*
|
||||
|
||||
fieldHashBlocks = DataPaletteHash.class.getDeclaredField("b");
|
||||
fieldHashBlocks.setAccessible(true);
|
||||
fieldLinearBlocks = DataPaletteLinear.class.getDeclaredField("b");
|
||||
@ -156,9 +117,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
fieldPalette = DataPaletteBlock.class.getDeclaredField("h");
|
||||
fieldPalette.setAccessible(true);
|
||||
|
||||
// methodResize = DataPaletteBlock.class.getDeclaredMethod("b", int.class);
|
||||
// methodResize.setAccessible(true);
|
||||
|
||||
fieldDirtyCount = PlayerChunk.class.getDeclaredField("dirtyCount");
|
||||
fieldDirtyBits = PlayerChunk.class.getDeclaredField("h");
|
||||
fieldDirtyCount.setAccessible(true);
|
||||
@ -229,54 +187,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
|
||||
@Override
|
||||
public boolean regenerateChunk(World world, int x, int z, BiomeType biome, Long seed) {
|
||||
// if (biome != null) {
|
||||
// try {
|
||||
// if (seed == null) {
|
||||
// seed = world.getSeed();
|
||||
// }
|
||||
// nmsWorld.worldData.getSeed();
|
||||
// boolean result;
|
||||
// ChunkProviderGenerate generator = new ChunkProviderGenerate(nmsWorld, seed, false, "");
|
||||
// Biome bukkitBiome = getAdapter().getBiome(biome.getId());
|
||||
// BiomeBase base = BiomeBase.getBiome(biome.getId());
|
||||
// fieldBiomes.set(generator, new BiomeBase[]{base});
|
||||
// boolean cold = base.getTemperature() <= 1;
|
||||
// net.minecraft.server.v1_13_R2.ChunkGenerator existingGenerator = nmsWorld.getChunkProvider().chunkGenerator;
|
||||
// long existingSeed = world.getSeed();
|
||||
// {
|
||||
// if (genLayer == null) genLayer = new MutableGenLayer(seed);
|
||||
// genLayer.set(biome.getId());
|
||||
// Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.getWorldChunkManager());
|
||||
// Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.getWorldChunkManager());
|
||||
// fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), genLayer);
|
||||
// fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), genLayer);
|
||||
//
|
||||
// fieldSeed.set(nmsWorld.worldData, seed);
|
||||
//
|
||||
// ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.getWorldChunkManager(), new BiomeCache(this.nmsWorld.getWorldChunkManager()));
|
||||
//
|
||||
// ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), generator);
|
||||
//
|
||||
// keepLoaded.remove(MathMan.pairInt(x, z));
|
||||
// result = getWorld().regenerateChunk(x, z);
|
||||
// net.minecraft.server.v1_13_R2.Chunk nmsChunk = getCachedChunk(world, x, z);
|
||||
// if (nmsChunk != null) {
|
||||
// nmsChunk.f(true); // Set Modified
|
||||
// nmsChunk.mustSave = true;
|
||||
// }
|
||||
//
|
||||
// ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), existingGenerator);
|
||||
//
|
||||
// fieldSeed.set(nmsWorld.worldData, existingSeed);
|
||||
//
|
||||
// fieldGenLayer1.set(nmsWorld.getWorldChunkManager(), existingGenLayer1);
|
||||
// fieldGenLayer2.set(nmsWorld.getWorldChunkManager(), existingGenLayer2);
|
||||
// }
|
||||
// return result;
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
return super.regenerateChunk(world, x, z, biome, seed);
|
||||
}
|
||||
|
||||
@ -409,89 +319,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public World createWorld(final WorldCreator creator) {
|
||||
// final String name = creator.name();
|
||||
// ChunkGenerator generator = creator.generator();
|
||||
// final CraftServer server = (CraftServer) Bukkit.getServer();
|
||||
// final MinecraftServer console = server.getServer();
|
||||
// final File folder = new File(server.getWorldContainer(), name);
|
||||
// final World world = server.getWorld(name);
|
||||
// final WorldType type = WorldType.getType(creator.type().getName());
|
||||
// final boolean generateStructures = creator.generateStructures();
|
||||
// if (world != null) {
|
||||
// return world;
|
||||
// }
|
||||
// if (folder.exists() && !folder.isDirectory()) {
|
||||
// throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||
// }
|
||||
// TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
// @Override
|
||||
// public void run(Object value) {
|
||||
// try {
|
||||
// Field field = CraftServer.class.getDeclaredField("worlds");
|
||||
// field.setAccessible(true);
|
||||
// Map<Object, Object> existing = (Map<Object, Object>) field.get(server);
|
||||
// if (!existing.getClass().getName().contains("SynchronizedMap")) {
|
||||
// field.set(server, Collections.synchronizedMap(existing));
|
||||
// }
|
||||
// } catch (Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// if (generator == null) {
|
||||
// generator = server.getGenerator(name);
|
||||
// }
|
||||
// int dimension = 10 + console.worlds.size();
|
||||
// boolean used = false;
|
||||
// do {
|
||||
// for (final WorldServer ws : console.worlds) {
|
||||
// used = (ws.dimension == dimension);
|
||||
// if (used) {
|
||||
// ++dimension;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// } while (used);
|
||||
// final boolean hardcore = false;
|
||||
// final IDataManager sdm = new ServerNBTManager(server.getWorldContainer(), name, true, server.getHandle().getServer().dataConverterManager);
|
||||
// WorldData worlddata = sdm.getWorldData();
|
||||
// final WorldSettings worldSettings;
|
||||
// if (worlddata == null) {
|
||||
// worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type);
|
||||
// worldSettings.setGeneratorSettings(creator.generatorSettings());
|
||||
// worlddata = new WorldData(worldSettings, name);
|
||||
// } else {
|
||||
// worldSettings = null;
|
||||
// }
|
||||
// worlddata.checkName(name);
|
||||
// final WorldServer internal = (WorldServer)new WorldServer(console, sdm, worlddata, dimension, console.methodProfiler, creator.environment(), generator).b();
|
||||
// startSet(true); // Temporarily allow async chunk load since the world isn't added yet
|
||||
// if (worldSettings != null) {
|
||||
// internal.a(worldSettings);
|
||||
// }
|
||||
// endSet(true);
|
||||
// internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle();
|
||||
// internal.tracker = new EntityTracker(internal);
|
||||
// internal.addIWorldAccess(new WorldManager(console, internal));
|
||||
// internal.worldData.setDifficulty(EnumDifficulty.EASY);
|
||||
// internal.setSpawnFlags(true, true);
|
||||
// if (generator != null) {
|
||||
// internal.getWorld().getPopulators().addAll(generator.getDefaultPopulators(internal.getWorld()));
|
||||
// }
|
||||
// // Add the world
|
||||
// return TaskManager.IMP.sync(new RunnableVal<World>() {
|
||||
// @Override
|
||||
// public void run(World value) {
|
||||
// console.worlds.add(internal);
|
||||
// server.getPluginManager().callEvent(new WorldInitEvent(internal.getWorld()));
|
||||
// server.getPluginManager().callEvent(new WorldLoadEvent(internal.getWorld()));
|
||||
// this.value = internal.getWorld();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getCombinedId4Data(ChunkSection lastSection, int x, int y, int z) {
|
||||
DataPaletteBlock<IBlockData> dataPalette = lastSection.getBlocks();
|
||||
@ -681,40 +508,6 @@ public class BukkitQueue_1_13 extends BukkitQueue_0<net.minecraft.server.v1_13_R
|
||||
return null;
|
||||
});
|
||||
}
|
||||
// if (mask == 0) {
|
||||
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65535);
|
||||
// for (EntityPlayer player : playerChunk.players) {
|
||||
// player.playerConnection.sendPacket(packet);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// // Send chunks
|
||||
// boolean empty = false;
|
||||
// ChunkSection[] sections = nmsChunk.getSections();
|
||||
// for (int i = 0; i < sections.length; i++) {
|
||||
// if (sections[i] == null) {
|
||||
// sections[i] = emptySection;
|
||||
// empty = true;
|
||||
// }
|
||||
// }
|
||||
// if (mask == 0 || mask == 65535 && hasEntities(nmsChunk)) {
|
||||
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, 65280);
|
||||
// for (EntityPlayer player : playerChunk.players) {
|
||||
// player.playerConnection.sendPacket(packet);
|
||||
// }
|
||||
// mask = 255;
|
||||
// }
|
||||
// PacketPlayOutMapChunk packet = new PacketPlayOutMapChunk(nmsChunk, mask);
|
||||
// for (EntityPlayer player : playerChunk.players) {
|
||||
// player.playerConnection.sendPacket(packet);
|
||||
// }
|
||||
// if (empty) {
|
||||
// for (int i = 0; i < sections.length; i++) {
|
||||
// if (sections[i] == emptySection) {
|
||||
// sections[i] = null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,28 +19,21 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.bekvon.bukkit.residence.commands.material;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.command.tool.BlockDataCyler;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
|
@ -19,26 +19,24 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
||||
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag {
|
||||
public class BukkitPlayerBlockBag extends BlockBag {
|
||||
|
||||
private Player player;
|
||||
private ItemStack[] items;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
public BukkitPlayerBlockBag(Player player) {
|
||||
@ -56,7 +54,7 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
@ -182,16 +180,4 @@ public class BukkitPlayerBlockBag extends BlockBag implements SlottableBlockBag
|
||||
public void addSingleSourcePosition(Location pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseItem getItem(int slot) {
|
||||
loadInventory();
|
||||
return BukkitAdapter.adapt(items[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int slot, BaseItem block) {
|
||||
loadInventory();
|
||||
BaseItemStack stack = block instanceof BaseItemStack ? (BaseItemStack) block : new BaseItemStack(block.getType(), block.getNbtData(), 1);
|
||||
items[slot] = BukkitAdapter.adapt(stack);
|
||||
}
|
||||
}
|
||||
|
@ -36,14 +36,13 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitServerInterface implements MultiUserPlatform {
|
||||
public Server server;
|
||||
public WorldEditPlugin plugin;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
@ -18,11 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -38,7 +38,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
@ -57,7 +56,6 @@ import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class BukkitWorld extends AbstractWorld {
|
||||
|
||||
|
@ -24,13 +24,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Handles incoming WorldEditCui init message.
|
||||
*/
|
||||
public class CUIChannelListener implements PluginMessageListener {
|
||||
|
||||
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
||||
public static final Charset UTF_8_CHARSET = StandardCharsets.UTF_8;
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public CUIChannelListener(WorldEditPlugin plugin) {
|
||||
|
@ -1,52 +0,0 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DelegateEntity implements Entity {
|
||||
private final Entity parent;
|
||||
|
||||
public DelegateEntity(Entity parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Entity getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public BaseEntity getState() {
|
||||
return parent.getState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return parent.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Extent getExtent() {
|
||||
return parent.getExtent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
return parent.remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getFacet(Class<? extends T> cls) {
|
||||
return parent.getFacet(cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setLocation(Location location) {
|
||||
return parent.setLocation(location);
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event.Result;
|
||||
@ -111,14 +110,11 @@ public class WorldEditListener implements Listener {
|
||||
public void onPlayerCommand(PlayerCommandSendEvent event) {
|
||||
CommandLocals locals = new CommandLocals();
|
||||
locals.put(Actor.class, plugin.wrapCommandSender(event.getPlayer()));
|
||||
Dispatcher dispatcher = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher();
|
||||
if (dispatcher != null) {
|
||||
Set<String> toRemove = dispatcher.getCommands().stream()
|
||||
.filter(commandMapping -> !commandMapping.getCallable().testPermission(locals))
|
||||
.map(CommandMapping::getPrimaryAlias)
|
||||
.collect(Collectors.toSet());
|
||||
event.getCommands().removeIf(toRemove::contains);
|
||||
}
|
||||
Set<String> toRemove = plugin.getWorldEdit().getPlatformManager().getCommandManager().getDispatcher().getCommands().stream()
|
||||
.filter(commandMapping -> !commandMapping.getCallable().testPermission(locals))
|
||||
.map(CommandMapping::getPrimaryAlias)
|
||||
.collect(Collectors.toSet());
|
||||
event.getCommands().removeIf(toRemove::contains);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,9 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.adapter.v1_13_1.Spigot_v1_13_R2;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -61,7 +63,11 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -72,8 +78,6 @@ import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Plugin for Bukkit.
|
||||
*/
|
||||
@ -89,39 +93,38 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
|
||||
private static Map<String, Plugin> lookupNames;
|
||||
static {
|
||||
{ // Disable AWE as otherwise both fail to load
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
try {
|
||||
Field pluginsField = manager.getClass().getDeclaredField("plugins");
|
||||
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
|
||||
pluginsField.setAccessible(true);
|
||||
lookupNamesField.setAccessible(true);
|
||||
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
||||
lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
||||
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
|
||||
@Override
|
||||
public boolean add(Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible");
|
||||
} else if (plugin.getName().startsWith("BetterShutdown")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)");
|
||||
} else {
|
||||
return super.add(plugin);
|
||||
}
|
||||
return false;
|
||||
// Disable AWE as otherwise both fail to load
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
try {
|
||||
Field pluginsField = manager.getClass().getDeclaredField("plugins");
|
||||
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
|
||||
pluginsField.setAccessible(true);
|
||||
lookupNamesField.setAccessible(true);
|
||||
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
||||
lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
||||
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
|
||||
@Override
|
||||
public boolean add(Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible");
|
||||
} else if (plugin.getName().startsWith("BetterShutdown")) {
|
||||
Fawe.debug("Disabling `" + plugin.getName() + "` as it is incompatible (Improperly shaded classes from com.sk89q.minecraft.util.commands)");
|
||||
} else {
|
||||
return super.add(plugin);
|
||||
}
|
||||
});
|
||||
lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap<String, Plugin>(lookupNames) {
|
||||
@Override
|
||||
public Plugin put(@NotNull String key, @NotNull Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) {
|
||||
return null;
|
||||
}
|
||||
return super.put(key, plugin);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
lookupNamesField.set(manager, lookupNames = new ConcurrentHashMap<String, Plugin>(lookupNames) {
|
||||
@Override
|
||||
public Plugin put(@NotNull String key, @NotNull Plugin plugin) {
|
||||
if (plugin.getName().startsWith("AsyncWorldEdit") || plugin.getName().startsWith("BetterShutdown")) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
return super.put(key, plugin);
|
||||
}
|
||||
});
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
|
||||
public WorldEditPlugin() {
|
||||
@ -180,10 +183,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
PermissionsResolverManager.initialize(this); // Setup permission resolver
|
||||
|
||||
// Register CUI
|
||||
fail(() -> {
|
||||
getServer().getMessenger().registerIncomingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL, new CUIChannelListener(INSTANCE));
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(INSTANCE, CUI_PLUGIN_CHANNEL);
|
||||
}, "Failed to register CUI");
|
||||
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
|
||||
|
||||
// Now we can register events
|
||||
getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
|
||||
@ -193,12 +194,11 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
// platforms to be worried about... at the current time of writing
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||
|
||||
{ // Register 1.13 Material ids with LegacyMapper
|
||||
LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
||||
for (Material m : Material.values()) {
|
||||
if (!m.isLegacy() && m.isBlock()) {
|
||||
legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
||||
}
|
||||
// Register 1.13 Material ids with LegacyMapper
|
||||
LegacyMapper legacyMapper = LegacyMapper.getInstance();
|
||||
for (Material m : Material.values()) {
|
||||
if (!m.isLegacy() && m.isBlock()) {
|
||||
legacyMapper.register(m.getId(), 0, BukkitAdapter.adapt(m).getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,8 +262,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
|
||||
}
|
||||
|
||||
private void rename() {
|
||||
File dir = getDataFolder();
|
||||
dir = new File(dir.getParentFile(), "FastAsyncWorldEdit");
|
||||
File dir = new File(getDataFolder().getParentFile(), "FastAsyncWorldEdit");
|
||||
try {
|
||||
Field descriptionField = JavaPlugin.class.getDeclaredField("dataFolder");
|
||||
descriptionField.setAccessible(true);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
# About editing this file:
|
||||
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain and post
|
||||
# errors. If you use an editor, like Notepad++ (recommended for Windows
|
||||
# errors. If you use an editor, like Notepad++ (recommended for Windows
|
||||
# users), you must configure it to "replace tabs with spaces."
|
||||
# This can be changed in Settings > Preferences > Language Menu.
|
||||
# - Don't get rid of indentations. They are indented so some entries that are
|
||||
@ -30,9 +30,67 @@ limits:
|
||||
butcher-radius:
|
||||
default: -1
|
||||
maximum: -1
|
||||
# Use either block ids, names, or regex
|
||||
# Regex supports properties as well (see FAWE mask documentation)
|
||||
disallowed-blocks: []
|
||||
disallowed-blocks:
|
||||
- "minecraft:oak_sapling"
|
||||
- "minecraft:jungle_sapling"
|
||||
- "minecraft:dark_oak_sapling:"
|
||||
- "minecraft:spruce_sapling"
|
||||
- "minecraft:birch_sapling"
|
||||
- "minecraft:acacia_sapling"
|
||||
- "minecraft:black_bed"
|
||||
- "minecraft:blue_bed"
|
||||
- "minecraft:brown_bed"
|
||||
- "minecraft:cyan_bed"
|
||||
- "minecraft:gray_bed"
|
||||
- "minecraft:green_bed"
|
||||
- "minecraft:light_blue_bed"
|
||||
- "minecraft:light_gray_bed"
|
||||
- "minecraft:lime_bed"
|
||||
- "minecraft:magenta_bed"
|
||||
- "minecraft:orange_bed"
|
||||
- "minecraft:pink_bed"
|
||||
- "minecraft:purple_bed"
|
||||
- "minecraft:red_bed"
|
||||
- "minecraft:white_bed"
|
||||
- "minecraft:yellow_bed"
|
||||
- "minecraft:powered_rail"
|
||||
- "minecraft:detector_rail"
|
||||
- "minecraft:grass"
|
||||
- "minecraft:dead_bush"
|
||||
- "minecraft:moving_piston"
|
||||
- "minecraft:piston_head"
|
||||
- "minecraft:sunflower"
|
||||
- "minecraft:rose_bush"
|
||||
- "minecraft:dandelion"
|
||||
- "minecraft:poppy"
|
||||
- "minecraft:brown_mushroom"
|
||||
- "minecraft:red_mushroom"
|
||||
- "minecraft:tnt"
|
||||
- "minecraft:torch"
|
||||
- "minecraft:fire"
|
||||
- "minecraft:redstone_wire"
|
||||
- "minecraft:wheat"
|
||||
- "minecraft:potatoes"
|
||||
- "minecraft:carrots"
|
||||
- "minecraft:melon_stem"
|
||||
- "minecraft:pumpkin_stem"
|
||||
- "minecraft:beetroots"
|
||||
- "minecraft:rail"
|
||||
- "minecraft:lever"
|
||||
- "minecraft:redstone_torch"
|
||||
- "minecraft:redstone_wall_torch"
|
||||
- "minecraft:repeater"
|
||||
- "minecraft:comparator"
|
||||
- "minecraft:stone_button"
|
||||
- "minecraft:birch_button"
|
||||
- "minecraft:acacia_button"
|
||||
- "minecraft:dark_oak_button"
|
||||
- "minecraft:jungle_button"
|
||||
- "minecraft:oak_button"
|
||||
- "minecraft:spruce_button"
|
||||
- "minecraft:cactus"
|
||||
- "minecraft:sugar_cane"
|
||||
- "minecraft:bedrock"
|
||||
|
||||
use-inventory:
|
||||
enable: false
|
||||
|
@ -8,6 +8,7 @@ import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
|
||||
@ -19,6 +20,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompressedCompoundTag;
|
||||
import com.sk89q.jnbt.CompressedSchematicTag;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -27,9 +29,7 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@ -48,7 +48,7 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
return true;
|
||||
}
|
||||
FaweQueue faweQueue = SetQueue.IMP.getNewQueue(((FaweLocalBlockQueue) queue).IMP.getWEWorld(), true, false);
|
||||
faweQueue.setTile(x, y, z, (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(compoundTag));
|
||||
faweQueue.setTile(x, y, z, (CompoundTag) FaweCache.asTag(compoundTag));
|
||||
faweQueue.flush();
|
||||
return false;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
}
|
||||
} else {
|
||||
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new PGZIPOutputStream(stream))) {
|
||||
Map<String, com.sk89q.jnbt.Tag> map = tag.getValue();
|
||||
Map<String, Tag> map = tag.getValue();
|
||||
output.writeNamedTag("Schematic", map.getOrDefault("Schematic", tag));
|
||||
}
|
||||
}
|
||||
@ -123,9 +123,9 @@ public class FaweSchematicHandler extends SchematicHandler {
|
||||
public void run(OutputStream output) {
|
||||
try {
|
||||
try (PGZIPOutputStream gzip = new PGZIPOutputStream(output)) {
|
||||
com.sk89q.jnbt.CompoundTag weTag = (com.sk89q.jnbt.CompoundTag) FaweCache.asTag(tag);
|
||||
CompoundTag weTag = (CompoundTag) FaweCache.asTag(tag);
|
||||
try (NBTOutputStream nos = new NBTOutputStream(gzip)) {
|
||||
Map<String, com.sk89q.jnbt.Tag> map = weTag.getValue();
|
||||
Map<String, Tag> map = weTag.getValue();
|
||||
nos.writeNamedTag("Schematic", map.getOrDefault("Schematic", weTag));
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.boydti.fawe.object.RunnableVal2;
|
||||
import com.boydti.fawe.object.changeset.CPUOptimizedChangeSet;
|
||||
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;
|
||||
@ -21,10 +22,12 @@ import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
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 static java.lang.System.arraycopy;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
import net.jpountz.lz4.LZ4Compressor;
|
||||
@ -39,7 +42,6 @@ import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
@ -76,8 +78,6 @@ import java.util.zip.Inflater;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import static java.lang.System.arraycopy;
|
||||
|
||||
public class MainUtil {
|
||||
/*
|
||||
* Generic non plugin related utils
|
||||
@ -132,13 +132,6 @@ public class MainUtil {
|
||||
return size.get();
|
||||
}
|
||||
|
||||
public static double getJavaVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
int pos = version.indexOf('.');
|
||||
pos = version.indexOf('.', pos + 1);
|
||||
return Double.parseDouble(version.substring(0, pos));
|
||||
}
|
||||
|
||||
public static void traverse(Path path, final BiConsumer<Path, BasicFileAttributes> onEach) {
|
||||
try {
|
||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||
@ -507,45 +500,6 @@ public class MainUtil {
|
||||
return new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
||||
}
|
||||
|
||||
public static void sendCompressedMessage(FaweStreamChangeSet set, FawePlayer actor) {
|
||||
try {
|
||||
long elements = set.size();
|
||||
long compressedSize = set.getCompressedSize();
|
||||
if (compressedSize == 0) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* BlockVector
|
||||
* - reference to the object --> 8 bytes
|
||||
* - object header (java internals) --> 8 bytes
|
||||
* - double x, y, z --> 24 bytes
|
||||
*
|
||||
* BaseBlock
|
||||
* - reference to the object --> 8 bytes
|
||||
* - object header (java internals) --> 8 bytes
|
||||
* - short id, data --> 4 bytes
|
||||
* - NBTCompound (assuming null) --> 4 bytes
|
||||
*
|
||||
* There are usually two lists for the block changes:
|
||||
* 2 * BlockVector + 2 * BaseBlock = 128b
|
||||
*
|
||||
* WE has a lot more overhead, this is just a generous lower bound
|
||||
*
|
||||
* This compares FAWE's usage to standard WE.
|
||||
*/
|
||||
long total = 128 * elements;
|
||||
|
||||
long ratio = total / compressedSize;
|
||||
long saved = total - compressedSize;
|
||||
|
||||
if (ratio > 3 && !Fawe.isMainThread() && actor != null) {
|
||||
BBC.COMPRESSED.send(actor, saved, ratio);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Thread[] getThreads() {
|
||||
ThreadGroup rootGroup = Thread.currentThread( ).getThreadGroup( );
|
||||
ThreadGroup parentGroup;
|
||||
@ -667,47 +621,6 @@ public class MainUtil {
|
||||
}
|
||||
e.printStackTrace(); }
|
||||
|
||||
public static String[] getTrace(Throwable e) {
|
||||
if (e == null) {
|
||||
return new String[0];
|
||||
}
|
||||
StackTraceElement[] elems = e.getStackTrace();
|
||||
String[] msg = new String[elems.length];//[elems.length + 1];
|
||||
// HashSet<String> packages = new HashSet<>();
|
||||
for (int i = 0; i < elems.length; i++) {
|
||||
StackTraceElement elem = elems[i];
|
||||
elem.getLineNumber();
|
||||
String methodName = elem.getMethodName();
|
||||
int index = elem.getClassName().lastIndexOf('.');
|
||||
String className = elem.getClassName();
|
||||
// if (!(index == -1 || className.startsWith("io.netty") || className.startsWith("javax") || className.startsWith("java") || className.startsWith("sun") || className.startsWith("net.minecraft") || className.startsWith("org.spongepowered") || className.startsWith("org.bukkit") || className.startsWith("com.google"))) {
|
||||
// packages.add(className.substring(0, index-1));
|
||||
// }
|
||||
String name = className.substring(index == -1 ? 0 : index + 1);
|
||||
name = name.length() == 0 ? elem.getClassName() : name;
|
||||
String argString = "(...)";
|
||||
try {
|
||||
for (Method method : Class.forName(elem.getClassName()).getDeclaredMethods()) {
|
||||
if (method.getName().equals(methodName)) {
|
||||
Class<?>[] params = method.getParameterTypes();
|
||||
argString = "";
|
||||
String prefix = "";
|
||||
for (Class param : params) {
|
||||
argString += prefix + param.getSimpleName();
|
||||
prefix = ",";
|
||||
}
|
||||
argString = "[" + method.getReturnType().getSimpleName() + "](" + argString + ")";
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
msg[i] = name + "." + methodName + argString + ":" + elem.getLineNumber();
|
||||
}
|
||||
// msg[msg.length-1] = StringMan.getString(packages);
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static int[] regionNameToCoords(String fileName) {
|
||||
int[] res = new int[2];
|
||||
int len = fileName.length() - 4;
|
||||
@ -935,7 +848,7 @@ public class MainUtil {
|
||||
long age = now - file.lastModified();
|
||||
if (age > timeDiff) {
|
||||
pool.submit(file::delete);
|
||||
if (printDebug) BBC.FILE_DELETED.send(null, file);
|
||||
if (printDebug) BBC.FILE_DELETED.send((Player)null, file);
|
||||
}
|
||||
});
|
||||
pool.shutdown();
|
||||
@ -946,51 +859,4 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public enum OS {
|
||||
LINUX, WINDOWS, MACOS, UNKNOWN;
|
||||
}
|
||||
|
||||
public static File getWorkingDirectory(String applicationName) {
|
||||
String userHome = System.getProperty("user.home", ".");
|
||||
File workingDirectory;
|
||||
switch (getPlatform()) {
|
||||
case LINUX:
|
||||
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||
break;
|
||||
case WINDOWS:
|
||||
String applicationData = System.getenv("APPDATA");
|
||||
if (applicationData != null) {
|
||||
workingDirectory = new File(applicationData, "." + applicationName + '/');
|
||||
} else {
|
||||
workingDirectory = new File(userHome, '.' + applicationName + '/');
|
||||
}
|
||||
break;
|
||||
case MACOS:
|
||||
workingDirectory = new File(userHome, "Library/Application Support/" + applicationName);
|
||||
break;
|
||||
default:
|
||||
workingDirectory = new File(userHome, applicationName + '/');
|
||||
}
|
||||
if ((!workingDirectory.exists()) && (!workingDirectory.mkdirs())) {
|
||||
throw new RuntimeException("The working directory could not be created: " + workingDirectory);
|
||||
}
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
public static OS getPlatform() {
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
if (osName.contains("win")) {
|
||||
return OS.WINDOWS;
|
||||
}
|
||||
if (osName.contains("mac")) {
|
||||
return OS.MACOS;
|
||||
}
|
||||
if (osName.contains("linux")) {
|
||||
return OS.LINUX;
|
||||
}
|
||||
if (osName.contains("unix")) {
|
||||
return OS.LINUX;
|
||||
}
|
||||
return OS.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
@ -57,31 +57,6 @@ public class ReflectionUtils9 {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends Enum<?>> void clearEnum(Class<T> enumType) {
|
||||
// 0. Sanity checks
|
||||
if (!Enum.class.isAssignableFrom(enumType)) {
|
||||
throw new RuntimeException("class " + enumType + " is not an instance of Enum");
|
||||
}
|
||||
// 1. Lookup "$VALUES" holder in enum class and get previous enum instances
|
||||
Field valuesField = null;
|
||||
Field[] fields = enumType.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getName().contains("$VALUES")) {
|
||||
valuesField = field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
AccessibleObject.setAccessible(new Field[]{valuesField}, true);
|
||||
try {
|
||||
setFailsafeFieldValue(valuesField, null, Array.newInstance(enumType, 0));
|
||||
// 6. Clean enum cache
|
||||
cleanEnumCache(enumType);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object makeEnum(Class<?> enumClass, String value, int ordinal) throws Exception {
|
||||
Constructor<?> constructor = Unsafe.class.getDeclaredConstructors()[0];
|
||||
constructor.setAccessible(true);
|
||||
|
@ -44,17 +44,7 @@ import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
|
||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.extent.FastWorldEditExtent;
|
||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||
import com.boydti.fawe.object.extent.HeightBoundExtent;
|
||||
import com.boydti.fawe.object.extent.MultiRegionExtent;
|
||||
import com.boydti.fawe.object.extent.NullExtent;
|
||||
import com.boydti.fawe.object.extent.ProcessedWEExtent;
|
||||
import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
||||
import com.boydti.fawe.object.extent.SlowExtent;
|
||||
import com.boydti.fawe.object.extent.SourceMaskExtent;
|
||||
import com.boydti.fawe.object.extent.StripNBTExtent;
|
||||
import com.boydti.fawe.object.extent.*;
|
||||
import com.boydti.fawe.object.function.SurfaceRegionFunction;
|
||||
import com.boydti.fawe.object.mask.ResettableMask;
|
||||
import com.boydti.fawe.object.pattern.ExistingPattern;
|
||||
@ -68,6 +58,9 @@ import com.boydti.fawe.util.Perm;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.wrappers.WorldWrapper;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
@ -88,17 +81,7 @@ import com.sk89q.worldedit.function.block.BlockReplace;
|
||||
import com.sk89q.worldedit.function.block.Naturalizer;
|
||||
import com.sk89q.worldedit.function.generator.ForestGenerator;
|
||||
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMaskBuilder;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.MaskUnion;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -120,8 +103,8 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionTimeoutException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
@ -139,6 +122,9 @@ import com.sk89q.worldedit.regions.EllipsoidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryShape;
|
||||
import com.sk89q.worldedit.regions.shape.RegionShape;
|
||||
@ -150,22 +136,27 @@ import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||
import com.sk89q.worldedit.world.SimpleWorld;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.*;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
/**
|
||||
* An {@link Extent} that handles history, {@link BlockBag}s, change limits,
|
||||
* block re-ordering, and much more. Most operations in WorldEdit use this class.
|
||||
@ -213,7 +204,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
|
||||
private final World world;
|
||||
@SuppressWarnings("ProtectedField")
|
||||
protected final World world;
|
||||
private String worldName;
|
||||
private FaweQueue queue;
|
||||
private boolean wrapped;
|
||||
@ -245,7 +237,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
super(world);
|
||||
this.worldName = worldName == null ? world == null ? queue == null ? "" : queue.getWorldName() : world.getName() : worldName;
|
||||
if (world == null && this.worldName != null) world = FaweAPI.getWorld(this.worldName);
|
||||
|
||||
this.world = world;
|
||||
|
||||
if (bus == null) {
|
||||
bus = WorldEdit.getInstance().getEventBus();
|
||||
}
|
||||
@ -650,6 +644,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return changeTask != null ? changeTask : history != null ? history.getChangeSet() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be removed very soon. Use getChangeSet()
|
||||
*/
|
||||
@Deprecated
|
||||
public FaweChangeSet getChangeTask() {
|
||||
return changeTask;
|
||||
}
|
||||
@ -867,7 +865,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
*
|
||||
* @param enabled true to enable
|
||||
*/
|
||||
public void setFastMode(final boolean enabled) {
|
||||
public void setFastMode(boolean enabled) {
|
||||
this.fastMode = enabled;
|
||||
disableHistory(enabled);
|
||||
}
|
||||
@ -1004,6 +1002,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
/**
|
||||
* Disable all buffering extents.
|
||||
*
|
||||
* @see #setReorderMode(ReorderMode)
|
||||
* @see #setBatchingChunks(boolean)
|
||||
*/
|
||||
public void disableBuffering() {
|
||||
@ -1021,12 +1020,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(final BlockVector2 position) {
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return this.extent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
this.changes++;
|
||||
return this.extent.setBiome(position, biome);
|
||||
}
|
||||
@ -1272,19 +1271,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
public boolean setBlockIfAir(final BlockVector3 position, final BlockStateHolder block) throws MaxChangedBlocksException {
|
||||
return this.getBlock(position).getBlockType().getMaterial().isAir() && this.setBlock(position, block);
|
||||
}
|
||||
// private int setBlocks(Set<BlockVector3> vset, Pattern pattern) throws MaxChangedBlocksException {
|
||||
// int affected = 0;
|
||||
// for (BlockVector3 v : vset) {
|
||||
// affected += setBlock(v, pattern) ? 1 : 0;
|
||||
// }
|
||||
// return affected;
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Entity createEntity(final com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
||||
Entity result = this.extent.createEntity(location, entity);
|
||||
return result;
|
||||
public Entity createEntity(com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
||||
return this.extent.createEntity(location, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1615,7 +1606,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
MaskIntersection mask = new MaskIntersection(
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
new BoundedHeightMask(
|
||||
Math.max((origin.getBlockY() - depth) + 1, getMinimumPoint().getBlockY()),
|
||||
Math.max(origin.getBlockY() - depth + 1, getMinimumPoint().getBlockY()),
|
||||
Math.min(getMaximumPoint().getBlockY(), origin.getBlockY())),
|
||||
Masks.negate(new ExistingBlockMask(this)));
|
||||
|
||||
@ -1735,6 +1726,15 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return wrapped || getMask() != null || getSourceMask() != null || history != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove blocks of a certain type nearby a given position.
|
||||
*
|
||||
* @param position center position of cuboid
|
||||
* @param blockType the block type to match
|
||||
* @param apothem an apothem of the cuboid, where the minimum is 1
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int removeNear(BlockVector3 position, BlockType blockType, int apothem) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -1800,8 +1800,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (pattern instanceof BlockStateHolder) {
|
||||
return setBlocks(region, (BlockStateHolder) pattern);
|
||||
}
|
||||
final BlockReplace replace = new BlockReplace(EditSession.this, pattern);
|
||||
final RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionVisitor visitor = new RegionVisitor(region, replace, queue instanceof MappedFaweQueue ? (MappedFaweQueue) queue : null);
|
||||
Operations.completeBlindly(visitor);
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
@ -1900,7 +1900,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeCuboidFaces( Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
public int makeCuboidFaces(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
@ -1972,7 +1972,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
@ -2002,6 +2002,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
*/
|
||||
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
|
||||
checkNotNull(block);
|
||||
|
||||
return overlayCuboidBlocks(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
@ -2017,6 +2018,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionOffset offset = new RegionOffset(BlockVector3.UNIT_Y, replace);
|
||||
int minY = region.getMinimumPoint().getBlockY();
|
||||
@ -2045,10 +2047,6 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
return this.changes = naturalizer.getAffected();
|
||||
}
|
||||
|
||||
public int stackCuboidRegion(final Region region, final BlockVector3 dir, final int count, final boolean copyAir) {
|
||||
return stackCuboidRegion(region, dir, count, copyAir, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stack a cuboid region.
|
||||
*
|
||||
@ -2063,6 +2061,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
checkNotNull(region);
|
||||
checkNotNull(dir);
|
||||
checkArgument(count >= 1, "count >= 1 required");
|
||||
|
||||
BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
BlockVector3 to = region.getMinimumPoint();
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(this, region, this, to);
|
||||
@ -2094,22 +2093,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @return number of blocks moved
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, BlockStateHolder replacement) throws MaxChangedBlocksException {
|
||||
return moveRegion(region, dir, distance, copyAir, true, false, replacement);
|
||||
}
|
||||
|
||||
public int moveRegion(final Region region, final BlockVector3 dir, final int distance, final boolean copyAir, final boolean copyEntities, final boolean copyBiomes, BlockStateHolder replacement) {
|
||||
return moveRegion(region, dir, distance, copyAir, copyEntities, copyBiomes, (Pattern) replacement);
|
||||
}
|
||||
|
||||
public int moveRegion(final Region region, final BlockVector3 dir, final int distance, final boolean copyAir, final boolean copyEntities, final boolean copyBiomes, Pattern replacement) {
|
||||
public int moveRegion(Region region, BlockVector3 dir, int distance, boolean copyAir, boolean copyEntities, boolean copyBiomes, Pattern replacement) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(dir);
|
||||
checkArgument(distance >= 1, "distance >= 1 required");
|
||||
final BlockVector3 displace = dir.multiply(distance);
|
||||
BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance));
|
||||
|
||||
final BlockVector3 displace = dir.multiply(distance);
|
||||
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
|
||||
final BlockVector3 to = region.getMinimumPoint().add(dir.multiply(distance));
|
||||
|
||||
BlockVector3 disAbs = displace.abs();
|
||||
|
||||
@ -2122,10 +2113,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
|
||||
if (replacement == null) replacement = BlockTypes.AIR.getDefaultState();
|
||||
final BlockReplace remove = replacement instanceof ExistingPattern ? null : new BlockReplace(this, replacement);
|
||||
|
||||
copy.setCopyBiomes(copyBiomes);
|
||||
copy.setCopyingEntities(copyEntities);
|
||||
copy.setSourceFunction(remove);
|
||||
copy.setSourceFunction(remove); // Remove
|
||||
copy.setRemovingEntities(true);
|
||||
copy.setRepetitions(1);
|
||||
Mask sourceMask = getSourceMask();
|
||||
if (sourceMask != null) {
|
||||
@ -2179,6 +2170,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
public int drainArea(BlockVector3 origin, double radius, boolean waterlogged) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkArgument(radius >= 0, "radius >= 0 required");
|
||||
|
||||
Mask liquidMask;
|
||||
// Not thread safe, use hardcoded liquidmask
|
||||
// if (getWorld() != null) {
|
||||
@ -2188,9 +2180,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
liquidMask = new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
||||
MaskIntersection mask = new MaskIntersection(
|
||||
new BoundedHeightMask(0, getWorld().getMaxY()),
|
||||
new RegionMask(
|
||||
new EllipsoidRegion(null, origin,
|
||||
Vector3.at(radius, radius, radius))), liquidMask);
|
||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||
liquidMask);
|
||||
BlockReplace replace;
|
||||
if (waterlogged) {
|
||||
replace = new BlockReplace(this, new WaterloggedRemover(this));
|
||||
@ -2207,6 +2198,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
Operations.completeBlindly(visitor);
|
||||
|
||||
return this.changes = visitor.getAffected();
|
||||
}
|
||||
|
||||
@ -2287,11 +2279,14 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
|
||||
private int makeCylinder(BlockVector3 pos, final Pattern block, double radiusX, double radiusZ, int height, double thickness, final boolean filled) {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
radiusZ += 0.5;
|
||||
|
||||
MutableBlockVector3 posv = new MutableBlockVector3(pos);
|
||||
if (height == 0) {
|
||||
return this.changes;
|
||||
return 0;
|
||||
} else if (height < 0) {
|
||||
height = -height;
|
||||
posv.mutY(posv.getY() - height);
|
||||
@ -2320,8 +2315,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
double nextMinXn = 0;
|
||||
final double minInvRadiusX = 1 / (radiusX - thickness);
|
||||
final double minInvRadiusZ = 1 / (radiusZ - thickness);
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
double dx2 = nextMinXn * nextMinXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
@ -2329,8 +2323,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
double nextZn = 0;
|
||||
double nextMinZn = 0;
|
||||
dx = xn * xn;
|
||||
forZ:
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
double dz2 = nextMinZn * nextMinZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
@ -2357,14 +2350,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextZn = 0;
|
||||
dx = xn * xn;
|
||||
forZ:
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
dz = zn * zn;
|
||||
@ -2509,6 +2500,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
public int makeSphere(BlockVector3 pos, Pattern block, double radiusX, double radiusY, double radiusZ, boolean filled) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
radiusX += 0.5;
|
||||
radiusY += 0.5;
|
||||
radiusZ += 0.5;
|
||||
@ -2526,26 +2519,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
|
||||
double nextXn = invRadiusX;
|
||||
double dx, dy, dz, dxz, dxyz;
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
forX: for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
dx = xn * xn;
|
||||
double dx = xn * xn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextZn = invRadiusZ;
|
||||
forZ:
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
forZ: for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
dz = zn * zn;
|
||||
dxz = dx + dz;
|
||||
double dz = zn * zn;
|
||||
double dxz = dx + dz;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
double nextYn = invRadiusY;
|
||||
|
||||
forY:
|
||||
for (int y = 0; y <= ceilRadiusY; ++y) {
|
||||
forY: for (int y = 0; y <= ceilRadiusY; ++y) {
|
||||
final double yn = nextYn;
|
||||
dy = yn * yn;
|
||||
dxyz = dxz + dy;
|
||||
double dy = yn * yn;
|
||||
double dxyz = dxz + dy;
|
||||
nextYn = (y + 1) * invRadiusY;
|
||||
|
||||
if (dxyz > 1) {
|
||||
@ -2783,13 +2772,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
||||
if (block.getBlockType() == BlockTypes.DIRT ||
|
||||
(!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) {
|
||||
if (setBlock(pt, grass)) {
|
||||
break loop;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) {
|
||||
break loop;
|
||||
break;
|
||||
} else if (block.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
break loop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import com.boydti.fawe.object.schematic.Schematic;
|
||||
import com.boydti.fawe.util.ImgurUtility;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
@ -85,9 +86,11 @@ import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||
|
||||
|
||||
/**
|
||||
* Clipboard commands.
|
||||
*/
|
||||
@ -101,9 +104,9 @@ public class ClipboardCommands extends MethodCommands {
|
||||
*/
|
||||
public ClipboardCommands(WorldEdit worldEdit) {
|
||||
super(worldEdit);
|
||||
checkNotNull(worldEdit);
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
aliases = { "/lazycopy" },
|
||||
flags = "em",
|
||||
@ -233,17 +236,17 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/cut"},
|
||||
flags = "em",
|
||||
usage = "[leave-id]",
|
||||
desc = "Cut the selection to the clipboard",
|
||||
help = "Copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
aliases = { "/cut" },
|
||||
flags = "em",
|
||||
usage = "[leave-id]",
|
||||
desc = "Cut the selection to the clipboard",
|
||||
help = "Copy the selection to the clipboard\n" +
|
||||
"Flags:\n" +
|
||||
" -e will also cut entities\n" +
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||
max = 1
|
||||
" -m sets a source mask so that excluded blocks become air\n" +
|
||||
" -b copies biomes\n" +
|
||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.cut")
|
||||
@Logging(REGION)
|
||||
@ -434,20 +437,20 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/paste"},
|
||||
usage = "",
|
||||
flags = "saobe",
|
||||
desc = "Paste the clipboard's contents",
|
||||
help =
|
||||
"Pastes the clipboard's contents.\n" +
|
||||
"Flags:\n" +
|
||||
" -a skips air blocks\n" +
|
||||
" -b skips pasting biomes\n" +
|
||||
" -e skips pasting entities\n" +
|
||||
" -o pastes at the original position\n" +
|
||||
" -s selects the region after pasting",
|
||||
min = 0,
|
||||
max = 0
|
||||
aliases = { "/paste" },
|
||||
usage = "",
|
||||
flags = "saobe",
|
||||
desc = "Paste the clipboard's contents",
|
||||
help =
|
||||
"Pastes the clipboard's contents.\n" +
|
||||
"Flags:\n" +
|
||||
" -a skips air blocks\n" +
|
||||
" -b skips pasting biomes\n" +
|
||||
" -e skips pasting entities\n" +
|
||||
" -o pastes at the original position\n" +
|
||||
" -s selects the region after pasting",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.paste")
|
||||
@Logging(PLACEMENT)
|
||||
@ -455,6 +458,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
@Switch('a') boolean ignoreAirBlocks, @Switch('o') boolean atOrigin,
|
||||
@Switch('b') boolean ignoreBiomes, @Switch('e') boolean ignoreEntities,
|
||||
@Switch('s') boolean selectPasted) throws WorldEditException {
|
||||
|
||||
ClipboardHolder holder = session.getClipboard();
|
||||
if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) {
|
||||
place(player, session, editSession, ignoreAirBlocks, atOrigin, selectPasted);
|
||||
@ -462,6 +466,7 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
Clipboard clipboard = holder.getClipboard();
|
||||
Region region = clipboard.getRegion();
|
||||
|
||||
BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player);
|
||||
checkPaste(player, editSession, to, holder, clipboard);
|
||||
Operation operation = holder
|
||||
@ -543,12 +548,12 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/rotate"},
|
||||
usage = "<y-axis> [<x-axis>] [<z-axis>]",
|
||||
desc = "Rotate the contents of the clipboard",
|
||||
help = "Non-destructively rotate the contents of the clipboard.\n" +
|
||||
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
||||
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||
aliases = { "/rotate" },
|
||||
usage = "<y-axis> [<x-axis>] [<z-axis>]",
|
||||
desc = "Rotate the contents of the clipboard",
|
||||
help = "Non-destructively rotate the contents of the clipboard.\n" +
|
||||
"Angles are provided in degrees and a positive angle will result in a clockwise rotation. " +
|
||||
"Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n"
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.rotate")
|
||||
public void rotate(Player player, LocalSession session, Double yRotate, @Optional Double xRotate, @Optional Double zRotate) throws WorldEditException {
|
||||
@ -564,13 +569,13 @@ public class ClipboardCommands extends MethodCommands {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"/flip"},
|
||||
usage = "[<direction>]",
|
||||
desc = "Flip the contents of the clipboard",
|
||||
help =
|
||||
"Flips the contents of the clipboard across the point from which the copy was made.\n",
|
||||
min = 0,
|
||||
max = 1
|
||||
aliases = { "/flip" },
|
||||
usage = "[<direction>]",
|
||||
desc = "Flip the contents of the clipboard",
|
||||
help =
|
||||
"Flips the contents of the clipboard across the point from which the copy was made.\n",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.flip")
|
||||
public void flip(Player player, LocalSession session,
|
||||
@ -584,16 +589,14 @@ public class ClipboardCommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = { "clearclipboard" },
|
||||
usage = "",
|
||||
desc = "Clear your clipboard",
|
||||
min = 0,
|
||||
max = 0
|
||||
usage = "",
|
||||
desc = "Clear your clipboard",
|
||||
min = 0,
|
||||
max = 0
|
||||
)
|
||||
@CommandPermissions("worldedit.clipboard.clear")
|
||||
public void clearClipboard(Player player, LocalSession session) throws WorldEditException {
|
||||
session.setClipboard(null);
|
||||
BBC.CLIPBOARD_CLEARED.send(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,10 +20,15 @@
|
||||
package com.sk89q.worldedit.command.composition;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.object.extent.FaweRegionExtent;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
@ -52,8 +57,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class SelectionCommand extends SimpleCommand<Operation> {
|
||||
|
||||
private final CommandExecutor<Contextual<? extends Operation>> delegate;
|
||||
@ -116,11 +119,6 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
||||
fc.fillCuboid(0, 15, minY, maxY, 0, 15, block.getInternalId());
|
||||
fc.optimize();
|
||||
|
||||
int bcx = (current.minX) >> 4;
|
||||
int bcz = (current.minZ) >> 4;
|
||||
|
||||
int tcx = (current.maxX) >> 4;
|
||||
int tcz = (current.maxZ) >> 4;
|
||||
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
|
||||
MainUtil.chunkTaskSync(current, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
@ -181,7 +179,7 @@ public class SelectionCommand extends SimpleCommand<Operation> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPermission0(CommandLocals locals) {
|
||||
protected boolean testPermission0(CommandLocals locals) {
|
||||
return locals.get(Actor.class).hasPermission(permission);
|
||||
}
|
||||
|
||||
|
@ -19,18 +19,17 @@
|
||||
|
||||
package com.sk89q.worldedit.extension.factory.parser;
|
||||
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.jnbt.JSON2NBT;
|
||||
import com.boydti.fawe.jnbt.NBTException;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.NotABlockException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
|
||||
import com.sk89q.worldedit.blocks.SignBlock;
|
||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
||||
@ -42,9 +41,6 @@ import com.sk89q.worldedit.extension.input.NoMatchException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
@ -59,9 +55,6 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Parses block input strings.
|
||||
@ -163,11 +156,11 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
|
||||
private BaseBlock parseLogic(String input, ParserContext context) throws InputParseException {
|
||||
BlockType blockType = null;
|
||||
String[] blockAndExtraData = input.trim().split("\\|", 2);
|
||||
blockAndExtraData[0] = woolMapper(blockAndExtraData[0]);
|
||||
|
||||
BlockState state = null;
|
||||
CompoundTag nbt = null;
|
||||
|
||||
// Legacy matcher
|
||||
if (context.isTryingLegacy()) {
|
||||
@ -196,6 +189,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
}
|
||||
|
||||
CompoundTag nbt = null;
|
||||
if (state == null) {
|
||||
String typeString;
|
||||
String stateString = null;
|
||||
@ -209,14 +203,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
if (typeString == null || typeString.isEmpty()) {
|
||||
throw new InputParseException("Invalid format");
|
||||
}
|
||||
// PosX
|
||||
String[] stateProperties = EMPTY_STRING_ARRAY;
|
||||
if (typeString.matches("pos[0-9]+")) {
|
||||
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
|
||||
// Get the block type from the "primary position"
|
||||
final World world = context.requireWorld();
|
||||
final BlockVector3 primaryPosition;
|
||||
try {
|
||||
primaryPosition = context.requireSession().getRegionSelector(world).getVerticies().get(index - 1);
|
||||
primaryPosition = context.requireSession().getRegionSelector(world).getPrimaryPosition();
|
||||
} catch (IncompleteRegionException e) {
|
||||
throw new InputParseException("Your selection is not complete.");
|
||||
}
|
||||
@ -227,33 +221,15 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||
// Get the block type from the item in the user's off hand.
|
||||
state = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
|
||||
} else if (typeString.matches("slot[0-9]+")) {
|
||||
int slot = Integer.parseInt(typeString.substring(4)) - 1;
|
||||
Actor actor = context.requireActor();
|
||||
if (!(actor instanceof Player)) {
|
||||
throw new InputParseException("The user is not a player!");
|
||||
}
|
||||
Player player = (Player) actor;
|
||||
BlockBag bag = player.getInventoryBlockBag();
|
||||
if (bag == null || !(bag instanceof SlottableBlockBag)) {
|
||||
throw new InputParseException("Unsupported!");
|
||||
}
|
||||
SlottableBlockBag slottable = (SlottableBlockBag) bag;
|
||||
BaseItem item = slottable.getItem(slot);
|
||||
|
||||
if (!item.getType().hasBlockType()) {
|
||||
throw new InputParseException("You're not holding a block!");
|
||||
}
|
||||
state = item.getType().getBlockType().getDefaultState();
|
||||
nbt = item.getNbtData();
|
||||
} else {
|
||||
// Attempt to lookup a block from ID or name.
|
||||
BlockType type = BlockTypes.parse(typeString.toLowerCase());
|
||||
if (type != null) state = type.getDefaultState();
|
||||
if (state == null) {
|
||||
|
||||
if (type == null) {
|
||||
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
|
||||
}
|
||||
}
|
||||
if (nbt == null) nbt = state.getNbtData();
|
||||
nbt = state.getNbtData();
|
||||
|
||||
if (stateString != null) {
|
||||
state = BlockState.get(state.getBlockType(), "[" + stateString + "]", state);
|
||||
@ -288,7 +264,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
|
||||
// Check if the item is allowed
|
||||
BlockType blockType = state.getBlockType();
|
||||
blockType = state.getBlockType();
|
||||
if (context.isRestricted()) {
|
||||
Actor actor = context.requireActor();
|
||||
if (actor != null && !actor.hasPermission("worldedit.anyblock")
|
||||
&& worldEdit.getConfiguration().checkDisallowedBlocks(state)) {
|
||||
throw new DisallowedUsageException("You are not allowed to use '" + input + "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (nbt != null) return validate(context, state.toBaseBlock(nbt));
|
||||
|
||||
@ -299,7 +282,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
|
||||
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
|
||||
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
|
||||
return validate(context, new SignBlock(state, text));
|
||||
return new SignBlock(state, text);
|
||||
} else if (blockType == BlockTypes.SPAWNER) {
|
||||
// Allow setting mob spawn type
|
||||
if (blockAndExtraData.length > 1) {
|
||||
@ -311,27 +294,23 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
}
|
||||
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
|
||||
final String finalMobName = mobName.toLowerCase();
|
||||
throw new SuggestInputParseException("Unknown mob type '" + mobName + "'", mobName, () -> Stream.of(MobType.values())
|
||||
.map(m -> m.getName().toLowerCase())
|
||||
.filter(s -> s.startsWith(finalMobName))
|
||||
.collect(Collectors.toList()));
|
||||
throw new NoMatchException("Unknown mob type '" + mobName + "'");
|
||||
}
|
||||
return validate(context, new MobSpawnerBlock(state, mobName));
|
||||
return new MobSpawnerBlock(state, mobName);
|
||||
} else {
|
||||
return validate(context, new MobSpawnerBlock(state, MobType.PIG.getName()));
|
||||
return new MobSpawnerBlock(state, MobType.PIG.getName());
|
||||
}
|
||||
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {
|
||||
// allow setting type/player/rotation
|
||||
if (blockAndExtraData.length <= 1) {
|
||||
return validate(context, new SkullBlock(state));
|
||||
return new SkullBlock(state);
|
||||
}
|
||||
|
||||
String type = blockAndExtraData[1];
|
||||
|
||||
return validate(context, new SkullBlock(state, type.replace(" ", "_"))); // valid MC usernames
|
||||
return new SkullBlock(state, type.replace(" ", "_")); // valid MC usernames
|
||||
} else {
|
||||
return validate(context, state.toBaseBlock());
|
||||
return state.toBaseBlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.sk89q.worldedit.extent.inventory;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
|
||||
public interface SlottableBlockBag {
|
||||
BaseItem getItem(int slot);
|
||||
|
||||
void setItem(int slot, BaseItem block);
|
||||
|
||||
default int size() {
|
||||
return 36;
|
||||
}
|
||||
|
||||
default int getSelectedSlot() {
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -24,16 +24,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Executes several region functions in order.
|
||||
*/
|
||||
public class CombinedRegionFunction implements RegionFunction {
|
||||
|
||||
private RegionFunction[] functions;
|
||||
private final List<RegionFunction> functions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Create a combined region function.
|
||||
@ -48,8 +49,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
*/
|
||||
public CombinedRegionFunction(Collection<RegionFunction> functions) {
|
||||
checkNotNull(functions);
|
||||
this.functions = functions.toArray(new RegionFunction[functions.size()]);
|
||||
|
||||
this.functions.addAll(functions);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
* @param function an array of functions to match
|
||||
*/
|
||||
public CombinedRegionFunction(RegionFunction... function) {
|
||||
this.functions = function;
|
||||
this(Arrays.asList(checkNotNull(function)));
|
||||
}
|
||||
|
||||
public static CombinedRegionFunction combine(RegionFunction function, RegionFunction add) {
|
||||
@ -82,9 +82,7 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
*/
|
||||
public void add(Collection<RegionFunction> functions) {
|
||||
checkNotNull(functions);
|
||||
ArrayList<RegionFunction> functionsList = new ArrayList<>(Arrays.asList(this.functions));
|
||||
functionsList.addAll(functions);
|
||||
this.functions = functionsList.toArray(new RegionFunction[functionsList.size()]);
|
||||
this.functions.addAll(functions);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,6 +105,4 @@ public class CombinedRegionFunction implements RegionFunction {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,17 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.function;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Passes calls to {@link #apply(com.sk89q.worldedit.Vector)} to the
|
||||
* delegate {@link com.sk89q.worldedit.function.RegionFunction} if they
|
||||
* Passes calls to {@link #apply(BlockVector3)} to the
|
||||
* delegate {@link RegionFunction} if they
|
||||
* match the given mask.
|
||||
*/
|
||||
public class RegionMaskTestFunction implements RegionFunction {
|
||||
@ -41,7 +38,7 @@ public class RegionMaskTestFunction implements RegionFunction {
|
||||
* Create a new masking filter.
|
||||
*
|
||||
* @param mask the mask
|
||||
* @param function the function
|
||||
* @param failure the function
|
||||
*/
|
||||
public RegionMaskTestFunction(Mask mask, RegionFunction success, RegionFunction failure) {
|
||||
checkNotNull(success);
|
||||
|
@ -38,7 +38,7 @@ public class BlockReplace implements RegionFunction {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param extent an extent
|
||||
* @param extent an extent
|
||||
* @param pattern a pattern
|
||||
*/
|
||||
public BlockReplace(Extent extent, Pattern pattern) {
|
||||
@ -53,6 +53,4 @@ public class BlockReplace implements RegionFunction {
|
||||
return pattern.apply(extent, position, position);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -36,8 +32,6 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
@ -54,11 +48,11 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
/**
|
||||
* Make a new copy.
|
||||
*
|
||||
* @param source the source extent
|
||||
* @param from the source offset
|
||||
* @param source the source extent
|
||||
* @param from the source offset
|
||||
* @param destination the destination extent
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
* @param to the destination offset
|
||||
* @param transform a transform to apply to positions (after source offset, before destination offset)
|
||||
*/
|
||||
public ExtentBlockCopy(Extent source, BlockVector3 from, Extent destination, BlockVector3 to, Transform transform) {
|
||||
checkNotNull(source);
|
||||
@ -75,11 +69,13 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BaseBlock block = source.getFullBlock(position);
|
||||
BlockVector3 orig = position.subtract(from);
|
||||
BlockVector3 transformed = transform.apply(orig.toVector3()).toBlockPoint();
|
||||
|
||||
// Apply transformations to NBT data if necessary
|
||||
BaseBlock block = transformNbtData(source.getFullBlock(position));
|
||||
block = transformNbtData(block);
|
||||
|
||||
return destination.setBlock(transformed.add(to), block);
|
||||
}
|
||||
|
||||
@ -118,6 +114,4 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,21 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Makes a layer of grass on top, three layers of dirt below, and smooth stone
|
||||
* only below that for all layers that originally consist of grass, dirt,
|
||||
@ -76,15 +71,15 @@ public class Naturalizer implements LayerFunction {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
case 0:
|
||||
editSession.setBlock(position, BlockTypes.GRASS_BLOCK);
|
||||
editSession.setBlock(position, BlockTypes.GRASS_BLOCK.getDefaultState());
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
editSession.setBlock(position, BlockTypes.DIRT);
|
||||
editSession.setBlock(position, BlockTypes.DIRT.getDefaultState());
|
||||
break;
|
||||
default:
|
||||
editSession.setBlock(position, BlockTypes.STONE);
|
||||
editSession.setBlock(position, BlockTypes.STONE.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,15 @@
|
||||
package com.sk89q.worldedit.function.entity;
|
||||
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.jnbt.ByteTag;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.FloatTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -38,14 +40,12 @@ import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Direction.Flag;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Copies entities provided to the function to the provided destination
|
||||
* {@code Extent}.
|
||||
@ -61,10 +61,10 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param from the from position
|
||||
* @param from the from position
|
||||
* @param destination the destination {@code Extent}
|
||||
* @param to the destination position
|
||||
* @param transform the transformation to apply to both position and orientation
|
||||
* @param to the destination position
|
||||
* @param transform the transformation to apply to both position and orientation
|
||||
*/
|
||||
public ExtentEntityCopy(Vector3 from, Extent destination, Vector3 to, Transform transform) {
|
||||
checkNotNull(from);
|
||||
@ -103,7 +103,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
Location location = entity.getLocation();
|
||||
|
||||
Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
|
||||
Vector3 newPosition = transform.apply(location.subtract(pivot));
|
||||
Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||
Vector3 newDirection;
|
||||
|
||||
newDirection = transform.isIdentity() ?
|
||||
@ -111,12 +111,13 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
: transform.apply(location.getDirection()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||
newLocation = new Location(destination, newPosition.add(to.round().add(0.5, 0.5, 0.5)), newDirection);
|
||||
|
||||
// Some entities store their position data in NBT
|
||||
state = transformNbtData(state);
|
||||
|
||||
boolean success = destination.createEntity(newLocation, state) != null;
|
||||
|
||||
// Remove
|
||||
if (isRemoving()) {
|
||||
if (isRemoving() && success) {
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
@ -135,6 +136,7 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
*/
|
||||
private BaseEntity transformNbtData(BaseEntity state) {
|
||||
CompoundTag tag = state.getNbtData();
|
||||
|
||||
if (tag != null) {
|
||||
boolean changed = false;
|
||||
// Handle hanging entities (paintings, item frames, etc.)
|
||||
@ -192,8 +194,8 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
double xz = Math.cos(pitch);
|
||||
Vector3 direction = Vector3.at(-xz * Math.sin(yaw), -Math.sin(pitch), xz * Math.cos(yaw));
|
||||
direction = transform.apply(direction);
|
||||
FloatTag yawTag = new FloatTag((float)direction.toYaw());
|
||||
FloatTag pitchTag = new FloatTag((float)direction.toPitch());
|
||||
FloatTag yawTag = new FloatTag((float) direction.toYaw());
|
||||
FloatTag pitchTag = new FloatTag((float) direction.toPitch());
|
||||
values.put("Rotation", new ListTag(FloatTag.class, Arrays.asList(yawTag, pitchTag)));
|
||||
}
|
||||
|
||||
@ -205,6 +207,4 @@ public class ExtentEntityCopy implements EntityFunction {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,12 @@
|
||||
|
||||
package com.sk89q.worldedit.function.factory;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
@ -33,10 +39,6 @@ import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.regions.NullRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.regions.Regions.*;
|
||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||
|
||||
public class Paint implements Contextual<Operation> {
|
||||
|
||||
private final Extent destination;
|
||||
|
@ -25,7 +25,6 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -84,9 +83,9 @@ public class FloraGenerator implements RegionFunction {
|
||||
*/
|
||||
public static Pattern getDesertPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add((BlockTypes.DEAD_BUSH.getDefaultState()), 30);
|
||||
pattern.add((BlockTypes.CACTUS.getDefaultState()), 20);
|
||||
pattern.add((BlockTypes.AIR.getDefaultState()), 300);
|
||||
pattern.add(new BlockPattern(BlockTypes.DEAD_BUSH.getDefaultState()), 30);
|
||||
pattern.add(new BlockPattern(BlockTypes.CACTUS.getDefaultState()), 20);
|
||||
pattern.add(new BlockPattern(BlockTypes.AIR.getDefaultState()), 300);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@ -97,9 +96,9 @@ public class FloraGenerator implements RegionFunction {
|
||||
*/
|
||||
public static Pattern getTemperatePattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add((BlockTypes.GRASS.getDefaultState()), 300);
|
||||
pattern.add((BlockTypes.POPPY.getDefaultState()), 5);
|
||||
pattern.add((BlockTypes.DANDELION.getDefaultState()), 5);
|
||||
pattern.add(new BlockPattern(BlockTypes.GRASS.getDefaultState()), 300);
|
||||
pattern.add(new BlockPattern(BlockTypes.POPPY.getDefaultState()), 5);
|
||||
pattern.add(new BlockPattern(BlockTypes.DANDELION.getDefaultState()), 5);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import com.sk89q.worldedit.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -53,26 +52,23 @@ public class ForestGenerator implements RegionFunction {
|
||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||
BlockState block = editSession.getBlock(position);
|
||||
BlockType t = block.getBlockType();
|
||||
switch (t.getInternalId()) {
|
||||
case BlockID.GRASS_BLOCK:
|
||||
case BlockID.DIRT:
|
||||
treeType.generate(editSession, position.add(0, 1, 0));
|
||||
return true;
|
||||
case BlockID.TALL_GRASS: // TODO: This list needs to be moved
|
||||
case BlockID.DEAD_BUSH:
|
||||
case BlockID.POPPY:
|
||||
case BlockID.DANDELION:
|
||||
editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// and then trick the generator here by directly setting into the world
|
||||
editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// so that now the generator can generate the tree
|
||||
boolean success = treeType.generate(editSession, position);
|
||||
if (!success) {
|
||||
editSession.setBlock(position, block); // restore on failure
|
||||
}
|
||||
return success;
|
||||
default: // Trees won't grow on this!
|
||||
return false;
|
||||
|
||||
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
||||
return treeType.generate(editSession, position.add(0, 1, 0));
|
||||
} else if (t.getMaterial().isReplacedDuringPlacement()) {
|
||||
// since the implementation's tree generators generally don't generate in non-air spots,
|
||||
// we trick editsession history here in the first call
|
||||
editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// and then trick the generator here by directly setting into the world
|
||||
editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// so that now the generator can generate the tree
|
||||
boolean success = treeType.generate(editSession, position);
|
||||
if (!success) {
|
||||
editSession.setBlock(position, block); // restore on failure
|
||||
}
|
||||
return success;
|
||||
} else { // Trees won't grow on this!
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
int h = random.nextInt(3) - 1;
|
||||
BlockVector3 p;
|
||||
|
||||
BlockStateHolder log = BlockTypes.OAK_LOG.getDefaultState();
|
||||
BlockState log = BlockTypes.OAK_LOG.getDefaultState();
|
||||
|
||||
switch (t) {
|
||||
case 0:
|
||||
@ -167,7 +167,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockStateHolder leavesBlock = BlockTypes.OAK_LEAVES.getDefaultState();
|
||||
BlockState leavesBlock = BlockTypes.OAK_LEAVES.getDefaultState();
|
||||
|
||||
if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
||||
editSession.setBlock(position, leavesBlock);
|
||||
@ -187,7 +187,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @return a pumpkin pattern
|
||||
*/
|
||||
public static Pattern getPumpkinPattern() {
|
||||
return BlockTypes.PUMPKIN.getDefaultState();
|
||||
return new BlockPattern(BlockTypes.PUMPKIN.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -208,6 +208,6 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @return a melon pattern
|
||||
*/
|
||||
public static Pattern getMelonPattern() {
|
||||
return (BlockTypes.MELON.getDefaultState());
|
||||
return new BlockPattern(BlockTypes.MELON.getDefaultState());
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,28 @@
|
||||
/*
|
||||
* 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.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.boydti.fawe.object.collection.FastBitSet;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -32,16 +53,31 @@ public class BlockMask extends AbstractExtentMask {
|
||||
private final long[][] bitSets;
|
||||
protected final static long[] ALL = new long[0];
|
||||
|
||||
|
||||
/**
|
||||
* Create a new block mask.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param blocks a list of blocks to match
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||
super(extent);
|
||||
checkNotNull(blocks);
|
||||
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new block mask.
|
||||
*
|
||||
* @param extent the extent
|
||||
* @param block an array of blocks to match
|
||||
*/
|
||||
@Deprecated
|
||||
public BlockMask(Extent extent, BaseBlock... blocks) {
|
||||
public BlockMask(Extent extent, BaseBlock... block) {
|
||||
super(extent);
|
||||
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
|
||||
checkNotNull(block);
|
||||
this.bitSets = new BlockMaskBuilder().addBlocks(block).optimize().getBits();
|
||||
}
|
||||
|
||||
public BlockMask() {
|
||||
@ -236,5 +272,4 @@ public class BlockMask extends AbstractExtentMask {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,43 @@
|
||||
/*
|
||||
* 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.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* A mask that checks whether blocks at the given positions are matched by
|
||||
* a block in a list.
|
||||
*
|
||||
* <p>This mask checks for ONLY the block type. If state should also be checked,
|
||||
* use {@link BlockMask}.</p>
|
||||
*/
|
||||
public class BlockTypeMask extends AbstractExtentMask {
|
||||
private final boolean[] types;
|
||||
|
||||
@ -57,12 +80,10 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
/**
|
||||
* Add the given blocks to the list of criteria.
|
||||
*
|
||||
* @param blocks an array of blocks
|
||||
* @param block an array of blocks
|
||||
*/
|
||||
public void add(BlockType... blocks) {
|
||||
for (BlockType type : blocks) {
|
||||
this.types[type.getInternalId()] = true;
|
||||
}
|
||||
public void add(BlockType... block) {
|
||||
add(Arrays.asList(checkNotNull(block)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,12 @@ public class ExpressionMask extends AbstractMask {
|
||||
if (expression.getEnvironment() instanceof WorldEditExpressionEnvironment) {
|
||||
((WorldEditExpressionEnvironment) expression.getEnvironment()).setCurrentBlock(vector.toVector3());
|
||||
}
|
||||
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
|
||||
if (timeout == null) {
|
||||
return expression.evaluate(vector.getX(), vector.getY(), vector.getZ()) > 0;
|
||||
} else {
|
||||
return expression.evaluate(new double[]{vector.getX(), vector.getY(), vector.getZ()},
|
||||
timeout.getAsInt()) > 0;
|
||||
}
|
||||
} catch (EvaluationException e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,14 +19,23 @@
|
||||
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Combines several masks and requires that all masks return true
|
||||
@ -177,6 +186,7 @@ public class MaskIntersection extends AbstractMask {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -194,4 +204,5 @@ public class MaskIntersection extends AbstractMask {
|
||||
}
|
||||
return new MaskIntersection2D(mask2dList);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,13 +18,13 @@
|
||||
*/
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Various utility functions related to {@link Mask} and {@link Mask2D}.
|
||||
*/
|
||||
|
@ -1,3 +1,22 @@
|
||||
/*
|
||||
* 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.sk89q.worldedit.function.mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -6,9 +25,6 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Checks whether another mask tests true for a position that is offset
|
||||
* a given vector.
|
||||
@ -21,7 +37,7 @@ public class OffsetMask extends AbstractMask {
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param mask the mask
|
||||
* @param mask the mask
|
||||
* @param offset the offset
|
||||
*/
|
||||
public OffsetMask(Mask mask, BlockVector3 offset) {
|
||||
@ -85,5 +101,4 @@ public class OffsetMask extends AbstractMask {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,28 @@
|
||||
/*
|
||||
* 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.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -22,6 +40,7 @@ public class SolidBlockMask extends BlockTypeMask {
|
||||
public SolidBlockMask(Extent extent) {
|
||||
super(extent, getTypes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Extent extent = getExtent();
|
||||
@ -35,5 +54,4 @@ public class SolidBlockMask extends BlockTypeMask {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,17 +20,18 @@
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.boydti.fawe.object.changeset.FaweChangeSet;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.history.changeset.ChangeSet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Performs an undo or redo from a given {@link ChangeSet}.
|
||||
*/
|
||||
@ -46,13 +47,14 @@ public class ChangeSetExecutor implements Operation {
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param changeSet the change set
|
||||
* @param type type of change
|
||||
* @param context the undo context
|
||||
* @param type type of change
|
||||
* @param context the undo context
|
||||
*/
|
||||
private ChangeSetExecutor(ChangeSet changeSet, Type type, UndoContext context, BlockBag blockBag, int inventory) {
|
||||
checkNotNull(changeSet);
|
||||
checkNotNull(type);
|
||||
checkNotNull(context);
|
||||
|
||||
this.type = type;
|
||||
this.context = context;
|
||||
if (changeSet instanceof FaweChangeSet) {
|
||||
@ -66,15 +68,15 @@ public class ChangeSetExecutor implements Operation {
|
||||
|
||||
@Override
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (type == Type.UNDO) {
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().undo(context);
|
||||
}
|
||||
} else {
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().redo(context);
|
||||
while (iterator.hasNext()) {
|
||||
Change change = iterator.next();
|
||||
if (type == Type.UNDO) {
|
||||
change.undo(context);
|
||||
} else {
|
||||
change.redo(context);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -94,7 +96,7 @@ public class ChangeSetExecutor implements Operation {
|
||||
* Create a new undo operation.
|
||||
*
|
||||
* @param changeSet the change set
|
||||
* @param context an undo context
|
||||
* @param context an undo context
|
||||
* @return an operation
|
||||
*/
|
||||
@Deprecated
|
||||
@ -106,7 +108,7 @@ public class ChangeSetExecutor implements Operation {
|
||||
* Create a new redo operation.
|
||||
*
|
||||
* @param changeSet the change set
|
||||
* @param context an undo context
|
||||
* @param context an undo context
|
||||
* @return an operation
|
||||
*/
|
||||
@Deprecated
|
||||
@ -114,5 +116,4 @@ public class ChangeSetExecutor implements Operation {
|
||||
return new ChangeSetExecutor(changeSet, Type.REDO, context, null, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -27,14 +27,11 @@ import com.boydti.fawe.object.function.block.BiomeCopy;
|
||||
import com.boydti.fawe.object.function.block.CombinedBlockCopy;
|
||||
import com.boydti.fawe.object.function.block.SimpleBlockCopy;
|
||||
import com.boydti.fawe.util.MaskTraverser;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
@ -42,32 +39,26 @@ import com.sk89q.worldedit.function.CombinedRegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionMaskTestFunction;
|
||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.block.ExtentBlockCopy;
|
||||
import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Makes a copy of a portion of one extent to another extent or another point.
|
||||
* <p>
|
||||
*
|
||||
* <p>This is a forward extent copy, meaning that it iterates over the blocks
|
||||
* in the source extent, and will copy as many blocks as there are in the
|
||||
* source. Therefore, interpolation will not occur to fill in the gaps.</p>
|
||||
@ -82,11 +73,11 @@ public class ForwardExtentCopy implements Operation {
|
||||
private int repetitions = 1;
|
||||
private Mask sourceMask = Masks.alwaysTrue();
|
||||
private boolean removingEntities;
|
||||
private boolean copyingEntities = true; // default to true for backwards compatibility, sort of
|
||||
private RegionFunction sourceFunction = null;
|
||||
private Transform transform = new Identity();
|
||||
private Transform currentTransform = null;
|
||||
private int affected;
|
||||
private boolean copyEntities = true;
|
||||
private boolean copyBiomes = false;
|
||||
private RegionFunction filterFunction;
|
||||
|
||||
@ -94,8 +85,8 @@ public class ForwardExtentCopy implements Operation {
|
||||
* Create a new copy using the region's lowest minimum point as the
|
||||
* "from" position.
|
||||
*
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param destination the destination extent
|
||||
* @param to the destination position
|
||||
* @see #ForwardExtentCopy(Extent, Region, BlockVector3, Extent, BlockVector3) the main constructor
|
||||
@ -107,11 +98,11 @@ public class ForwardExtentCopy implements Operation {
|
||||
/**
|
||||
* Create a new copy.
|
||||
*
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param from the source position
|
||||
* @param source the source extent
|
||||
* @param region the region to copy
|
||||
* @param from the source position
|
||||
* @param destination the destination extent
|
||||
* @param to the destination position
|
||||
* @param to the destination position
|
||||
*/
|
||||
public ForwardExtentCopy(Extent source, Region region, BlockVector3 from, Extent destination, BlockVector3 to) {
|
||||
checkNotNull(source);
|
||||
@ -128,7 +119,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
|
||||
/**
|
||||
* Get the transformation that will occur on every point.
|
||||
* <p>
|
||||
*
|
||||
* <p>The transformation will stack with each repetition.</p>
|
||||
*
|
||||
* @return a transformation
|
||||
@ -150,7 +141,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
|
||||
/**
|
||||
* Get the mask that gets applied to the source extent.
|
||||
* <p>
|
||||
*
|
||||
* <p>This mask can be used to filter what will be copied from the source.</p>
|
||||
*
|
||||
* @return a source mask
|
||||
@ -159,14 +150,6 @@ public class ForwardExtentCopy implements Operation {
|
||||
return sourceMask;
|
||||
}
|
||||
|
||||
public void setCopyingEntities(boolean copyEntities) {
|
||||
this.copyEntities = copyEntities;
|
||||
}
|
||||
|
||||
public boolean isCopyingEntities() {
|
||||
return copyEntities;
|
||||
}
|
||||
|
||||
public void setCopyBiomes(boolean copyBiomes) {
|
||||
this.copyBiomes = copyBiomes;
|
||||
}
|
||||
@ -206,7 +189,6 @@ public class ForwardExtentCopy implements Operation {
|
||||
*
|
||||
* @param function a source function, or null if none is to be applied
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSourceFunction(RegionFunction function) {
|
||||
this.sourceFunction = function;
|
||||
}
|
||||
@ -230,6 +212,24 @@ public class ForwardExtentCopy implements Operation {
|
||||
this.repetitions = repetitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether entities should be copied along with blocks.
|
||||
*
|
||||
* @return true if copying
|
||||
*/
|
||||
public boolean isCopyingEntities() {
|
||||
return copyingEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether entities should be copied along with blocks.
|
||||
*
|
||||
* @param copyingEntities true if copying
|
||||
*/
|
||||
public void setCopyingEntities(boolean copyingEntities) {
|
||||
this.copyingEntities = copyingEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether entities that are copied should be removed.
|
||||
*
|
||||
|
@ -30,17 +30,15 @@ public final class Operations {
|
||||
private Operations() {
|
||||
}
|
||||
|
||||
private static RunContext context = new RunContext();
|
||||
|
||||
/**
|
||||
* Complete a given operation synchronously until it completes.
|
||||
*
|
||||
* @param operation operation to execute
|
||||
* @param op operation to execute
|
||||
* @throws WorldEditException WorldEdit exception
|
||||
*/
|
||||
public static void complete(Operation operation) throws WorldEditException {
|
||||
while (operation != null) {
|
||||
operation = operation.resume(context);
|
||||
public static void complete(Operation op) throws WorldEditException {
|
||||
while (op != null) {
|
||||
op = op.resume(new RunContext());
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,11 +46,19 @@ public final class Operations {
|
||||
* Complete a given operation synchronously until it completes. Catch all
|
||||
* errors that is not {@link MaxChangedBlocksException} for legacy reasons.
|
||||
*
|
||||
* @param operation operation to execute
|
||||
* @param op operation to execute
|
||||
* @throws MaxChangedBlocksException thrown when too many blocks have been changed
|
||||
*/
|
||||
public static void completeLegacy(Operation operation) throws MaxChangedBlocksException {
|
||||
completeBlindly(operation);
|
||||
public static void completeLegacy(Operation op) throws MaxChangedBlocksException {
|
||||
while (op != null) {
|
||||
try {
|
||||
op = op.resume(new RunContext());
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
throw e;
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,25 +66,16 @@ public final class Operations {
|
||||
* {@link com.sk89q.worldedit.WorldEditException} exceptions as
|
||||
* {@link java.lang.RuntimeException}s.
|
||||
*
|
||||
* @param operation operation to execute
|
||||
* @param op operation to execute
|
||||
*/
|
||||
public static void completeBlindly(Operation operation) {
|
||||
try {
|
||||
while (operation != null) {
|
||||
operation = operation.resume(context);
|
||||
public static void completeBlindly(Operation op) {
|
||||
while (op != null) {
|
||||
try {
|
||||
op = op.resume(new RunContext());
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (WorldEditException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void completeSmart(final Operation op, final Runnable whenDone, final boolean threadsafe) {
|
||||
completeBlindly(op);
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,12 +22,10 @@ package com.sk89q.worldedit.function.pattern;
|
||||
import com.boydti.fawe.object.collection.RandomCollection;
|
||||
import com.boydti.fawe.object.random.SimpleRandom;
|
||||
import com.boydti.fawe.object.random.TrueRandom;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
@ -36,8 +34,6 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Uses a random pattern of a weighted list of patterns.
|
||||
*/
|
||||
@ -83,8 +79,8 @@ public class RandomPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 get) {
|
||||
return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(get);
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
return collection.next(position.getBlockX(), position.getBlockY(), position.getBlockZ()).apply(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,9 +90,9 @@ public class RepeatingExtentPattern extends AbstractExtentPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 p) {
|
||||
int x = (Math.abs((p.getX() + offset.getX())) % size.getBlockX()) + origin.getX();
|
||||
int y = (Math.abs((p.getY() + offset.getY())) % size.getBlockY()) + origin.getY();
|
||||
int z = (Math.abs((p.getZ() + offset.getZ())) % size.getBlockZ()) + origin.getZ();
|
||||
int x = Math.abs(p.getX() + offset.getX()) % size.getBlockX() + origin.getX();
|
||||
int y = Math.abs(p.getY() + offset.getY()) % size.getBlockY() + origin.getY();
|
||||
int z = Math.abs(p.getZ() + offset.getZ()) % size.getBlockZ() + origin.getZ();
|
||||
return getExtent().getFullBlock(mutable.setComponents(x, y, z));
|
||||
}
|
||||
|
||||
|
@ -26,19 +26,18 @@ import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.object.IntegerTrio;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -98,13 +97,17 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
*/
|
||||
public BreadthFirstSearch(RegionFunction function) {
|
||||
this(function, Integer.MAX_VALUE);
|
||||
checkNotNull(function);
|
||||
}
|
||||
|
||||
public BreadthFirstSearch(final RegionFunction function, int maxDepth) {
|
||||
public BreadthFirstSearch(RegionFunction function, int maxDepth) {
|
||||
this(function, maxDepth, null);
|
||||
checkNotNull(function);
|
||||
|
||||
}
|
||||
|
||||
public BreadthFirstSearch(final RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
|
||||
public BreadthFirstSearch(RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
|
||||
checkNotNull(function);
|
||||
FaweQueue fq = faweQueue != null ? faweQueue.getQueue() : null;
|
||||
this.mFaweQueue = fq instanceof MappedFaweQueue ? (MappedFaweQueue) fq : null;
|
||||
this.queue = new BlockVectorSet();
|
||||
@ -126,7 +129,7 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the list of directions will be visited.
|
||||
*
|
||||
@ -179,21 +182,15 @@ public abstract class BreadthFirstSearch implements Operation {
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
|
||||
public void visit(BlockVector3 position) {
|
||||
if (!isVisited(position)) {
|
||||
isVisitable(position, position); // Ignore this, just to initialize mask on this point
|
||||
queue.add(position);
|
||||
visited.add(position);
|
||||
BlockVector3 blockVector = position;
|
||||
if (!visited.contains(blockVector)) {
|
||||
isVisitable(blockVector, blockVector); // Ignore this, just to initialize mask on this point
|
||||
queue.add(blockVector);
|
||||
visited.add(blockVector);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetVisited() {
|
||||
queue.clear();
|
||||
visited.clear();
|
||||
affected = 0;
|
||||
}
|
||||
|
||||
public void setVisited(BlockVectorSet set) {
|
||||
this.visited = set;
|
||||
}
|
||||
|
@ -20,26 +20,26 @@
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.function.EntityFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Visits entities as provided by an {@code Iterator}.
|
||||
*/
|
||||
public class EntityVisitor implements Operation {
|
||||
|
||||
private final Iterator<? extends Entity> iterator;
|
||||
private final EntityFunction function;
|
||||
private int affected = 0;
|
||||
private final Iterator<? extends Entity> iterator;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -47,12 +47,11 @@ public class EntityVisitor implements Operation {
|
||||
* @param iterator the iterator
|
||||
* @param function the function
|
||||
*/
|
||||
public EntityVisitor(final Iterator<? extends Entity> iterator, final EntityFunction function) {
|
||||
public EntityVisitor(Iterator<? extends Entity> iterator, EntityFunction function) {
|
||||
checkNotNull(iterator);
|
||||
checkNotNull(function);
|
||||
|
||||
this.function = function;
|
||||
this.iterator = iterator;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,16 +60,17 @@ public class EntityVisitor implements Operation {
|
||||
* @return the number of affected
|
||||
*/
|
||||
public int getAffected() {
|
||||
return this.affected;
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(final RunContext run) throws WorldEditException {
|
||||
while (this.iterator.hasNext()) {
|
||||
if (this.function.apply(this.iterator.next())) {
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
while (iterator.hasNext()) {
|
||||
if (function.apply(iterator.next())) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -79,9 +79,8 @@ public class EntityVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(final List<String> messages) {
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(BBC.VISITOR_ENTITY.format(getAffected()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,20 +24,17 @@ import com.boydti.fawe.example.MappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Applies region functions to columns in a {@link FlatRegion}.
|
||||
*/
|
||||
@ -52,11 +49,12 @@ public class FlatRegionVisitor implements Operation {
|
||||
* Create a new visitor.
|
||||
*
|
||||
* @param flatRegion a flat region
|
||||
* @param function a function to apply to columns
|
||||
* @param function a function to apply to columns
|
||||
*/
|
||||
public FlatRegionVisitor(final FlatRegion flatRegion, final FlatRegionFunction function) {
|
||||
public FlatRegionVisitor(FlatRegion flatRegion, FlatRegionFunction function) {
|
||||
checkNotNull(flatRegion);
|
||||
checkNotNull(function);
|
||||
|
||||
this.function = function;
|
||||
this.iterator = flatRegion.asFlatRegion();
|
||||
}
|
||||
@ -76,20 +74,25 @@ public class FlatRegionVisitor implements Operation {
|
||||
* @return the number of affected
|
||||
*/
|
||||
public int getAffected() {
|
||||
return this.affected;
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(final RunContext run) throws WorldEditException {
|
||||
if (this.queue != null) {
|
||||
for (final BlockVector2 pt : new Fast2DIterator(this.iterator, queue)) {
|
||||
if (this.function.apply(pt)) affected++;
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (queue != null) {
|
||||
for (BlockVector2 pt : new Fast2DIterator(iterator, queue)) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final BlockVector2 pt : this.iterator) {
|
||||
if (this.function.apply(pt)) affected++;
|
||||
for (BlockVector2 pt : this.iterator) {
|
||||
if (function.apply(pt)) {
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -98,10 +101,9 @@ public class FlatRegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(final List<String> messages) {
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(BBC.VISITOR_FLAT.format(getAffected()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
@ -31,9 +34,6 @@ import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Visits the layers within a region.
|
||||
*
|
||||
@ -54,14 +54,15 @@ public class LayerVisitor implements Operation {
|
||||
* Create a new visitor.
|
||||
*
|
||||
* @param flatRegion the flat region to visit
|
||||
* @param minY the minimum Y to stop the search at
|
||||
* @param maxY the maximum Y to begin the search at
|
||||
* @param function the layer function to apply t blocks
|
||||
* @param minY the minimum Y to stop the search at
|
||||
* @param maxY the maximum Y to begin the search at
|
||||
* @param function the layer function to apply t blocks
|
||||
*/
|
||||
public LayerVisitor(FlatRegion flatRegion, int minY, int maxY, LayerFunction function) {
|
||||
checkNotNull(flatRegion);
|
||||
checkArgument(minY <= maxY, "minY <= maxY required");
|
||||
checkNotNull(function);
|
||||
|
||||
this.flatRegion = flatRegion;
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
@ -119,6 +120,7 @@ public class LayerVisitor implements Operation {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -130,5 +132,4 @@ public class LayerVisitor implements Operation {
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,8 +20,7 @@
|
||||
package com.sk89q.worldedit.function.visitor;
|
||||
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
@ -36,10 +35,9 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
||||
/**
|
||||
* Create a new recursive visitor.
|
||||
*
|
||||
* @param mask the mask
|
||||
* @param mask the mask
|
||||
* @param function the function
|
||||
*/
|
||||
|
||||
public NonRisingVisitor(Mask mask, RegionFunction function) {
|
||||
this(mask, function, Integer.MAX_VALUE, null);
|
||||
}
|
||||
@ -48,13 +46,11 @@ public class NonRisingVisitor extends RecursiveVisitor {
|
||||
super(mask, function, depth, hasFaweQueue);
|
||||
Collection<BlockVector3> directions = getDirections();
|
||||
directions.clear();
|
||||
directions.add(BlockVector3.at(1, 0, 0));
|
||||
directions.add(BlockVector3.at(-1, 0, 0));
|
||||
directions.add(BlockVector3.at(0, 0, 1));
|
||||
directions.add(BlockVector3.at(0, 0, -1));
|
||||
directions.add(BlockVector3.at(0, -1, 0));
|
||||
directions.add(BlockVector3.UNIT_X);
|
||||
directions.add(BlockVector3.UNIT_MINUS_X);
|
||||
directions.add(BlockVector3.UNIT_Z);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Z);
|
||||
directions.add(BlockVector3.UNIT_MINUS_Y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -34,21 +34,21 @@ public class RecursiveVisitor extends BreadthFirstSearch {
|
||||
|
||||
private final Mask mask;
|
||||
|
||||
public RecursiveVisitor(final Mask mask, final RegionFunction function) {
|
||||
public RecursiveVisitor(Mask mask, RegionFunction function) {
|
||||
this(mask, function, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new recursive visitor.
|
||||
*
|
||||
* @param mask the mask
|
||||
* @param mask the mask
|
||||
* @param function the function
|
||||
*/
|
||||
public RecursiveVisitor(final Mask mask, final RegionFunction function, int maxDepth) {
|
||||
public RecursiveVisitor(Mask mask, RegionFunction function, int maxDepth) {
|
||||
this(mask, function, maxDepth, null);
|
||||
}
|
||||
|
||||
public RecursiveVisitor(final Mask mask, final RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
|
||||
public RecursiveVisitor(Mask mask, RegionFunction function, int maxDepth, HasFaweQueue faweQueue) {
|
||||
super(function, maxDepth, faweQueue);
|
||||
checkNotNull(mask);
|
||||
this.mask = mask;
|
||||
@ -58,6 +58,4 @@ public class RecursiveVisitor extends BreadthFirstSearch {
|
||||
protected boolean isVisitable(BlockVector3 from, BlockVector3 to) {
|
||||
return mask.test(to);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,15 @@ import com.boydti.fawe.example.MappedFaweQueue;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.operation.RunContext;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -42,11 +43,10 @@ import java.util.List;
|
||||
public class RegionVisitor implements Operation {
|
||||
|
||||
public final Region region;
|
||||
public final Iterable<? extends BlockVector3> iterable;
|
||||
public final RegionFunction function;
|
||||
private final MappedFaweQueue queue;
|
||||
private boolean useCuboidIterator = false;
|
||||
public int affected = 0;
|
||||
public final Iterable<? extends BlockVector3> iterable;
|
||||
private final MappedFaweQueue queue;
|
||||
|
||||
/**
|
||||
* Deprecated in favor of the other constructors which will preload chunks during iteration
|
||||
@ -68,9 +68,9 @@ public class RegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
public RegionVisitor(Iterable<? extends BlockVector3> iterable, RegionFunction function, HasFaweQueue hasQueue) {
|
||||
region = (iterable instanceof Region) ? (Region) iterable : null;
|
||||
this.iterable = iterable;
|
||||
this.region = iterable instanceof Region ? (Region) iterable : null;
|
||||
this.function = function;
|
||||
this.iterable = iterable;
|
||||
this.queue = hasQueue != null && hasQueue.getQueue() instanceof MappedFaweQueue ? (MappedFaweQueue) hasQueue.getQueue() : null;
|
||||
}
|
||||
|
||||
@ -80,11 +80,11 @@ public class RegionVisitor implements Operation {
|
||||
* @return the number of affected
|
||||
*/
|
||||
public int getAffected() {
|
||||
return this.affected;
|
||||
return affected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation resume(final RunContext run) throws WorldEditException {
|
||||
public Operation resume(RunContext run) throws WorldEditException {
|
||||
if (queue != null && Settings.IMP.QUEUE.PRELOAD_CHUNKS > 1) {
|
||||
/*
|
||||
* The following is done to reduce iteration cost
|
||||
@ -194,9 +194,9 @@ public class RegionVisitor implements Operation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStatusMessages(final List<String> messages) {
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
messages.add(BBC.VISITOR_BLOCK.format(getAffected()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,11 @@ import com.sk89q.worldedit.regions.iterator.RegionIterator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AbstractRegion implements Region {
|
||||
|
||||
|
@ -28,10 +28,9 @@ import com.google.common.io.Resources;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.util.gson.VectorAdapter;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -48,11 +47,8 @@ import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class LegacyMapper {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class);
|
||||
@ -90,7 +86,6 @@ public class LegacyMapper {
|
||||
}
|
||||
String source = Resources.toString(url, Charset.defaultCharset());
|
||||
LegacyDataFile dataFile = gson.fromJson(source, new TypeToken<LegacyDataFile>() {}.getType());
|
||||
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setPreferringWildcard(false);
|
||||
parserContext.setRestricted(false);
|
||||
@ -226,7 +221,7 @@ public class LegacyMapper {
|
||||
Integer combinedId = getLegacyCombined(blockState);
|
||||
return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
|
||||
}
|
||||
|
||||
|
||||
public BaseBlock getBaseBlockFromPlotBlock(PlotBlock plotBlock) {
|
||||
if(plotBlock instanceof StringPlotBlock) {
|
||||
try {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren