本文整理匯總了Java中com.sk89q.worldedit.Vector類的典型用法代碼示例。如果您正苦於以下問題:Java Vector類的具體用法?Java Vector怎麽用?Java Vector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Vector類屬於com.sk89q.worldedit包,在下文中一共展示了Vector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setBlock
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException
{
Player player = WorldGuardExtraFlagsPlugin.getPlugin().getServer().getPlayer(this.actor.getUniqueId());
if (WorldGuardUtils.hasBypass(player))
{
return super.setBlock(location, block);
}
else
{
if (WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(BukkitUtil.toLocation(player.getWorld(), location)).queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.WORLDEDIT) != State.DENY)
{
return super.setBlock(location, block);
}
else
{
return false;
}
}
}
示例2: execute
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
World world = (World) this.world.getSingle(event);
ItemStack block = (ItemStack) this.block.getSingle(event);
RegionManager regionManager = WGBukkit.getRegionManager((org.bukkit.World) world);
if (!regionManager.hasRegion(name)) {
Skript.error("Region \"" + name + "\" in world \"" + world.getName() + "\" does not exists.");
return;
}
Vector v1 = regionManager.getRegion(name).getMaximumPoint();
Vector v2 = regionManager.getRegion(name).getMinimumPoint();
Region region = new CuboidRegion(v1, v2);
BaseBlock b = new BaseBlock(block.getTypeId(), block.getData().getData());
EditSession es = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
try {
es.setBlocks(region, b);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: execute
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
protected void execute(Event event) {
String name = (String) this.name.getSingle(event);
Location loc1 = (Location) this.loc1.getSingle(event);
Location loc2 = (Location) this.loc2.getSingle(event);
World world = (World) this.world.getSingle(event);
int x1 = loc1.getBlockX();
int y1 = loc1.getBlockY();
int z1 = loc1.getBlockZ();
int x2 = loc2.getBlockX();
int y2 = loc2.getBlockY();
int z2 = loc2.getBlockZ();
Vector p1 = new Vector(x1, y1, z1);
Vector p2 = new Vector(x2, y2, z2);
RegionManager regionManager = WGBukkit.getRegionManager(world);
ProtectedCuboidRegion region = new ProtectedCuboidRegion(name, p1.toBlockVector(), p2.toBlockVector());
regionManager.addRegion(region);
try {
regionManager.save();
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: test
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public boolean test(Vector to) {
if (pos == null) {
pos = new MutableBlockVector(to);
}
int dx = pos.getBlockX() - to.getBlockX();
int d = dx * dx;
if (d > maxSqr) {
return false;
}
int dz = pos.getBlockZ() - to.getBlockZ();
d += dz * dz;
if (d > maxSqr) {
return false;
}
int dy = pos.getBlockY() - to.getBlockY();
d += dy * dy;
if (d < minSqr || d > maxSqr) {
return false;
}
return true;
}
示例5: dispatchCUIEvent
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public void dispatchCUIEvent(CUIEvent event) {
if (event instanceof SelectionShapeEvent) {
clear();
this.cuboid = event.getParameters()[0].equalsIgnoreCase("cuboid");
} else if (cuboid && event instanceof SelectionPointEvent) {
SelectionPointEvent spe = (SelectionPointEvent) event;
String[] param = spe.getParameters();
int id = Integer.parseInt(param[0]);
int x = Integer.parseInt(param[1]);
int y = Integer.parseInt(param[2]);
int z = Integer.parseInt(param[3]);
Vector pos = new Vector(x, y, z);
if (id == 0) {
pos1 = pos;
} else {
pos2 = pos;
}
update();
}
}
示例6: createProxy
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
public PlayerProxy createProxy() {
Player player = getPlayer();
World world = getWorldForEditing();
PlatformManager platformManager = WorldEdit.getInstance().getPlatformManager();
Player permActor = platformManager.queryCapability(Capability.PERMISSIONS).matchPlayer(player);
if (permActor == null) {
permActor = player;
}
Player cuiActor = platformManager.queryCapability(Capability.WORLDEDIT_CUI).matchPlayer(player);
if (cuiActor == null) {
cuiActor = player;
}
PlayerProxy proxy = new PlayerProxy(player, permActor, cuiActor, world);
if (world instanceof HeightMapMCAGenerator) {
proxy.setOffset(Vector.ZERO.subtract(((HeightMapMCAGenerator) world).getOrigin()));
}
return proxy;
}
示例7: removeLayers
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Command(
aliases = {"removelayers"},
usage = "<id>",
desc = "Removes matching chunk layers",
help = "Remove if all the selected layers in a chunk match the provided id"
)
@CommandPermissions("worldedit.anvil.removelayer")
public void removeLayers(Player player, EditSession editSession, @Selection Region selection, int id) throws WorldEditException {
Vector min = selection.getMinimumPoint();
Vector max = selection.getMaximumPoint();
int minY = min.getBlockY();
int maxY = max.getBlockY();
RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id);
MCAFilterCounter result = runWithSelection(player, editSession, selection, filter);
if (result != null) {
player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
}
}
示例8: clearContainerBlockContents
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public boolean clearContainerBlockContents(Vector position) {
BaseBlock block = extent.getLazyBlock(position);
if (block.hasNbtData()) {
Map<String, Tag> nbt = ReflectionUtils.getMap(block.getNbtData().getValue());
if (nbt.containsKey("Items")) {
nbt.put("Items", new ListTag(CompoundTag.class, new ArrayList<CompoundTag>()));
try {
extent.setBlock(position, block);
} catch (WorldEditException e) {
e.printStackTrace();
}
}
}
return true;
}
示例9: getInformationLines
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public List<String> getInformationLines() {
final List<String> lines = new ArrayList<String>();
final Vector center = region.getCenter();
if (center.lengthSq() > 0) {
lines.add("Center: " + center);
}
final Vector radius = region.getRadius();
if (radius.lengthSq() > 0) {
lines.add("X/Y/Z radius: " + radius);
}
return lines;
}
示例10: setBlock
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public boolean setBlock(int x1, int y1, int z1, BaseBlock block) throws WorldEditException {
boolean result = false;
Vector pos = getPos(x1, y1, z1);
double sx = pos.getX();
double sy = pos.getY();
double sz = pos.getZ();
double ex = pos.getX() + dx;
double ey = Math.min(maxy, sy + dy);
double ez = pos.getZ() + dz;
for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
result |= super.setBlock(pos, block);
}
}
}
return result;
}
示例11: setBlock
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public boolean setBlock(final Vector location, final BaseBlock block) throws WorldEditException {
if (super.setBlock(location, block)) {
if (MemUtil.isMemoryLimited()) {
if (this.player != null) {
player.sendMessage(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s()));
if (Perm.hasPermission(this.player, "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
}
}
WEManager.IMP.cancelEdit(this, BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY);
return false;
}
return true;
}
return false;
}
示例12: getVertex
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
public static Vector getVertex(Vector pos1, Vector pos2, double lenPercent) {
if (lenPercent <= 1) return Vector.getMidpoint(pos1, pos2);
double curveLen = pos1.distance(pos2) * lenPercent;
double dy = pos2.getY() - pos1.getY();
double dx = pos2.getX() - pos1.getX();
double dz = pos2.getZ() - pos1.getZ();
double dh = Math.sqrt(dx * dx + dz * dz);
double g = Math.sqrt(curveLen * curveLen - dy * dy) / 2;
double a = 0.00001;
for (;g < a * Math.sinh(dh/(2 * a)); a *= 1.00001);
double vertX = (dh-a*Math.log((curveLen + dy)/(curveLen - dy)))/2.0;
double z = (dh/2)/a;
double oY = (dy - curveLen * (Math.cosh(z) / Math.sinh(z))) / 2;
double vertY = a * 1 + oY;
return pos1.add(pos2.subtract(pos1).multiply(vertX / dh).add(0, vertY, 0)).round();
}
示例13: explainPrimarySelection
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
checkNotNull(player);
checkNotNull(session);
checkNotNull(pos);
Message msg;
if (position1 != null && position2 != null) {
msg = BBC.SELECTOR_POS.m(1, position1, region.getArea());
} else {
msg = BBC.SELECTOR_POS.m(1, position1, "");
}
String prefix = WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/";
String cmd = prefix + Commands.getAlias(SelectionCommands.class, "/pos1") + " " + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ();
msg.suggestTip(cmd).send(player);
session.dispatchCUIEvent(player, new SelectionPointEvent(0, pos, getArea()));
}
示例14: hsphere
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Command(
aliases = {"/hsphere"},
usage = "<pattern> <radius>[,<radius>,<radius>] [raised?]",
desc = "Generates a hollow sphere.",
help =
"Generates a hollow sphere.\n" +
"By specifying 3 radii, separated by commas,\n" +
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
"is north/south, up/down, east/west.",
min = 2,
max = 3
)
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void hsphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession, Pattern pattern, Vector radius, @Optional("false") boolean raised, CommandContext context) throws WorldEditException, ParameterException {
sphere(fp, player, session, editSession, pattern, radius, raised, true, context);
}
示例15: swap
import com.sk89q.worldedit.Vector; //導入依賴的package包/類
@Override
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
EditSession sessionA = new EditSessionBuilder(pos1.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
EditSession sessionB = new EditSessionBuilder(pos3.getWorld()).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
CuboidRegion regionA = new CuboidRegion(new Vector(pos1.getX(), pos1.getY(), pos1.getZ()), new Vector(pos2.getX(), pos2.getY(), pos2.getZ()));
CuboidRegion regionB = new CuboidRegion(new Vector(pos3.getX(), pos3.getY(), pos3.getZ()), new Vector(pos4.getX(), pos4.getY(), pos4.getZ()));
ForwardExtentCopy copyA = new ForwardExtentCopy(sessionA, regionA, sessionB, regionB.getMinimumPoint());
ForwardExtentCopy copyB = new ForwardExtentCopy(sessionB, regionB, sessionA, regionA.getMinimumPoint());
try {
Operations.completeLegacy(copyA);
Operations.completeLegacy(copyB);
sessionA.flushQueue();
sessionB.flushQueue();
} catch (MaxChangedBlocksException e) {
e.printStackTrace();
}
TaskManager.IMP.task(whenDone);
}
});
}