use of com.sk89q.worldedit.EditSession in project Skree by Skelril.
the class SkyWarsInstance method showStartingPlatform.
private void showStartingPlatform(boolean present) {
Location<World> platformLocation = startingLocation.add(0, -1, 0);
EditSession editor = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new WorldResolver(getRegion().getExtent()).getWorldEditWorld(), -1);
com.sk89q.worldedit.Vector origin = new com.sk89q.worldedit.Vector(platformLocation.getX(), platformLocation.getY(), platformLocation.getZ());
BaseBlock targetBlock;
if (present) {
targetBlock = WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.STAINED_GLASS, 15);
} else {
targetBlock = WorldEdit.getInstance().getBaseBlockFactory().getBaseBlock(BlockID.AIR);
}
try {
editor.makeCylinder(origin, new SingleBlockPattern(targetBlock), 12, 1, true);
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
}
use of com.sk89q.worldedit.EditSession in project PixelsSkyblock by dudullle.
the class WEManager method count_entities.
public static List<? extends Entity> count_entities(World world, Location loc1, Location loc2) {
EditSession es = new EditSessionBuilder(FaweAPI.getWorld("world")).fastmode(true).build();
CuboidSelection cbs = new CuboidSelection(world, loc1, loc2);
Region r = null;
try {
r = cbs.getRegionSelector().getRegion();
} catch (IncompleteRegionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return es.getEntities(r);
}
use of com.sk89q.worldedit.EditSession in project PixelsSkyblock by dudullle.
the class WEManager method count.
public static List<Countable<Integer>> count(World world, Location loc1, Location loc2) {
EditSession es = new EditSessionBuilder(FaweAPI.getWorld("world")).fastmode(true).build();
CuboidSelection cbs = new CuboidSelection(world, loc1, loc2);
Region r = null;
try {
r = cbs.getRegionSelector().getRegion();
} catch (IncompleteRegionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return es.getBlockDistribution(r);
}
use of com.sk89q.worldedit.EditSession in project PixelsSkyblock by dudullle.
the class WEManager method pasteSchematics.
public static boolean pasteSchematics(World world, File file, Location origin) throws DataException, IOException, MaxChangedBlocksException {
EditSession es = new EditSessionBuilder(FaweAPI.getWorld("world")).fastmode(true).build();
MCEditSchematicFormat.getFormat(file).load(file).paste(es, new Vector(origin.getBlockX(), origin.getBlockY(), origin.getBlockZ()), false);
return true;
}
use of com.sk89q.worldedit.EditSession in project Skree by Skelril.
the class WEDecorator method pasteAt.
public <T> ZoneWorldBoundingBox pasteAt(WorldResolver world, Vector3i origin, String resourceName, Function<ZoneWorldBoundingBox, T> initMapper, Consumer<T> callback) {
EditSession transaction = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world.getWorldEditWorld(), -1);
transaction.setFastMode(true);
transaction.getChangeSet().setRecordChanges(false);
hashRefMap.computeIfAbsent(resourceName, (a) -> {
HashRef ref = new HashRef();
try {
ref.holder = getHolder(resourceName, world.getWorldEditWorld().getWorldData());
} catch (IOException e) {
e.printStackTrace();
}
return ref;
});
HashRef ref = hashRefMap.get(resourceName);
if (ref == null) {
callback.accept(null);
return null;
}
++ref.refCount;
Clipboard clipboard = ref.holder.getClipboard();
Region clipReg = clipboard.getRegion();
clipboard.setOrigin(clipReg.getMinimumPoint());
Operation operation = ref.holder.createPaste(transaction, transaction.getWorld().getWorldData()).to(new Vector(origin.getX(), origin.getY(), origin.getZ())).build();
Vector dimensions = clipboard.getDimensions();
ZoneWorldBoundingBox region = new ZoneWorldBoundingBox(world.getSpongeWorld(), origin, new Vector3i(dimensions.getX(), dimensions.getY(), dimensions.getZ()));
T returnVal = initMapper.apply(region);
RunManager.runOperation(operation, () -> {
RunManager.runOperation(transaction.commit(), () -> {
region.getChunks().forEach(chunk -> {
tf(chunk).resetRelightChecks();
tf(chunk).generateSkylightMap();
tf(chunk).checkLight();
});
callback.accept(returnVal);
if (--ref.refCount == 0) {
hashRefMap.remove(resourceName);
System.gc();
}
});
});
return region;
}
Aggregations