Java Code Examples for protocolsupport.protocol.serializer.MiscSerializer#writeByteEnum()
The following examples show how to use
protocolsupport.protocol.serializer.MiscSerializer#writeByteEnum() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StartGame.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData startgame = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_START_GAME); startgame.writeInt(player.getId()); startgame.writeByte(gamemodeCurrent.getId() | (hardcore ? 0x8 : 0)); if (version.isBefore(ProtocolVersion.MINECRAFT_1_9_1)) { startgame.writeByte(LegacyDimension.getId(dimension)); } else { startgame.writeInt(LegacyDimension.getId(dimension)); } MiscSerializer.writeByteEnum(startgame, Difficulty.HARD); startgame.writeByte(maxplayers); StringSerializer.writeVarIntUTF8String(startgame, "default"); startgame.writeBoolean(reducedDebugInfo); codec.write(startgame); }
Example 2
Source File: ScoreboardTeam.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData scoreboardteam = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_TEAM); StringSerializer.writeString(scoreboardteam, version, name); MiscSerializer.writeByteEnum(scoreboardteam, mode); if ((mode == Mode.CREATE) || (mode == Mode.UPDATE)) { StringSerializer.writeString(scoreboardteam, version, LegacyChat.clampLegacyText(displayName.toLegacyText(clientCache.getLocale()), 32)); Any<String, String> nfix = formatPrefixSuffix(); StringSerializer.writeString(scoreboardteam, version, nfix.getObj1()); StringSerializer.writeString(scoreboardteam, version, nfix.getObj2()); scoreboardteam.writeByte(friendlyFire); } if ((mode == Mode.CREATE) || (mode == Mode.PLAYERS_ADD) || (mode == Mode.PLAYERS_REMOVE)) { ArraySerializer.writeShortTArray(scoreboardteam, players, (to, element) -> StringSerializer.writeString(to, version, Utils.clampString(element, 16))); } codec.write(scoreboardteam); }
Example 3
Source File: ScoreboardTeam.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData scoreboardteam = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_TEAM); StringSerializer.writeVarIntUTF8String(scoreboardteam, name); MiscSerializer.writeByteEnum(scoreboardteam, mode); if ((mode == Mode.CREATE) || (mode == Mode.UPDATE)) { StringSerializer.writeVarIntUTF8String(scoreboardteam, LegacyChat.clampLegacyText(displayName.toLegacyText(clientCache.getLocale()), 32)); Any<String, String> nfix = formatPrefixSuffix(); StringSerializer.writeVarIntUTF8String(scoreboardteam, nfix.getObj1()); StringSerializer.writeVarIntUTF8String(scoreboardteam, nfix.getObj2()); scoreboardteam.writeByte(friendlyFire); StringSerializer.writeVarIntUTF8String(scoreboardteam, nameTagVisibility); scoreboardteam.writeByte(format.isColor() ? format.ordinal() : -1); } if ((mode == Mode.CREATE) || (mode == Mode.PLAYERS_ADD) || (mode == Mode.PLAYERS_REMOVE)) { ArraySerializer.writeVarIntTArray(scoreboardteam, players, (to, element) -> StringSerializer.writeVarIntUTF8String(to, Utils.clampString(element, 16))); } codec.write(scoreboardteam); }
Example 4
Source File: ScoreboardTeam.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { String locale = clientCache.getLocale(); ClientBoundPacketData scoreboardteam = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_TEAM); StringSerializer.writeVarIntUTF8String(scoreboardteam, name); MiscSerializer.writeByteEnum(scoreboardteam, mode); if ((mode == Mode.CREATE) || (mode == Mode.UPDATE)) { StringSerializer.writeVarIntUTF8String(scoreboardteam, ChatAPI.toJSON(LegacyChatJson.convert(version, locale, displayName))); scoreboardteam.writeByte(friendlyFire); StringSerializer.writeVarIntUTF8String(scoreboardteam, nameTagVisibility); StringSerializer.writeVarIntUTF8String(scoreboardteam, collisionRule); MiscSerializer.writeVarIntEnum(scoreboardteam, format); StringSerializer.writeVarIntUTF8String(scoreboardteam, ChatAPI.toJSON(LegacyChatJson.convert(version, locale, prefix))); StringSerializer.writeVarIntUTF8String(scoreboardteam, ChatAPI.toJSON(LegacyChatJson.convert(version, locale, suffix))); } if ((mode == Mode.CREATE) || (mode == Mode.PLAYERS_ADD) || (mode == Mode.PLAYERS_REMOVE)) { ArraySerializer.writeVarIntVarIntUTF8StringArray(scoreboardteam, players); } codec.write(scoreboardteam); }
Example 5
Source File: ScoreboardTeam.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData scoreboardteam = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_TEAM); StringSerializer.writeVarIntUTF8String(scoreboardteam, name); MiscSerializer.writeByteEnum(scoreboardteam, mode); if ((mode == Mode.CREATE) || (mode == Mode.UPDATE)) { StringSerializer.writeVarIntUTF8String(scoreboardteam, LegacyChat.clampLegacyText(displayName.toLegacyText(clientCache.getLocale()), 32)); Any<String, String> nfix = formatPrefixSuffix(); StringSerializer.writeVarIntUTF8String(scoreboardteam, nfix.getObj1()); StringSerializer.writeVarIntUTF8String(scoreboardteam, nfix.getObj2()); scoreboardteam.writeByte(friendlyFire); StringSerializer.writeVarIntUTF8String(scoreboardteam, nameTagVisibility); StringSerializer.writeVarIntUTF8String(scoreboardteam, collisionRule); scoreboardteam.writeByte(format.isColor() ? format.ordinal() : -1); } if ((mode == Mode.CREATE) || (mode == Mode.PLAYERS_ADD) || (mode == Mode.PLAYERS_REMOVE)) { ArraySerializer.writeVarIntVarIntUTF8StringArray(scoreboardteam, players); } codec.write(scoreboardteam); }
Example 6
Source File: ScoreboardObjective.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData scoreboardobjective = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_OBJECTIVE); StringSerializer.writeString(scoreboardobjective, version, name); StringSerializer.writeString( scoreboardobjective, version, mode == Mode.REMOVE ? "" : LegacyChat.clampLegacyText(value.toLegacyText(cache.getClientCache().getLocale()), 32) ); MiscSerializer.writeByteEnum(scoreboardobjective, mode); codec.write(scoreboardobjective); }
Example 7
Source File: ServerDifficulty.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData serverdifficulty = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SERVER_DIFFICULTY); MiscSerializer.writeByteEnum(serverdifficulty, difficulty); serverdifficulty.writeBoolean(locked); codec.write(serverdifficulty); }
Example 8
Source File: ChangeDimension.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData changedimension = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_RESPAWN); changedimension.writeInt(LegacyDimension.getId(dimension)); MiscSerializer.writeByteEnum(changedimension, Difficulty.HARD); changedimension.writeByte(gamemodeCurrent.getId()); StringSerializer.writeVarIntUTF8String(changedimension, "default"); codec.write(changedimension); }
Example 9
Source File: StartGame.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData startgame = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_START_GAME); startgame.writeInt(player.getId()); startgame.writeByte(gamemodeCurrent.getId() | (hardcore ? 0x8 : 0)); startgame.writeByte(LegacyDimension.getId(dimension)); MiscSerializer.writeByteEnum(startgame, Difficulty.HARD); startgame.writeByte(Math.min(maxplayers, 60)); StringSerializer.writeVarIntUTF8String(startgame, "default"); codec.write(startgame); }
Example 10
Source File: Chat.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public static ClientBoundPacketData create(MessagePosition position, BaseComponent message, UUID sender) { ClientBoundPacketData chat = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHAT); StringSerializer.writeVarIntUTF8String(chat, ChatAPI.toJSON(message)); MiscSerializer.writeByteEnum(chat, position); UUIDSerializer.writeUUID2L(chat, sender); return chat; }
Example 11
Source File: GameStateChange.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData gamestatechange = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_GAME_STATE_CHANGE); MiscSerializer.writeByteEnum(gamestatechange, action); gamestatechange.writeByte((int) value); codec.write(gamestatechange); }
Example 12
Source File: StartGame.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData startgame = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_START_GAME); startgame.writeInt(player.getId()); StringSerializer.writeShortUTF16BEString(startgame, "default"); startgame.writeByte(gamemodeCurrent.getId() | (hardcore ? 0x8 : 0)); startgame.writeByte(LegacyDimension.getId(dimension)); MiscSerializer.writeByteEnum(startgame, Difficulty.HARD); startgame.writeByte(0); startgame.writeByte(maxplayers); codec.write(startgame); }
Example 13
Source File: ChangeDimension.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData changedimension = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_RESPAWN); changedimension.writeInt(LegacyDimension.getId(dimension)); MiscSerializer.writeByteEnum(changedimension, Difficulty.HARD); changedimension.writeByte(gamemodeCurrent.getId()); changedimension.writeShort(256); StringSerializer.writeShortUTF16BEString(changedimension, "default"); codec.write(changedimension); }
Example 14
Source File: ScoreboardObjective.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData scoreboardobjective = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SCOREBOARD_OBJECTIVE); StringSerializer.writeVarIntUTF8String(scoreboardobjective, name); MiscSerializer.writeByteEnum(scoreboardobjective, mode); if (mode != Mode.REMOVE) { StringSerializer.writeVarIntUTF8String(scoreboardobjective, LegacyChat.clampLegacyText(value.toLegacyText(cache.getClientCache().getLocale()), 32)); StringSerializer.writeVarIntUTF8String(scoreboardobjective, getTypeString(type)); } codec.write(scoreboardobjective); }
Example 15
Source File: GameStateChange.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData gamestatechange = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_GAME_STATE_CHANGE); MiscSerializer.writeByteEnum(gamestatechange, action); gamestatechange.writeFloat(value); codec.write(gamestatechange); }
Example 16
Source File: Chat.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
public static ClientBoundPacketData create(MessagePosition position, BaseComponent message) { ClientBoundPacketData chat = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_CHAT); StringSerializer.writeVarIntUTF8String(chat, ChatAPI.toJSON(message)); MiscSerializer.writeByteEnum(chat, position); return chat; }
Example 17
Source File: ServerDifficulty.java From ProtocolSupport with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void writeToClient() { ClientBoundPacketData serverdifficulty = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_SERVER_DIFFICULTY); MiscSerializer.writeByteEnum(serverdifficulty, difficulty); codec.write(serverdifficulty); }