mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Implemented 1.20.3
This commit is contained in:
parent
1e60b611e9
commit
790e0bfe55
13 changed files with 650 additions and 271 deletions
|
|
@ -1221,16 +1221,16 @@ public class WebSocketBot : ChatBot
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnScoreboardObjective(string objectiveName, byte mode, string objectiveValue, int type,
|
public override void OnScoreboardObjective(string objectiveName, byte mode, string objectiveValue, int type,
|
||||||
string json_)
|
string json_, int numberFormat)
|
||||||
{
|
{
|
||||||
SendEvent("OnScoreboardObjective",
|
SendEvent("OnScoreboardObjective",
|
||||||
new { objectiveName, mode, objectiveValue, type, rawJson = json_ });
|
new { objectiveName, mode, objectiveValue, type, rawJson = json_, numberFormat });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdateScore(string entityName, int action, string objectiveName, int value)
|
public override void OnUpdateScore(string entityName, int action, string objectiveName, string objectiveDisplayName, int value, int numberFormat)
|
||||||
{
|
{
|
||||||
SendEvent("OnUpdateScore",
|
SendEvent("OnUpdateScore",
|
||||||
new { entityName, action, objectiveName, type = value });
|
new { entityName, action, objectiveName, objectiveDisplayName, type = value, numberFormat });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnInventoryUpdate(int inventoryId)
|
public override void OnInventoryUpdate(int inventoryId)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public abstract class EntityMetadataPalette
|
||||||
<= Protocol18Handler.MC_1_12_2_Version => new EntityMetadataPalette1122(), // 1.9 - 1.12.2
|
<= Protocol18Handler.MC_1_12_2_Version => new EntityMetadataPalette1122(), // 1.9 - 1.12.2
|
||||||
<= Protocol18Handler.MC_1_19_2_Version => new EntityMetadataPalette1191(), // 1.13 - 1.19.2
|
<= Protocol18Handler.MC_1_19_2_Version => new EntityMetadataPalette1191(), // 1.13 - 1.19.2
|
||||||
<= Protocol18Handler.MC_1_19_3_Version => new EntityMetadataPalette1193(), // 1.19.3
|
<= Protocol18Handler.MC_1_19_3_Version => new EntityMetadataPalette1193(), // 1.19.3
|
||||||
<= Protocol18Handler.MC_1_20_2_Version => new EntityMetadataPalette1194(), // 1.19.4 - 1.20.2 +
|
<= Protocol18Handler.MC_1_20_4_Version => new EntityMetadataPalette1194(), // 1.19.4 - 1.20.4 +
|
||||||
_ => throw new NotImplementedException()
|
_ => throw new NotImplementedException()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3414,29 +3414,32 @@ namespace MinecraftClient
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when coreboardObjective
|
/// Called when Soreboard Objective
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectivename">objective name</param>
|
/// <param name="objectiveName">objective name</param>
|
||||||
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
||||||
/// <param name="objectivevalue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
/// <param name="objectiveValue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
||||||
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
||||||
public void OnScoreboardObjective(string objectivename, byte mode, string objectivevalue, int type)
|
/// <param name="numberFormat">Number format: 0 - blank, 1 - styled, 2 - fixed</param>
|
||||||
|
public void OnScoreboardObjective(string objectiveName, byte mode, string objectiveValue, int type, int numberFormat)
|
||||||
{
|
{
|
||||||
string json = objectivevalue;
|
var json = objectiveValue;
|
||||||
objectivevalue = ChatParser.ParseText(objectivevalue);
|
objectiveValue = ChatParser.ParseText(objectiveValue);
|
||||||
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectivename, mode, objectivevalue, type, json));
|
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectiveName, mode, objectiveValue, type, json, numberFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when DisplayScoreboard
|
/// Called when DisplayScoreboard
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entityname">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
/// <param name="entityName">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
||||||
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
||||||
/// <param name="objectivename">The name of the objective the score belongs to</param>
|
/// <param name="objectiveName">The name of the objective the score belongs to</param>
|
||||||
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
/// <param name="objectiveDisplayName">The name of the objective the score belongs to, but with chat formatting</param>
|
||||||
public void OnUpdateScore(string entityname, int action, string objectivename, int value)
|
/// <param name="objectiveValue">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
||||||
|
/// <param name="numberFormat">Number format: 0 - blank, 1 - styled, 2 - fixed</param>
|
||||||
|
public void OnUpdateScore(string entityName, int action, string objectiveName, string objectiveDisplayName, int objectiveValue, int numberFormat)
|
||||||
{
|
{
|
||||||
DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value));
|
DispatchBotEvent(bot => bot.OnUpdateScore(entityName, action, objectiveName, objectiveDisplayName, objectiveValue, numberFormat));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ public enum ConfigurationPacketTypesIn
|
||||||
Ping,
|
Ping,
|
||||||
RegistryData,
|
RegistryData,
|
||||||
ResourcePack,
|
ResourcePack,
|
||||||
|
RemoveResourcePack,
|
||||||
FeatureFlags,
|
FeatureFlags,
|
||||||
UpdateTags,
|
UpdateTags,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -844,21 +844,21 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cache"></param>
|
/// <param name="cache"></param>
|
||||||
/// <param name="itemPalette"></param>
|
/// <param name="itemPalette"></param>
|
||||||
protected void ReadParticleData(Queue<byte> cache, ItemPalette itemPalette)
|
public void ReadParticleData(Queue<byte> cache, ItemPalette itemPalette)
|
||||||
{
|
{
|
||||||
if (protocolversion < Protocol18Handler.MC_1_13_Version)
|
if (protocolversion < Protocol18Handler.MC_1_13_Version)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int ParticleID = ReadNextVarInt(cache);
|
var particleId = ReadNextVarInt(cache);
|
||||||
|
|
||||||
// Refernece:
|
// Documentation:
|
||||||
// 1.19.3 - https://wiki.vg/index.php?title=Data_types&oldid=17986
|
// 1.19.3+ - https://wiki.vg/index.php?title=Data_types&oldid=17986
|
||||||
// 1.18 - https://wiki.vg/index.php?title=Data_types&oldid=17180
|
// 1.18 - https://wiki.vg/index.php?title=Data_types&oldid=17180
|
||||||
// 1.17 - https://wiki.vg/index.php?title=Data_types&oldid=16740
|
// 1.17 - https://wiki.vg/index.php?title=Data_types&oldid=16740
|
||||||
// 1.15 - https://wiki.vg/index.php?title=Data_types&oldid=15338
|
// 1.15 - https://wiki.vg/index.php?title=Data_types&oldid=15338
|
||||||
// 1.13 - https://wiki.vg/index.php?title=Data_types&oldid=14271
|
// 1.13 - https://wiki.vg/index.php?title=Data_types&oldid=14271
|
||||||
|
|
||||||
switch (ParticleID)
|
switch (particleId)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
// 1.18 +
|
// 1.18 +
|
||||||
|
|
@ -866,14 +866,12 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
ReadNextVarInt(cache); // Block state (minecraft:block)
|
ReadNextVarInt(cache); // Block state (minecraft:block)
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (protocolversion < Protocol18Handler.MC_1_17_Version
|
if (protocolversion is < Protocol18Handler.MC_1_17_Version or > Protocol18Handler.MC_1_17_1_Version)
|
||||||
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
ReadNextVarInt(
|
ReadNextVarInt(
|
||||||
cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18)
|
cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18)
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version)
|
||||||
|| protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:block)
|
ReadNextVarInt(cache); // Block State (minecraft:block)
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
|
|
@ -883,44 +881,38 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
// 1.15 - 1.16.5 and 1.18 - 1.19.4
|
// 1.15 - 1.16.5 and 1.18 - 1.19.4
|
||||||
if ((protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
if (protocolversion is >= Protocol18Handler.MC_1_15_Version and < Protocol18Handler.MC_1_17_Version or > Protocol18Handler.MC_1_17_1_Version)
|
||||||
protocolversion < Protocol18Handler.MC_1_17_Version)
|
|
||||||
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
ReadDustParticle(cache);
|
ReadDustParticle(cache);
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
switch (protocolversion)
|
||||||
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
ReadDustParticle(cache);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
case Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version:
|
||||||
|
ReadDustParticle(cache);
|
||||||
|
break;
|
||||||
|
case > Protocol18Handler.MC_1_17_1_Version:
|
||||||
ReadDustParticleColorTransition(cache);
|
ReadDustParticleColorTransition(cache);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version)
|
||||||
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
ReadDustParticleColorTransition(cache);
|
ReadDustParticleColorTransition(cache);
|
||||||
break;
|
break;
|
||||||
case 23:
|
case 23:
|
||||||
// 1.15 - 1.16.5
|
// 1.15 - 1.16.5
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
if (protocolversion is >= Protocol18Handler.MC_1_15_Version and < Protocol18Handler.MC_1_17_Version)
|
||||||
protocolversion < Protocol18Handler.MC_1_17_Version)
|
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
// 1.18 - 1.19.2 onwards
|
// 1.18 - 1.19.2 onwards
|
||||||
if (protocolversion > Protocol18Handler.MC_1_17_1_Version &&
|
if (protocolversion is > Protocol18Handler.MC_1_17_1_Version and < Protocol18Handler.MC_1_19_3_Version)
|
||||||
protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
// 1.17 - 1.17.1 and 1.19.3 onwards
|
// 1.17 - 1.17.1 and 1.19.3 onwards
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version or >= Protocol18Handler.MC_1_19_3_Version)
|
||||||
|| protocolversion == Protocol18Handler.MC_1_17_1_Version
|
|
||||||
|| protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
|
||||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
|
|
@ -934,31 +926,28 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
// 1.15 - 1.16.5
|
// 1.15 - 1.16.5
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
if (protocolversion is >= Protocol18Handler.MC_1_15_Version and < Protocol18Handler.MC_1_17_Version)
|
||||||
protocolversion < Protocol18Handler.MC_1_17_Version)
|
|
||||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||||
break;
|
break;
|
||||||
case 36:
|
case 36:
|
||||||
// 1.17 - 1.17.1
|
switch (protocolversion)
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
|
||||||
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
{
|
{
|
||||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
// 1.17 - 1.17.1
|
||||||
}
|
case Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version:
|
||||||
else if (protocolversion > Protocol18Handler.MC_1_17_1_Version &&
|
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||||
protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
break;
|
||||||
{
|
case > Protocol18Handler.MC_1_17_1_Version and < Protocol18Handler.MC_1_19_3_Version:
|
||||||
// minecraft:vibration
|
// minecraft:vibration
|
||||||
ReadNextLocation(cache); // Origin (Starting Position)
|
ReadNextLocation(cache); // Origin (Starting Position)
|
||||||
ReadNextLocation(cache); // Desitination (Ending Position)
|
ReadNextLocation(cache); // Destination (Ending Position)
|
||||||
ReadNextVarInt(cache); // Ticks
|
ReadNextVarInt(cache); // Ticks
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 37:
|
case 37:
|
||||||
// minecraft:vibration
|
// minecraft:vibration
|
||||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version)
|
||||||
|| protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
|
||||||
{
|
{
|
||||||
ReadNextDouble(cache); // Origin X
|
ReadNextDouble(cache); // Origin X
|
||||||
ReadNextDouble(cache); // Origin Y
|
ReadNextDouble(cache); // Origin Y
|
||||||
|
|
@ -977,15 +966,16 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 40:
|
case 40:
|
||||||
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
||||||
{
|
{
|
||||||
string positionSourceType = ReadNextString(cache);
|
var positionSourceType = ReadNextString(cache);
|
||||||
if (positionSourceType == "minecraft:block")
|
switch (positionSourceType)
|
||||||
{
|
{
|
||||||
ReadNextLocation(cache);
|
case "minecraft:block":
|
||||||
}
|
ReadNextLocation(cache);
|
||||||
else if (positionSourceType == "minecraft:entity")
|
break;
|
||||||
{
|
case "minecraft:entity":
|
||||||
ReadNextVarInt(cache);
|
ReadNextVarInt(cache);
|
||||||
ReadNextFloat(cache);
|
ReadNextFloat(cache);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadNextVarInt(cache);
|
ReadNextVarInt(cache);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,215 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Protocol.Handlers.PacketPalettes;
|
||||||
|
|
||||||
|
public class PacketPalette1204 : PacketTypePalette
|
||||||
|
{
|
||||||
|
private readonly Dictionary<int, PacketTypesIn> typeIn = new()
|
||||||
|
{
|
||||||
|
{ 0x00, PacketTypesIn.Bundle }, // Added in 1.19.4
|
||||||
|
{ 0x01, PacketTypesIn.SpawnEntity }, // Changed in 1.19 (Wiki name: Spawn Entity)
|
||||||
|
{ 0x02, PacketTypesIn.SpawnExperienceOrb }, // (Wiki name: Spawn Exeprience Orb)
|
||||||
|
{ 0x03, PacketTypesIn.EntityAnimation }, // (Wiki name: Entity Animation (clientbound))
|
||||||
|
{ 0x04, PacketTypesIn.Statistics }, // (Wiki name: Award Statistics)
|
||||||
|
{ 0x05, PacketTypesIn.BlockChangedAck }, // Added 1.19 (Wiki name: Acknowledge Block Change)
|
||||||
|
{ 0x06, PacketTypesIn.BlockBreakAnimation }, // (Wiki name: Set Block Destroy Stage)
|
||||||
|
{ 0x07, PacketTypesIn.BlockEntityData }, //
|
||||||
|
{ 0x08, PacketTypesIn.BlockAction }, //
|
||||||
|
{ 0x09, PacketTypesIn.BlockChange }, // (Wiki name: Block Update)
|
||||||
|
{ 0x0A, PacketTypesIn.BossBar }, //
|
||||||
|
{ 0x0B, PacketTypesIn.ServerDifficulty }, // (Wiki name: Change Difficulty)
|
||||||
|
{ 0x0C, PacketTypesIn.ChunkBatchFinished }, // Added in 1.20.2
|
||||||
|
{ 0x0D, PacketTypesIn.ChunkBatchStarted }, // Added in 1.20.2
|
||||||
|
{ 0x0E, PacketTypesIn.ChunksBiomes }, // Added in 1.19.4
|
||||||
|
{ 0x0F, PacketTypesIn.ClearTiles }, //
|
||||||
|
{ 0x10, PacketTypesIn.TabComplete }, // (Wiki name: Command Suggestions Response)
|
||||||
|
{ 0x11, PacketTypesIn.DeclareCommands }, // (Wiki name: Commands)
|
||||||
|
{ 0x12, PacketTypesIn.CloseWindow }, // (Wiki name: Close Container (clientbound))
|
||||||
|
{ 0x13, PacketTypesIn.WindowItems }, // (Wiki name: Set Container Content)
|
||||||
|
{ 0x14, PacketTypesIn.WindowProperty }, // (Wiki name: Set Container Property)
|
||||||
|
{ 0x15, PacketTypesIn.SetSlot }, // (Wiki name: Set Container Slot)
|
||||||
|
{ 0x16, PacketTypesIn.SetCooldown }, //
|
||||||
|
{ 0x17, PacketTypesIn.ChatSuggestions }, // Added in 1.19.1
|
||||||
|
{ 0x18, PacketTypesIn.PluginMessage }, // (Wiki name: Plugin Message (clientbound))
|
||||||
|
{ 0x19, PacketTypesIn.DamageEvent }, // Added in 1.19.4
|
||||||
|
{ 0x1A, PacketTypesIn.HideMessage }, // Added in 1.19.1
|
||||||
|
{ 0x1B, PacketTypesIn.Disconnect }, //
|
||||||
|
{ 0x1C, PacketTypesIn.ProfilelessChatMessage }, // Added in 1.19.3 (Wiki name: Disguised Chat Message)
|
||||||
|
{ 0x1D, PacketTypesIn.EntityStatus }, // (Wiki name: Entity Event)
|
||||||
|
{ 0x1E, PacketTypesIn.Explosion }, // Changed in 1.19 (Location fields are now Double instead of Float) (Wiki name: Explosion)
|
||||||
|
{ 0x1F, PacketTypesIn.UnloadChunk }, // (Wiki name: Forget Chunk)
|
||||||
|
{ 0x20, PacketTypesIn.ChangeGameState }, // (Wiki name: Game Event)
|
||||||
|
{ 0x21, PacketTypesIn.OpenHorseWindow }, // (Wiki name: Horse Screen Open)
|
||||||
|
{ 0x22, PacketTypesIn.HurtAnimation }, // Added in 1.19.4
|
||||||
|
{ 0x23, PacketTypesIn.InitializeWorldBorder }, //
|
||||||
|
{ 0x24, PacketTypesIn.KeepAlive }, //
|
||||||
|
{ 0x25, PacketTypesIn.ChunkData }, //
|
||||||
|
{ 0x26, PacketTypesIn.Effect }, // (Wiki name: World Event)
|
||||||
|
{ 0x27, PacketTypesIn.Particle }, // Changed in 1.19 (Wiki name: Level Particle) (No need to be implemented)
|
||||||
|
{ 0x28, PacketTypesIn.UpdateLight }, // (Wiki name: Light Update)
|
||||||
|
{ 0x29, PacketTypesIn.JoinGame }, // Changed in 1.20.2 (Wiki name: Login (play))
|
||||||
|
{ 0x2A, PacketTypesIn.MapData }, // (Wiki name: Map Item Data)
|
||||||
|
{ 0x2B, PacketTypesIn.TradeList }, // (Wiki name: Merchant Offers)
|
||||||
|
{ 0x2C, PacketTypesIn.EntityPosition }, // (Wiki name: Move Entity Position)
|
||||||
|
{ 0x2D, PacketTypesIn.EntityPositionAndRotation }, // (Wiki name: Move Entity Position and Rotation)
|
||||||
|
{ 0x2E, PacketTypesIn.EntityRotation }, // (Wiki name: Move Entity Rotation)
|
||||||
|
{ 0x2F, PacketTypesIn.VehicleMove }, // (Wiki name: Move Vehicle)
|
||||||
|
{ 0x30, PacketTypesIn.OpenBook }, //
|
||||||
|
{ 0x31, PacketTypesIn.OpenWindow }, // (Wiki name: Open Screen)
|
||||||
|
{ 0x32, PacketTypesIn.OpenSignEditor }, //
|
||||||
|
{ 0x33, PacketTypesIn.Ping }, // (Wiki name: Ping (play))
|
||||||
|
{ 0x34, PacketTypesIn.PingResponse }, // Added in 1.20.2
|
||||||
|
{ 0x35, PacketTypesIn.CraftRecipeResponse }, // (Wiki name: Place Ghost Recipe)
|
||||||
|
{ 0x36, PacketTypesIn.PlayerAbilities }, //
|
||||||
|
{ 0x37, PacketTypesIn.ChatMessage }, // Changed in 1.19 (Completely changed) (Wiki name: Player Chat Message)
|
||||||
|
{ 0x38, PacketTypesIn.EndCombatEvent }, // (Wiki name: End Combat)
|
||||||
|
{ 0x39, PacketTypesIn.EnterCombatEvent }, // (Wiki name: Enter Combat)
|
||||||
|
{ 0x3A, PacketTypesIn.DeathCombatEvent }, // (Wiki name: Combat Death)
|
||||||
|
{ 0x3B, PacketTypesIn.PlayerRemove }, // Added in 1.19.3 (Not used)
|
||||||
|
{ 0x3C, PacketTypesIn.PlayerInfo }, // Changed in 1.19 (Heavy changes)
|
||||||
|
{ 0x3D, PacketTypesIn.FacePlayer }, // (Wiki name: Player Look At)
|
||||||
|
{ 0x3E, PacketTypesIn.PlayerPositionAndLook }, // (Wiki name: Synchronize Player Position)
|
||||||
|
{ 0x3F, PacketTypesIn.UnlockRecipes }, // (Wiki name: Update Recipe Book)
|
||||||
|
{ 0x40, PacketTypesIn.DestroyEntities }, // (Wiki name: Remove Entites)
|
||||||
|
{ 0x41, PacketTypesIn.RemoveEntityEffect }, //
|
||||||
|
{ 0x42, PacketTypesIn.ResetScore }, // Added in 1.20.3
|
||||||
|
{ 0x43, PacketTypesIn.RemoveResourcePack }, // Added in 1.20.3
|
||||||
|
{ 0x44, PacketTypesIn.ResourcePackSend }, // (Wiki name: Add Resource pack (play))
|
||||||
|
{ 0x45, PacketTypesIn.Respawn }, // Changed in 1.20.2
|
||||||
|
{ 0x46, PacketTypesIn.EntityHeadLook }, // (Wiki name: Set Head Rotation)
|
||||||
|
{ 0x47, PacketTypesIn.MultiBlockChange }, // (Wiki name: Update Section Blocks)
|
||||||
|
{ 0x48, PacketTypesIn.SelectAdvancementTab }, //
|
||||||
|
{ 0x49, PacketTypesIn.ServerData }, // Added in 1.19
|
||||||
|
{ 0x4A, PacketTypesIn.ActionBar }, // (Wiki name: Set Action Bar Text)
|
||||||
|
{ 0x4B, PacketTypesIn.WorldBorderCenter }, // (Wiki name: Set Border Center)
|
||||||
|
{ 0x4C, PacketTypesIn.WorldBorderLerpSize }, //
|
||||||
|
{ 0x4D, PacketTypesIn.WorldBorderSize }, // (Wiki name: Set World Border Size)
|
||||||
|
{ 0x4E, PacketTypesIn.WorldBorderWarningDelay }, // (Wiki name: Set World Border Warning Delay)
|
||||||
|
{ 0x4F, PacketTypesIn.WorldBorderWarningReach }, // (Wiki name: Set Border Warning Distance)
|
||||||
|
{ 0x50, PacketTypesIn.Camera }, // (Wiki name: Set Camera)
|
||||||
|
{ 0x51, PacketTypesIn.HeldItemChange }, // (Wiki name: Set Held Item)
|
||||||
|
{ 0x52, PacketTypesIn.UpdateViewPosition }, // (Wiki name: Set Center Chunk)
|
||||||
|
{ 0x53, PacketTypesIn.UpdateViewDistance }, // (Wiki name: Set Render Distance)
|
||||||
|
{ 0x54, PacketTypesIn.SpawnPosition }, // (Wiki name: Set Default Spawn Position)
|
||||||
|
{ 0x55, PacketTypesIn.DisplayScoreboard }, // (Wiki name: Set Display Objective)
|
||||||
|
{ 0x56, PacketTypesIn.EntityMetadata }, // (Wiki name: Set Entity Metadata)
|
||||||
|
{ 0x57, PacketTypesIn.AttachEntity }, // (Wiki name: Link Entities)
|
||||||
|
{ 0x58, PacketTypesIn.EntityVelocity }, // (Wiki name: Set Entity Velocity)
|
||||||
|
{ 0x59, PacketTypesIn.EntityEquipment }, // (Wiki name: Set Equipment)
|
||||||
|
{ 0x5A, PacketTypesIn.SetExperience }, // Changed in 1.20.2
|
||||||
|
{ 0x5B, PacketTypesIn.UpdateHealth }, // (Wiki name: Set Health)
|
||||||
|
{ 0x5C, PacketTypesIn.ScoreboardObjective }, // (Wiki name: Update Objectives) - Changed in 1.20.3
|
||||||
|
{ 0x5D, PacketTypesIn.SetPassengers }, //
|
||||||
|
{ 0x5E, PacketTypesIn.Teams }, // (Wiki name: Update Teams)
|
||||||
|
{ 0x5F, PacketTypesIn.UpdateScore }, // (Wiki name: Update Score)
|
||||||
|
{ 0x60, PacketTypesIn.UpdateSimulationDistance }, // (Wiki name: Set Simulation Distance)
|
||||||
|
{ 0x61, PacketTypesIn.SetTitleSubTitle }, // (Wiki name: Set Subtitle Test)
|
||||||
|
{ 0x62, PacketTypesIn.TimeUpdate }, // (Wiki name: Set Time)
|
||||||
|
{ 0x63, PacketTypesIn.SetTitleText }, // (Wiki name: Set Title)
|
||||||
|
{ 0x64, PacketTypesIn.SetTitleTime }, // (Wiki name: Set Title Animation Times)
|
||||||
|
{ 0x65, PacketTypesIn.EntitySoundEffect }, // (Wiki name: Sound Entity)
|
||||||
|
{ 0x66, PacketTypesIn.SoundEffect }, // Changed in 1.19 (Added "Seed" field) (Wiki name: Sound Effect) (No need to be implemented)
|
||||||
|
{ 0x67, PacketTypesIn.StartConfiguration }, // Added in 1.20.2
|
||||||
|
{ 0x68, PacketTypesIn.StopSound }, //
|
||||||
|
{ 0x69, PacketTypesIn.SystemChat }, // Added in 1.19 (Wiki name: System Chat Message)
|
||||||
|
{ 0x6A, PacketTypesIn.PlayerListHeaderAndFooter }, // (Wiki name: Set Tab List Header And Footer)
|
||||||
|
{ 0x6B, PacketTypesIn.NBTQueryResponse }, // (Wiki name: Tag Query Response)
|
||||||
|
{ 0x6C, PacketTypesIn.CollectItem }, // (Wiki name: Pickup Item)
|
||||||
|
{ 0x6D, PacketTypesIn.EntityTeleport }, // (Wiki name: Teleport Entity)
|
||||||
|
{ 0x6E, PacketTypesIn.SetTickingState }, // Added in 1.20.3
|
||||||
|
{ 0x6F, PacketTypesIn.StepTick }, // Added in 1.20.3
|
||||||
|
{ 0x70, PacketTypesIn.Advancements }, // (Wiki name: Update Advancements) (Unused)
|
||||||
|
{ 0x71, PacketTypesIn.EntityProperties }, // (Wiki name: Update Attributes)
|
||||||
|
{ 0x72, PacketTypesIn.EntityEffect }, // Changed in 1.19 (Added "Has Factor Data" and "Factor Codec" fields) (Wiki name: Entity Effect)
|
||||||
|
{ 0x73, PacketTypesIn.DeclareRecipes }, // (Wiki name: Update Recipes) (Unused)
|
||||||
|
{ 0x74, PacketTypesIn.Tags }, // (Wiki name: Update Tags)
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly Dictionary<int, PacketTypesOut> typeOut = new()
|
||||||
|
{
|
||||||
|
{ 0x00, PacketTypesOut.TeleportConfirm }, // (Wiki name: Confirm Teleportation)
|
||||||
|
{ 0x01, PacketTypesOut.QueryBlockNBT }, // (Wiki name: Query Block Entity Tag)
|
||||||
|
{ 0x02, PacketTypesOut.SetDifficulty }, // (Wiki name: Change Difficulty)
|
||||||
|
{ 0x03, PacketTypesOut.MessageAcknowledgment }, // Added in 1.19.1
|
||||||
|
{ 0x04, PacketTypesOut.ChatCommand }, // Added in 1.19
|
||||||
|
{ 0x05, PacketTypesOut.ChatMessage }, // Changed in 1.19 (Completely changed) (Wiki name: Chat)
|
||||||
|
{ 0x06, PacketTypesOut.PlayerSession }, // Added in 1.19.3
|
||||||
|
{ 0x07, PacketTypesOut.ChunkBatchReceived }, // Added in 1.20.2
|
||||||
|
{ 0x08, PacketTypesOut.ClientStatus }, // (Wiki name: Client Command)
|
||||||
|
{ 0x09, PacketTypesOut.ClientSettings }, // (Wiki name: Client Information)
|
||||||
|
{ 0x0A, PacketTypesOut.TabComplete }, // (Wiki name: Command Suggestions Request)
|
||||||
|
{ 0x0B, PacketTypesOut.AcknowledgeConfiguration }, // Added in 1.20.2
|
||||||
|
{ 0x0C, PacketTypesOut.ClickWindowButton }, // (Wiki name: Click Container Button)
|
||||||
|
{ 0x0D, PacketTypesOut.ClickWindow }, // (Wiki name: Click Container)
|
||||||
|
{ 0x0E, PacketTypesOut.CloseWindow }, // (Wiki name: Close Container (serverbound))
|
||||||
|
{ 0x0F, PacketTypesOut.ChangeContainerSlotState }, // Added in 1.20.3
|
||||||
|
{ 0x10, PacketTypesOut.PluginMessage }, // (Wiki name: Serverbound Plugin Message)
|
||||||
|
{ 0x11, PacketTypesOut.EditBook }, //
|
||||||
|
{ 0x12, PacketTypesOut.EntityNBTRequest }, // (Wiki name: Query Entity Tag)
|
||||||
|
{ 0x13, PacketTypesOut.InteractEntity }, // (Wiki name: Interact)
|
||||||
|
{ 0x14, PacketTypesOut.GenerateStructure }, // (Wiki name: Jigsaw Generate)
|
||||||
|
{ 0x15, PacketTypesOut.KeepAlive }, // (Wiki name: Serverbound Keep Alive (play))
|
||||||
|
{ 0x16, PacketTypesOut.LockDifficulty }, //
|
||||||
|
{ 0x17, PacketTypesOut.PlayerPosition }, // (Wiki name: Move Player Position)
|
||||||
|
{ 0x18, PacketTypesOut.PlayerPositionAndRotation }, // (Wiki name: Set Player Position and Rotation)
|
||||||
|
{ 0x19, PacketTypesOut.PlayerRotation }, // (Wiki name: Set Player Rotation)
|
||||||
|
{ 0x1A, PacketTypesOut.PlayerMovement }, // (Wiki name: Set Player On Ground)
|
||||||
|
{ 0x1B, PacketTypesOut.VehicleMove }, // (Wiki name: Move Vehicle (serverbound))
|
||||||
|
{ 0x1C, PacketTypesOut.SteerBoat }, // (Wiki name: Paddle Boat)
|
||||||
|
{ 0x1D, PacketTypesOut.PickItem }, //
|
||||||
|
{ 0x1E, PacketTypesOut.PingRequest }, // Added in 1.20.2
|
||||||
|
{ 0x1F, PacketTypesOut.CraftRecipeRequest }, // (Wiki name: Place recipe)
|
||||||
|
{ 0x20, PacketTypesOut.PlayerAbilities }, //
|
||||||
|
{ 0x21, PacketTypesOut.PlayerDigging }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Player Action)
|
||||||
|
{ 0x22, PacketTypesOut.EntityAction }, // (Wiki name: Player Command)
|
||||||
|
{ 0x23, PacketTypesOut.SteerVehicle }, // (Wiki name: Player Input)
|
||||||
|
{ 0x24, PacketTypesOut.Pong }, // (Wiki name: Pong (play))
|
||||||
|
{ 0x25, PacketTypesOut.SetDisplayedRecipe }, // (Wiki name: Recipe Book Change Settings)
|
||||||
|
{ 0x26, PacketTypesOut.SetRecipeBookState }, // (Wiki name: Recipe Book Seen Recipe)
|
||||||
|
{ 0x27, PacketTypesOut.NameItem }, // (Wiki name: Rename Item)
|
||||||
|
{ 0x28, PacketTypesOut.ResourcePackStatus }, // (Wiki name: Resource Pack (serverbound))
|
||||||
|
{ 0x29, PacketTypesOut.AdvancementTab }, // (Wiki name: Seen Advancements)
|
||||||
|
{ 0x2A, PacketTypesOut.SelectTrade }, //
|
||||||
|
{ 0x2B, PacketTypesOut.SetBeaconEffect }, // Changed in 1.19 (No need to be implemented yet)
|
||||||
|
{ 0x2C, PacketTypesOut.HeldItemChange }, // (Wiki name: Set Carried Item (serverbound))
|
||||||
|
{ 0x2D, PacketTypesOut.UpdateCommandBlock }, // (Wiki name: Program Command Block)
|
||||||
|
{ 0x2E, PacketTypesOut.UpdateCommandBlockMinecart }, // (Wiki name: Program Command Block Minecart)
|
||||||
|
{ 0x2F, PacketTypesOut.CreativeInventoryAction }, // (Wiki name: Set Creative Mode Slot)
|
||||||
|
{ 0x30, PacketTypesOut.UpdateJigsawBlock }, // (Wiki name: Program Jigsaw Block)
|
||||||
|
{ 0x31, PacketTypesOut.UpdateStructureBlock }, // (Wiki name: Program Structure Block)
|
||||||
|
{ 0x32, PacketTypesOut.UpdateSign }, // (Wiki name: Update Sign)
|
||||||
|
{ 0x33, PacketTypesOut.Animation }, // (Wiki name: Swing Arm)
|
||||||
|
{ 0x34, PacketTypesOut.Spectate }, // (Wiki name: Teleport To Entity)
|
||||||
|
{ 0x35, PacketTypesOut.PlayerBlockPlacement }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item On)
|
||||||
|
{ 0x36, PacketTypesOut.UseItem }, // Changed in 1.19 (Added a "Sequence" field) (Wiki name: Use Item)
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly Dictionary<int, ConfigurationPacketTypesIn> configurationTypesIn = new()
|
||||||
|
{
|
||||||
|
{ 0x00, ConfigurationPacketTypesIn.PluginMessage },
|
||||||
|
{ 0x01, ConfigurationPacketTypesIn.Disconnect },
|
||||||
|
{ 0x02, ConfigurationPacketTypesIn.FinishConfiguration },
|
||||||
|
{ 0x03, ConfigurationPacketTypesIn.KeepAlive },
|
||||||
|
{ 0x04, ConfigurationPacketTypesIn.Ping },
|
||||||
|
{ 0x05, ConfigurationPacketTypesIn.RegistryData },
|
||||||
|
{ 0x06, ConfigurationPacketTypesIn.RemoveResourcePack },
|
||||||
|
{ 0x07, ConfigurationPacketTypesIn.ResourcePack },
|
||||||
|
{ 0x08, ConfigurationPacketTypesIn.FeatureFlags },
|
||||||
|
{ 0x09, ConfigurationPacketTypesIn.UpdateTags },
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly Dictionary<int, ConfigurationPacketTypesOut> configurationTypesOut = new()
|
||||||
|
{
|
||||||
|
{ 0x00, ConfigurationPacketTypesOut.ClientInformation },
|
||||||
|
{ 0x01, ConfigurationPacketTypesOut.PluginMessage },
|
||||||
|
{ 0x02, ConfigurationPacketTypesOut.FinishConfiguration },
|
||||||
|
{ 0x03, ConfigurationPacketTypesOut.KeepAlive },
|
||||||
|
{ 0x04, ConfigurationPacketTypesOut.Pong },
|
||||||
|
{ 0x05, ConfigurationPacketTypesOut.ResourcePackResponse }
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override Dictionary<int, PacketTypesIn> GetListIn() => typeIn;
|
||||||
|
protected override Dictionary<int, PacketTypesOut> GetListOut() => typeOut;
|
||||||
|
protected override Dictionary<int, ConfigurationPacketTypesIn> GetConfigurationListIn() => configurationTypesIn!;
|
||||||
|
protected override Dictionary<int, ConfigurationPacketTypesOut> GetConfigurationListOut() => configurationTypesOut!;
|
||||||
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
PacketTypePalette p = protocol switch
|
PacketTypePalette p = protocol switch
|
||||||
{
|
{
|
||||||
> Protocol18Handler.MC_1_20_2_Version => throw new NotImplementedException(Translations
|
> Protocol18Handler.MC_1_20_4_Version => throw new NotImplementedException(Translations
|
||||||
.exception_palette_packet),
|
.exception_palette_packet),
|
||||||
<= Protocol18Handler.MC_1_8_Version => new PacketPalette17(),
|
<= Protocol18Handler.MC_1_8_Version => new PacketPalette17(),
|
||||||
<= Protocol18Handler.MC_1_11_2_Version => new PacketPalette110(),
|
<= Protocol18Handler.MC_1_11_2_Version => new PacketPalette110(),
|
||||||
|
|
@ -64,8 +64,9 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
<= Protocol18Handler.MC_1_19_Version => new PacketPalette119(),
|
<= Protocol18Handler.MC_1_19_Version => new PacketPalette119(),
|
||||||
<= Protocol18Handler.MC_1_19_2_Version => new PacketPalette1192(),
|
<= Protocol18Handler.MC_1_19_2_Version => new PacketPalette1192(),
|
||||||
<= Protocol18Handler.MC_1_19_3_Version => new PacketPalette1193(),
|
<= Protocol18Handler.MC_1_19_3_Version => new PacketPalette1193(),
|
||||||
< Protocol18Handler.MC_1_20_2_Version => new PacketPalette1194(),
|
<= Protocol18Handler.MC_1_19_4_Version => new PacketPalette1194(),
|
||||||
_ => new PacketPalette1202()
|
<= Protocol18Handler.MC_1_20_2_Version => new PacketPalette1202(),
|
||||||
|
_ => new PacketPalette1204()
|
||||||
};
|
};
|
||||||
|
|
||||||
p.SetForgeEnabled(forgeEnabled);
|
p.SetForgeEnabled(forgeEnabled);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
namespace MinecraftClient.Protocol.Handlers
|
namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Incomming packet types
|
/// Incoming packet types
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum PacketTypesIn
|
public enum PacketTypesIn
|
||||||
{
|
{
|
||||||
|
|
@ -84,6 +84,8 @@
|
||||||
PluginMessage, //
|
PluginMessage, //
|
||||||
ProfilelessChatMessage, // Added in 1.19.3
|
ProfilelessChatMessage, // Added in 1.19.3
|
||||||
RemoveEntityEffect, //
|
RemoveEntityEffect, //
|
||||||
|
RemoveResourcePack, // Added in 1.20.3
|
||||||
|
ResetScore, // Added in 1.20.3
|
||||||
ResourcePackSend, //
|
ResourcePackSend, //
|
||||||
Respawn, //
|
Respawn, //
|
||||||
ScoreboardObjective, //
|
ScoreboardObjective, //
|
||||||
|
|
@ -96,6 +98,8 @@
|
||||||
SetExperience, //
|
SetExperience, //
|
||||||
SetPassengers, //
|
SetPassengers, //
|
||||||
SetSlot, //
|
SetSlot, //
|
||||||
|
SetTickingState, // Added in 1.20.3
|
||||||
|
StepTick, // Added in 1.20.3
|
||||||
SetTitleSubTitle, //
|
SetTitleSubTitle, //
|
||||||
SetTitleText, //
|
SetTitleText, //
|
||||||
SetTitleTime, //
|
SetTitleTime, //
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
AcknowledgeConfiguration, // Added in 1.20.2
|
AcknowledgeConfiguration, // Added in 1.20.2
|
||||||
AdvancementTab, //
|
AdvancementTab, //
|
||||||
Animation, //
|
Animation, //
|
||||||
|
ChangeContainerSlotState, // Added in 1.20.3
|
||||||
ChatCommand, // Added in 1.19
|
ChatCommand, // Added in 1.19
|
||||||
ChatMessage, //
|
ChatMessage, //
|
||||||
ChatPreview, // Added in 1.19
|
ChatPreview, // Added in 1.19
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
internal const int MC_1_19_4_Version = 762;
|
internal const int MC_1_19_4_Version = 762;
|
||||||
internal const int MC_1_20_Version = 763;
|
internal const int MC_1_20_Version = 763;
|
||||||
internal const int MC_1_20_2_Version = 764;
|
internal const int MC_1_20_2_Version = 764;
|
||||||
|
internal const int MC_1_20_4_Version = 765;
|
||||||
|
|
||||||
private int compression_treshold = 0;
|
private int compression_treshold = 0;
|
||||||
private int autocomplete_transaction_id = 0;
|
private int autocomplete_transaction_id = 0;
|
||||||
|
|
@ -120,21 +121,21 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
lastSeenMessagesCollector = protocolVersion >= MC_1_19_3_Version ? new(20) : new(5);
|
lastSeenMessagesCollector = protocolVersion >= MC_1_19_3_Version ? new(20) : new(5);
|
||||||
chunkBatchStartTime = GetNanos();
|
chunkBatchStartTime = GetNanos();
|
||||||
|
|
||||||
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_20_2_Version)
|
if (handler.GetTerrainEnabled() && protocolVersion > MC_1_20_4_Version)
|
||||||
{
|
{
|
||||||
log.Error($"§c{Translations.extra_terrainandmovement_disabled}");
|
log.Error($"§c{Translations.extra_terrainandmovement_disabled}");
|
||||||
handler.SetTerrainEnabled(false);
|
handler.SetTerrainEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler.GetInventoryEnabled() &&
|
if (handler.GetInventoryEnabled() &&
|
||||||
protocolVersion is < MC_1_9_Version or > MC_1_20_2_Version)
|
protocolVersion is < MC_1_9_Version or > MC_1_20_4_Version)
|
||||||
{
|
{
|
||||||
log.Error($"§c{Translations.extra_inventory_disabled}");
|
log.Error($"§c{Translations.extra_inventory_disabled}");
|
||||||
handler.SetInventoryEnabled(false);
|
handler.SetInventoryEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler.GetEntityHandlingEnabled() &&
|
if (handler.GetEntityHandlingEnabled() &&
|
||||||
protocolVersion is < MC_1_8_Version or > MC_1_20_2_Version)
|
protocolVersion is < MC_1_8_Version or > MC_1_20_4_Version)
|
||||||
{
|
{
|
||||||
log.Error($"§c{Translations.extra_entity_disabled}");
|
log.Error($"§c{Translations.extra_entity_disabled}");
|
||||||
handler.SetEntityHandlingEnabled(false);
|
handler.SetEntityHandlingEnabled(false);
|
||||||
|
|
@ -143,7 +144,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
Block.Palette = protocolVersion switch
|
Block.Palette = protocolVersion switch
|
||||||
{
|
{
|
||||||
// Block palette
|
// Block palette
|
||||||
> MC_1_20_2_Version when handler.GetTerrainEnabled() =>
|
> MC_1_20_4_Version when handler.GetTerrainEnabled() =>
|
||||||
throw new NotImplementedException(Translations.exception_palette_block),
|
throw new NotImplementedException(Translations.exception_palette_block),
|
||||||
>= MC_1_20_Version => new Palette120(),
|
>= MC_1_20_Version => new Palette120(),
|
||||||
MC_1_19_4_Version => new Palette1194(),
|
MC_1_19_4_Version => new Palette1194(),
|
||||||
|
|
@ -160,7 +161,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
entityPalette = protocolVersion switch
|
entityPalette = protocolVersion switch
|
||||||
{
|
{
|
||||||
// Entity palette
|
// Entity palette
|
||||||
> MC_1_20_2_Version when handler.GetEntityHandlingEnabled() =>
|
> MC_1_20_4_Version when handler.GetEntityHandlingEnabled() =>
|
||||||
throw new NotImplementedException(Translations.exception_palette_entity),
|
throw new NotImplementedException(Translations.exception_palette_entity),
|
||||||
>= MC_1_20_Version => new EntityPalette120(),
|
>= MC_1_20_Version => new EntityPalette120(),
|
||||||
MC_1_19_4_Version => new EntityPalette1194(),
|
MC_1_19_4_Version => new EntityPalette1194(),
|
||||||
|
|
@ -181,7 +182,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
itemPalette = protocolVersion switch
|
itemPalette = protocolVersion switch
|
||||||
{
|
{
|
||||||
// Item palette
|
// Item palette
|
||||||
> MC_1_20_2_Version when handler.GetInventoryEnabled() =>
|
> MC_1_20_4_Version when handler.GetInventoryEnabled() =>
|
||||||
throw new NotImplementedException(Translations.exception_palette_item),
|
throw new NotImplementedException(Translations.exception_palette_item),
|
||||||
>= MC_1_20_Version => new ItemPalette120(),
|
>= MC_1_20_Version => new ItemPalette120(),
|
||||||
MC_1_19_4_Version => new ItemPalette1194(),
|
MC_1_19_4_Version => new ItemPalette1194(),
|
||||||
|
|
@ -422,28 +423,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ConfigurationPacketTypesIn.RemoveResourcePack:
|
||||||
|
if (dataTypes.ReadNextBool(packetData)) // Has UUID
|
||||||
|
dataTypes.ReadNextUUID(packetData); // UUID
|
||||||
|
break;
|
||||||
|
|
||||||
case ConfigurationPacketTypesIn.ResourcePack:
|
case ConfigurationPacketTypesIn.ResourcePack:
|
||||||
var url = dataTypes.ReadNextString(packetData);
|
HandleResourcePackPacket(packetData);
|
||||||
var hash = dataTypes.ReadNextString(packetData);
|
|
||||||
dataTypes.ReadNextBool(packetData); // Forced
|
|
||||||
var hasPromptMessage =
|
|
||||||
dataTypes.ReadNextBool(packetData);
|
|
||||||
|
|
||||||
if (hasPromptMessage)
|
|
||||||
dataTypes.SkipNextString(packetData);
|
|
||||||
|
|
||||||
// Some server plugins may send invalid resource packs to probe the client and we need to ignore them (issue #1056)
|
|
||||||
if (!url.StartsWith("http") &&
|
|
||||||
hash.Length != 40) // Some server may have null hash value
|
|
||||||
break;
|
|
||||||
|
|
||||||
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
|
||||||
var responseHeader = Array.Empty<byte>();
|
|
||||||
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse,
|
|
||||||
dataTypes.ConcatBytes(responseHeader, DataTypes.GetVarInt(3))); // Accepted pack
|
|
||||||
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse,
|
|
||||||
dataTypes.ConcatBytes(responseHeader,
|
|
||||||
DataTypes.GetVarInt(0))); // Successfully loaded
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Ignore other packets at this stage
|
// Ignore other packets at this stage
|
||||||
|
|
@ -480,6 +466,52 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void HandleResourcePackPacket(Queue<byte> packetData)
|
||||||
|
{
|
||||||
|
var uuid = Guid.Empty;
|
||||||
|
|
||||||
|
if (protocolVersion >= MC_1_20_4_Version)
|
||||||
|
uuid = dataTypes.ReadNextUUID(packetData);
|
||||||
|
|
||||||
|
var url = dataTypes.ReadNextString(packetData);
|
||||||
|
var hash = dataTypes.ReadNextString(packetData);
|
||||||
|
|
||||||
|
if (protocolVersion >= MC_1_17_Version)
|
||||||
|
{
|
||||||
|
dataTypes.ReadNextBool(packetData); // Forced
|
||||||
|
if (dataTypes.ReadNextBool(packetData)) // Has Prompt Message
|
||||||
|
dataTypes.SkipNextString(packetData); // Prompt Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some server plugins may send invalid resource packs to probe the client and we need to ignore them (issue #1056)
|
||||||
|
if (!url.StartsWith("http") &&
|
||||||
|
hash.Length != 40) // Some server may have null hash value
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
||||||
|
var responseHeader = protocolVersion < MC_1_10_Version // After 1.10, the MC does not include resource pack hash in responses
|
||||||
|
? dataTypes.ConcatBytes(DataTypes.GetVarInt(hash.Length), Encoding.UTF8.GetBytes(hash))
|
||||||
|
: Array.Empty<byte>();
|
||||||
|
|
||||||
|
var basePacketData = protocolVersion >= MC_1_20_4_Version && uuid != Guid.Empty
|
||||||
|
? dataTypes.ConcatBytes(responseHeader, DataTypes.GetUUID(uuid))
|
||||||
|
: responseHeader;
|
||||||
|
|
||||||
|
var acceptedResourcePackData = dataTypes.ConcatBytes(basePacketData, DataTypes.GetVarInt(3));
|
||||||
|
var loadedResourcePackData = dataTypes.ConcatBytes(basePacketData, DataTypes.GetVarInt(0));
|
||||||
|
|
||||||
|
if (currentState == CurrentState.Configuration)
|
||||||
|
{
|
||||||
|
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, acceptedResourcePackData); // Accepted
|
||||||
|
SendPacket(ConfigurationPacketTypesOut.ResourcePackResponse, loadedResourcePackData); // Successfully loaded
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SendPacket(PacketTypesOut.ResourcePackStatus, acceptedResourcePackData); // Accepted
|
||||||
|
SendPacket(PacketTypesOut.ResourcePackStatus, loadedResourcePackData); // Successfully loaded
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool HandlePlayPackets(int packetId, Queue<byte> packetData)
|
private bool HandlePlayPackets(int packetId, Queue<byte> packetData)
|
||||||
{
|
{
|
||||||
switch (packetPalette.GetIncomingTypeById(packetId))
|
switch (packetPalette.GetIncomingTypeById(packetId))
|
||||||
|
|
@ -1648,7 +1680,15 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
var iconBase64 = "-";
|
var iconBase64 = "-";
|
||||||
var hasIcon = dataTypes.ReadNextBool(packetData);
|
var hasIcon = dataTypes.ReadNextBool(packetData);
|
||||||
if (hasIcon)
|
if (hasIcon)
|
||||||
iconBase64 = dataTypes.ReadNextString(packetData);
|
{
|
||||||
|
if(protocolVersion < MC_1_20_2_Version)
|
||||||
|
iconBase64 = dataTypes.ReadNextString(packetData);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pngData = dataTypes.ReadNextByteArray(packetData);
|
||||||
|
iconBase64 = Convert.ToBase64String(pngData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var previewsChat = false;
|
var previewsChat = false;
|
||||||
if (protocolVersion < MC_1_19_3_Version)
|
if (protocolVersion < MC_1_19_3_Version)
|
||||||
|
|
@ -2119,34 +2159,18 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case PacketTypesIn.RemoveResourcePack:
|
||||||
|
if (dataTypes.ReadNextBool(packetData)) // Has UUID
|
||||||
|
dataTypes.ReadNextUUID(packetData); // UUID
|
||||||
|
break;
|
||||||
case PacketTypesIn.ResourcePackSend:
|
case PacketTypesIn.ResourcePackSend:
|
||||||
var url = dataTypes.ReadNextString(packetData);
|
HandleResourcePackPacket(packetData);
|
||||||
var hash = dataTypes.ReadNextString(packetData);
|
break;
|
||||||
var forced = true; // Assume forced for MC 1.16 and below
|
case PacketTypesIn.ResetScore:
|
||||||
if (protocolVersion >= MC_1_17_Version)
|
dataTypes.ReadNextString(packetData); // Entity Name
|
||||||
{
|
if(dataTypes.ReadNextBool(packetData)) // Has Objective Name
|
||||||
forced = dataTypes.ReadNextBool(packetData);
|
dataTypes.ReadNextString(packetData); // Objective Name
|
||||||
var hasPromptMessage =
|
|
||||||
dataTypes.ReadNextBool(packetData); // Has Prompt Message (Boolean) - 1.17 and above
|
|
||||||
if (hasPromptMessage)
|
|
||||||
dataTypes.SkipNextString(
|
|
||||||
packetData); // Prompt Message (Optional Chat) - 1.17 and above
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some server plugins may send invalid resource packs to probe the client and we need to ignore them (issue #1056)
|
|
||||||
if (!url.StartsWith("http") && hash.Length != 40) // Some server may have null hash value
|
|
||||||
break;
|
|
||||||
|
|
||||||
//Send back "accepted" and "successfully loaded" responses for plugins or server config making use of resource pack mandatory
|
|
||||||
var responseHeader = Array.Empty<byte>();
|
|
||||||
if (protocolVersion <
|
|
||||||
MC_1_10_Version) //MC 1.10 does not include resource pack hash in responses
|
|
||||||
responseHeader = dataTypes.ConcatBytes(DataTypes.GetVarInt(hash.Length),
|
|
||||||
Encoding.UTF8.GetBytes(hash));
|
|
||||||
SendPacket(PacketTypesOut.ResourcePackStatus,
|
|
||||||
dataTypes.ConcatBytes(responseHeader, DataTypes.GetVarInt(3))); // Accepted pack
|
|
||||||
SendPacket(PacketTypesOut.ResourcePackStatus,
|
|
||||||
dataTypes.ConcatBytes(responseHeader, DataTypes.GetVarInt(0))); // Successfully loaded
|
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.SpawnEntity:
|
case PacketTypesIn.SpawnEntity:
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
|
|
@ -2395,7 +2419,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// Also make a palette for field? Will be a lot of work
|
// Also make a palette for field? Will be a lot of work
|
||||||
var healthField = protocolVersion switch
|
var healthField = protocolVersion switch
|
||||||
{
|
{
|
||||||
> MC_1_20_2_Version => throw new NotImplementedException(Translations
|
> MC_1_20_4_Version => throw new NotImplementedException(Translations
|
||||||
.exception_palette_healthfield),
|
.exception_palette_healthfield),
|
||||||
// 1.17 and above
|
// 1.17 and above
|
||||||
>= MC_1_17_Version => 9,
|
>= MC_1_17_Version => 9,
|
||||||
|
|
@ -2481,15 +2505,29 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
var explosionStrength = dataTypes.ReadNextFloat(packetData);
|
var explosionStrength = dataTypes.ReadNextFloat(packetData);
|
||||||
var explosionBlockCount = protocolVersion >= MC_1_17_Version
|
var explosionBlockCount = protocolVersion >= MC_1_17_Version
|
||||||
? dataTypes.ReadNextVarInt(packetData)
|
? dataTypes.ReadNextVarInt(packetData)
|
||||||
: dataTypes.ReadNextInt(packetData);
|
: dataTypes.ReadNextInt(packetData); // Record count
|
||||||
|
|
||||||
|
// Records
|
||||||
for (var i = 0; i < explosionBlockCount; i++)
|
for (var i = 0; i < explosionBlockCount; i++)
|
||||||
dataTypes.ReadData(3, packetData);
|
dataTypes.ReadData(3, packetData);
|
||||||
|
|
||||||
// Maybe use in the future when the physics are implemented
|
// Maybe use in the future when the physics are implemented
|
||||||
var playerVelocityX = dataTypes.ReadNextFloat(packetData);
|
dataTypes.ReadNextFloat(packetData); // Player Motion X
|
||||||
var playerVelocityY = dataTypes.ReadNextFloat(packetData);
|
dataTypes.ReadNextFloat(packetData); // Player Motion Y
|
||||||
var playerVelocityZ = dataTypes.ReadNextFloat(packetData);
|
dataTypes.ReadNextFloat(packetData); // Player Motion Z
|
||||||
|
|
||||||
|
if (protocolVersion >= MC_1_20_4_Version)
|
||||||
|
{
|
||||||
|
dataTypes.ReadNextVarInt(packetData); // Block Interaction
|
||||||
|
dataTypes.ReadParticleData(packetData, itemPalette); // Small Explosion Particles
|
||||||
|
dataTypes.ReadParticleData(packetData, itemPalette); // Large Explosion Particles
|
||||||
|
|
||||||
|
// Explosion Sound
|
||||||
|
dataTypes.ReadNextString(packetData); // Sound Name
|
||||||
|
var hasFixedRange = dataTypes.ReadNextBool(packetData);
|
||||||
|
if (hasFixedRange)
|
||||||
|
dataTypes.ReadNextFloat(packetData); // Range
|
||||||
|
}
|
||||||
|
|
||||||
handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
|
handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
|
||||||
break;
|
break;
|
||||||
|
|
@ -2497,30 +2535,61 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
handler.OnHeldItemChange(dataTypes.ReadNextByte(packetData)); // Slot
|
handler.OnHeldItemChange(dataTypes.ReadNextByte(packetData)); // Slot
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.ScoreboardObjective:
|
case PacketTypesIn.ScoreboardObjective:
|
||||||
var objectiveName2 = dataTypes.ReadNextString(packetData);
|
var objectiveName = dataTypes.ReadNextString(packetData);
|
||||||
var mode = dataTypes.ReadNextByte(packetData);
|
var mode = dataTypes.ReadNextByte(packetData);
|
||||||
|
|
||||||
var objectiveValue = string.Empty;
|
var objectiveValue = string.Empty;
|
||||||
var type2 = -1;
|
var objectiveType = -1;
|
||||||
|
var numberFormat = 0;
|
||||||
|
|
||||||
if (mode is 0 or 2)
|
if (mode is 0 or 2)
|
||||||
{
|
{
|
||||||
objectiveValue = dataTypes.ReadNextString(packetData);
|
objectiveValue = dataTypes.ReadNextString(packetData);
|
||||||
type2 = dataTypes.ReadNextVarInt(packetData);
|
objectiveType = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
|
||||||
|
if (protocolVersion >= MC_1_20_4_Version)
|
||||||
|
{
|
||||||
|
if (dataTypes.ReadNextBool(packetData)) // Has Number Format
|
||||||
|
numberFormat = dataTypes.ReadNextVarInt(packetData); // Number Format
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.OnScoreboardObjective(objectiveName2, mode, objectiveValue, type2);
|
handler.OnScoreboardObjective(objectiveName, mode, objectiveValue, objectiveType, numberFormat);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.UpdateScore:
|
case PacketTypesIn.UpdateScore:
|
||||||
var entityName = dataTypes.ReadNextString(packetData);
|
var entityName = dataTypes.ReadNextString(packetData);
|
||||||
var action3 = protocolVersion >= MC_1_18_2_Version
|
|
||||||
? dataTypes.ReadNextVarInt(packetData)
|
var action3 = 0;
|
||||||
: dataTypes.ReadNextByte(packetData);
|
|
||||||
var objectiveName3 = string.Empty;
|
var objectiveName3 = string.Empty;
|
||||||
var value = -1;
|
var objectiveValue2 = -1;
|
||||||
if (action3 != 1 || protocolVersion >= MC_1_8_Version)
|
var objectiveDisplayName3 = string.Empty;
|
||||||
objectiveName3 = dataTypes.ReadNextString(packetData);
|
var numberFormat2 = 0;
|
||||||
if (action3 != 1)
|
|
||||||
value = dataTypes.ReadNextVarInt(packetData);
|
if (protocolVersion >= MC_1_20_4_Version)
|
||||||
handler.OnUpdateScore(entityName, action3, objectiveName3, value);
|
{
|
||||||
|
objectiveName3 = dataTypes.ReadNextString(packetData); // Objective Name
|
||||||
|
objectiveValue2 = dataTypes.ReadNextVarInt(packetData); // Value
|
||||||
|
|
||||||
|
if (dataTypes.ReadNextBool(packetData)) // Has Display Name
|
||||||
|
objectiveDisplayName3 = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); // Has Display Name
|
||||||
|
|
||||||
|
if (dataTypes.ReadNextBool(packetData)) // Has Number Format
|
||||||
|
numberFormat2 = dataTypes.ReadNextVarInt(packetData); // Number Format
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
action3 = protocolVersion >= MC_1_18_2_Version
|
||||||
|
? dataTypes.ReadNextVarInt(packetData)
|
||||||
|
: dataTypes.ReadNextByte(packetData);
|
||||||
|
|
||||||
|
if (action3 != 1 || protocolVersion >= MC_1_8_Version)
|
||||||
|
objectiveName3 = dataTypes.ReadNextString(packetData);
|
||||||
|
|
||||||
|
if (action3 != 1)
|
||||||
|
objectiveValue2 = dataTypes.ReadNextVarInt(packetData);
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.OnUpdateScore(entityName, action3, objectiveName3, objectiveDisplayName3, objectiveValue2, numberFormat2);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.BlockChangedAck:
|
case PacketTypesIn.BlockChangedAck:
|
||||||
handler.OnBlockChangeAck(dataTypes.ReadNextVarInt(packetData));
|
handler.OnBlockChangeAck(dataTypes.ReadNextVarInt(packetData));
|
||||||
|
|
@ -4175,7 +4244,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendAnimation(int animation, int playerid)
|
public bool SendAnimation(int animation, int playerId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -4186,7 +4255,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
switch (protocolVersion)
|
switch (protocolVersion)
|
||||||
{
|
{
|
||||||
case < MC_1_8_Version:
|
case < MC_1_8_Version:
|
||||||
packet.AddRange(DataTypes.GetInt(playerid));
|
packet.AddRange(DataTypes.GetInt(playerId));
|
||||||
packet.Add(1); // Swing arm
|
packet.Add(1); // Swing arm
|
||||||
break;
|
break;
|
||||||
case < MC_1_9_Version:
|
case < MC_1_9_Version:
|
||||||
|
|
@ -4423,10 +4492,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendRenameItem(string itemName)
|
public bool SendRenameItem(string itemName)
|
||||||
|
|
|
||||||
|
|
@ -430,22 +430,25 @@ namespace MinecraftClient.Protocol
|
||||||
void OnEntityEffect(int entityid, Effects effect, int amplifier, int duration, byte flags, bool hasFactorData, Dictionary<String, object>? factorCodec);
|
void OnEntityEffect(int entityid, Effects effect, int amplifier, int duration, byte flags, bool hasFactorData, Dictionary<String, object>? factorCodec);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when coreboardObjective
|
/// Called when Soreboard Objective
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectivename">objective name</param>
|
/// <param name="objectiveName">objective name</param>
|
||||||
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
||||||
/// <param name="objectivevalue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
/// <param name="objectiveValue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
||||||
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
||||||
void OnScoreboardObjective(string objectivename, byte mode, string objectivevalue, int type);
|
/// <param name="numberFormat">Number format: 0 - blank, 1 - styled, 2 - fixed</param>
|
||||||
|
void OnScoreboardObjective(string objectiveName, byte mode, string objectiveValue, int type, int numberFormat);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when DisplayScoreboard
|
/// Called when DisplayScoreboard
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entityname">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
/// <param name="entityName">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
||||||
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
||||||
/// <param name="objectivename">The name of the objective the score belongs to</param>
|
/// <param name="objectiveName">The name of the objective the score belongs to</param>
|
||||||
/// <param name="value">he score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
/// <param name="objectiveDisplayName">The name of the objective the score belongs to, but with chat formatting</param>
|
||||||
void OnUpdateScore(string entityname, int action, string objectivename, int value);
|
/// <param name="objectiveValue">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
||||||
|
/// <param name="numberFormat">Number format: 0 - blank, 1 - styled, 2 - fixed</param>
|
||||||
|
void OnUpdateScore(string entityName, int action, string objectiveName, string objectiveDisplayName, int objectiveValue, int numberFormat);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the client received the Tab Header and Footer
|
/// Called when the client received the Tab Header and Footer
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ using MinecraftClient.Protocol.Handlers;
|
||||||
using MinecraftClient.Protocol.Handlers.Forge;
|
using MinecraftClient.Protocol.Handlers.Forge;
|
||||||
using MinecraftClient.Protocol.Session;
|
using MinecraftClient.Protocol.Session;
|
||||||
using MinecraftClient.Proxy;
|
using MinecraftClient.Proxy;
|
||||||
using static MinecraftClient.Protocol.Microsoft;
|
|
||||||
using static MinecraftClient.Settings;
|
using static MinecraftClient.Settings;
|
||||||
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig;
|
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig;
|
||||||
|
|
||||||
|
|
@ -43,32 +42,39 @@ namespace MinecraftClient.Protocol
|
||||||
if (!String.IsNullOrEmpty(domain) && domain.Any(c => char.IsLetter(c)))
|
if (!String.IsNullOrEmpty(domain) && domain.Any(c => char.IsLetter(c)))
|
||||||
{
|
{
|
||||||
AutoTimeout.Perform(() =>
|
AutoTimeout.Perform(() =>
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLine(string.Format(Translations.mcc_resolve, domainVal));
|
try
|
||||||
var lookupClient = new LookupClient();
|
|
||||||
var response = lookupClient.Query(new DnsQuestion($"_minecraft._tcp.{domainVal}", QueryType.SRV));
|
|
||||||
if (response.HasError != true && response.Answers.SrvRecords().Any())
|
|
||||||
{
|
{
|
||||||
//Order SRV records by priority and weight, then randomly
|
ConsoleIO.WriteLine(string.Format(Translations.mcc_resolve, domainVal));
|
||||||
var result = response.Answers.SrvRecords()
|
var lookupClient = new LookupClient();
|
||||||
.OrderBy(record => record.Priority)
|
var response =
|
||||||
.ThenByDescending(record => record.Weight)
|
lookupClient.Query(new DnsQuestion($"_minecraft._tcp.{domainVal}", QueryType.SRV));
|
||||||
.ThenBy(record => Guid.NewGuid())
|
if (response.HasError != true && response.Answers.SrvRecords().Any())
|
||||||
.First();
|
{
|
||||||
string target = result.Target.Value.Trim('.');
|
//Order SRV records by priority and weight, then randomly
|
||||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_found, target, result.Port, domainVal));
|
var result = response.Answers.SrvRecords()
|
||||||
domainVal = target;
|
.OrderBy(record => record.Priority)
|
||||||
portVal = result.Port;
|
.ThenByDescending(record => record.Weight)
|
||||||
foundService = true;
|
.ThenBy(record => Guid.NewGuid())
|
||||||
|
.First();
|
||||||
|
string target = result.Target.Value.Trim('.');
|
||||||
|
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_found, target,
|
||||||
|
result.Port, domainVal));
|
||||||
|
domainVal = target;
|
||||||
|
portVal = result.Port;
|
||||||
|
foundService = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_not_found, domainVal,
|
||||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_not_found, domainVal, e.GetType().FullName, e.Message));
|
e.GetType().FullName, e.Message));
|
||||||
}
|
}
|
||||||
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30));
|
},
|
||||||
|
TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords ==
|
||||||
|
MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast
|
||||||
|
? 10
|
||||||
|
: 30));
|
||||||
}
|
}
|
||||||
|
|
||||||
domain = domainVal;
|
domain = domainVal;
|
||||||
|
|
@ -83,28 +89,34 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="serverPort">Server Port to ping</param>
|
/// <param name="serverPort">Server Port to ping</param>
|
||||||
/// <param name="protocolversion">Will contain protocol version, if ping successful</param>
|
/// <param name="protocolversion">Will contain protocol version, if ping successful</param>
|
||||||
/// <returns>TRUE if ping was successful</returns>
|
/// <returns>TRUE if ping was successful</returns>
|
||||||
public static bool GetServerInfo(string serverIP, ushort serverPort, ref int protocolversion, ref ForgeInfo? forgeInfo)
|
public static bool GetServerInfo(string serverIP, ushort serverPort, ref int protocolversion,
|
||||||
|
ref ForgeInfo? forgeInfo)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
int protocolversionTmp = 0;
|
int protocolversionTmp = 0;
|
||||||
ForgeInfo? forgeInfoTmp = null;
|
ForgeInfo? forgeInfoTmp = null;
|
||||||
if (AutoTimeout.Perform(() =>
|
if (AutoTimeout.Perform(() =>
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (Protocol18Handler.DoPing(serverIP, serverPort, ref protocolversionTmp, ref forgeInfoTmp)
|
|
||||||
|| Protocol16Handler.DoPing(serverIP, serverPort, ref protocolversionTmp))
|
|
||||||
{
|
{
|
||||||
success = true;
|
try
|
||||||
}
|
{
|
||||||
else
|
if (Protocol18Handler.DoPing(serverIP, serverPort, ref protocolversionTmp, ref forgeInfoTmp)
|
||||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_unexpect_response, acceptnewlines: true);
|
|| Protocol16Handler.DoPing(serverIP, serverPort, ref protocolversionTmp))
|
||||||
}
|
{
|
||||||
catch (Exception e)
|
success = true;
|
||||||
{
|
}
|
||||||
ConsoleIO.WriteLineFormatted(String.Format("§8{0}: {1}", e.GetType().FullName, e.Message));
|
else
|
||||||
}
|
ConsoleIO.WriteLineFormatted("§8" + Translations.error_unexpect_response,
|
||||||
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30)))
|
acceptnewlines: true);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ConsoleIO.WriteLineFormatted(string.Format("§8{0}: {1}", e.GetType().FullName, e.Message));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords ==
|
||||||
|
MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast
|
||||||
|
? 10
|
||||||
|
: 30)))
|
||||||
{
|
{
|
||||||
if (protocolversion != 0 && protocolversion != protocolversionTmp)
|
if (protocolversion != 0 && protocolversion != protocolversionTmp)
|
||||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_version_different, acceptnewlines: true);
|
ConsoleIO.WriteLineFormatted("§8" + Translations.error_version_different, acceptnewlines: true);
|
||||||
|
|
@ -125,23 +137,29 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a protocol handler for the specified Minecraft version
|
/// Get a protocol handler for the specified Minecraft version
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Client">Tcp Client connected to the server</param>
|
/// <param name="client">Tcp Client connected to the server</param>
|
||||||
/// <param name="ProtocolVersion">Protocol version to handle</param>
|
/// <param name="protocolVersion">Protocol version to handle</param>
|
||||||
/// <param name="Handler">Handler with the appropriate callbacks</param>
|
/// <param name="forgeInfo">Forge info</param>
|
||||||
|
/// <param name="handler">Handler with the appropriate callbacks</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IMinecraftCom GetProtocolHandler(TcpClient Client, int ProtocolVersion, ForgeInfo? forgeInfo, IMinecraftComHandler Handler)
|
public static IMinecraftCom GetProtocolHandler(TcpClient client, int protocolVersion, ForgeInfo? forgeInfo,
|
||||||
|
IMinecraftComHandler handler)
|
||||||
{
|
{
|
||||||
int[] supportedVersions_Protocol16 = { 51, 60, 61, 72, 73, 74, 78 };
|
int[] suppoertedVersionsProtocol16 = { 51, 60, 61, 72, 73, 74, 78 };
|
||||||
|
|
||||||
if (Array.IndexOf(supportedVersions_Protocol16, ProtocolVersion) > -1)
|
if (Array.IndexOf(suppoertedVersionsProtocol16, protocolVersion) > -1)
|
||||||
return new Protocol16Handler(Client, ProtocolVersion, Handler);
|
return new Protocol16Handler(client, protocolVersion, handler);
|
||||||
|
|
||||||
int[] supportedVersions_Protocol18 = { 4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 404, 477, 480, 485, 490, 498, 573, 575, 578, 735, 736, 751, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764};
|
int[] suppoertedVersionsProtocol18 =
|
||||||
|
{
|
||||||
|
4, 5, 47, 107, 108, 109, 110, 210, 315, 316, 335, 338, 340, 393, 401, 404, 477, 480, 485, 490, 498, 573,
|
||||||
|
575, 578, 735, 736, 751, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765
|
||||||
|
};
|
||||||
|
|
||||||
if (Array.IndexOf(supportedVersions_Protocol18, ProtocolVersion) > -1)
|
if (Array.IndexOf(suppoertedVersionsProtocol18, protocolVersion) > -1)
|
||||||
return new Protocol18Handler(Client, ProtocolVersion, Handler, forgeInfo);
|
return new Protocol18Handler(client, protocolVersion, handler, forgeInfo);
|
||||||
|
|
||||||
throw new NotSupportedException(string.Format(Translations.exception_version_unsupport, ProtocolVersion));
|
throw new NotSupportedException(string.Format(Translations.exception_version_unsupport, protocolVersion));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -149,11 +167,11 @@ namespace MinecraftClient.Protocol
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="MCVersion">The Minecraft version number</param>
|
/// <param name="MCVersion">The Minecraft version number</param>
|
||||||
/// <returns>The protocol version number or 0 if could not determine protocol version: error, unknown, not supported</returns>
|
/// <returns>The protocol version number or 0 if could not determine protocol version: error, unknown, not supported</returns>
|
||||||
public static int MCVer2ProtocolVersion(string MCVersion)
|
public static int MCVer2ProtocolVersion(string mcVersion)
|
||||||
{
|
{
|
||||||
if (MCVersion.Contains('.'))
|
if (mcVersion.Contains('.'))
|
||||||
{
|
{
|
||||||
switch (MCVersion.Split(' ')[0].Trim())
|
switch (mcVersion.Split(' ')[0].Trim())
|
||||||
{
|
{
|
||||||
case "1.0":
|
case "1.0":
|
||||||
case "1.0.0":
|
case "1.0.0":
|
||||||
|
|
@ -324,20 +342,21 @@ namespace MinecraftClient.Protocol
|
||||||
return 763;
|
return 763;
|
||||||
case "1.20.2":
|
case "1.20.2":
|
||||||
return 764;
|
return 764;
|
||||||
|
case "1.20.3":
|
||||||
|
case "1.20.4":
|
||||||
|
return 765;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
return int.Parse(mcVersion, NumberStyles.Any, CultureInfo.CurrentCulture);
|
||||||
{
|
}
|
||||||
return int.Parse(MCVersion, NumberStyles.Any, CultureInfo.CurrentCulture);
|
catch
|
||||||
}
|
{
|
||||||
catch
|
return 0;
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,6 +423,7 @@ namespace MinecraftClient.Protocol
|
||||||
762 => "1.19.4",
|
762 => "1.19.4",
|
||||||
763 => "1.20",
|
763 => "1.20",
|
||||||
764 => "1.20.2",
|
764 => "1.20.2",
|
||||||
|
765 => "1.20.4",
|
||||||
_ => "0.0"
|
_ => "0.0"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +431,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if we can force-enable Forge support for a Minecraft version without using server Ping
|
/// Check if we can force-enable Forge support for a Minecraft version without using server Ping
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="protocolVersion">Minecraft protocol version</param>
|
/// <param name="protocol">Minecraft protocol version</param>
|
||||||
/// <returns>TRUE if we can force-enable Forge support without using server Ping</returns>
|
/// <returns>TRUE if we can force-enable Forge support without using server Ping</returns>
|
||||||
public static bool ProtocolMayForceForge(int protocol)
|
public static bool ProtocolMayForceForge(int protocol)
|
||||||
{
|
{
|
||||||
|
|
@ -421,15 +441,35 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Server Info: Consider Forge to be enabled regardless of server Ping
|
/// Server Info: Consider Forge to be enabled regardless of server Ping
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="protocolVersion">Minecraft protocol version</param>
|
/// <param name="protocol">Minecraft protocol version</param>
|
||||||
/// <returns>ForgeInfo item stating that Forge is enabled</returns>
|
/// <returns>ForgeInfo item stating that Forge is enabled</returns>
|
||||||
public static ForgeInfo ProtocolForceForge(int protocol)
|
public static ForgeInfo ProtocolForceForge(int protocol)
|
||||||
{
|
{
|
||||||
return Protocol18Forge.ServerForceForge(protocol);
|
return Protocol18Forge.ServerForceForge(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LoginResult { OtherError, ServiceUnavailable, SSLError, Success, WrongPassword, AccountMigrated, NotPremium, LoginRequired, InvalidToken, InvalidResponse, NullError, UserCancel, WrongSelection };
|
public enum LoginResult
|
||||||
public enum AccountType { Mojang, Microsoft };
|
{
|
||||||
|
OtherError,
|
||||||
|
ServiceUnavailable,
|
||||||
|
SSLError,
|
||||||
|
Success,
|
||||||
|
WrongPassword,
|
||||||
|
AccountMigrated,
|
||||||
|
NotPremium,
|
||||||
|
LoginRequired,
|
||||||
|
InvalidToken,
|
||||||
|
InvalidResponse,
|
||||||
|
NullError,
|
||||||
|
UserCancel,
|
||||||
|
WrongSelection
|
||||||
|
};
|
||||||
|
|
||||||
|
public enum AccountType
|
||||||
|
{
|
||||||
|
Mojang,
|
||||||
|
Microsoft
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows to login to a premium Minecraft account using the Yggdrasil authentication scheme.
|
/// Allows to login to a premium Minecraft account using the Yggdrasil authentication scheme.
|
||||||
|
|
@ -455,7 +495,9 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
return YggdrasiLogin(user, pass, out session);
|
return YggdrasiLogin(user, pass, out session);
|
||||||
}
|
}
|
||||||
else throw new InvalidOperationException("Account type must be Mojang or Microsoft or valid authlib 3rd Servers!");
|
else
|
||||||
|
throw new InvalidOperationException(
|
||||||
|
"Account type must be Mojang or Microsoft or valid authlib 3rd Servers!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -472,8 +514,10 @@ namespace MinecraftClient.Protocol
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" + JsonEncode(user) + "\", \"password\": \"" + JsonEncode(pass) + "\", \"clientToken\": \"" + JsonEncode(session.ClientID) + "\" }";
|
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" +
|
||||||
int code = DoHTTPSPost("authserver.mojang.com",443, "/authenticate", json_request, ref result);
|
JsonEncode(user) + "\", \"password\": \"" + JsonEncode(pass) +
|
||||||
|
"\", \"clientToken\": \"" + JsonEncode(session.ClientID) + "\" }";
|
||||||
|
int code = DoHTTPSPost("authserver.mojang.com", 443, "/authenticate", json_request, ref result);
|
||||||
if (code == 200)
|
if (code == 200)
|
||||||
{
|
{
|
||||||
if (result.Contains("availableProfiles\":[]}"))
|
if (result.Contains("availableProfiles\":[]}"))
|
||||||
|
|
@ -490,7 +534,8 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
session.ID = loginResponse.Properties["accessToken"].StringValue;
|
session.ID = loginResponse.Properties["accessToken"].StringValue;
|
||||||
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
||||||
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"].StringValue;
|
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"]
|
||||||
|
.StringValue;
|
||||||
return LoginResult.Success;
|
return LoginResult.Success;
|
||||||
}
|
}
|
||||||
else return LoginResult.InvalidResponse;
|
else return LoginResult.InvalidResponse;
|
||||||
|
|
@ -520,6 +565,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginResult.SSLError;
|
return LoginResult.SSLError;
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException e)
|
catch (System.IO.IOException e)
|
||||||
|
|
@ -528,6 +574,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.Message.Contains("authentication"))
|
if (e.Message.Contains("authentication"))
|
||||||
{
|
{
|
||||||
return LoginResult.SSLError;
|
return LoginResult.SSLError;
|
||||||
|
|
@ -540,18 +587,23 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginResult.OtherError;
|
return LoginResult.OtherError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static LoginResult YggdrasiLogin(string user, string pass, out SessionToken session)
|
|
||||||
|
private static LoginResult YggdrasiLogin(string user, string pass, out SessionToken session)
|
||||||
{
|
{
|
||||||
session = new SessionToken() { ClientID = Guid.NewGuid().ToString().Replace("-", "") };
|
session = new SessionToken() { ClientID = Guid.NewGuid().ToString().Replace("-", "") };
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" + JsonEncode(user) + "\", \"password\": \"" + JsonEncode(pass) + "\", \"clientToken\": \"" + JsonEncode(session.ClientID) + "\" }";
|
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" +
|
||||||
int code = DoHTTPSPost(Config.Main.General.AuthServer.Host,Config.Main.General.AuthServer.Port, "/api/yggdrasil/authserver/authenticate", json_request, ref result);
|
JsonEncode(user) + "\", \"password\": \"" + JsonEncode(pass) +
|
||||||
|
"\", \"clientToken\": \"" + JsonEncode(session.ClientID) + "\" }";
|
||||||
|
int code = DoHTTPSPost(Config.Main.General.AuthServer.Host, Config.Main.General.AuthServer.Port,
|
||||||
|
"/api/yggdrasil/authserver/authenticate", json_request, ref result);
|
||||||
if (code == 200)
|
if (code == 200)
|
||||||
{
|
{
|
||||||
if (result.Contains("availableProfiles\":[]}"))
|
if (result.Contains("availableProfiles\":[]}"))
|
||||||
|
|
@ -568,36 +620,43 @@ namespace MinecraftClient.Protocol
|
||||||
&& loginResponse.Properties["selectedProfile"].Properties.ContainsKey("id")
|
&& loginResponse.Properties["selectedProfile"].Properties.ContainsKey("id")
|
||||||
&& loginResponse.Properties["selectedProfile"].Properties.ContainsKey("name"))
|
&& loginResponse.Properties["selectedProfile"].Properties.ContainsKey("name"))
|
||||||
{
|
{
|
||||||
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"]
|
||||||
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"].StringValue;
|
.StringValue;
|
||||||
|
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"]
|
||||||
|
.StringValue;
|
||||||
return LoginResult.Success;
|
return LoginResult.Success;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string availableProfiles = "";
|
string availableProfiles = "";
|
||||||
foreach (Json.JSONData profile in loginResponse.Properties["availableProfiles"].DataArray)
|
foreach (Json.JSONData profile in loginResponse.Properties["availableProfiles"]
|
||||||
|
.DataArray)
|
||||||
{
|
{
|
||||||
availableProfiles += " " + profile.Properties["name"].StringValue;
|
availableProfiles += " " + profile.Properties["name"].StringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleIO.WriteLine(Translations.mcc_avaliable_profiles + availableProfiles);
|
ConsoleIO.WriteLine(Translations.mcc_avaliable_profiles + availableProfiles);
|
||||||
|
|
||||||
ConsoleIO.WriteLine(Translations.mcc_select_profile);
|
ConsoleIO.WriteLine(Translations.mcc_select_profile);
|
||||||
string selectedProfileName = ConsoleIO.ReadLine();
|
string selectedProfileName = ConsoleIO.ReadLine();
|
||||||
ConsoleIO.WriteLine(Translations.mcc_selected_profile + " " + selectedProfileName);
|
ConsoleIO.WriteLine(Translations.mcc_selected_profile + " " + selectedProfileName);
|
||||||
Json.JSONData? selectedProfile = null;
|
Json.JSONData? selectedProfile = null;
|
||||||
foreach (Json.JSONData profile in loginResponse.Properties["availableProfiles"].DataArray)
|
foreach (Json.JSONData profile in loginResponse.Properties["availableProfiles"]
|
||||||
|
.DataArray)
|
||||||
{
|
{
|
||||||
selectedProfile = profile.Properties["name"].StringValue == selectedProfileName ? profile : selectedProfile;
|
selectedProfile = profile.Properties["name"].StringValue == selectedProfileName
|
||||||
|
? profile
|
||||||
|
: selectedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedProfile != null)
|
if (selectedProfile != null)
|
||||||
{
|
{
|
||||||
session.PlayerID = selectedProfile.Properties["id"].StringValue;
|
session.PlayerID = selectedProfile.Properties["id"].StringValue;
|
||||||
session.PlayerName = selectedProfile.Properties["name"].StringValue;
|
session.PlayerName = selectedProfile.Properties["name"].StringValue;
|
||||||
SessionToken currentsession = session;
|
SessionToken currentsession = session;
|
||||||
return GetNewYggdrasilToken(currentsession, out session);
|
return GetNewYggdrasilToken(currentsession, out session);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return LoginResult.WrongSelection;
|
return LoginResult.WrongSelection;
|
||||||
}
|
}
|
||||||
|
|
@ -630,6 +689,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginResult.SSLError;
|
return LoginResult.SSLError;
|
||||||
}
|
}
|
||||||
catch (System.IO.IOException e)
|
catch (System.IO.IOException e)
|
||||||
|
|
@ -638,6 +698,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.Message.Contains("authentication"))
|
if (e.Message.Contains("authentication"))
|
||||||
{
|
{
|
||||||
return LoginResult.SSLError;
|
return LoginResult.SSLError;
|
||||||
|
|
@ -650,9 +711,11 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginResult.OtherError;
|
return LoginResult.OtherError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sign-in to Microsoft Account without using browser. Only works if 2FA is disabled.
|
/// Sign-in to Microsoft Account without using browser. Only works if 2FA is disabled.
|
||||||
/// Might not work well in some rare cases.
|
/// Might not work well in some rare cases.
|
||||||
|
|
@ -678,6 +741,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginResult.WrongPassword; // Might not always be wrong password
|
return LoginResult.WrongPassword; // Might not always be wrong password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -748,6 +812,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginResult.WrongPassword; // Might not always be wrong password
|
return LoginResult.WrongPassword; // Might not always be wrong password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -761,13 +826,15 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
var payload = JwtPayloadDecode.GetPayload(session.ID);
|
var payload = JwtPayloadDecode.GetPayload(session.ID);
|
||||||
var json = Json.ParseJson(payload);
|
var json = Json.ParseJson(payload);
|
||||||
var expTimestamp = long.Parse(json.Properties["exp"].StringValue, NumberStyles.Any, CultureInfo.CurrentCulture);
|
var expTimestamp = long.Parse(json.Properties["exp"].StringValue, NumberStyles.Any,
|
||||||
|
CultureInfo.CurrentCulture);
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
var tokenExp = UnixTimeStampToDateTime(expTimestamp);
|
var tokenExp = UnixTimeStampToDateTime(expTimestamp);
|
||||||
if (Settings.Config.Logging.DebugMessages)
|
if (Settings.Config.Logging.DebugMessages)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLine("Access token expiration time is " + tokenExp.ToString());
|
ConsoleIO.WriteLine("Access token expiration time is " + tokenExp.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now < tokenExp)
|
if (now < tokenExp)
|
||||||
{
|
{
|
||||||
// Still valid
|
// Still valid
|
||||||
|
|
@ -792,8 +859,11 @@ namespace MinecraftClient.Protocol
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) + "\", \"clientToken\": \"" + JsonEncode(currentsession.ClientID) + "\", \"selectedProfile\": { \"id\": \"" + JsonEncode(currentsession.PlayerID) + "\", \"name\": \"" + JsonEncode(currentsession.PlayerName) + "\" } }";
|
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) +
|
||||||
int code = DoHTTPSPost("authserver.mojang.com",443, "/refresh", json_request, ref result);
|
"\", \"clientToken\": \"" + JsonEncode(currentsession.ClientID) +
|
||||||
|
"\", \"selectedProfile\": { \"id\": \"" + JsonEncode(currentsession.PlayerID) +
|
||||||
|
"\", \"name\": \"" + JsonEncode(currentsession.PlayerName) + "\" } }";
|
||||||
|
int code = DoHTTPSPost("authserver.mojang.com", 443, "/refresh", json_request, ref result);
|
||||||
if (code == 200)
|
if (code == 200)
|
||||||
{
|
{
|
||||||
if (result == null)
|
if (result == null)
|
||||||
|
|
@ -810,7 +880,8 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
session.ID = loginResponse.Properties["accessToken"].StringValue;
|
session.ID = loginResponse.Properties["accessToken"].StringValue;
|
||||||
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
||||||
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"].StringValue;
|
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"]
|
||||||
|
.StringValue;
|
||||||
return LoginResult.Success;
|
return LoginResult.Success;
|
||||||
}
|
}
|
||||||
else return LoginResult.InvalidResponse;
|
else return LoginResult.InvalidResponse;
|
||||||
|
|
@ -838,8 +909,12 @@ namespace MinecraftClient.Protocol
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) + "\", \"clientToken\": \"" + JsonEncode(currentsession.ClientID) + "\", \"selectedProfile\": { \"id\": \"" + JsonEncode(currentsession.PlayerID) + "\", \"name\": \"" + JsonEncode(currentsession.PlayerName) + "\" } }";
|
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) +
|
||||||
int code = DoHTTPSPost(Config.Main.General.AuthServer.Host, Config.Main.General.AuthServer.Port, "/api/yggdrasil/authserver/refresh", json_request, ref result);
|
"\", \"clientToken\": \"" + JsonEncode(currentsession.ClientID) +
|
||||||
|
"\", \"selectedProfile\": { \"id\": \"" + JsonEncode(currentsession.PlayerID) +
|
||||||
|
"\", \"name\": \"" + JsonEncode(currentsession.PlayerName) + "\" } }";
|
||||||
|
int code = DoHTTPSPost(Config.Main.General.AuthServer.Host, Config.Main.General.AuthServer.Port,
|
||||||
|
"/api/yggdrasil/authserver/refresh", json_request, ref result);
|
||||||
if (code == 200)
|
if (code == 200)
|
||||||
{
|
{
|
||||||
if (result == null)
|
if (result == null)
|
||||||
|
|
@ -856,7 +931,8 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
session.ID = loginResponse.Properties["accessToken"].StringValue;
|
session.ID = loginResponse.Properties["accessToken"].StringValue;
|
||||||
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
||||||
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"].StringValue;
|
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"]
|
||||||
|
.StringValue;
|
||||||
return LoginResult.Success;
|
return LoginResult.Success;
|
||||||
}
|
}
|
||||||
else return LoginResult.InvalidResponse;
|
else return LoginResult.InvalidResponse;
|
||||||
|
|
@ -891,15 +967,23 @@ namespace MinecraftClient.Protocol
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string json_request = "{\"accessToken\":\"" + accesstoken + "\",\"selectedProfile\":\"" + uuid + "\",\"serverId\":\"" + serverhash + "\"}";
|
string json_request = "{\"accessToken\":\"" + accesstoken + "\",\"selectedProfile\":\"" + uuid +
|
||||||
string host = type == LoginType.yggdrasil ? Config.Main.General.AuthServer.Host : "sessionserver.mojang.com";
|
"\",\"serverId\":\"" + serverhash + "\"}";
|
||||||
|
string host = type == LoginType.yggdrasil
|
||||||
|
? Config.Main.General.AuthServer.Host
|
||||||
|
: "sessionserver.mojang.com";
|
||||||
int port = type == LoginType.yggdrasil ? Config.Main.General.AuthServer.Port : 443;
|
int port = type == LoginType.yggdrasil ? Config.Main.General.AuthServer.Port : 443;
|
||||||
string endpoint = type == LoginType.yggdrasil ? "/api/yggdrasil/sessionserver/session/minecraft/join" : "/session/minecraft/join";
|
string endpoint = type == LoginType.yggdrasil
|
||||||
|
? "/api/yggdrasil/sessionserver/session/minecraft/join"
|
||||||
|
: "/session/minecraft/join";
|
||||||
|
|
||||||
int code = DoHTTPSPost(host, port, endpoint, json_request, ref result);
|
int code = DoHTTPSPost(host, port, endpoint, json_request, ref result);
|
||||||
return (code >= 200 && code < 300);
|
return (code >= 200 && code < 300);
|
||||||
}
|
}
|
||||||
catch { return false; }
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -915,8 +999,9 @@ namespace MinecraftClient.Protocol
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username, Program.MCHighestVersion);
|
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username,
|
||||||
DoHTTPSGet("pc.realms.minecraft.net", 443,"/worlds", cookies, ref result);
|
Program.MCHighestVersion);
|
||||||
|
DoHTTPSGet("pc.realms.minecraft.net", 443, "/worlds", cookies, ref result);
|
||||||
Json.JSONData realmsWorlds = Json.ParseJson(result);
|
Json.JSONData realmsWorlds = Json.ParseJson(result);
|
||||||
if (realmsWorlds.Properties.ContainsKey("servers")
|
if (realmsWorlds.Properties.ContainsKey("servers")
|
||||||
&& realmsWorlds.Properties["servers"].Type == Json.JSONData.DataType.Array
|
&& realmsWorlds.Properties["servers"].Type == Json.JSONData.DataType.Array
|
||||||
|
|
@ -942,6 +1027,7 @@ namespace MinecraftClient.Protocol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (availableWorlds.Count > 0)
|
if (availableWorlds.Count > 0)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLine(Translations.mcc_realms_available);
|
ConsoleIO.WriteLine(Translations.mcc_realms_available);
|
||||||
|
|
@ -950,7 +1036,6 @@ namespace MinecraftClient.Protocol
|
||||||
ConsoleIO.WriteLine(Translations.mcc_realms_join);
|
ConsoleIO.WriteLine(Translations.mcc_realms_join);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -960,6 +1045,7 @@ namespace MinecraftClient.Protocol
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.StackTrace);
|
ConsoleIO.WriteLineFormatted("§8" + e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return realmsWorldsResult;
|
return realmsWorldsResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -971,13 +1057,16 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="uuid">Player UUID</param>
|
/// <param name="uuid">Player UUID</param>
|
||||||
/// <param name="accesstoken">Access token</param>
|
/// <param name="accesstoken">Access token</param>
|
||||||
/// <returns>Server address (host:port) or empty string if failure</returns>
|
/// <returns>Server address (host:port) or empty string if failure</returns>
|
||||||
public static string GetRealmsWorldServerAddress(string worldId, string username, string uuid, string accesstoken)
|
public static string GetRealmsWorldServerAddress(string worldId, string username, string uuid,
|
||||||
|
string accesstoken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string result = "";
|
string result = "";
|
||||||
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username, Program.MCHighestVersion);
|
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username,
|
||||||
int statusCode = DoHTTPSGet("pc.realms.minecraft.net",443, "/worlds/v1/" + worldId + "/join/pc", cookies, ref result);
|
Program.MCHighestVersion);
|
||||||
|
int statusCode = DoHTTPSGet("pc.realms.minecraft.net", 443, "/worlds/v1/" + worldId + "/join/pc",
|
||||||
|
cookies, ref result);
|
||||||
if (statusCode == 200)
|
if (statusCode == 200)
|
||||||
{
|
{
|
||||||
Json.JSONData serverAddress = Json.ParseJson(result);
|
Json.JSONData serverAddress = Json.ParseJson(result);
|
||||||
|
|
@ -1002,6 +1091,7 @@ namespace MinecraftClient.Protocol
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted("§8" + e.StackTrace);
|
ConsoleIO.WriteLineFormatted("§8" + e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1014,7 +1104,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="cookies">Cookies for making the request</param>
|
/// <param name="cookies">Cookies for making the request</param>
|
||||||
/// <param name="result">Request result</param>
|
/// <param name="result">Request result</param>
|
||||||
/// <returns>HTTP Status code</returns>
|
/// <returns>HTTP Status code</returns>
|
||||||
private static int DoHTTPSGet(string host,int port, string endpoint, string cookies, ref string result)
|
private static int DoHTTPSGet(string host, int port, string endpoint, string cookies, ref string result)
|
||||||
{
|
{
|
||||||
List<String> http_request = new()
|
List<String> http_request = new()
|
||||||
{
|
{
|
||||||
|
|
@ -1029,7 +1119,7 @@ namespace MinecraftClient.Protocol
|
||||||
"",
|
"",
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
return DoHTTPSRequest(http_request, host,port, ref result);
|
return DoHTTPSRequest(http_request, host, port, ref result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1053,7 +1143,7 @@ namespace MinecraftClient.Protocol
|
||||||
"",
|
"",
|
||||||
request
|
request
|
||||||
};
|
};
|
||||||
return DoHTTPSRequest(http_request, host,port, ref result);
|
return DoHTTPSRequest(http_request, host, port, ref result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1064,7 +1154,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="host">Host to connect to</param>
|
/// <param name="host">Host to connect to</param>
|
||||||
/// <param name="result">Request result</param>
|
/// <param name="result">Request result</param>
|
||||||
/// <returns>HTTP Status code</returns>
|
/// <returns>HTTP Status code</returns>
|
||||||
private static int DoHTTPSRequest(List<string> headers, string host,int port, ref string result)
|
private static int DoHTTPSRequest(List<string> headers, string host, int port, ref string result)
|
||||||
{
|
{
|
||||||
string? postResult = null;
|
string? postResult = null;
|
||||||
int statusCode = 520;
|
int statusCode = 520;
|
||||||
|
|
@ -1078,7 +1168,8 @@ namespace MinecraftClient.Protocol
|
||||||
|
|
||||||
TcpClient client = ProxyHandler.NewTcpClient(host, port, true);
|
TcpClient client = ProxyHandler.NewTcpClient(host, port, true);
|
||||||
SslStream stream = new(client.GetStream());
|
SslStream stream = new(client.GetStream());
|
||||||
stream.AuthenticateAsClient(host, null, SslProtocols.Tls12, true); // Enable TLS 1.2. Hotfix for #1780
|
stream.AuthenticateAsClient(host, null, SslProtocols.Tls12,
|
||||||
|
true); // Enable TLS 1.2. Hotfix for #1780
|
||||||
|
|
||||||
if (Settings.Config.Logging.DebugMessages)
|
if (Settings.Config.Logging.DebugMessages)
|
||||||
foreach (string line in headers)
|
foreach (string line in headers)
|
||||||
|
|
@ -1098,12 +1189,12 @@ namespace MinecraftClient.Protocol
|
||||||
if (raw_result.StartsWith("HTTP/1.1"))
|
if (raw_result.StartsWith("HTTP/1.1"))
|
||||||
{
|
{
|
||||||
statusCode = int.Parse(raw_result.Split(' ')[1], NumberStyles.Any, CultureInfo.CurrentCulture);
|
statusCode = int.Parse(raw_result.Split(' ')[1], NumberStyles.Any, CultureInfo.CurrentCulture);
|
||||||
if (statusCode != 204)
|
if (statusCode != 204)
|
||||||
{
|
{
|
||||||
var splited = raw_result[(raw_result.IndexOf("\r\n\r\n") + 4)..].Split("\r\n");
|
var splited = raw_result[(raw_result.IndexOf("\r\n\r\n") + 4)..].Split("\r\n");
|
||||||
postResult = splited[1] + splited[3];
|
postResult = splited[1] + splited[3];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
postResult = "No Content";
|
postResult = "No Content";
|
||||||
}
|
}
|
||||||
|
|
@ -1165,4 +1256,4 @@ namespace MinecraftClient.Protocol
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -332,20 +332,23 @@ namespace MinecraftClient.Scripting
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a scoreboard objective updated
|
/// Called when a scoreboard objective updated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectivename">objective name</param>
|
/// <param name="objectiveName">objective name</param>
|
||||||
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
/// <param name="mode">0 to create the scoreboard. 1 to remove the scoreboard. 2 to update the display text.</param>
|
||||||
/// <param name="objectivevalue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
/// <param name="objectiveValue">Only if mode is 0 or 2. The text to be displayed for the score</param>
|
||||||
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
/// <param name="type">Only if mode is 0 or 2. 0 = "integer", 1 = "hearts".</param>
|
||||||
public virtual void OnScoreboardObjective(string objectivename, byte mode, string objectivevalue, int type, string json) { }
|
/// <param name="numberFormat">Number format: 0 - blank, 1 - styled, 2 - fixed</param>
|
||||||
|
public virtual void OnScoreboardObjective(string objectiveName, byte mode, string objectiveValue, int type, string json, int numberFormat) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a scoreboard updated
|
/// Called when a scoreboard updated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entityname">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
/// <param name="entityName">The entity whose score this is. For players, this is their username; for other entities, it is their UUID.</param>
|
||||||
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
/// <param name="action">0 to create/update an item. 1 to remove an item.</param>
|
||||||
/// <param name="objectivename">The name of the objective the score belongs to</param>
|
/// <param name="objectiveName">The name of the objective the score belongs to</param>
|
||||||
|
/// <param name="objectiveDisplayName">The name of the objective the score belongs to, but with chat formatting</param>
|
||||||
/// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
/// <param name="value">The score to be displayed next to the entry. Only sent when Action does not equal 1.</param>
|
||||||
public virtual void OnUpdateScore(string entityname, int action, string objectivename, int value) { }
|
/// <param name="numberFormat">Number format: 0 - blank, 1 - styled, 2 - fixed</param>
|
||||||
|
public virtual void OnUpdateScore(string entityName, int action, string objectiveName, string objectiveDisplayName, int value, int numberFormat) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the client received the Tab Header and Footer
|
/// Called when the client received the Tab Header and Footer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue