本文整理汇总了Java中org.cubeengine.libcube.util.math.shape.Shape类的典型用法代码示例。如果您正苦于以下问题:Java Shape类的具体用法?Java Shape怎么用?Java Shape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Shape类属于org.cubeengine.libcube.util.math.shape包,在下文中一共展示了Shape类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: define
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
@Command(desc = "Defines a new Region")
public void define(Player context, String name)
{
Shape shape = selector.getSelection(context);
if (shape == null)
{
i18n.send(context, NEGATIVE, "Nothing selected!");
return;
}
World world = selector.getFirstPoint(context).getExtent();
if (manager.hasRegion(world, name))
{
i18n.send(context, NEGATIVE, "There is already a Region named {name}", name);
return;
}
Region region = manager.newRegion(world, shape.getBoundingCuboid(), name);
manager.setActiveRegion(context, region);
i18n.send(context, POSITIVE, "Region {region} created!", region);
}
示例2: redefine
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
@Command(desc = "Redefines an existing Region")
public void redefine(Player context, @Default Region region)
{
Shape shape = selector.getSelection(context);
if (shape == null)
{
i18n.send(context, NEGATIVE, "Nothing selected!");
return;
}
World world = selector.getFirstPoint(context).getExtent();
if (!region.getWorld().equals(world))
{
i18n.send(context, NEGATIVE, "This region is in another world!");
return;
}
manager.changeRegion(region, shape.getBoundingCuboid());
i18n.send(context, POSITIVE, "Region {region} updated!", region);
}
示例3: getSelection
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
public Shape getSelection()
{
for (Location<World> point : this.points)
{
if (point == null) // missing point
{
return null;
}
if (lastPointWorld != point.getExtent()) // points are in different worlds
{
return null;
}
}
if (this.getPoint(0) == null || this.getPoint(1) == null)
{
return null;
}
return this.getSelection0();
}
示例4: spawnNuke
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
/**
* iterates through the points of the shape and spawns a tnt block at the positions.
*
* @return the number of spawned tnt blocks.
*/
public int spawnNuke(Shape shape, World world, int range, boolean unsafe)
{
int numberOfBlocks = 0;
for (Vector3d vector : shape)
{
PrimedTNT tnt = (PrimedTNT)world.createEntity(PRIMED_TNT, vector.clone());
tnt.setVelocity(new Vector3d(0,0,0));
tnt.offer(Keys.EXPLOSION_RADIUS, java.util.Optional.of(range));
// TODO push cause
world.spawnEntity(tnt);
numberOfBlocks++;
if (!unsafe)
{
this.nukeListener.add(tnt);
}
if(numberOfBlocks >= this.module.getConfig().command.nuke.maxTNTAmount)
{
return numberOfBlocks;
}
}
return numberOfBlocks;
}
示例5: hasSelection
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
public boolean hasSelection()
{
Selector selector = this.module.getCore().getModuleManager().getServiceManager().getServiceImplementation(Selector.class);
Shape selection = selector.getSelection(this.getHolder());
return selection != null && selection instanceof Cuboid;
}
示例6: getSelection
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
@Override
public Shape getSelection(Player user)
{
SelectorData data = this.selectorData.get(user.getUniqueId());
return data == null ? null : data.getSelection();
}
示例7: get2DProjection
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
@Override
public Shape get2DProjection(Player user)
{
throw new UnsupportedOperationException("Not supported yet!"); // TODO Shape.projectOnto(Plane)
}
示例8: getSelection0
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
private Shape getSelection0()
{
Vector3d v1 = new Vector3d(this.getPoint(0).getX(), this.getPoint(0).getY(), this.getPoint(0).getZ());
Vector3d v2 = new Vector3d(this.getPoint(1).getX(), this.getPoint(1).getY(), this.getPoint(1).getZ());
return new Cuboid(v1, v2.sub(v1));
}
示例9: nuke
import org.cubeengine.libcube.util.math.shape.Shape; //导入依赖的package包/类
@Command(desc = "Makes a carpet of TNT fall on a player or where you're looking")
public void nuke(CommandSource context,
@Optional Integer diameter,
@Named({"player", "p"}) Player player,
@Named({"height", "h"}) Integer height,
@Named({"range", "r"}) Integer range,
@Flag boolean unsafe,
@Flag boolean quiet)
{
Location<World> location;
range = range == null ? 4 : range;
height = height == null ? 5 : height;
if(range != 4 && !context.hasPermission(module.perms().COMMAND_NUKE_CHANGE_RANGE.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to change the explosion range of the nuke carpet!");
return;
}
if(range < 0 || range > this.module.getConfig().command.nuke.maxExplosionRange)
{
i18n.send(context, NEGATIVE, "The explosion range can't be less than 0 or greater than {integer}", this.module.getConfig().command.nuke.maxExplosionRange);
return;
}
if(player != null)
{
if (!context.equals(player) && !context.hasPermission(module.perms().COMMAND_NUKE_OTHER.getId()))
{
i18n.send(context, NEGATIVE, "You are not allowed to specify a player!");
return;
}
location = ((Player)context).getLocation();
}
else
{
if(!(context instanceof Player))
{
i18n.send(context, NEGATIVE, "This command can only be used by a player!");
return;
}
java.util.Optional<BlockRayHit<World>> end = BlockRay.from(((Player)context)).stopFilter(onlyAirFilter()).distanceLimit(100).build().end();
if (!end.isPresent())
{
throw new IllegalStateException();
}
location = end.get().getLocation();
}
location = this.getSpawnLocation(location, height);
Shape aShape = new Cuboid(new Vector3d(location.getX() + .5, location.getY() + .5, location.getZ()+ .5) , diameter, 1, diameter);
int blockAmount = this.spawnNuke(aShape, location.getExtent(), range, unsafe);
if(!quiet)
{
i18n.send(context, POSITIVE, "You spawned {integer} blocks of tnt.", blockAmount);
}
}