本文整理汇总了Java中org.spongepowered.api.world.TeleportHelper类的典型用法代码示例。如果您正苦于以下问题:Java TeleportHelper类的具体用法?Java TeleportHelper怎么用?Java TeleportHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TeleportHelper类属于org.spongepowered.api.world包,在下文中一共展示了TeleportHelper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: randomLocation
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
private Optional<Location<World>> randomLocation(Player player, int searchDiameter){
Location<World> playerLocation = player.getLocation();
//Adding world border support, otherwise you could murder players by using a location within the border.
WorldBorder border = player.getWorld().getWorldBorder();
Vector3d center = border.getCenter();
double diameter = Math.min(border.getDiameter(), searchDiameter);
double radius = border.getDiameter() / 2;
Random rand = new Random();
int x = (int) (rand.nextInt((int) (center.getX()+diameter)) - radius);
int y = rand.nextInt(256);
int z = rand.nextInt((int) (rand.nextInt((int) (center.getZ()+diameter)) - radius));
Location<World> randLocation = new Location<World>(playerLocation.getExtent(), x, y, z);
TeleportHelper teleportHelper = Sponge.getGame().getTeleportHelper();
return teleportHelper.getSafeLocation(randLocation);
}
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:17,代码来源:RTPExecutor.java
示例2: cast
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
@Override
public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo extendedSkillInfo, SkillModifier skillModifier) {
Player player = character.getPlayer();
Optional<BlockRayHit<World>> optHit = BlockRay.from(player).stopFilter(Utils.SKILL_TARGET_BLOCK_FILTER).build().end();
if (optHit.isPresent()) {
Vector3d lookPos = optHit.get().getBlockPosition().toDouble();
Location<World> worldLocation = new Location<>(player.getWorld(), lookPos);
TeleportHelper helper = Sponge.getGame().getTeleportHelper();
Optional<Location<World>> safeLocation = helper.getSafeLocation(worldLocation);
if (safeLocation.isPresent()) {
player.setLocation(safeLocation.get());
}
}
return SkillResult.OK;
}
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:16,代码来源:SkillTeleport.java
示例3: execute
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
checkIfPlayer(src);
Player p = (Player) src;
Vector3d pos = p.getLocation().getPosition();
TeleportHelper tph = Sponge.getGame().getTeleportHelper();
int tries = 0;
while (tries < this.maxTries) {
tries++;
//Try to find suitable location
Integer x = pos.getFloorX() + RandomUtil.nextInt(-this.maxDistance, this.maxDistance);
Integer z = pos.getFloorZ() + RandomUtil.nextInt(-this.maxDistance, this.maxDistance);
Integer y = LocationUtil.getHighestY(p.getWorld(), x, z).orElse(null);
if (y == null) continue;
Location<World> loc = tph.getSafeLocation(new Location<>(p.getWorld(), x, y, z)).orElse(null);
if (loc == null) continue;
if (this.bannedBlocks.contains(loc.getBlockType()) || this.bannedBlocks.contains(loc.add(0, -1, 0).getBlockType())) continue;
//Found suitable location
Teleportation request = UltimateCore.get().getTeleportService().createTeleportation(p, Arrays.asList(p), new Transform<>(loc, p.getRotation(), p.getScale()), teleportRequest -> {
//Complete
Messages.send(p, "teleport.command.randomteleport.success");
}, (teleportRequest, reason) -> {
}, true, false);
request.start();
return CommandResult.success();
}
throw Messages.error(src, "teleport.command.randomteleport.fail");
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:32,代码来源:RandomTeleportCommand.java
示例4: findBiome
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
public static Optional<Location<World>> findBiome(Player p, BiomeType type) {
int tries = 0;
TeleportHelper tph = Sponge.getGame().getTeleportHelper();
while (tries < maxTries) {
tries++;
//Try to find suitable location
Integer x = RandomUtil.nextInt(-maxDistance, maxDistance);
Integer z = RandomUtil.nextInt(-maxDistance, maxDistance);
//Check if biome matches
MutableBiomeVolume volume = p.getWorld().getBiomeView(new Vector3i(x, 0, z), new Vector3i(x, 0, z)).getBiomeCopy();
p.getWorld().getWorldGenerator().getBiomeGenerator().generateBiomes(volume);
BiomeType biome = volume.getBiome(new Vector3i(x, 0, z));
if (!biome.equals(type)) continue;
//Get y + get safe location
Integer y = LocationUtil.getHighestY(p.getWorld(), x, z).orElse(null);
if (y == null) continue;
Location<World> loc = tph.getSafeLocation(new Location<>(p.getWorld(), x, y, z)).orElse(null);
if (loc == null) continue;
return Optional.of(loc);
}
return Optional.empty();
}
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:29,代码来源:BiomeFindHandler.java
示例5: getTeleportHelper
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
@Override
public TeleportHelper getTeleportHelper() {
return this.teleportHelper;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternGame.java
示例6: ProtectionManager
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
@Inject
ProtectionManager(Settings config, TeleportHelper teleportHelper) {
this.config = config;
this.teleportHelper = teleportHelper;
}
开发者ID:games647,项目名称:FlexibleLogin,代码行数:6,代码来源:ProtectionManager.java
示例7: getTeleportHelper
import org.spongepowered.api.world.TeleportHelper; //导入依赖的package包/类
@Override
public TeleportHelper getTeleportHelper() {
return null;
}
开发者ID:InspireNXE,项目名称:Pulse,代码行数:5,代码来源:SpongeGame.java
注:本文中的org.spongepowered.api.world.TeleportHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论