當前位置: 首頁>>代碼示例>>Java>>正文


Java Difficulty.NORMAL屬性代碼示例

本文整理匯總了Java中org.spacehq.mc.protocol.data.game.values.setting.Difficulty.NORMAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Difficulty.NORMAL屬性的具體用法?Java Difficulty.NORMAL怎麽用?Java Difficulty.NORMAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.spacehq.mc.protocol.data.game.values.setting.Difficulty的用法示例。


在下文中一共展示了Difficulty.NORMAL屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transformDifficulty

public static Difficulty transformDifficulty(Byte value) {
    if (value == 0) {
        return Difficulty.PEACEFUL;
    } else if (value == 1) {
        return Difficulty.EASY;
    } else if (value == 3) {
        return Difficulty.HARD;
    }
    return Difficulty.NORMAL;
}
 
開發者ID:BeYkeRYkt,項目名稱:CyanWool,代碼行數:10,代碼來源:Transform.java

示例2: loginPlayer

public synchronized Player loginPlayer(Session session) {
    GameProfile profile = session.getFlag(ProtocolConstants.PROFILE_KEY);
    World world = server.getWorldManager().getWorld("world");
    Location location = world.getSpawnLocation();
    CyanPlayer player = new CyanPlayer(server, profile, location);
    player.setPlayerNetwork(new CyanPlayerNetwork(server, session, player));
    // world.getPlayerService().readPlayer(player);
    player.loadData();

    // player.load();
    ServerJoinGamePacket packet = new ServerJoinGamePacket(player.getEntityID(), world.isHardcore(), player.getGameMode(), world.getDimension().getId(), world.getDifficulty(), server.getMaxPlayers(), WorldType.DEFAULT, false);
    session.send(packet);
    players.add(player);

    // Send spawn packet
    ServerPlayerPositionRotationPacket ppacket = new ServerPlayerPositionRotationPacket(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getLocation().getYaw(), player.getLocation().getPitch());
    session.send(ppacket);

    Position position = new Position(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
    ServerSpawnPositionPacket spawnPacket = new ServerSpawnPositionPacket(position);
    session.send(spawnPacket);

    // set time
    player.setTime(0);// TODO

    // Send health
    ServerUpdateHealthPacket healthPacket = new ServerUpdateHealthPacket(20, 20, 1);
    session.send(healthPacket);

    // Send Difficulty
    ServerDifficultyPacket diffPacket = new ServerDifficultyPacket(Difficulty.NORMAL);
    session.send(diffPacket);
    world.getPlayerService().savePlayer(player);

    // Send packets for all players
    for (Packet packets : player.getSpawnPackets()) {
        server.getNetworkServer().sendPacketForAll(packets);
    }

    player.chat("Hello! This test message for CyanWool!");
    player.setMoveable(true);

    // Test sounds
    player.damage(5);
    return player;
}
 
開發者ID:BeYkeRYkt,項目名稱:CyanWool,代碼行數:46,代碼來源:PlayerManager.java


注:本文中的org.spacehq.mc.protocol.data.game.values.setting.Difficulty.NORMAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。