mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Merge branch 'MCCTeam:master' into forge-cmds
This commit is contained in:
commit
79910b50f7
28 changed files with 10032 additions and 5418 deletions
|
|
@ -1221,16 +1221,16 @@ public class WebSocketBot : ChatBot
|
|||
}
|
||||
|
||||
public override void OnScoreboardObjective(string objectiveName, byte mode, string objectiveValue, int type,
|
||||
string json_)
|
||||
string json_, int numberFormat)
|
||||
{
|
||||
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",
|
||||
new { entityName, action, objectiveName, type = value });
|
||||
new { entityName, action, objectiveName, objectiveDisplayName, type = value, numberFormat });
|
||||
}
|
||||
|
||||
public override void OnInventoryUpdate(int inventoryId)
|
||||
|
|
|
|||
1330
MinecraftClient/Inventory/ItemPalettes/ItemPalette1204.cs
Normal file
1330
MinecraftClient/Inventory/ItemPalettes/ItemPalette1204.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -154,6 +154,7 @@
|
|||
BrainCoralBlock,
|
||||
BrainCoralFan,
|
||||
Bread,
|
||||
BreezeSpawnEgg,
|
||||
BrewerPotterySherd,
|
||||
BrewingStand,
|
||||
Brick,
|
||||
|
|
@ -228,6 +229,7 @@
|
|||
ChickenSpawnEgg,
|
||||
ChippedAnvil,
|
||||
ChiseledBookshelf,
|
||||
ChiseledCopper,
|
||||
ChiseledDeepslate,
|
||||
ChiseledNetherBricks,
|
||||
ChiseledPolishedBlackstone,
|
||||
|
|
@ -235,6 +237,8 @@
|
|||
ChiseledRedSandstone,
|
||||
ChiseledSandstone,
|
||||
ChiseledStoneBricks,
|
||||
ChiseledTuff,
|
||||
ChiseledTuffBricks,
|
||||
ChorusFlower,
|
||||
ChorusFruit,
|
||||
ChorusPlant,
|
||||
|
|
@ -274,8 +278,12 @@
|
|||
CookedSalmon,
|
||||
Cookie,
|
||||
CopperBlock,
|
||||
CopperBulb,
|
||||
CopperDoor,
|
||||
CopperGrate,
|
||||
CopperIngot,
|
||||
CopperOre,
|
||||
CopperTrapdoor,
|
||||
Cornflower,
|
||||
CowSpawnEgg,
|
||||
CrackedDeepslateBricks,
|
||||
|
|
@ -283,6 +291,7 @@
|
|||
CrackedNetherBricks,
|
||||
CrackedPolishedBlackstoneBricks,
|
||||
CrackedStoneBricks,
|
||||
Crafter,
|
||||
CraftingTable,
|
||||
CreeperBannerPattern,
|
||||
CreeperHead,
|
||||
|
|
@ -444,7 +453,12 @@
|
|||
EvokerSpawnEgg,
|
||||
ExperienceBottle,
|
||||
ExplorerPotterySherd,
|
||||
ExposedChiseledCopper,
|
||||
ExposedCopper,
|
||||
ExposedCopperBulb,
|
||||
ExposedCopperDoor,
|
||||
ExposedCopperGrate,
|
||||
ExposedCopperTrapdoor,
|
||||
ExposedCutCopper,
|
||||
ExposedCutCopperSlab,
|
||||
ExposedCutCopperStairs,
|
||||
|
|
@ -511,7 +525,7 @@
|
|||
GraniteSlab,
|
||||
GraniteStairs,
|
||||
GraniteWall,
|
||||
Grass,
|
||||
Grass, // 1.20.3+ renamed to ShortGrass
|
||||
GrassBlock,
|
||||
Gravel,
|
||||
GrayBanner,
|
||||
|
|
@ -826,7 +840,12 @@
|
|||
OrangeTulip,
|
||||
OrangeWool,
|
||||
OxeyeDaisy,
|
||||
OxidizedChiseledCopper,
|
||||
OxidizedCopper,
|
||||
OxidizedCopperBulb,
|
||||
OxidizedCopperDoor,
|
||||
OxidizedCopperGrate,
|
||||
OxidizedCopperTrapdoor,
|
||||
OxidizedCutCopper,
|
||||
OxidizedCutCopperSlab,
|
||||
OxidizedCutCopperStairs,
|
||||
|
|
@ -895,6 +914,10 @@
|
|||
PolishedGranite,
|
||||
PolishedGraniteSlab,
|
||||
PolishedGraniteStairs,
|
||||
PolishedTuff,
|
||||
PolishedTuffSlab,
|
||||
PolishedTuffStairs,
|
||||
PolishedTuffWall,
|
||||
PoppedChorusFruit,
|
||||
Poppy,
|
||||
Porkchop,
|
||||
|
|
@ -1020,6 +1043,7 @@
|
|||
SheepSpawnEgg,
|
||||
ShelterPotterySherd,
|
||||
Shield,
|
||||
ShortGrass,
|
||||
Shroomlight,
|
||||
ShulkerBox,
|
||||
ShulkerShell,
|
||||
|
|
@ -1156,6 +1180,8 @@
|
|||
TotemOfUndying,
|
||||
TraderLlamaSpawnEgg,
|
||||
TrappedChest,
|
||||
TrialKey,
|
||||
TrialSpawner,
|
||||
Trident,
|
||||
TripwireHook,
|
||||
TropicalFish,
|
||||
|
|
@ -1165,6 +1191,13 @@
|
|||
TubeCoralBlock,
|
||||
TubeCoralFan,
|
||||
Tuff,
|
||||
TuffBrickSlab,
|
||||
TuffBrickStairs,
|
||||
TuffBrickWall,
|
||||
TuffBricks,
|
||||
TuffSlab,
|
||||
TuffStairs,
|
||||
TuffWall,
|
||||
TurtleEgg,
|
||||
TurtleHelmet,
|
||||
TurtleSpawnEgg,
|
||||
|
|
@ -1197,24 +1230,49 @@
|
|||
WarpedTrapdoor,
|
||||
WarpedWartBlock,
|
||||
WaterBucket,
|
||||
WaxedChiseledCopper,
|
||||
WaxedCopperBlock,
|
||||
WaxedCopperBulb,
|
||||
WaxedCopperDoor,
|
||||
WaxedCopperGrate,
|
||||
WaxedCopperTrapdoor,
|
||||
WaxedCutCopper,
|
||||
WaxedCutCopperSlab,
|
||||
WaxedCutCopperStairs,
|
||||
WaxedExposedChiseledCopper,
|
||||
WaxedExposedCopper,
|
||||
WaxedExposedCopperBulb,
|
||||
WaxedExposedCopperDoor,
|
||||
WaxedExposedCopperGrate,
|
||||
WaxedExposedCopperTrapdoor,
|
||||
WaxedExposedCutCopper,
|
||||
WaxedExposedCutCopperSlab,
|
||||
WaxedExposedCutCopperStairs,
|
||||
WaxedOxidizedChiseledCopper,
|
||||
WaxedOxidizedCopper,
|
||||
WaxedOxidizedCopperBulb,
|
||||
WaxedOxidizedCopperDoor,
|
||||
WaxedOxidizedCopperGrate,
|
||||
WaxedOxidizedCopperTrapdoor,
|
||||
WaxedOxidizedCutCopper,
|
||||
WaxedOxidizedCutCopperSlab,
|
||||
WaxedOxidizedCutCopperStairs,
|
||||
WaxedWeatheredChiseledCopper,
|
||||
WaxedWeatheredCopper,
|
||||
WaxedWeatheredCopperBulb,
|
||||
WaxedWeatheredCopperDoor,
|
||||
WaxedWeatheredCopperGrate,
|
||||
WaxedWeatheredCopperTrapdoor,
|
||||
WaxedWeatheredCutCopper,
|
||||
WaxedWeatheredCutCopperSlab,
|
||||
WaxedWeatheredCutCopperStairs,
|
||||
WayfinderArmorTrimSmithingTemplate,
|
||||
WeatheredChiseledCopper,
|
||||
WeatheredCopper,
|
||||
WeatheredCopperBulb,
|
||||
WeatheredCopperDoor,
|
||||
WeatheredCopperGrate,
|
||||
WeatheredCopperTrapdoor,
|
||||
WeatheredCutCopper,
|
||||
WeatheredCutCopperSlab,
|
||||
WeatheredCutCopperStairs,
|
||||
|
|
|
|||
1762
MinecraftClient/Mapping/BlockPalettes/Palette1204.cs
Normal file
1762
MinecraftClient/Mapping/BlockPalettes/Palette1204.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -22,7 +22,7 @@ public abstract class EntityMetadataPalette
|
|||
<= 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_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()
|
||||
};
|
||||
}
|
||||
|
|
|
|||
144
MinecraftClient/Mapping/EntityPalettes/EntityPalette1204.cs
Normal file
144
MinecraftClient/Mapping/EntityPalettes/EntityPalette1204.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
public class EntityPalette1204 : EntityPalette
|
||||
{
|
||||
private static readonly Dictionary<int, EntityType> mappings = new();
|
||||
|
||||
static EntityPalette1204()
|
||||
{
|
||||
mappings[0] = EntityType.Allay;
|
||||
mappings[1] = EntityType.AreaEffectCloud;
|
||||
mappings[2] = EntityType.ArmorStand;
|
||||
mappings[3] = EntityType.Arrow;
|
||||
mappings[4] = EntityType.Axolotl;
|
||||
mappings[5] = EntityType.Bat;
|
||||
mappings[6] = EntityType.Bee;
|
||||
mappings[7] = EntityType.Blaze;
|
||||
mappings[8] = EntityType.BlockDisplay;
|
||||
mappings[9] = EntityType.Boat;
|
||||
mappings[10] = EntityType.Breeze;
|
||||
mappings[11] = EntityType.Camel;
|
||||
mappings[12] = EntityType.Cat;
|
||||
mappings[13] = EntityType.CaveSpider;
|
||||
mappings[14] = EntityType.ChestBoat;
|
||||
mappings[15] = EntityType.ChestMinecart;
|
||||
mappings[16] = EntityType.Chicken;
|
||||
mappings[17] = EntityType.Cod;
|
||||
mappings[18] = EntityType.CommandBlockMinecart;
|
||||
mappings[19] = EntityType.Cow;
|
||||
mappings[20] = EntityType.Creeper;
|
||||
mappings[21] = EntityType.Dolphin;
|
||||
mappings[22] = EntityType.Donkey;
|
||||
mappings[23] = EntityType.DragonFireball;
|
||||
mappings[24] = EntityType.Drowned;
|
||||
mappings[25] = EntityType.Egg;
|
||||
mappings[26] = EntityType.ElderGuardian;
|
||||
mappings[27] = EntityType.EndCrystal;
|
||||
mappings[28] = EntityType.EnderDragon;
|
||||
mappings[29] = EntityType.EnderPearl;
|
||||
mappings[30] = EntityType.Enderman;
|
||||
mappings[31] = EntityType.Endermite;
|
||||
mappings[32] = EntityType.Evoker;
|
||||
mappings[33] = EntityType.EvokerFangs;
|
||||
mappings[34] = EntityType.ExperienceBottle;
|
||||
mappings[35] = EntityType.ExperienceOrb;
|
||||
mappings[36] = EntityType.EyeOfEnder;
|
||||
mappings[37] = EntityType.FallingBlock;
|
||||
mappings[58] = EntityType.Fireball;
|
||||
mappings[38] = EntityType.FireworkRocket;
|
||||
mappings[125] = EntityType.FishingBobber;
|
||||
mappings[39] = EntityType.Fox;
|
||||
mappings[40] = EntityType.Frog;
|
||||
mappings[41] = EntityType.FurnaceMinecart;
|
||||
mappings[42] = EntityType.Ghast;
|
||||
mappings[43] = EntityType.Giant;
|
||||
mappings[44] = EntityType.GlowItemFrame;
|
||||
mappings[45] = EntityType.GlowSquid;
|
||||
mappings[46] = EntityType.Goat;
|
||||
mappings[47] = EntityType.Guardian;
|
||||
mappings[48] = EntityType.Hoglin;
|
||||
mappings[49] = EntityType.HopperMinecart;
|
||||
mappings[50] = EntityType.Horse;
|
||||
mappings[51] = EntityType.Husk;
|
||||
mappings[52] = EntityType.Illusioner;
|
||||
mappings[53] = EntityType.Interaction;
|
||||
mappings[54] = EntityType.IronGolem;
|
||||
mappings[55] = EntityType.Item;
|
||||
mappings[56] = EntityType.ItemDisplay;
|
||||
mappings[57] = EntityType.ItemFrame;
|
||||
mappings[59] = EntityType.LeashKnot;
|
||||
mappings[60] = EntityType.LightningBolt;
|
||||
mappings[61] = EntityType.Llama;
|
||||
mappings[62] = EntityType.LlamaSpit;
|
||||
mappings[63] = EntityType.MagmaCube;
|
||||
mappings[64] = EntityType.Marker;
|
||||
mappings[65] = EntityType.Minecart;
|
||||
mappings[66] = EntityType.Mooshroom;
|
||||
mappings[67] = EntityType.Mule;
|
||||
mappings[68] = EntityType.Ocelot;
|
||||
mappings[69] = EntityType.Painting;
|
||||
mappings[70] = EntityType.Panda;
|
||||
mappings[71] = EntityType.Parrot;
|
||||
mappings[72] = EntityType.Phantom;
|
||||
mappings[73] = EntityType.Pig;
|
||||
mappings[74] = EntityType.Piglin;
|
||||
mappings[75] = EntityType.PiglinBrute;
|
||||
mappings[76] = EntityType.Pillager;
|
||||
mappings[124] = EntityType.Player;
|
||||
mappings[77] = EntityType.PolarBear;
|
||||
mappings[78] = EntityType.Potion;
|
||||
mappings[79] = EntityType.Pufferfish;
|
||||
mappings[80] = EntityType.Rabbit;
|
||||
mappings[81] = EntityType.Ravager;
|
||||
mappings[82] = EntityType.Salmon;
|
||||
mappings[83] = EntityType.Sheep;
|
||||
mappings[84] = EntityType.Shulker;
|
||||
mappings[85] = EntityType.ShulkerBullet;
|
||||
mappings[86] = EntityType.Silverfish;
|
||||
mappings[87] = EntityType.Skeleton;
|
||||
mappings[88] = EntityType.SkeletonHorse;
|
||||
mappings[89] = EntityType.Slime;
|
||||
mappings[90] = EntityType.SmallFireball;
|
||||
mappings[91] = EntityType.Sniffer;
|
||||
mappings[92] = EntityType.SnowGolem;
|
||||
mappings[93] = EntityType.Snowball;
|
||||
mappings[94] = EntityType.SpawnerMinecart;
|
||||
mappings[95] = EntityType.SpectralArrow;
|
||||
mappings[96] = EntityType.Spider;
|
||||
mappings[97] = EntityType.Squid;
|
||||
mappings[98] = EntityType.Stray;
|
||||
mappings[99] = EntityType.Strider;
|
||||
mappings[100] = EntityType.Tadpole;
|
||||
mappings[101] = EntityType.TextDisplay;
|
||||
mappings[102] = EntityType.Tnt;
|
||||
mappings[103] = EntityType.TntMinecart;
|
||||
mappings[104] = EntityType.TraderLlama;
|
||||
mappings[105] = EntityType.Trident;
|
||||
mappings[106] = EntityType.TropicalFish;
|
||||
mappings[107] = EntityType.Turtle;
|
||||
mappings[108] = EntityType.Vex;
|
||||
mappings[109] = EntityType.Villager;
|
||||
mappings[110] = EntityType.Vindicator;
|
||||
mappings[111] = EntityType.WanderingTrader;
|
||||
mappings[112] = EntityType.Warden;
|
||||
mappings[113] = EntityType.WindCharge;
|
||||
mappings[114] = EntityType.Witch;
|
||||
mappings[115] = EntityType.Wither;
|
||||
mappings[116] = EntityType.WitherSkeleton;
|
||||
mappings[117] = EntityType.WitherSkull;
|
||||
mappings[118] = EntityType.Wolf;
|
||||
mappings[119] = EntityType.Zoglin;
|
||||
mappings[120] = EntityType.Zombie;
|
||||
mappings[121] = EntityType.ZombieHorse;
|
||||
mappings[122] = EntityType.ZombieVillager;
|
||||
mappings[123] = EntityType.ZombifiedPiglin;
|
||||
}
|
||||
|
||||
protected override Dictionary<int, EntityType> GetDict()
|
||||
{
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,10 @@ namespace MinecraftClient.Mapping.EntityPalettes
|
|||
/// Generate EntityType.cs from Minecraft registries.json
|
||||
/// </summary>
|
||||
/// <param name="registriesJsonFile">path to registries.json</param>
|
||||
/// <remarks>java -cp minecraft_server.jar net.minecraft.data.Main --reports</remarks>
|
||||
/// <remarks>
|
||||
/// java -cp minecraft_server.jar net.minecraft.data.Main --reports</remarks>
|
||||
/// For 1.18+: java -DbundlerMainClass=net.minecraft.data.Main -jar minecraft_server.jar --reports
|
||||
/// </remarks>
|
||||
public static void GenerateEntityTypes(string registriesJsonFile)
|
||||
{
|
||||
DataTypeGenerator.GenerateEnumWithPalette(registriesJsonFile, "minecraft:entity_type", "EntityType", "MinecraftClient.Mapping", "EntityPalette", "MinecraftClient.Mapping.EntityPalettes");
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
Blaze,
|
||||
BlockDisplay,
|
||||
Boat,
|
||||
Breeze,
|
||||
Camel,
|
||||
Cat,
|
||||
CaveSpider,
|
||||
|
|
@ -128,6 +129,7 @@
|
|||
Vindicator,
|
||||
WanderingTrader,
|
||||
Warden,
|
||||
WindCharge,
|
||||
Witch,
|
||||
Wither,
|
||||
WitherSkeleton,
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@
|
|||
Chest,
|
||||
ChippedAnvil,
|
||||
ChiseledBookshelf,
|
||||
ChiseledCopper,
|
||||
ChiseledDeepslate,
|
||||
ChiseledNetherBricks,
|
||||
ChiseledPolishedBlackstone,
|
||||
|
|
@ -205,6 +206,8 @@
|
|||
ChiseledRedSandstone,
|
||||
ChiseledSandstone,
|
||||
ChiseledStoneBricks,
|
||||
ChiseledTuff,
|
||||
ChiseledTuffBricks,
|
||||
ChorusFlower,
|
||||
ChorusPlant,
|
||||
Clay,
|
||||
|
|
@ -226,13 +229,18 @@
|
|||
Composter,
|
||||
Conduit,
|
||||
CopperBlock,
|
||||
CopperBulb,
|
||||
CopperDoor,
|
||||
CopperGrate,
|
||||
CopperOre,
|
||||
CopperTrapdoor,
|
||||
Cornflower,
|
||||
CrackedDeepslateBricks,
|
||||
CrackedDeepslateTiles,
|
||||
CrackedNetherBricks,
|
||||
CrackedPolishedBlackstoneBricks,
|
||||
CrackedStoneBricks,
|
||||
Crafter,
|
||||
CraftingTable,
|
||||
CreeperHead,
|
||||
CreeperWallHead,
|
||||
|
|
@ -367,7 +375,12 @@
|
|||
EndStoneBrickWall,
|
||||
EndStoneBricks,
|
||||
EnderChest,
|
||||
ExposedChiseledCopper,
|
||||
ExposedCopper,
|
||||
ExposedCopperBulb,
|
||||
ExposedCopperDoor,
|
||||
ExposedCopperGrate,
|
||||
ExposedCopperTrapdoor,
|
||||
ExposedCutCopper,
|
||||
ExposedCutCopperSlab,
|
||||
ExposedCutCopperStairs,
|
||||
|
|
@ -396,7 +409,7 @@
|
|||
GraniteSlab,
|
||||
GraniteStairs,
|
||||
GraniteWall,
|
||||
Grass,
|
||||
Grass, // 1.20.3+ renamed to ShortGrass
|
||||
GrassBlock,
|
||||
Gravel,
|
||||
GrayBanner,
|
||||
|
|
@ -638,7 +651,12 @@
|
|||
OrangeWallBanner,
|
||||
OrangeWool,
|
||||
OxeyeDaisy,
|
||||
OxidizedChiseledCopper,
|
||||
OxidizedCopper,
|
||||
OxidizedCopperBulb,
|
||||
OxidizedCopperDoor,
|
||||
OxidizedCopperGrate,
|
||||
OxidizedCopperTrapdoor,
|
||||
OxidizedCutCopper,
|
||||
OxidizedCutCopperSlab,
|
||||
OxidizedCutCopperStairs,
|
||||
|
|
@ -697,6 +715,10 @@
|
|||
PolishedGranite,
|
||||
PolishedGraniteSlab,
|
||||
PolishedGraniteStairs,
|
||||
PolishedTuff,
|
||||
PolishedTuffSlab,
|
||||
PolishedTuffStairs,
|
||||
PolishedTuffWall,
|
||||
Poppy,
|
||||
Potatoes,
|
||||
PottedAcaciaSapling,
|
||||
|
|
@ -824,6 +846,7 @@
|
|||
SeaLantern,
|
||||
SeaPickle,
|
||||
Seagrass,
|
||||
ShortGrass,
|
||||
Shroomlight,
|
||||
ShulkerBox,
|
||||
SkeletonSkull,
|
||||
|
|
@ -924,6 +947,7 @@
|
|||
Torchflower,
|
||||
TorchflowerCrop,
|
||||
TrappedChest,
|
||||
TrialSpawner,
|
||||
Tripwire,
|
||||
TripwireHook,
|
||||
TubeCoral,
|
||||
|
|
@ -931,6 +955,13 @@
|
|||
TubeCoralFan,
|
||||
TubeCoralWallFan,
|
||||
Tuff,
|
||||
TuffBrickSlab,
|
||||
TuffBrickStairs,
|
||||
TuffBrickWall,
|
||||
TuffBricks,
|
||||
TuffSlab,
|
||||
TuffStairs,
|
||||
TuffWall,
|
||||
TurtleEgg,
|
||||
TwistingVines,
|
||||
TwistingVinesPlant,
|
||||
|
|
@ -959,23 +990,48 @@
|
|||
WarpedWartBlock,
|
||||
Water,
|
||||
WaterCauldron,
|
||||
WaxedChiseledCopper,
|
||||
WaxedCopperBlock,
|
||||
WaxedCopperBulb,
|
||||
WaxedCopperDoor,
|
||||
WaxedCopperGrate,
|
||||
WaxedCopperTrapdoor,
|
||||
WaxedCutCopper,
|
||||
WaxedCutCopperSlab,
|
||||
WaxedCutCopperStairs,
|
||||
WaxedExposedChiseledCopper,
|
||||
WaxedExposedCopper,
|
||||
WaxedExposedCopperBulb,
|
||||
WaxedExposedCopperDoor,
|
||||
WaxedExposedCopperGrate,
|
||||
WaxedExposedCopperTrapdoor,
|
||||
WaxedExposedCutCopper,
|
||||
WaxedExposedCutCopperSlab,
|
||||
WaxedExposedCutCopperStairs,
|
||||
WaxedOxidizedChiseledCopper,
|
||||
WaxedOxidizedCopper,
|
||||
WaxedOxidizedCopperBulb,
|
||||
WaxedOxidizedCopperDoor,
|
||||
WaxedOxidizedCopperGrate,
|
||||
WaxedOxidizedCopperTrapdoor,
|
||||
WaxedOxidizedCutCopper,
|
||||
WaxedOxidizedCutCopperSlab,
|
||||
WaxedOxidizedCutCopperStairs,
|
||||
WaxedWeatheredChiseledCopper,
|
||||
WaxedWeatheredCopper,
|
||||
WaxedWeatheredCopperBulb,
|
||||
WaxedWeatheredCopperDoor,
|
||||
WaxedWeatheredCopperGrate,
|
||||
WaxedWeatheredCopperTrapdoor,
|
||||
WaxedWeatheredCutCopper,
|
||||
WaxedWeatheredCutCopperSlab,
|
||||
WaxedWeatheredCutCopperStairs,
|
||||
WeatheredChiseledCopper,
|
||||
WeatheredCopper,
|
||||
WeatheredCopperBulb,
|
||||
WeatheredCopperDoor,
|
||||
WeatheredCopperGrate,
|
||||
WeatheredCopperTrapdoor,
|
||||
WeatheredCutCopper,
|
||||
WeatheredCutCopperSlab,
|
||||
WeatheredCutCopperStairs,
|
||||
|
|
|
|||
|
|
@ -3414,29 +3414,32 @@ namespace MinecraftClient
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when coreboardObjective
|
||||
/// Called when Soreboard Objective
|
||||
/// </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="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>
|
||||
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;
|
||||
objectivevalue = ChatParser.ParseText(objectivevalue);
|
||||
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectivename, mode, objectivevalue, type, json));
|
||||
var json = objectiveValue;
|
||||
objectiveValue = ChatParser.ParseText(objectiveValue);
|
||||
DispatchBotEvent(bot => bot.OnScoreboardObjective(objectiveName, mode, objectiveValue, type, json, numberFormat));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when DisplayScoreboard
|
||||
/// </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="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>
|
||||
public void OnUpdateScore(string entityname, int action, string objectivename, int value)
|
||||
/// <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="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>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace MinecraftClient
|
|||
|
||||
public const string Version = MCHighestVersion;
|
||||
public const string MCLowestVersion = "1.4.6";
|
||||
public const string MCHighestVersion = "1.20.2";
|
||||
public const string MCHighestVersion = "1.20.4";
|
||||
public static readonly string? BuildInfo = null;
|
||||
|
||||
private static Tuple<Thread, CancellationTokenSource>? offlinePrompt = null;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ public enum ConfigurationPacketTypesIn
|
|||
Ping,
|
||||
RegistryData,
|
||||
ResourcePack,
|
||||
RemoveResourcePack,
|
||||
FeatureFlags,
|
||||
UpdateTags,
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using MinecraftClient.Inventory;
|
|||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Mapping.EntityPalettes;
|
||||
using MinecraftClient.Protocol.Message;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers
|
||||
{
|
||||
|
|
@ -561,18 +562,37 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
return nbtData;
|
||||
}
|
||||
|
||||
if (cache.Peek() != 10) // TAG_Compound
|
||||
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound");
|
||||
ReadNextByte(cache); // Tag type (TAG_Compound)
|
||||
|
||||
var nextId = cache.Dequeue();
|
||||
if (protocolversion < Protocol18Handler.MC_1_20_2_Version)
|
||||
{
|
||||
if (nextId is not 10) // TAG_Compound
|
||||
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound");
|
||||
|
||||
// NBT root name
|
||||
var rootName = Encoding.ASCII.GetString(ReadData(ReadNextUShort(cache), cache));
|
||||
|
||||
if (!string.IsNullOrEmpty(rootName))
|
||||
nbtData[""] = rootName;
|
||||
}
|
||||
// In 1.20.2 The root TAG_Compound doesn't have a name
|
||||
// In 1.20.3+ The root can be TAG_Compound or TAG_String
|
||||
else
|
||||
{
|
||||
if (nextId is not (10 or 8)) // TAG_Compound or TAG_String
|
||||
throw new System.IO.InvalidDataException("Failed to decode NBT: Does not start with TAG_Compound or TAG_String");
|
||||
|
||||
// Read TAG_String
|
||||
if(nextId is 8)
|
||||
{
|
||||
var byteArrayLength = ReadNextUShort(cache);
|
||||
var result = Encoding.UTF8.GetString(ReadData(byteArrayLength, cache));
|
||||
|
||||
return new Dictionary<string, object>()
|
||||
{
|
||||
{ "", result }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (true)
|
||||
|
|
@ -666,7 +686,6 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
? key >> 5 // 1.8
|
||||
: ReadNextVarInt(cache); // 1.9+
|
||||
|
||||
|
||||
EntityMetaDataType type;
|
||||
try
|
||||
{
|
||||
|
|
@ -716,11 +735,11 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
value = ReadNextString(cache);
|
||||
break;
|
||||
case EntityMetaDataType.Chat: // Chat
|
||||
value = ReadNextString(cache);
|
||||
value = ReadNextChat(cache);
|
||||
break;
|
||||
case EntityMetaDataType.OptionalChat: // Optional Chat
|
||||
if (ReadNextBool(cache))
|
||||
value = ReadNextString(cache);
|
||||
value = ReadNextChat(cache);
|
||||
break;
|
||||
case EntityMetaDataType.Slot: // Slot
|
||||
value = ReadNextItemSlot(cache, itemPalette);
|
||||
|
|
@ -844,21 +863,21 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// </summary>
|
||||
/// <param name="cache"></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)
|
||||
return;
|
||||
|
||||
int ParticleID = ReadNextVarInt(cache);
|
||||
var particleId = ReadNextVarInt(cache);
|
||||
|
||||
// Refernece:
|
||||
// 1.19.3 - https://wiki.vg/index.php?title=Data_types&oldid=17986
|
||||
// Documentation:
|
||||
// 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.17 - https://wiki.vg/index.php?title=Data_types&oldid=16740
|
||||
// 1.15 - https://wiki.vg/index.php?title=Data_types&oldid=15338
|
||||
// 1.13 - https://wiki.vg/index.php?title=Data_types&oldid=14271
|
||||
|
||||
switch (ParticleID)
|
||||
switch (particleId)
|
||||
{
|
||||
case 2:
|
||||
// 1.18 +
|
||||
|
|
@ -866,14 +885,12 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
ReadNextVarInt(cache); // Block state (minecraft:block)
|
||||
break;
|
||||
case 3:
|
||||
if (protocolversion < Protocol18Handler.MC_1_17_Version
|
||||
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
||||
if (protocolversion is < Protocol18Handler.MC_1_17_Version or > Protocol18Handler.MC_1_17_1_Version)
|
||||
ReadNextVarInt(
|
||||
cache); // Block State (minecraft:block before 1.18, minecraft:block_marker after 1.18)
|
||||
break;
|
||||
case 4:
|
||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
||||
|| protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version)
|
||||
ReadNextVarInt(cache); // Block State (minecraft:block)
|
||||
break;
|
||||
case 11:
|
||||
|
|
@ -883,44 +900,38 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
break;
|
||||
case 14:
|
||||
// 1.15 - 1.16.5 and 1.18 - 1.19.4
|
||||
if ((protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
||||
protocolversion < Protocol18Handler.MC_1_17_Version)
|
||||
|| protocolversion > Protocol18Handler.MC_1_17_1_Version)
|
||||
if (protocolversion is >= Protocol18Handler.MC_1_15_Version and < Protocol18Handler.MC_1_17_Version or > Protocol18Handler.MC_1_17_1_Version)
|
||||
ReadDustParticle(cache);
|
||||
break;
|
||||
case 15:
|
||||
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
||||
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||
ReadDustParticle(cache);
|
||||
else
|
||||
switch (protocolversion)
|
||||
{
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 16:
|
||||
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
||||
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version)
|
||||
ReadDustParticleColorTransition(cache);
|
||||
break;
|
||||
case 23:
|
||||
// 1.15 - 1.16.5
|
||||
if (protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
||||
protocolversion < Protocol18Handler.MC_1_17_Version)
|
||||
if (protocolversion is >= Protocol18Handler.MC_1_15_Version and < Protocol18Handler.MC_1_17_Version)
|
||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||
break;
|
||||
case 24:
|
||||
// 1.18 - 1.19.2 onwards
|
||||
if (protocolversion > Protocol18Handler.MC_1_17_1_Version &&
|
||||
protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
||||
if (protocolversion is > Protocol18Handler.MC_1_17_1_Version and < Protocol18Handler.MC_1_19_3_Version)
|
||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||
break;
|
||||
case 25:
|
||||
// 1.17 - 1.17.1 and 1.19.3 onwards
|
||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
||||
|| protocolversion == Protocol18Handler.MC_1_17_1_Version
|
||||
|| protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
||||
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version or >= Protocol18Handler.MC_1_19_3_Version)
|
||||
ReadNextVarInt(cache); // Block State (minecraft:falling_dust)
|
||||
break;
|
||||
case 27:
|
||||
|
|
@ -934,31 +945,28 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
break;
|
||||
case 32:
|
||||
// 1.15 - 1.16.5
|
||||
if (protocolversion >= Protocol18Handler.MC_1_15_Version &&
|
||||
protocolversion < Protocol18Handler.MC_1_17_Version)
|
||||
if (protocolversion is >= Protocol18Handler.MC_1_15_Version and < Protocol18Handler.MC_1_17_Version)
|
||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||
break;
|
||||
case 36:
|
||||
// 1.17 - 1.17.1
|
||||
if (protocolversion == Protocol18Handler.MC_1_17_Version ||
|
||||
protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||
switch (protocolversion)
|
||||
{
|
||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||
}
|
||||
else if (protocolversion > Protocol18Handler.MC_1_17_1_Version &&
|
||||
protocolversion < Protocol18Handler.MC_1_19_3_Version)
|
||||
{
|
||||
// minecraft:vibration
|
||||
ReadNextLocation(cache); // Origin (Starting Position)
|
||||
ReadNextLocation(cache); // Desitination (Ending Position)
|
||||
ReadNextVarInt(cache); // Ticks
|
||||
// 1.17 - 1.17.1
|
||||
case Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version:
|
||||
ReadNextItemSlot(cache, itemPalette); // Item (minecraft:item)
|
||||
break;
|
||||
case > Protocol18Handler.MC_1_17_1_Version and < Protocol18Handler.MC_1_19_3_Version:
|
||||
// minecraft:vibration
|
||||
ReadNextLocation(cache); // Origin (Starting Position)
|
||||
ReadNextLocation(cache); // Destination (Ending Position)
|
||||
ReadNextVarInt(cache); // Ticks
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case 37:
|
||||
// minecraft:vibration
|
||||
if (protocolversion == Protocol18Handler.MC_1_17_Version
|
||||
|| protocolversion == Protocol18Handler.MC_1_17_1_Version)
|
||||
if (protocolversion is Protocol18Handler.MC_1_17_Version or Protocol18Handler.MC_1_17_1_Version)
|
||||
{
|
||||
ReadNextDouble(cache); // Origin X
|
||||
ReadNextDouble(cache); // Origin Y
|
||||
|
|
@ -977,15 +985,16 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 40:
|
||||
if (protocolversion >= Protocol18Handler.MC_1_19_3_Version)
|
||||
{
|
||||
string positionSourceType = ReadNextString(cache);
|
||||
if (positionSourceType == "minecraft:block")
|
||||
var positionSourceType = ReadNextString(cache);
|
||||
switch (positionSourceType)
|
||||
{
|
||||
ReadNextLocation(cache);
|
||||
}
|
||||
else if (positionSourceType == "minecraft:entity")
|
||||
{
|
||||
ReadNextVarInt(cache);
|
||||
ReadNextFloat(cache);
|
||||
case "minecraft:block":
|
||||
ReadNextLocation(cache);
|
||||
break;
|
||||
case "minecraft:entity":
|
||||
ReadNextVarInt(cache);
|
||||
ReadNextFloat(cache);
|
||||
break;
|
||||
}
|
||||
|
||||
ReadNextVarInt(cache);
|
||||
|
|
@ -1044,6 +1053,23 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
maximumNumberOfTradeUses, xp, specialPrice, priceMultiplier, demand);
|
||||
}
|
||||
|
||||
public string ReadNextChat(Queue<byte> cache)
|
||||
{
|
||||
if (protocolversion >= Protocol18Handler.MC_1_20_4_Version)
|
||||
{
|
||||
// Read as NBT
|
||||
var r = ReadNextNbt(cache);
|
||||
var msg = ChatParser.ParseText(r);
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read as String
|
||||
var json = ReadNextString(cache);
|
||||
return ChatParser.ParseText(json);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build an uncompressed Named Binary Tag blob for sending over the network
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -143,32 +143,18 @@ namespace MinecraftClient.Protocol.Handlers.Forge
|
|||
case FMLVersion.FML3:
|
||||
// Example ModInfo for Minecraft 1.18 and greater (FML3)
|
||||
|
||||
// {
|
||||
// "enforcesSecureChat": true,
|
||||
// "forgeData": {
|
||||
// "channels": [],
|
||||
// "mods": [],
|
||||
// "truncated": false, // legacy versions see truncated lists, modern versions ignore this truncated flag (binary data has its own)
|
||||
// "fmlNetworkVersion": 3,
|
||||
// "d": "ȳ\u0000\u0000ࠨ㐤獋㙖⹌ᦘ̺⸱恤䒸⡑⛧沮婙㨹牥ఈㄵচ₀沮婙㨹牥ఈㄵচ倠岙㜲獥䋊㷍᭳ႇׇ㘴娘▅筳ص䰭宛㘲、\u0000ᠸጋ囗湌夜㘲杩棐䐱ᅱ挃☥ోᤗ㌮ఀ䬣 坖ɍ䮌ᤘ\r\n旉䠳ዣ◆䲌㜃瑥廮ⷉࠋ–䁠奚Ҵ㔱摜䂸ᅱ獳ౠᡚ㜷汥戊䂸űဓĠ嵛㖱数嫤Ǎ塰䛶ⶎᮚ㞳晲擞ᖝ″ዣ䘆ఋʂ潦令ඕ爈䖔⺁ᥚ⾹潳棤㦥ᬻ挐䅀㠹楬ۨ㣄উ瀀渀嬛㘼扩搢䃀熁挂♥\r\n墋㒺摬牜ࣜ䁠嘗湌孛㜴浩惂䠙熙排٥孁㒰ͮ屢Ӏ䠐⚐䷮ᣛ㊴瑳戚䢸熁匒إܴ䫜巑፻ᚷؠ䀀ㆃ牵䋨㦥ࠫ㋣䗆䂌㨈慲䫬ᖱᮓᘧ汬尚ㆰ٫屲㣄ᆉ恳ಭ川㤷፫擨妅挫♖乮塘 㖱慰\r\n囆䓩\t"
|
||||
// },
|
||||
// "description": {
|
||||
// "text": "A Minecraft Server"
|
||||
// },
|
||||
// "players": {
|
||||
// "max": 100,
|
||||
// "online": 0
|
||||
// },
|
||||
// "version": {
|
||||
// "name": "1.20.1",
|
||||
// "protocol": 763
|
||||
// }
|
||||
// }
|
||||
// "forgeData": {
|
||||
// "channels": [],
|
||||
// "mods": [],
|
||||
// "truncated": false, // legacy versions see truncated lists, modern versions ignore this truncated flag (binary data has its own)
|
||||
// "fmlNetworkVersion": 3,
|
||||
// "d": "ȳ\u0000\u0000ࠨ㐤獋㙖⹌ᦘ̺⸱恤䒸⡑⛧沮婙㨹牥ఈㄵচ₀沮婙㨹牥ఈㄵচ倠岙㜲獥䋊㷍᭳ႇׇ㘴娘▅筳ص䰭宛㘲、\u0000ᠸጋ囗湌夜㘲杩棐䐱ᅱ挃☥ోᤗ㌮ఀ䬣 坖ɍ䮌ᤘ\r\n旉䠳ዣ◆䲌㜃瑥廮ⷉࠋ–䁠奚Ҵ㔱摜䂸ᅱ獳ౠᡚ㜷汥戊䂸űဓĠ嵛㖱数嫤Ǎ塰䛶ⶎᮚ㞳晲擞ᖝ″ዣ䘆ఋʂ潦令ඕ爈䖔⺁ᥚ⾹潳棤㦥ᬻ挐䅀㠹楬ۨ㣄উ瀀渀嬛㘼扩搢䃀熁挂♥\r\n墋㒺摬牜ࣜ䁠嘗湌孛㜴浩惂䠙熙排٥孁㒰ͮ屢Ӏ䠐⚐䷮ᣛ㊴瑳戚䢸熁匒إܴ䫜巑፻ᚷؠ䀀ㆃ牵䋨㦥ࠫ㋣䗆䂌㨈慲䫬ᖱᮓᘧ汬尚ㆰ٫屲㣄ᆉ恳ಭ川㤷፫擨妅挫♖乮塘 㖱慰\r\n囆䓩\t"
|
||||
// }
|
||||
|
||||
// All buffer data are encoded and write to forgeData["d"]
|
||||
// 1.18 and greater, the mod list and channel list is compressed to forgeData["d"] for efficiency,
|
||||
// - Here is how forge encode and decode them:
|
||||
// https://github.com/MinecraftForge/MinecraftForge/blob/cb12df41e13da576b781be695f80728b9594c25f/src/main/java/net/minecraftforge/network/ServerStatusPing.java#L264
|
||||
|
||||
// 1.18 and greater, the buffer is encoded for efficiency
|
||||
// - Here is the discussion:
|
||||
// see https://github.com/MinecraftForge/MinecraftForge/pull/8169
|
||||
|
||||
string encodedData = data.Properties["d"].StringValue;
|
||||
|
|
@ -176,14 +162,21 @@ namespace MinecraftClient.Protocol.Handlers.Forge
|
|||
DataTypes dataTypes = new DataTypes(Protocol18Handler.MC_1_18_1_Version);
|
||||
|
||||
//
|
||||
// [truncated][boolean] placeholder for whether we are truncating
|
||||
// [Mod Size][unsigned short] short so that we can replace it later in case of truncation
|
||||
// [ Truncated ][ Bool ] // Unused
|
||||
// [ Mod Size ][ Unsigned short ]
|
||||
//
|
||||
bool truncated = dataTypes.ReadNextBool(dataPackage);
|
||||
dataTypes.ReadNextBool(dataPackage); // truncated: boolean
|
||||
var modsSize = dataTypes.ReadNextUShort(dataPackage);
|
||||
|
||||
Dictionary<string, string> channels = new();
|
||||
Dictionary<string, string> mods = new();
|
||||
// Mod Array Definition:
|
||||
// [ Channel Size And Version Flag ][ VarInt ] // If the value at bit Mask 0x01 is 1, The Mod Version will be ignore.
|
||||
// // The one-right-shifted int is the Channel List size.
|
||||
// [ Mod Id ][ String ]
|
||||
// [ Mod Version ][ Optional String ] // Depends on the Flag above
|
||||
// [ Channel List ][ Array ] [ Channel Name ][ String ]
|
||||
// [ Channel Version ][ String ]
|
||||
// [ Required On Client ][ Bool ]
|
||||
|
||||
for (var i = 0; i < modsSize; i++) {
|
||||
var channelSizeAndVersionFlag = dataTypes.ReadNextVarInt(dataPackage);
|
||||
|
|
@ -194,27 +187,24 @@ namespace MinecraftClient.Protocol.Handlers.Forge
|
|||
|
||||
var modId = dataTypes.ReadNextString(dataPackage);
|
||||
|
||||
string IGNORESERVERONLY = "";// it was "OHNOES\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31";
|
||||
string IGNORESERVERONLY = "IGNORED";
|
||||
var modVersion = isIgnoreServerOnly ? IGNORESERVERONLY : dataTypes.ReadNextString(dataPackage);
|
||||
|
||||
for (var i1 = 0; i1 < channelSize; i1++) {
|
||||
var channelName = dataTypes.ReadNextString(dataPackage);
|
||||
var channelVersion = dataTypes.ReadNextString(dataPackage);
|
||||
var requiredOnClient = dataTypes.ReadNextBool(dataPackage);
|
||||
channels.Add(modId + ":" + channelName, channelVersion + ":" + requiredOnClient);
|
||||
dataTypes.ReadNextString(dataPackage); // channelName
|
||||
dataTypes.ReadNextString(dataPackage); // channelVersion
|
||||
dataTypes.ReadNextBool(dataPackage); // requiredOnClient
|
||||
}
|
||||
|
||||
mods.Add(modId, modVersion);
|
||||
Mods.Add(new ForgeMod(modId, modVersion));
|
||||
}
|
||||
|
||||
var nonModChannelCount = dataTypes.ReadNextVarInt(dataPackage);
|
||||
for (var i = 0; i < nonModChannelCount; i++) {
|
||||
var channelName = dataTypes.ReadNextString(dataPackage);
|
||||
var channelVersion = dataTypes.ReadNextString(dataPackage);
|
||||
var requiredOnClient = dataTypes.ReadNextBool(dataPackage);
|
||||
channels.Add(channelName, channelVersion + ":" + requiredOnClient);
|
||||
}
|
||||
// Ignore the left data, which is NonMod Channel List
|
||||
// [ nonMod Channel Count ][ VarInt ]
|
||||
// [ nonMod Channel List ][ Array ] [ Channel Name ][ String ]
|
||||
// [ Channel Version ][ Bool ]
|
||||
// [ Required On Client ][ Bool ]
|
||||
|
||||
break;
|
||||
default:
|
||||
|
|
@ -222,10 +212,17 @@ namespace MinecraftClient.Protocol.Handlers.Forge
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/MinecraftForge/MinecraftForge/blob/cb12df41e13da576b781be695f80728b9594c25f/src/main/java/net/minecraftforge/network/ServerStatusPing.java#L361
|
||||
// Decode binary data ForgeData["d"] to Queue<byte>
|
||||
/// <summary>
|
||||
/// Decompress binary data ForgeData["d"] (FML 3)
|
||||
/// </summary>
|
||||
/// <param name="encodedData">The encoded data.</param>
|
||||
/// <returns>Decoded forge data Queue<byte>.</returns>
|
||||
/// <para>
|
||||
/// 1.18 and greater, the mod list and channel list is compressed for efficiency
|
||||
/// The code below is converted from forge source code, see:
|
||||
/// https://github.com/MinecraftForge/MinecraftForge/blob/cb12df41e13da576b781be695f80728b9594c25f/src/main/java/net/minecraftforge/network/ServerStatusPing.java#L361
|
||||
/// </para>
|
||||
private static Queue<byte> decodeOptimized(string encodedData) {
|
||||
// Console.WriteLine("Got encoded data:" + encodedData + ", decoding...");
|
||||
int size0 = encodedData[0];
|
||||
int size1 = encodedData[1];
|
||||
int size = size0 | (size1 << 15);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
50 => new ParserForgeEnum(dataTypes, packetData),
|
||||
_ => new ParserEmpty(dataTypes, packetData),
|
||||
};
|
||||
else // 1.19.4+
|
||||
else if (protocolVersion <= Protocol18Handler.MC_1_20_2_Version)// 1.19.4 - 1.20.2
|
||||
parser = parserId switch
|
||||
{
|
||||
1 => new ParserFloat(dataTypes, packetData),
|
||||
|
|
@ -103,11 +103,34 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
new ParserEmpty(dataTypes, packetData),
|
||||
_ => new ParserEmpty(dataTypes, packetData),
|
||||
};
|
||||
else // 1.20.3+
|
||||
parser = parserId switch
|
||||
{
|
||||
1 => new ParserFloat(dataTypes, packetData),
|
||||
2 => new ParserDouble(dataTypes, packetData),
|
||||
3 => new ParserInteger(dataTypes, packetData),
|
||||
4 => new ParserLong(dataTypes, packetData),
|
||||
5 => new ParserString(dataTypes, packetData),
|
||||
6 => new ParserEntity(dataTypes, packetData),
|
||||
8 => new ParserBlockPos(dataTypes, packetData),
|
||||
9 => new ParserColumnPos(dataTypes, packetData),
|
||||
10 => new ParserVec3(dataTypes, packetData),
|
||||
11 => new ParserVec2(dataTypes, packetData),
|
||||
18 => new ParserMessage(dataTypes, packetData),
|
||||
27 => new ParserRotation(dataTypes, packetData),
|
||||
30 => new ParserScoreHolder(dataTypes, packetData),
|
||||
41 => new ParserTime(dataTypes, packetData),
|
||||
42 => new ParserResourceOrTag(dataTypes, packetData),
|
||||
43 => new ParserResourceOrTag(dataTypes, packetData),
|
||||
44 => new ParserResource(dataTypes, packetData),
|
||||
45 => new ParserResource(dataTypes, packetData),
|
||||
_ => new ParserEmpty(dataTypes, packetData),
|
||||
};
|
||||
}
|
||||
|
||||
string? suggestionsType = ((flags & 0x10) == 0x10) ? dataTypes.ReadNextString(packetData) : null;
|
||||
|
||||
Nodes[i] = new(flags, childs, redirectNode, name, parser, suggestionsType);
|
||||
Nodes[i] = new(flags, childs, redirectNode, name, parser, suggestionsType, parserId);
|
||||
}
|
||||
RootIdx = dataTypes.ReadNextVarInt(packetData);
|
||||
|
||||
|
|
@ -183,6 +206,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
public string? Name;
|
||||
public Parser? Paser;
|
||||
public string? SuggestionsType;
|
||||
public int ParserId; // Added for easy debug
|
||||
|
||||
|
||||
public CommandNode(byte Flags,
|
||||
|
|
@ -190,7 +214,8 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
int RedirectNode = -1,
|
||||
string? Name = null,
|
||||
Parser? Paser = null,
|
||||
string? SuggestionsType = null)
|
||||
string? SuggestionsType = null,
|
||||
int parserId = -1)
|
||||
{
|
||||
this.Flags = Flags;
|
||||
this.Clildren = Clildren;
|
||||
|
|
@ -198,6 +223,7 @@ namespace MinecraftClient.Protocol.Handlers.packet.s2c
|
|||
this.Name = Name;
|
||||
this.Paser = Paser;
|
||||
this.SuggestionsType = SuggestionsType;
|
||||
ParserId = parserId;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
> Protocol18Handler.MC_1_20_2_Version => throw new NotImplementedException(Translations
|
||||
> Protocol18Handler.MC_1_20_4_Version => throw new NotImplementedException(Translations
|
||||
.exception_palette_packet),
|
||||
<= Protocol18Handler.MC_1_8_Version => new PacketPalette17(),
|
||||
<= 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_2_Version => new PacketPalette1192(),
|
||||
<= Protocol18Handler.MC_1_19_3_Version => new PacketPalette1193(),
|
||||
< Protocol18Handler.MC_1_20_2_Version => new PacketPalette1194(),
|
||||
_ => new PacketPalette1202()
|
||||
<= Protocol18Handler.MC_1_19_4_Version => new PacketPalette1194(),
|
||||
<= Protocol18Handler.MC_1_20_2_Version => new PacketPalette1202(),
|
||||
_ => new PacketPalette1204()
|
||||
};
|
||||
|
||||
p.SetForgeEnabled(forgeEnabled);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
namespace MinecraftClient.Protocol.Handlers
|
||||
{
|
||||
/// <summary>
|
||||
/// Incomming packet types
|
||||
/// Incoming packet types
|
||||
/// </summary>
|
||||
public enum PacketTypesIn
|
||||
{
|
||||
|
|
@ -84,6 +84,8 @@
|
|||
PluginMessage, //
|
||||
ProfilelessChatMessage, // Added in 1.19.3
|
||||
RemoveEntityEffect, //
|
||||
RemoveResourcePack, // Added in 1.20.3
|
||||
ResetScore, // Added in 1.20.3
|
||||
ResourcePackSend, //
|
||||
Respawn, //
|
||||
ScoreboardObjective, //
|
||||
|
|
@ -96,6 +98,8 @@
|
|||
SetExperience, //
|
||||
SetPassengers, //
|
||||
SetSlot, //
|
||||
SetTickingState, // Added in 1.20.3
|
||||
StepTick, // Added in 1.20.3
|
||||
SetTitleSubTitle, //
|
||||
SetTitleText, //
|
||||
SetTitleTime, //
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
AcknowledgeConfiguration, // Added in 1.20.2
|
||||
AdvancementTab, //
|
||||
Animation, //
|
||||
ChangeContainerSlotState, // Added in 1.20.3
|
||||
ChatCommand, // Added in 1.19
|
||||
ChatMessage, //
|
||||
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_20_Version = 763;
|
||||
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 autocomplete_transaction_id = 0;
|
||||
|
|
@ -120,21 +121,21 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
lastSeenMessagesCollector = protocolVersion >= MC_1_19_3_Version ? new(20) : new(5);
|
||||
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}");
|
||||
handler.SetTerrainEnabled(false);
|
||||
}
|
||||
|
||||
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}");
|
||||
handler.SetInventoryEnabled(false);
|
||||
}
|
||||
|
||||
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}");
|
||||
handler.SetEntityHandlingEnabled(false);
|
||||
|
|
@ -143,8 +144,9 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
Block.Palette = protocolVersion switch
|
||||
{
|
||||
// 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),
|
||||
>= MC_1_20_4_Version => new Palette1204(),
|
||||
>= MC_1_20_Version => new Palette120(),
|
||||
MC_1_19_4_Version => new Palette1194(),
|
||||
MC_1_19_3_Version => new Palette1193(),
|
||||
|
|
@ -160,8 +162,9 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
entityPalette = protocolVersion switch
|
||||
{
|
||||
// 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),
|
||||
>= MC_1_20_4_Version => new EntityPalette1204(),
|
||||
>= MC_1_20_Version => new EntityPalette120(),
|
||||
MC_1_19_4_Version => new EntityPalette1194(),
|
||||
MC_1_19_3_Version => new EntityPalette1193(),
|
||||
|
|
@ -181,8 +184,9 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
itemPalette = protocolVersion switch
|
||||
{
|
||||
// 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),
|
||||
>= MC_1_20_4_Version => new ItemPalette1204(),
|
||||
>= MC_1_20_Version => new ItemPalette120(),
|
||||
MC_1_19_4_Version => new ItemPalette1194(),
|
||||
MC_1_19_3_Version => new ItemPalette1193(),
|
||||
|
|
@ -397,7 +401,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
case ConfigurationPacketTypesIn.Disconnect:
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick,
|
||||
ChatParser.ParseText(dataTypes.ReadNextString(packetData)));
|
||||
dataTypes.ReadNextChat(packetData));
|
||||
return false;
|
||||
|
||||
case ConfigurationPacketTypesIn.FinishConfiguration:
|
||||
|
|
@ -422,28 +426,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
break;
|
||||
|
||||
case ConfigurationPacketTypesIn.RemoveResourcePack:
|
||||
if (dataTypes.ReadNextBool(packetData)) // Has UUID
|
||||
dataTypes.ReadNextUUID(packetData); // UUID
|
||||
break;
|
||||
|
||||
case ConfigurationPacketTypesIn.ResourcePack:
|
||||
var url = dataTypes.ReadNextString(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
|
||||
HandleResourcePackPacket(packetData);
|
||||
break;
|
||||
|
||||
// Ignore other packets at this stage
|
||||
|
|
@ -480,6 +469,54 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
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.ReadNextChat(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)
|
||||
{
|
||||
switch (packetPalette.GetIncomingTypeById(packetId))
|
||||
|
|
@ -886,7 +923,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
// Other
|
||||
var unsignedChatContent = dataTypes.ReadNextBool(packetData)
|
||||
? dataTypes.ReadNextString(packetData)
|
||||
? dataTypes.ReadNextChat(packetData)
|
||||
: null;
|
||||
|
||||
var filterType = (MessageFilterType)dataTypes.ReadNextVarInt(packetData);
|
||||
|
|
@ -897,26 +934,17 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Network Target
|
||||
// net.minecraft.network.message.MessageType.Serialized#write
|
||||
var chatTypeId = dataTypes.ReadNextVarInt(packetData);
|
||||
var chatName = dataTypes.ReadNextString(packetData);
|
||||
var chatName = dataTypes.ReadNextChat(packetData);
|
||||
var targetName = dataTypes.ReadNextBool(packetData)
|
||||
? dataTypes.ReadNextString(packetData)
|
||||
? dataTypes.ReadNextChat(packetData)
|
||||
: null;
|
||||
|
||||
var messageTypeEnum =
|
||||
ChatParser.ChatId2Type!.GetValueOrDefault(chatTypeId, ChatParser.MessageType.CHAT);
|
||||
|
||||
var chatInfo =
|
||||
Json.ParseJson(targetName ?? chatName).Properties;
|
||||
var senderDisplayName = chatInfo != null && chatInfo.Count > 0
|
||||
? (chatInfo.ContainsKey("insertion") ? chatInfo["insertion"] : chatInfo["text"])
|
||||
.StringValue
|
||||
: "";
|
||||
string? senderTeamName = null;
|
||||
if (targetName != null &&
|
||||
messageTypeEnum is ChatParser.MessageType.TEAM_MSG_COMMAND_INCOMING
|
||||
or ChatParser.MessageType.TEAM_MSG_COMMAND_OUTGOING)
|
||||
senderTeamName = Json.ParseJson(targetName).Properties["with"].DataArray[0]
|
||||
.Properties["text"].StringValue;
|
||||
//var chatInfo = Json.ParseJson(targetName ?? chatName).Properties;
|
||||
var senderDisplayName = chatName;
|
||||
string? senderTeamName = targetName;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(senderDisplayName))
|
||||
{
|
||||
|
|
@ -924,7 +952,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (player != null && (player.DisplayName != null || player.Name != null) &&
|
||||
string.IsNullOrWhiteSpace(senderDisplayName))
|
||||
{
|
||||
senderDisplayName = ChatParser.ParseText(player.DisplayName ?? player.Name);
|
||||
senderDisplayName = player.DisplayName ?? player.Name;
|
||||
if (string.IsNullOrWhiteSpace(senderDisplayName))
|
||||
senderDisplayName = player.DisplayName ?? player.Name;
|
||||
else
|
||||
|
|
@ -989,7 +1017,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
$"HideMessage was not processed! (SigLen={hideMessageSignature.Length})");
|
||||
break;
|
||||
case PacketTypesIn.SystemChat:
|
||||
var systemMessage = dataTypes.ReadNextString(packetData);
|
||||
var systemMessage = dataTypes.ReadNextChat(packetData);
|
||||
|
||||
if (protocolVersion >= MC_1_19_3_Version)
|
||||
{
|
||||
|
|
@ -1005,7 +1033,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
break;
|
||||
}
|
||||
|
||||
handler.OnTextReceived(new(systemMessage, null, true, -1, Guid.Empty, true));
|
||||
handler.OnTextReceived(new(systemMessage, null, false, -1, Guid.Empty, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1017,15 +1045,15 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
break;
|
||||
case PacketTypesIn.ProfilelessChatMessage:
|
||||
var message_ = dataTypes.ReadNextString(packetData);
|
||||
var message_ = dataTypes.ReadNextChat(packetData);
|
||||
var messageType_ = dataTypes.ReadNextVarInt(packetData);
|
||||
var messageName = dataTypes.ReadNextString(packetData);
|
||||
var messageName = dataTypes.ReadNextChat(packetData);
|
||||
var targetName_ = dataTypes.ReadNextBool(packetData)
|
||||
? dataTypes.ReadNextString(packetData)
|
||||
? dataTypes.ReadNextChat(packetData)
|
||||
: null;
|
||||
ChatMessage profilelessChat = new(message_, targetName_ ?? messageName, true, messageType_,
|
||||
ChatMessage profilelessChat = new(message_, targetName_ ?? messageName, false, messageType_,
|
||||
Guid.Empty, true);
|
||||
profilelessChat.isSenderJson = true;
|
||||
profilelessChat.isSenderJson = false;
|
||||
handler.OnTextReceived(profilelessChat);
|
||||
break;
|
||||
case PacketTypesIn.CombatEvent:
|
||||
|
|
@ -1051,7 +1079,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
handler.OnPlayerKilled(
|
||||
protocolVersion >= MC_1_20_Version ? -1 : dataTypes.ReadNextInt(packetData),
|
||||
ChatParser.ParseText(dataTypes.ReadNextString(packetData))
|
||||
ChatParser.ParseText(dataTypes.ReadNextChat(packetData))
|
||||
);
|
||||
|
||||
break;
|
||||
|
|
@ -1450,7 +1478,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
if (dataTypes.ReadNextBool(packetData)) // Has Display Name?
|
||||
mapIcon.DisplayName =
|
||||
ChatParser.ParseText(dataTypes.ReadNextString(packetData));
|
||||
ChatParser.ParseText(dataTypes.ReadNextChat(packetData));
|
||||
}
|
||||
|
||||
icons.Add(mapIcon);
|
||||
|
|
@ -1638,18 +1666,26 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
hasMotd = dataTypes.ReadNextBool(packetData);
|
||||
|
||||
if (hasMotd)
|
||||
motd = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
|
||||
motd = ChatParser.ParseText(dataTypes.ReadNextChat(packetData));
|
||||
}
|
||||
else
|
||||
{
|
||||
hasMotd = true;
|
||||
motd = ChatParser.ParseText(dataTypes.ReadNextString(packetData));
|
||||
motd = ChatParser.ParseText(dataTypes.ReadNextChat(packetData));
|
||||
}
|
||||
|
||||
var iconBase64 = "-";
|
||||
var hasIcon = dataTypes.ReadNextBool(packetData);
|
||||
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;
|
||||
if (protocolVersion < MC_1_19_3_Version)
|
||||
|
|
@ -1849,7 +1885,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Actions bit 5: update display name
|
||||
if ((actionBitset & 1 << 5) <= 0) continue;
|
||||
player.DisplayName = dataTypes.ReadNextBool(packetData)
|
||||
? dataTypes.ReadNextString(packetData)
|
||||
? dataTypes.ReadNextChat(packetData)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1995,7 +2031,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
// Skip optional tooltip for each tab-complete resul`t
|
||||
if (dataTypes.ReadNextBool(packetData))
|
||||
dataTypes.SkipNextString(packetData);
|
||||
dataTypes.ReadNextChat(packetData);
|
||||
}
|
||||
|
||||
handler.OnAutoCompleteDone(oldTransactionId, autocompleteResult);
|
||||
|
|
@ -2009,7 +2045,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
return pForge.HandlePluginMessage(channel, packetData, ref currentDimension);
|
||||
case PacketTypesIn.Disconnect:
|
||||
handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick,
|
||||
ChatParser.ParseText(dataTypes.ReadNextString(packetData)));
|
||||
ChatParser.ParseText(dataTypes.ReadNextChat(packetData)));
|
||||
return false;
|
||||
case PacketTypesIn.SetCompression:
|
||||
if (protocolVersion is >= MC_1_8_Version and < MC_1_9_Version)
|
||||
|
|
@ -2026,7 +2062,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
.ToUpper();
|
||||
var inventoryType =
|
||||
(ContainerTypeOld)Enum.Parse(typeof(ContainerTypeOld), type);
|
||||
var title = dataTypes.ReadNextString(packetData);
|
||||
var title = dataTypes.ReadNextChat(packetData);
|
||||
var slots = dataTypes.ReadNextByte(packetData);
|
||||
Container inventory = new(windowId, inventoryType, ChatParser.ParseText(title));
|
||||
handler.OnInventoryOpen(windowId, inventory);
|
||||
|
|
@ -2036,7 +2072,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// MC 1.14 or greater
|
||||
var windowId = dataTypes.ReadNextVarInt(packetData);
|
||||
var windowType = dataTypes.ReadNextVarInt(packetData);
|
||||
var title = dataTypes.ReadNextString(packetData);
|
||||
var title = dataTypes.ReadNextChat(packetData);
|
||||
Container inventory = new(windowId, windowType, ChatParser.ParseText(title));
|
||||
handler.OnInventoryOpen(windowId, inventory);
|
||||
}
|
||||
|
|
@ -2120,34 +2156,18 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
|
||||
break;
|
||||
case PacketTypesIn.RemoveResourcePack:
|
||||
if (dataTypes.ReadNextBool(packetData)) // Has UUID
|
||||
dataTypes.ReadNextUUID(packetData); // UUID
|
||||
break;
|
||||
case PacketTypesIn.ResourcePackSend:
|
||||
var url = dataTypes.ReadNextString(packetData);
|
||||
var hash = dataTypes.ReadNextString(packetData);
|
||||
var forced = true; // Assume forced for MC 1.16 and below
|
||||
if (protocolVersion >= MC_1_17_Version)
|
||||
{
|
||||
forced = dataTypes.ReadNextBool(packetData);
|
||||
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
|
||||
}
|
||||
HandleResourcePackPacket(packetData);
|
||||
break;
|
||||
case PacketTypesIn.ResetScore:
|
||||
dataTypes.ReadNextString(packetData); // Entity Name
|
||||
if (dataTypes.ReadNextBool(packetData)) // Has Objective Name
|
||||
dataTypes.ReadNextString(packetData); // Objective Name
|
||||
|
||||
// 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;
|
||||
case PacketTypesIn.SpawnEntity:
|
||||
if (handler.GetEntityHandlingEnabled())
|
||||
|
|
@ -2396,7 +2416,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// Also make a palette for field? Will be a lot of work
|
||||
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),
|
||||
// 1.17 and above
|
||||
>= MC_1_17_Version => 9,
|
||||
|
|
@ -2482,15 +2502,29 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
var explosionStrength = dataTypes.ReadNextFloat(packetData);
|
||||
var explosionBlockCount = protocolVersion >= MC_1_17_Version
|
||||
? dataTypes.ReadNextVarInt(packetData)
|
||||
: dataTypes.ReadNextInt(packetData);
|
||||
: dataTypes.ReadNextInt(packetData); // Record count
|
||||
|
||||
// Records
|
||||
for (var i = 0; i < explosionBlockCount; i++)
|
||||
dataTypes.ReadData(3, packetData);
|
||||
|
||||
// Maybe use in the future when the physics are implemented
|
||||
var playerVelocityX = dataTypes.ReadNextFloat(packetData);
|
||||
var playerVelocityY = dataTypes.ReadNextFloat(packetData);
|
||||
var playerVelocityZ = dataTypes.ReadNextFloat(packetData);
|
||||
dataTypes.ReadNextFloat(packetData); // Player Motion X
|
||||
dataTypes.ReadNextFloat(packetData); // Player Motion Y
|
||||
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);
|
||||
break;
|
||||
|
|
@ -2498,30 +2532,63 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
handler.OnHeldItemChange(dataTypes.ReadNextByte(packetData)); // Slot
|
||||
break;
|
||||
case PacketTypesIn.ScoreboardObjective:
|
||||
var objectiveName2 = dataTypes.ReadNextString(packetData);
|
||||
var objectiveName = dataTypes.ReadNextString(packetData);
|
||||
var mode = dataTypes.ReadNextByte(packetData);
|
||||
|
||||
var objectiveValue = string.Empty;
|
||||
var type2 = -1;
|
||||
var objectiveType = -1;
|
||||
var numberFormat = 0;
|
||||
|
||||
if (mode is 0 or 2)
|
||||
{
|
||||
objectiveValue = dataTypes.ReadNextString(packetData);
|
||||
type2 = dataTypes.ReadNextVarInt(packetData);
|
||||
objectiveValue = dataTypes.ReadNextChat(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;
|
||||
case PacketTypesIn.UpdateScore:
|
||||
var entityName = dataTypes.ReadNextString(packetData);
|
||||
var action3 = protocolVersion >= MC_1_18_2_Version
|
||||
? dataTypes.ReadNextVarInt(packetData)
|
||||
: dataTypes.ReadNextByte(packetData);
|
||||
|
||||
var action3 = 0;
|
||||
var objectiveName3 = string.Empty;
|
||||
var value = -1;
|
||||
if (action3 != 1 || protocolVersion >= MC_1_8_Version)
|
||||
objectiveName3 = dataTypes.ReadNextString(packetData);
|
||||
if (action3 != 1)
|
||||
value = dataTypes.ReadNextVarInt(packetData);
|
||||
handler.OnUpdateScore(entityName, action3, objectiveName3, value);
|
||||
var objectiveValue2 = -1;
|
||||
var objectiveDisplayName3 = string.Empty;
|
||||
var numberFormat2 = 0;
|
||||
|
||||
if (protocolVersion >= MC_1_20_4_Version)
|
||||
{
|
||||
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;
|
||||
case PacketTypesIn.BlockChangedAck:
|
||||
handler.OnBlockChangeAck(dataTypes.ReadNextVarInt(packetData));
|
||||
|
|
@ -2567,6 +2634,11 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
break;*/
|
||||
|
||||
case PacketTypesIn.SetTickingState:
|
||||
dataTypes.ReadNextFloat(packetData);
|
||||
dataTypes.ReadNextBool(packetData);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false; //Ignored packet
|
||||
}
|
||||
|
|
@ -4176,7 +4248,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
}
|
||||
|
||||
public bool SendAnimation(int animation, int playerid)
|
||||
public bool SendAnimation(int animation, int playerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -4187,7 +4259,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
switch (protocolVersion)
|
||||
{
|
||||
case < MC_1_8_Version:
|
||||
packet.AddRange(DataTypes.GetInt(playerid));
|
||||
packet.AddRange(DataTypes.GetInt(playerId));
|
||||
packet.Add(1); // Swing arm
|
||||
break;
|
||||
case < MC_1_9_Version:
|
||||
|
|
@ -4424,10 +4496,8 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SendRenameItem(string itemName)
|
||||
|
|
|
|||
|
|
@ -417,21 +417,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 5:
|
||||
// FML 3
|
||||
// Server Config: FMLHandshakeMessages.java > S2CModData > decode()
|
||||
// [ Size ][ VarInt ]
|
||||
// [ Mod Data List ][ Array ] [ Mod Id ][ String ]
|
||||
// [ Display Name ][ String ]
|
||||
// [ Version ][ String ]
|
||||
//
|
||||
// We're ignoring this packet in MCC
|
||||
|
||||
/*
|
||||
// Uncomment this code block if needed
|
||||
var size = dataTypes.ReadNextVarInt(packetData);
|
||||
Dictionary<string, string> modsData = new();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var modId = dataTypes.ReadNextString(packetData);
|
||||
var displayName = dataTypes.ReadNextString(packetData);
|
||||
var version = dataTypes.ReadNextString(packetData);
|
||||
modsData.Add(modId, displayName + ":" + version);
|
||||
}
|
||||
*/
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + "Received FML3 Server Mod Data List");
|
||||
|
|
@ -441,20 +433,11 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 6:
|
||||
// FML 3
|
||||
// Server Config: FMLHandshakeMessages.java > S2CChannelMismatchData > decode()
|
||||
//
|
||||
// [ Size ][ VarInt ]
|
||||
// [ Mismatched Mod List ][ Array ] [ Mod Id ][ String ]
|
||||
// [ Version ][ String ]
|
||||
// We're ignoring this packet in MCC
|
||||
|
||||
/*
|
||||
// Uncomment this code block if needed
|
||||
Dictionary<string, string> mismatchedMods = new();
|
||||
var size0 = dataTypes.ReadNextVarInt(packetData);
|
||||
for (int i = 0; i < size0; i++)
|
||||
{
|
||||
var modId = dataTypes.ReadNextString(packetData);
|
||||
var version = dataTypes.ReadNextString(packetData);
|
||||
mismatchedMods.Add(modId, version);
|
||||
}
|
||||
*/
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + "Received FML3 Server Mismatched Mods List");
|
||||
|
|
@ -523,15 +506,15 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// </summary>
|
||||
/// <param name="protocolVersion">Minecraft protocol version</param>
|
||||
/// <returns>ForgeInfo item stating that Forge is enabled</returns>
|
||||
/// <para>
|
||||
/// 1.18 change the fml version to 3
|
||||
/// https://github.com/MinecraftForge/MinecraftForge/commit/997d8e0aa28b831edcd712e59a96181d3b2117d4
|
||||
/// </para>
|
||||
public static ForgeInfo ServerForceForge(int protocolVersion)
|
||||
{
|
||||
if (ServerMayForceForge(protocolVersion))
|
||||
{
|
||||
// 1.17 is still FML2
|
||||
// https://github.com/MinecraftForge/MinecraftForge/blob/50b5414033de82f46be23201db50484f36c37d4f/src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java#L37C29-L37C42
|
||||
// 1.18 change the constant FMLNETVERSION to 3
|
||||
// https://github.com/MinecraftForge/MinecraftForge/blob/cb12df41e13da576b781be695f80728b9594c25f/src/main/java/net/minecraftforge/network/NetworkConstants.java#L28
|
||||
if (protocolVersion > ProtocolHandler.MCVer2ProtocolVersion("1.18"))
|
||||
if (protocolVersion >= ProtocolHandler.MCVer2ProtocolVersion("1.18"))
|
||||
{
|
||||
return new ForgeInfo(FMLVersion.FML3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Called when coreboardObjective
|
||||
/// Called when Soreboard Objective
|
||||
/// </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="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>
|
||||
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>
|
||||
/// Called when DisplayScoreboard
|
||||
/// </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="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>
|
||||
void OnUpdateScore(string entityname, int action, string objectivename, int value);
|
||||
/// <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="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>
|
||||
/// Called when the client received the Tab Header and Footer
|
||||
|
|
|
|||
|
|
@ -34,11 +34,12 @@ namespace MinecraftClient.Protocol.Message
|
|||
public static void ReadChatType(Dictionary<string, object> registryCodec)
|
||||
{
|
||||
Dictionary<int, MessageType> chatTypeDictionary = ChatId2Type ?? new();
|
||||
var chatTypeListNbt = (object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
|
||||
var chatTypeListNbt =
|
||||
(object[])(((Dictionary<string, object>)registryCodec["minecraft:chat_type"])["value"]);
|
||||
foreach (var (chatName, chatId) in from Dictionary<string, object> chatTypeNbt in chatTypeListNbt
|
||||
let chatName = (string)chatTypeNbt["name"]
|
||||
let chatId = (int)chatTypeNbt["id"]
|
||||
select (chatName, chatId))
|
||||
let chatName = (string)chatTypeNbt["name"]
|
||||
let chatId = (int)chatTypeNbt["id"]
|
||||
select (chatName, chatId))
|
||||
{
|
||||
chatTypeDictionary[chatId] = chatName switch
|
||||
{
|
||||
|
|
@ -52,6 +53,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
_ => MessageType.CHAT,
|
||||
};
|
||||
}
|
||||
|
||||
ChatId2Type = chatTypeDictionary;
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +68,11 @@ namespace MinecraftClient.Protocol.Message
|
|||
return JSONData2String(Json.ParseJson(json), "", links);
|
||||
}
|
||||
|
||||
public static string ParseText(Dictionary<string, object> nbt)
|
||||
{
|
||||
return NbtToString(nbt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main function to convert text from MC 1.9+ JSON to MC 1.5.2 formatted text
|
||||
/// </summary>
|
||||
|
|
@ -142,6 +149,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
default:
|
||||
goto case MessageType.CHAT;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
@ -193,7 +201,14 @@ namespace MinecraftClient.Protocol.Message
|
|||
/// Initialize translation rules.
|
||||
/// Necessary for properly printing some chat messages.
|
||||
/// </summary>
|
||||
public static void InitTranslations() { if (!RulesInitialized) { InitRules(); RulesInitialized = true; } }
|
||||
public static void InitTranslations()
|
||||
{
|
||||
if (!RulesInitialized)
|
||||
{
|
||||
InitRules();
|
||||
RulesInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Internal rule initialization method. Looks for local rule file or download it from Mojang asset servers.
|
||||
|
|
@ -202,7 +217,9 @@ namespace MinecraftClient.Protocol.Message
|
|||
{
|
||||
if (Config.Main.Advanced.Language == "en_us")
|
||||
{
|
||||
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>((byte[])MinecraftAssets.ResourceManager.GetObject("en_us.json")!)!;
|
||||
TranslationRules =
|
||||
JsonSerializer.Deserialize<Dictionary<string, string>>(
|
||||
(byte[])MinecraftAssets.ResourceManager.GetObject("en_us.json")!)!;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -217,13 +234,19 @@ namespace MinecraftClient.Protocol.Message
|
|||
{
|
||||
try
|
||||
{
|
||||
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>(File.OpenRead(languageFilePath))!;
|
||||
TranslationRules =
|
||||
JsonSerializer.Deserialize<Dictionary<string, string>>(File.OpenRead(languageFilePath))!;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
}
|
||||
catch (IOException) { }
|
||||
catch (JsonException) { }
|
||||
}
|
||||
|
||||
if (TranslationRules.TryGetValue("Version", out string? version) && version == Settings.TranslationsFile_Version)
|
||||
if (TranslationRules.TryGetValue("Version", out string? version) &&
|
||||
version == Settings.TranslationsFile_Version)
|
||||
{
|
||||
if (Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(Translations.chat_loaded, acceptnewlines: true);
|
||||
|
|
@ -231,32 +254,39 @@ namespace MinecraftClient.Protocol.Message
|
|||
}
|
||||
|
||||
// Try downloading language file from Mojang's servers?
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_download, Config.Main.Advanced.Language));
|
||||
ConsoleIO.WriteLineFormatted(
|
||||
"§8" + string.Format(Translations.chat_download, Config.Main.Advanced.Language));
|
||||
HttpClient httpClient = new();
|
||||
try
|
||||
{
|
||||
Task<string> fetch_index = httpClient.GetStringAsync(TranslationsFile_Website_Index);
|
||||
fetch_index.Wait();
|
||||
Match match = Regex.Match(fetch_index.Result, $"minecraft/lang/{Config.Main.Advanced.Language}.json" + @""":\s\{""hash"":\s""([\d\w]{40})""");
|
||||
Match match = Regex.Match(fetch_index.Result,
|
||||
$"minecraft/lang/{Config.Main.Advanced.Language}.json" + @""":\s\{""hash"":\s""([\d\w]{40})""");
|
||||
fetch_index.Dispose();
|
||||
if (match.Success && match.Groups.Count == 2)
|
||||
{
|
||||
string hash = match.Groups[1].Value;
|
||||
string translation_file_location = TranslationsFile_Website_Download + '/' + hash[..2] + '/' + hash;
|
||||
if (Config.Logging.DebugMessages)
|
||||
ConsoleIO.WriteLineFormatted(string.Format(Translations.chat_request, translation_file_location));
|
||||
ConsoleIO.WriteLineFormatted(
|
||||
string.Format(Translations.chat_request, translation_file_location));
|
||||
|
||||
Task<Dictionary<string, string>?> fetckFileTask = httpClient.GetFromJsonAsync<Dictionary<string, string>>(translation_file_location);
|
||||
Task<Dictionary<string, string>?> fetckFileTask =
|
||||
httpClient.GetFromJsonAsync<Dictionary<string, string>>(translation_file_location);
|
||||
fetckFileTask.Wait();
|
||||
if (fetckFileTask.Result != null && fetckFileTask.Result.Count > 0)
|
||||
{
|
||||
TranslationRules = fetckFileTask.Result;
|
||||
TranslationRules["Version"] = TranslationsFile_Version;
|
||||
File.WriteAllText(languageFilePath, JsonSerializer.Serialize(TranslationRules, typeof(Dictionary<string, string>)), Encoding.UTF8);
|
||||
File.WriteAllText(languageFilePath,
|
||||
JsonSerializer.Serialize(TranslationRules, typeof(Dictionary<string, string>)),
|
||||
Encoding.UTF8);
|
||||
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_done, languageFilePath));
|
||||
return;
|
||||
}
|
||||
|
||||
fetckFileTask.Dispose();
|
||||
}
|
||||
else
|
||||
|
|
@ -270,7 +300,8 @@ namespace MinecraftClient.Protocol.Message
|
|||
}
|
||||
catch (IOException)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_save_fail, languageFilePath), acceptnewlines: true);
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.chat_save_fail, languageFilePath),
|
||||
acceptnewlines: true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -284,7 +315,9 @@ namespace MinecraftClient.Protocol.Message
|
|||
httpClient.Dispose();
|
||||
}
|
||||
|
||||
TranslationRules = JsonSerializer.Deserialize<Dictionary<string, string>>((byte[])MinecraftAssets.ResourceManager.GetObject("en_us.json")!)!;
|
||||
TranslationRules =
|
||||
JsonSerializer.Deserialize<Dictionary<string, string>>(
|
||||
(byte[])MinecraftAssets.ResourceManager.GetObject("en_us.json")!)!;
|
||||
ConsoleIO.WriteLine(Translations.chat_use_default);
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +338,12 @@ namespace MinecraftClient.Protocol.Message
|
|||
/// <returns>Returns the formatted text according to the given data</returns>
|
||||
private static string TranslateString(string rulename, List<string> using_data)
|
||||
{
|
||||
if (!RulesInitialized) { InitRules(); RulesInitialized = true; }
|
||||
if (!RulesInitialized)
|
||||
{
|
||||
InitRules();
|
||||
RulesInitialized = true;
|
||||
}
|
||||
|
||||
if (TranslationRules.ContainsKey(rulename))
|
||||
{
|
||||
int using_idx = 0;
|
||||
|
|
@ -329,8 +367,8 @@ namespace MinecraftClient.Protocol.Message
|
|||
|
||||
//Using specified string or int with %1$s, %2$s...
|
||||
else if (char.IsDigit(rule[i + 1])
|
||||
&& i + 3 < rule.Length && rule[i + 2] == '$'
|
||||
&& (rule[i + 3] == 's' || rule[i + 3] == 'd'))
|
||||
&& i + 3 < rule.Length && rule[i + 2] == '$'
|
||||
&& (rule[i + 3] == 's' || rule[i + 3] == 'd'))
|
||||
{
|
||||
int specified_idx = rule[i + 1] - '1';
|
||||
if (using_data.Count > specified_idx)
|
||||
|
|
@ -342,8 +380,10 @@ namespace MinecraftClient.Protocol.Message
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.Append(rule[i]);
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
else return "[" + rulename + "] " + string.Join(" ", using_data);
|
||||
|
|
@ -366,6 +406,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
{
|
||||
colorcode = Color2tag(JSONData2String(data.Properties["color"], "", links));
|
||||
}
|
||||
|
||||
if (data.Properties.ContainsKey("clickEvent") && links != null)
|
||||
{
|
||||
Json.JSONData clickEvent = data.Properties["clickEvent"];
|
||||
|
|
@ -377,12 +418,14 @@ namespace MinecraftClient.Protocol.Message
|
|||
links.Add(clickEvent.Properties["value"].StringValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.Properties.ContainsKey("extra"))
|
||||
{
|
||||
Json.JSONData[] extras = data.Properties["extra"].DataArray.ToArray();
|
||||
foreach (Json.JSONData item in extras)
|
||||
extra_result = extra_result + JSONData2String(item, colorcode, links) + "§r";
|
||||
}
|
||||
|
||||
if (data.Properties.ContainsKey("text"))
|
||||
{
|
||||
return colorcode + JSONData2String(data.Properties["text"], colorcode, links) + extra_result;
|
||||
|
|
@ -400,7 +443,10 @@ namespace MinecraftClient.Protocol.Message
|
|||
using_data.Add(JSONData2String(array[i], colorcode, links));
|
||||
}
|
||||
}
|
||||
return colorcode + TranslateString(JSONData2String(data.Properties["translate"], "", links), using_data) + extra_result;
|
||||
|
||||
return colorcode +
|
||||
TranslateString(JSONData2String(data.Properties["translate"], "", links), using_data) +
|
||||
extra_result;
|
||||
}
|
||||
else return extra_result;
|
||||
|
||||
|
|
@ -410,6 +456,7 @@ namespace MinecraftClient.Protocol.Message
|
|||
{
|
||||
result += JSONData2String(item, colorcode, links);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
case Json.JSONData.DataType.String:
|
||||
|
|
@ -418,5 +465,90 @@ namespace MinecraftClient.Protocol.Message
|
|||
|
||||
return "";
|
||||
}
|
||||
|
||||
private static string NbtToString(Dictionary<string, object> nbt)
|
||||
{
|
||||
if (nbt.Count == 1 && nbt.TryGetValue("", out object? rootMessage))
|
||||
{
|
||||
// Nameless root tag
|
||||
return (string)rootMessage;
|
||||
}
|
||||
|
||||
string message = string.Empty;
|
||||
string colorCode = string.Empty;
|
||||
StringBuilder extraBuilder = new StringBuilder();
|
||||
foreach (var kvp in nbt)
|
||||
{
|
||||
string key = kvp.Key;
|
||||
object value = kvp.Value;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case "text":
|
||||
{
|
||||
message = (string)value;
|
||||
}
|
||||
break;
|
||||
case "extra":
|
||||
{
|
||||
object[] extras = (object[])value;
|
||||
for (var i = 0; i < extras.Length; i++)
|
||||
{
|
||||
var extraDict = extras[i] switch
|
||||
{
|
||||
int => new Dictionary<string, object> { { "text", $"{extras[i]}" } },
|
||||
string => new Dictionary<string, object>
|
||||
{
|
||||
{ "text", (string)extras[i] }
|
||||
},
|
||||
_ => (Dictionary<string, object>)extras[i]
|
||||
};
|
||||
|
||||
extraBuilder.Append(NbtToString(extraDict) + "§r");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "translate":
|
||||
{
|
||||
if (nbt.TryGetValue("translate", out object translate))
|
||||
{
|
||||
var translateKey = (string)translate;
|
||||
List<string> translateString = new();
|
||||
if (nbt.TryGetValue("with", out object withComponent))
|
||||
{
|
||||
var withs = (object[])withComponent;
|
||||
for (var i = 0; i < withs.Length; i++)
|
||||
{
|
||||
var withDict = withs[i] switch
|
||||
{
|
||||
int => new Dictionary<string, object> { { "text", $"{withs[i]}" } },
|
||||
string => new Dictionary<string, object>
|
||||
{
|
||||
{ "text", (string)withs[i] }
|
||||
},
|
||||
_ => (Dictionary<string, object>)withs[i]
|
||||
};
|
||||
|
||||
translateString.Add(NbtToString(withDict));
|
||||
}
|
||||
}
|
||||
|
||||
message = TranslateString(translateKey, translateString);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "color":
|
||||
{
|
||||
if (nbt.TryGetValue("color", out object color))
|
||||
{
|
||||
colorCode = Color2tag((string)color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return colorCode + message + extraBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ using System.Text;
|
|||
using MinecraftClient.Protocol.Handlers;
|
||||
using MinecraftClient.Protocol.Message;
|
||||
using static MinecraftClient.Protocol.Message.LastSeenMessageList;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MinecraftClient.Protocol.ProfileKey
|
||||
{
|
||||
|
|
@ -20,7 +19,8 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
ProxiedWebRequest.Response? response = null;
|
||||
try
|
||||
{
|
||||
if (!isYggdrasil) {
|
||||
if (!isYggdrasil)
|
||||
{
|
||||
var request = new ProxiedWebRequest(certificates)
|
||||
{
|
||||
Accept = "application/json"
|
||||
|
|
@ -37,8 +37,7 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
|
||||
// see https://github.com/yushijinhun/authlib-injector/blob/da910956eaa30d2f6c2c457222d188aeb53b0d1f/src/main/java/moe/yushi/authlibinjector/httpd/ProfileKeyFilter.java#L49
|
||||
// POST to "https://api.minecraftservices.com/player/certificates" with authlib-injector will get a dummy response
|
||||
string jsonString = isYggdrasil ? MakeDummyResponse() : response!.Body;
|
||||
Json.JSONData json = Json.ParseJson(jsonString);
|
||||
Json.JSONData json = isYggdrasil ? MakeDummyResponse() : Json.ParseJson(response!.Body);
|
||||
// Error here
|
||||
PublicKey publicKey = new(pemKey: json.Properties["keyPair"].Properties["publicKey"].StringValue,
|
||||
sig: json.Properties["publicKeySignature"].StringValue,
|
||||
|
|
@ -236,7 +235,7 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string MakeDummyResponse()
|
||||
public static Json.JSONData MakeDummyResponse()
|
||||
{
|
||||
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048);
|
||||
var mimePublicKey = Convert.ToBase64String(rsa.ExportSubjectPublicKeyInfo());
|
||||
|
|
@ -246,19 +245,19 @@ namespace MinecraftClient.Protocol.ProfileKey
|
|||
DateTime now = DateTime.UtcNow;
|
||||
DateTime expiresAt = now.AddHours(48);
|
||||
DateTime refreshedAfter = now.AddHours(36);
|
||||
JObject response = new JObject();
|
||||
JObject keyPairObj = new JObject
|
||||
{
|
||||
{ "privateKey", privateKeyPEM },
|
||||
{ "publicKey", publicKeyPEM }
|
||||
};
|
||||
response.Add("keyPair", keyPairObj);
|
||||
response.Add("publicKeySignature", "AA==");
|
||||
response.Add("publicKeySignatureV2", "AA==");
|
||||
Json.JSONData response = new(Json.JSONData.DataType.Object);
|
||||
Json.JSONData keyPairObj = new(Json.JSONData.DataType.Object);
|
||||
keyPairObj.Properties["privateKey"] = new(Json.JSONData.DataType.String){ StringValue = privateKeyPEM };
|
||||
keyPairObj.Properties["publicKey"] = new(Json.JSONData.DataType.String){ StringValue = publicKeyPEM };
|
||||
|
||||
response.Properties["keyPair"] = keyPairObj;
|
||||
response.Properties["publicKeySignature"] = new(Json.JSONData.DataType.String){ StringValue = "AA==" };
|
||||
response.Properties["publicKeySignatureV2"] = new(Json.JSONData.DataType.String){ StringValue = "AA==" };
|
||||
string format = "yyyy-MM-ddTHH:mm:ss.ffffffZ";
|
||||
response.Add("expiresAt", expiresAt.ToString(format));
|
||||
response.Add("refreshedAfter", refreshedAfter.ToString(format));
|
||||
return response.ToString();
|
||||
response.Properties["expiresAt"] = new(Json.JSONData.DataType.String){ StringValue = expiresAt.ToString(format) };
|
||||
response.Properties["refreshedAfter"] = new(Json.JSONData.DataType.String){ StringValue = refreshedAfter.ToString(format) };
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ using MinecraftClient.Protocol.Handlers;
|
|||
using MinecraftClient.Protocol.Handlers.Forge;
|
||||
using MinecraftClient.Protocol.Session;
|
||||
using MinecraftClient.Proxy;
|
||||
using static MinecraftClient.Protocol.Microsoft;
|
||||
using static MinecraftClient.Settings;
|
||||
using static MinecraftClient.Settings.MainConfigHealper.MainConfig.GeneralConfig;
|
||||
|
||||
|
|
@ -43,32 +42,39 @@ namespace MinecraftClient.Protocol
|
|||
if (!String.IsNullOrEmpty(domain) && domain.Any(c => char.IsLetter(c)))
|
||||
{
|
||||
AutoTimeout.Perform(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
ConsoleIO.WriteLine(string.Format(Translations.mcc_resolve, domainVal));
|
||||
var lookupClient = new LookupClient();
|
||||
var response = lookupClient.Query(new DnsQuestion($"_minecraft._tcp.{domainVal}", QueryType.SRV));
|
||||
if (response.HasError != true && response.Answers.SrvRecords().Any())
|
||||
try
|
||||
{
|
||||
//Order SRV records by priority and weight, then randomly
|
||||
var result = response.Answers.SrvRecords()
|
||||
.OrderBy(record => record.Priority)
|
||||
.ThenByDescending(record => record.Weight)
|
||||
.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;
|
||||
ConsoleIO.WriteLine(string.Format(Translations.mcc_resolve, domainVal));
|
||||
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
|
||||
var result = response.Answers.SrvRecords()
|
||||
.OrderBy(record => record.Priority)
|
||||
.ThenByDescending(record => record.Weight)
|
||||
.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)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_not_found, domainVal, e.GetType().FullName, e.Message));
|
||||
}
|
||||
}, TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords == MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast ? 10 : 30));
|
||||
catch (Exception e)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + string.Format(Translations.mcc_not_found, domainVal,
|
||||
e.GetType().FullName, e.Message));
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(Config.Main.Advanced.ResolveSrvRecords ==
|
||||
MainConfigHealper.MainConfig.AdvancedConfig.ResolveSrvRecordType.fast
|
||||
? 10
|
||||
: 30));
|
||||
}
|
||||
|
||||
domain = domainVal;
|
||||
|
|
@ -83,28 +89,34 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="serverPort">Server Port to ping</param>
|
||||
/// <param name="protocolversion">Will contain protocol version, if ping successful</param>
|
||||
/// <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;
|
||||
int protocolversionTmp = 0;
|
||||
ForgeInfo? forgeInfoTmp = null;
|
||||
if (AutoTimeout.Perform(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Protocol18Handler.DoPing(serverIP, serverPort, ref protocolversionTmp, ref forgeInfoTmp)
|
||||
|| Protocol16Handler.DoPing(serverIP, serverPort, ref protocolversionTmp))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_unexpect_response, 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)))
|
||||
try
|
||||
{
|
||||
if (Protocol18Handler.DoPing(serverIP, serverPort, ref protocolversionTmp, ref forgeInfoTmp)
|
||||
|| Protocol16Handler.DoPing(serverIP, serverPort, ref protocolversionTmp))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_unexpect_response,
|
||||
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)
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.error_version_different, acceptnewlines: true);
|
||||
|
|
@ -125,23 +137,29 @@ namespace MinecraftClient.Protocol
|
|||
/// <summary>
|
||||
/// Get a protocol handler for the specified Minecraft version
|
||||
/// </summary>
|
||||
/// <param name="Client">Tcp Client connected to the server</param>
|
||||
/// <param name="ProtocolVersion">Protocol version to handle</param>
|
||||
/// <param name="Handler">Handler with the appropriate callbacks</param>
|
||||
/// <param name="client">Tcp Client connected to the server</param>
|
||||
/// <param name="protocolVersion">Protocol version to handle</param>
|
||||
/// <param name="forgeInfo">Forge info</param>
|
||||
/// <param name="handler">Handler with the appropriate callbacks</param>
|
||||
/// <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)
|
||||
return new Protocol16Handler(Client, ProtocolVersion, Handler);
|
||||
if (Array.IndexOf(suppoertedVersionsProtocol16, protocolVersion) > -1)
|
||||
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)
|
||||
return new Protocol18Handler(Client, ProtocolVersion, Handler, forgeInfo);
|
||||
if (Array.IndexOf(suppoertedVersionsProtocol18, protocolVersion) > -1)
|
||||
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>
|
||||
|
|
@ -149,11 +167,11 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <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>
|
||||
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.0":
|
||||
|
|
@ -324,20 +342,21 @@ namespace MinecraftClient.Protocol
|
|||
return 763;
|
||||
case "1.20.2":
|
||||
return 764;
|
||||
case "1.20.3":
|
||||
case "1.20.4":
|
||||
return 765;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
return int.Parse(MCVersion, NumberStyles.Any, CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return int.Parse(mcVersion, NumberStyles.Any, CultureInfo.CurrentCulture);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -404,6 +423,7 @@ namespace MinecraftClient.Protocol
|
|||
762 => "1.19.4",
|
||||
763 => "1.20",
|
||||
764 => "1.20.2",
|
||||
765 => "1.20.4",
|
||||
_ => "0.0"
|
||||
};
|
||||
}
|
||||
|
|
@ -411,7 +431,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <summary>
|
||||
/// Check if we can force-enable Forge support for a Minecraft version without using server Ping
|
||||
/// </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>
|
||||
public static bool ProtocolMayForceForge(int protocol)
|
||||
{
|
||||
|
|
@ -421,15 +441,35 @@ namespace MinecraftClient.Protocol
|
|||
/// <summary>
|
||||
/// Server Info: Consider Forge to be enabled regardless of server Ping
|
||||
/// </summary>
|
||||
/// <param name="protocolVersion">Minecraft protocol version</param>
|
||||
/// <param name="protocol">Minecraft protocol version</param>
|
||||
/// <returns>ForgeInfo item stating that Forge is enabled</returns>
|
||||
public static ForgeInfo ProtocolForceForge(int protocol)
|
||||
{
|
||||
return Protocol18Forge.ServerForceForge(protocol);
|
||||
}
|
||||
|
||||
public enum LoginResult { OtherError, ServiceUnavailable, SSLError, Success, WrongPassword, AccountMigrated, NotPremium, LoginRequired, InvalidToken, InvalidResponse, NullError, UserCancel, WrongSelection };
|
||||
public enum AccountType { Mojang, Microsoft };
|
||||
public enum LoginResult
|
||||
{
|
||||
OtherError,
|
||||
ServiceUnavailable,
|
||||
SSLError,
|
||||
Success,
|
||||
WrongPassword,
|
||||
AccountMigrated,
|
||||
NotPremium,
|
||||
LoginRequired,
|
||||
InvalidToken,
|
||||
InvalidResponse,
|
||||
NullError,
|
||||
UserCancel,
|
||||
WrongSelection
|
||||
};
|
||||
|
||||
public enum AccountType
|
||||
{
|
||||
Mojang,
|
||||
Microsoft
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
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>
|
||||
|
|
@ -472,8 +514,10 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
string result = "";
|
||||
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" + JsonEncode(user) + "\", \"password\": \"" + JsonEncode(pass) + "\", \"clientToken\": \"" + JsonEncode(session.ClientID) + "\" }";
|
||||
int code = DoHTTPSPost("authserver.mojang.com",443, "/authenticate", json_request, ref result);
|
||||
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" +
|
||||
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 (result.Contains("availableProfiles\":[]}"))
|
||||
|
|
@ -490,7 +534,8 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
session.ID = loginResponse.Properties["accessToken"].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;
|
||||
}
|
||||
else return LoginResult.InvalidResponse;
|
||||
|
|
@ -520,6 +565,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||
}
|
||||
|
||||
return LoginResult.SSLError;
|
||||
}
|
||||
catch (System.IO.IOException e)
|
||||
|
|
@ -528,6 +574,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||
}
|
||||
|
||||
if (e.Message.Contains("authentication"))
|
||||
{
|
||||
return LoginResult.SSLError;
|
||||
|
|
@ -540,18 +587,23 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||
}
|
||||
|
||||
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("-", "") };
|
||||
|
||||
try
|
||||
{
|
||||
string result = "";
|
||||
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" + 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);
|
||||
string json_request = "{\"agent\": { \"name\": \"Minecraft\", \"version\": 1 }, \"username\": \"" +
|
||||
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 (result.Contains("availableProfiles\":[]}"))
|
||||
|
|
@ -568,26 +620,33 @@ namespace MinecraftClient.Protocol
|
|||
&& loginResponse.Properties["selectedProfile"].Properties.ContainsKey("id")
|
||||
&& loginResponse.Properties["selectedProfile"].Properties.ContainsKey("name"))
|
||||
{
|
||||
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"].StringValue;
|
||||
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"].StringValue;
|
||||
session.PlayerID = loginResponse.Properties["selectedProfile"].Properties["id"]
|
||||
.StringValue;
|
||||
session.PlayerName = loginResponse.Properties["selectedProfile"].Properties["name"]
|
||||
.StringValue;
|
||||
return LoginResult.Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
ConsoleIO.WriteLine(Translations.mcc_avaliable_profiles + availableProfiles);
|
||||
|
||||
ConsoleIO.WriteLine(Translations.mcc_select_profile);
|
||||
string selectedProfileName = ConsoleIO.ReadLine();
|
||||
ConsoleIO.WriteLine(Translations.mcc_selected_profile + " " + selectedProfileName);
|
||||
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)
|
||||
|
|
@ -630,6 +689,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||
}
|
||||
|
||||
return LoginResult.SSLError;
|
||||
}
|
||||
catch (System.IO.IOException e)
|
||||
|
|
@ -638,6 +698,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||
}
|
||||
|
||||
if (e.Message.Contains("authentication"))
|
||||
{
|
||||
return LoginResult.SSLError;
|
||||
|
|
@ -650,9 +711,11 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.ToString());
|
||||
}
|
||||
|
||||
return LoginResult.OtherError;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sign-in to Microsoft Account without using browser. Only works if 2FA is disabled.
|
||||
/// Might not work well in some rare cases.
|
||||
|
|
@ -678,6 +741,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
||||
}
|
||||
|
||||
return LoginResult.WrongPassword; // Might not always be wrong password
|
||||
}
|
||||
}
|
||||
|
|
@ -748,6 +812,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§c" + e.StackTrace);
|
||||
}
|
||||
|
||||
return LoginResult.WrongPassword; // Might not always be wrong password
|
||||
}
|
||||
}
|
||||
|
|
@ -761,13 +826,15 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
var payload = JwtPayloadDecode.GetPayload(session.ID);
|
||||
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 tokenExp = UnixTimeStampToDateTime(expTimestamp);
|
||||
if (Settings.Config.Logging.DebugMessages)
|
||||
{
|
||||
ConsoleIO.WriteLine("Access token expiration time is " + tokenExp.ToString());
|
||||
}
|
||||
|
||||
if (now < tokenExp)
|
||||
{
|
||||
// Still valid
|
||||
|
|
@ -792,8 +859,11 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
string result = "";
|
||||
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) + "\", \"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);
|
||||
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) +
|
||||
"\", \"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 (result == null)
|
||||
|
|
@ -810,7 +880,8 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
session.ID = loginResponse.Properties["accessToken"].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;
|
||||
}
|
||||
else return LoginResult.InvalidResponse;
|
||||
|
|
@ -838,8 +909,12 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
string result = "";
|
||||
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) + "\", \"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);
|
||||
string json_request = "{ \"accessToken\": \"" + JsonEncode(currentsession.ID) +
|
||||
"\", \"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 (result == null)
|
||||
|
|
@ -856,7 +931,8 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
session.ID = loginResponse.Properties["accessToken"].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;
|
||||
}
|
||||
else return LoginResult.InvalidResponse;
|
||||
|
|
@ -891,15 +967,23 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
string result = "";
|
||||
string json_request = "{\"accessToken\":\"" + accesstoken + "\",\"selectedProfile\":\"" + uuid + "\",\"serverId\":\"" + serverhash + "\"}";
|
||||
string host = type == LoginType.yggdrasil ? Config.Main.General.AuthServer.Host : "sessionserver.mojang.com";
|
||||
string json_request = "{\"accessToken\":\"" + accesstoken + "\",\"selectedProfile\":\"" + uuid +
|
||||
"\",\"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;
|
||||
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);
|
||||
return (code >= 200 && code < 300);
|
||||
}
|
||||
catch { return false; }
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -915,8 +999,9 @@ namespace MinecraftClient.Protocol
|
|||
try
|
||||
{
|
||||
string result = "";
|
||||
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username, Program.MCHighestVersion);
|
||||
DoHTTPSGet("pc.realms.minecraft.net", 443,"/worlds", cookies, ref result);
|
||||
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username,
|
||||
Program.MCHighestVersion);
|
||||
DoHTTPSGet("pc.realms.minecraft.net", 443, "/worlds", cookies, ref result);
|
||||
Json.JSONData realmsWorlds = Json.ParseJson(result);
|
||||
if (realmsWorlds.Properties.ContainsKey("servers")
|
||||
&& realmsWorlds.Properties["servers"].Type == Json.JSONData.DataType.Array
|
||||
|
|
@ -942,6 +1027,7 @@ namespace MinecraftClient.Protocol
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (availableWorlds.Count > 0)
|
||||
{
|
||||
ConsoleIO.WriteLine(Translations.mcc_realms_available);
|
||||
|
|
@ -950,7 +1036,6 @@ namespace MinecraftClient.Protocol
|
|||
ConsoleIO.WriteLine(Translations.mcc_realms_join);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -960,6 +1045,7 @@ namespace MinecraftClient.Protocol
|
|||
ConsoleIO.WriteLineFormatted("§8" + e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
return realmsWorldsResult;
|
||||
}
|
||||
|
||||
|
|
@ -971,13 +1057,16 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="uuid">Player UUID</param>
|
||||
/// <param name="accesstoken">Access token</param>
|
||||
/// <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
|
||||
{
|
||||
string result = "";
|
||||
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username, Program.MCHighestVersion);
|
||||
int statusCode = DoHTTPSGet("pc.realms.minecraft.net",443, "/worlds/v1/" + worldId + "/join/pc", cookies, ref result);
|
||||
string cookies = String.Format("sid=token:{0}:{1};user={2};version={3}", accesstoken, uuid, username,
|
||||
Program.MCHighestVersion);
|
||||
int statusCode = DoHTTPSGet("pc.realms.minecraft.net", 443, "/worlds/v1/" + worldId + "/join/pc",
|
||||
cookies, ref result);
|
||||
if (statusCode == 200)
|
||||
{
|
||||
Json.JSONData serverAddress = Json.ParseJson(result);
|
||||
|
|
@ -1002,6 +1091,7 @@ namespace MinecraftClient.Protocol
|
|||
{
|
||||
ConsoleIO.WriteLineFormatted("§8" + e.StackTrace);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
@ -1014,7 +1104,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="cookies">Cookies for making the request</param>
|
||||
/// <param name="result">Request result</param>
|
||||
/// <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()
|
||||
{
|
||||
|
|
@ -1029,7 +1119,7 @@ namespace MinecraftClient.Protocol
|
|||
"",
|
||||
""
|
||||
};
|
||||
return DoHTTPSRequest(http_request, host,port, ref result);
|
||||
return DoHTTPSRequest(http_request, host, port, ref result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1053,7 +1143,7 @@ namespace MinecraftClient.Protocol
|
|||
"",
|
||||
request
|
||||
};
|
||||
return DoHTTPSRequest(http_request, host,port, ref result);
|
||||
return DoHTTPSRequest(http_request, host, port, ref result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1064,7 +1154,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="host">Host to connect to</param>
|
||||
/// <param name="result">Request result</param>
|
||||
/// <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;
|
||||
int statusCode = 520;
|
||||
|
|
@ -1078,7 +1168,8 @@ namespace MinecraftClient.Protocol
|
|||
|
||||
TcpClient client = ProxyHandler.NewTcpClient(host, port, true);
|
||||
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)
|
||||
foreach (string line in headers)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -332,20 +332,23 @@ namespace MinecraftClient.Scripting
|
|||
/// <summary>
|
||||
/// Called when a scoreboard objective updated
|
||||
/// </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="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>
|
||||
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>
|
||||
/// Called when a scoreboard updated
|
||||
/// </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="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>
|
||||
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>
|
||||
/// Called when the client received the Tab Header and Footer
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ features:
|
|||
- title: Automation
|
||||
details: Create bots to do automated tasks
|
||||
- title: Supported Versions
|
||||
details: 1.4 - 1.20.1
|
||||
details: 1.4 - 1.20.4
|
||||
footer: Made by MCC Team with ❤️
|
||||
---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue