Java Code Examples for protocolsupport.api.ProtocolVersion#MINECRAFT_1_8

The following examples show how to use protocolsupport.api.ProtocolVersion#MINECRAFT_1_8 . 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: LegacyCustomPayloadData.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void transformAndWriteBookSign(PacketDataCodec codec, ProtocolVersion version, ByteBuf data) {
	NetworkItemStack book = ItemStackSerializer.readItemStack(data, version);
	if (!book.isNull()) {
		book.setTypeId(ItemMaterialLookup.getRuntimeId(Material.WRITABLE_BOOK));
		if (version == ProtocolVersion.MINECRAFT_1_8) {
			NBTCompound rootTag = book.getNBT();
			if (rootTag != null) {
				NBTList<NBTString> pages = rootTag.getTagListOfType("pages", NBTType.STRING);
				if (pages != null) {
					NBTList<NBTString> newPages = new NBTList<>(NBTType.STRING);
					for (NBTString page : pages.getTags()) {
						newPages.addTag(new NBTString(ChatAPI.fromJSON(page.getValue()).toLegacyText(I18NData.DEFAULT_LOCALE)));
					}
					rootTag.setTag("pages", newPages);
				}
			}
		}
		codec.read(MiddleEditBook.create(book, true, UsedHand.MAIN));
	}
}
 
Example 2
Source File: EntityAction.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void readClientData(ByteBuf clientdata) {
	entityId = VarNumberSerializer.readVarInt(clientdata);
	int actionId = VarNumberSerializer.readVarInt(clientdata);
	jumpBoost = VarNumberSerializer.readVarInt(clientdata);
	if (version == ProtocolVersion.MINECRAFT_1_8) {
		action = actionById8.get(actionId);
	} else {
		action = Action.CONSTANT_LOOKUP.getByOrdinal(actionId);
	}
}
 
Example 3
Source File: ProtocolSupportVersionProvider.java    From BungeeTabListPlus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean is18(ProxiedPlayer player) {
    ProtocolVersion protocolVersion = ProtocolSupportAPI.getProtocolVersion(player);
    return protocolVersion == ProtocolVersion.MINECRAFT_1_8;
}