• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TeleportHelper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReturningWork类代码示例发布时间:2022-05-23
下一篇:
Java Local类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap