Classic Protocol Extension API

Classic Protocol Extension API

Postby dzienny » 25 Feb 2014, 22:08

CPE API

Classic Protocol Extension (CPE) is a communication protocol that extends Minecraft Classic protocol. It was made to support additional functionalities in the game client. Currently the only client that supports CPE is ClassiCube.

The use of CPE requires, also, the server side implementation of the protocol. MCDzienny did support some of the CPE functionalities, mainly new blocks and models. However, MCDzienny didn't provide a reliable CPE API for coders to use, but it changed. The version 11.1 of MCDzienny includes CPE API. Mind that, at this point, the protocol specification is not finalized. It may be modified in the future, and if it happens, the API may have to be changed too.

MCDzienny CPE API supports the following extensions:
ClickDistance, HeldBlock, TextHotKey, ExtPlayerList, EnvColors, SelectionCuboid, BlockPermissions, ChangeModel, EnvMapAppearance, EnvWeatherType.

The class MCDzienny.Cpe.V1 contains a set of methods that serve to compose and send a certain packet. Their names are equivalent to the packets names. Their behaviour is defined by the CPE specification document.These methods are:
Code: Select all
public static void ClickDistance(Player player, short distance)
public static void HoldThis(Player player, byte block, byte preventChanges)
public static void SetTextHotKey(Player player, string label, string action, int keyCode, byte keyMods)
public static void ExtAddPlayerName(Player player, short itemId, string playerName, string listName, string groupName, byte groupRank)
public static void ExtAddEntity(Player player, byte entityId, string inGameName, string skinName)
public static void ExtRemovePlayerName(Player player, short itemId)
public static void EnvSetColor(Player player, byte target, short red, short green, short blue)
public static void MakeSelection(Player player, byte selectionId, string label, short x1, short y1, short z1, short x2, short y2, short z2, short red, short green, short blue, short opacity)
public static void RemoveSelection(Player player, byte selectionId)
public static void SetBlockPermission(Player player, byte blockType, byte allowPlacement, byte allowDeletion)
public static void ChangeModel(Player player, byte entityId, string modelName)
public static void EnvMapAppearance(Player player, string textureUrl, byte sideBlock, byte edgeBlock, short sideLevel)
public static void EnvWeather(Player player, byte weatherType)


The client may support only some of these packets, or none at all. Also, the packets have a certain version. Currenlty all are version 1. But they may evolve and change the version. The new versions are not guaranteed to be back compatible. You have to always check the supported version, and use correct method.

The class MCDzienny.Cpe.Support contains int fields that are named the same as the extension types. The fields are meant to return a supported version of the extension. If the field is equal to 0, it means that the extension is not supported. The fields are:
Code: Select all
public int ClickDistance
public int HeldBlock
public int TextHotKey
public int ExtPlayerList
public int EnvColors
public int SelectionCuboid
public int BlockPermissions
public int ChangeModel
public int EnvMapAppearance
public int EnvWeatherType


The instance of MCDzienny.Cpe.Support type is a member of MCDzienny.Player class and it's named Cpe. Hence, it can be accessed via Player.Cpe.

Example:
Code: Select all
namespace MCDzienny
{
    public class CmdExample : Command
    {
        public override string name { get { return "example"; } }
        public override string shortcut { get { return ""; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
        public override bool ConsoleAccess { get { return false; } }

        public override void Use(Player p, string message)
        {
            // Check what version of weather packet is supported by the player's client.
            // If it's the version 1, then we have a method that supports it.
            if (p.Cpe.EnvWeatherType == 1)
            {
                // Let's tell the player's client to invoke rain.
                Cpe.V1.EnvSetWeatherType(p, 1);
            }
            else
            {
                // The weather packet is not supported or there's an unknown version of it.
                // Notify the player about the situation.
                Player.SendMessage(p, "Sorry, this command isn't compatible with your game client.");
            }
        }

        public override void Help(Player p)
        {
            Player.SendMessage(p, "example - changes the weather.");
        }
    }
}
User avatar
dzienny
Administrator
 
Posts: 1181
Joined: 23 Jan 2011, 14:27

Re: Classic Protocol Extension API

Postby Leeizazombie » 25 Feb 2014, 22:21

Looks like I posted in help too early ;)
Thank you for adding some of the extensions, I'm going to have fun creating custom commands with these new features! :)
Owner of:
LeeIzaZombie Freebuild and Lava Survival V2 (Shut Down and updated)
LeeIzaZombie Survival (Comming back soon)

Contact:
Skype: leeizazombie
IRC: irc.geekshed.net, #leeizazombie, #mcclassichosting
User avatar
Leeizazombie
 
Posts: 536
Joined: 10 Jun 2013, 17:45
Location: Ireland.

Re: Classic Protocol Extension API

Postby HETAL » 26 Feb 2014, 22:43

According to fragmer, MakeHackControl is coming out in the new update :D , and I don't know yet about EmoteFix (I attempted it but made it into EmoteBreak).
YOU HAVENT SEEN THE LAST OF ME ISMELLIKE
HETAL
 
Posts: 397
Joined: 24 May 2013, 12:10


Return to Knowledge Base

Who is online

Users browsing this forum: No registered users and 1 guest

cron