From 61a682a69bf41e769069cd2c0efcde1eb8e54b5e Mon Sep 17 00:00:00 2001 From: Dusan Milutinovic Date: Sun, 13 Feb 2022 01:10:10 +0100 Subject: [PATCH 01/26] Added Entity, Item and Block palletes for 1.17/1 and 1.18/1. Added pallete generators as a command line option. Fixed a minor warning with AttackBot --- MinecraftClient/ChatBots/AutoAttack.cs | 12 +- .../Inventory/ItemPalettes/ItemPalette117.cs | 1119 +++++++++++++ .../Inventory/ItemPalettes/ItemPalette118.cs | 1120 +++++++++++++ MinecraftClient/Inventory/ItemType.cs | 193 ++- .../Inventory/ItemTypeExtensions.cs | 5 + .../BlockPalettes/BlockPaletteGenerator.cs | 20 +- .../Mapping/BlockPalettes/Palette117.cs | 1468 +++++++++++++++++ .../EntityPalettes/EntityPalette117.cs | 132 ++ MinecraftClient/Mapping/EntityType.cs | 39 +- .../Mapping/EntityTypeExtensions.cs | 1 + MinecraftClient/Mapping/Material.cs | 135 ++ MinecraftClient/Mapping/Material2Tool.cs | 82 +- MinecraftClient/Mapping/MaterialExtensions.cs | 119 ++ MinecraftClient/MinecraftClient.csproj | 4 + MinecraftClient/Program.cs | 78 + .../Protocol/Handlers/Protocol18.cs | 33 +- 16 files changed, 4488 insertions(+), 72 deletions(-) create mode 100644 MinecraftClient/Inventory/ItemPalettes/ItemPalette117.cs create mode 100644 MinecraftClient/Inventory/ItemPalettes/ItemPalette118.cs create mode 100644 MinecraftClient/Mapping/BlockPalettes/Palette117.cs create mode 100644 MinecraftClient/Mapping/EntityPalettes/EntityPalette117.cs diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs index dd45f9b4..fae80faa 100644 --- a/MinecraftClient/ChatBots/AutoAttack.cs +++ b/MinecraftClient/ChatBots/AutoAttack.cs @@ -100,11 +100,15 @@ namespace MinecraftClient.ChatBots } } } - // check entity distance and health again - if (shouldAttackEntity(entitiesToAttack[priorityEntity])) + + if (entitiesToAttack.ContainsKey(priorityEntity)) { - InteractEntity(priorityEntity, 1); // hit the entity! - SendAnimation(Inventory.Hand.MainHand); // Arm animation + // check entity distance and health again + if (shouldAttackEntity(entitiesToAttack[priorityEntity])) + { + InteractEntity(priorityEntity, 1); // hit the entity! + SendAnimation(Inventory.Hand.MainHand); // Arm animation + } } } else diff --git a/MinecraftClient/Inventory/ItemPalettes/ItemPalette117.cs b/MinecraftClient/Inventory/ItemPalettes/ItemPalette117.cs new file mode 100644 index 00000000..e11312dd --- /dev/null +++ b/MinecraftClient/Inventory/ItemPalettes/ItemPalette117.cs @@ -0,0 +1,1119 @@ +using System; +using System.Collections.Generic; + +namespace MinecraftClient.Inventory.ItemPalettes +{ + public class ItemPalette117 : ItemPalette + { + private static Dictionary mappings = new Dictionary(); + + static ItemPalette117() + { + mappings[0] = ItemType.Air; + mappings[1] = ItemType.Stone; + mappings[2] = ItemType.Granite; + mappings[3] = ItemType.PolishedGranite; + mappings[4] = ItemType.Diorite; + mappings[5] = ItemType.PolishedDiorite; + mappings[6] = ItemType.Andesite; + mappings[7] = ItemType.PolishedAndesite; + mappings[8] = ItemType.Deepslate; + mappings[9] = ItemType.CobbledDeepslate; + mappings[10] = ItemType.PolishedDeepslate; + mappings[11] = ItemType.Calcite; + mappings[12] = ItemType.Tuff; + mappings[13] = ItemType.DripstoneBlock; + mappings[14] = ItemType.GrassBlock; + mappings[15] = ItemType.Dirt; + mappings[16] = ItemType.CoarseDirt; + mappings[17] = ItemType.Podzol; + mappings[18] = ItemType.RootedDirt; + mappings[19] = ItemType.CrimsonNylium; + mappings[20] = ItemType.WarpedNylium; + mappings[21] = ItemType.Cobblestone; + mappings[22] = ItemType.OakPlanks; + mappings[23] = ItemType.SprucePlanks; + mappings[24] = ItemType.BirchPlanks; + mappings[25] = ItemType.JunglePlanks; + mappings[26] = ItemType.AcaciaPlanks; + mappings[27] = ItemType.DarkOakPlanks; + mappings[28] = ItemType.CrimsonPlanks; + mappings[29] = ItemType.WarpedPlanks; + mappings[30] = ItemType.OakSapling; + mappings[31] = ItemType.SpruceSapling; + mappings[32] = ItemType.BirchSapling; + mappings[33] = ItemType.JungleSapling; + mappings[34] = ItemType.AcaciaSapling; + mappings[35] = ItemType.DarkOakSapling; + mappings[36] = ItemType.Bedrock; + mappings[37] = ItemType.Sand; + mappings[38] = ItemType.RedSand; + mappings[39] = ItemType.Gravel; + mappings[40] = ItemType.CoalOre; + mappings[41] = ItemType.DeepslateCoalOre; + mappings[42] = ItemType.IronOre; + mappings[43] = ItemType.DeepslateIronOre; + mappings[44] = ItemType.CopperOre; + mappings[45] = ItemType.DeepslateCopperOre; + mappings[46] = ItemType.GoldOre; + mappings[47] = ItemType.DeepslateGoldOre; + mappings[48] = ItemType.RedstoneOre; + mappings[49] = ItemType.DeepslateRedstoneOre; + mappings[50] = ItemType.EmeraldOre; + mappings[51] = ItemType.DeepslateEmeraldOre; + mappings[52] = ItemType.LapisOre; + mappings[53] = ItemType.DeepslateLapisOre; + mappings[54] = ItemType.DiamondOre; + mappings[55] = ItemType.DeepslateDiamondOre; + mappings[56] = ItemType.NetherGoldOre; + mappings[57] = ItemType.NetherQuartzOre; + mappings[58] = ItemType.AncientDebris; + mappings[59] = ItemType.CoalBlock; + mappings[60] = ItemType.RawIronBlock; + mappings[61] = ItemType.RawCopperBlock; + mappings[62] = ItemType.RawGoldBlock; + mappings[63] = ItemType.AmethystBlock; + mappings[64] = ItemType.BuddingAmethyst; + mappings[65] = ItemType.IronBlock; + mappings[66] = ItemType.CopperBlock; + mappings[67] = ItemType.GoldBlock; + mappings[68] = ItemType.DiamondBlock; + mappings[69] = ItemType.NetheriteBlock; + mappings[70] = ItemType.ExposedCopper; + mappings[71] = ItemType.WeatheredCopper; + mappings[72] = ItemType.OxidizedCopper; + mappings[73] = ItemType.CutCopper; + mappings[74] = ItemType.ExposedCutCopper; + mappings[75] = ItemType.WeatheredCutCopper; + mappings[76] = ItemType.OxidizedCutCopper; + mappings[77] = ItemType.CutCopperStairs; + mappings[78] = ItemType.ExposedCutCopperStairs; + mappings[79] = ItemType.WeatheredCutCopperStairs; + mappings[80] = ItemType.OxidizedCutCopperStairs; + mappings[81] = ItemType.CutCopperSlab; + mappings[82] = ItemType.ExposedCutCopperSlab; + mappings[83] = ItemType.WeatheredCutCopperSlab; + mappings[84] = ItemType.OxidizedCutCopperSlab; + mappings[85] = ItemType.WaxedCopperBlock; + mappings[86] = ItemType.WaxedExposedCopper; + mappings[87] = ItemType.WaxedWeatheredCopper; + mappings[88] = ItemType.WaxedOxidizedCopper; + mappings[89] = ItemType.WaxedCutCopper; + mappings[90] = ItemType.WaxedExposedCutCopper; + mappings[91] = ItemType.WaxedWeatheredCutCopper; + mappings[92] = ItemType.WaxedOxidizedCutCopper; + mappings[93] = ItemType.WaxedCutCopperStairs; + mappings[94] = ItemType.WaxedExposedCutCopperStairs; + mappings[95] = ItemType.WaxedWeatheredCutCopperStairs; + mappings[96] = ItemType.WaxedOxidizedCutCopperStairs; + mappings[97] = ItemType.WaxedCutCopperSlab; + mappings[98] = ItemType.WaxedExposedCutCopperSlab; + mappings[99] = ItemType.WaxedWeatheredCutCopperSlab; + mappings[100] = ItemType.WaxedOxidizedCutCopperSlab; + mappings[101] = ItemType.OakLog; + mappings[102] = ItemType.SpruceLog; + mappings[103] = ItemType.BirchLog; + mappings[104] = ItemType.JungleLog; + mappings[105] = ItemType.AcaciaLog; + mappings[106] = ItemType.DarkOakLog; + mappings[107] = ItemType.CrimsonStem; + mappings[108] = ItemType.WarpedStem; + mappings[109] = ItemType.StrippedOakLog; + mappings[110] = ItemType.StrippedSpruceLog; + mappings[111] = ItemType.StrippedBirchLog; + mappings[112] = ItemType.StrippedJungleLog; + mappings[113] = ItemType.StrippedAcaciaLog; + mappings[114] = ItemType.StrippedDarkOakLog; + mappings[115] = ItemType.StrippedCrimsonStem; + mappings[116] = ItemType.StrippedWarpedStem; + mappings[117] = ItemType.StrippedOakWood; + mappings[118] = ItemType.StrippedSpruceWood; + mappings[119] = ItemType.StrippedBirchWood; + mappings[120] = ItemType.StrippedJungleWood; + mappings[121] = ItemType.StrippedAcaciaWood; + mappings[122] = ItemType.StrippedDarkOakWood; + mappings[123] = ItemType.StrippedCrimsonHyphae; + mappings[124] = ItemType.StrippedWarpedHyphae; + mappings[125] = ItemType.OakWood; + mappings[126] = ItemType.SpruceWood; + mappings[127] = ItemType.BirchWood; + mappings[128] = ItemType.JungleWood; + mappings[129] = ItemType.AcaciaWood; + mappings[130] = ItemType.DarkOakWood; + mappings[131] = ItemType.CrimsonHyphae; + mappings[132] = ItemType.WarpedHyphae; + mappings[133] = ItemType.OakLeaves; + mappings[134] = ItemType.SpruceLeaves; + mappings[135] = ItemType.BirchLeaves; + mappings[136] = ItemType.JungleLeaves; + mappings[137] = ItemType.AcaciaLeaves; + mappings[138] = ItemType.DarkOakLeaves; + mappings[139] = ItemType.AzaleaLeaves; + mappings[140] = ItemType.FloweringAzaleaLeaves; + mappings[141] = ItemType.Sponge; + mappings[142] = ItemType.WetSponge; + mappings[143] = ItemType.Glass; + mappings[144] = ItemType.TintedGlass; + mappings[145] = ItemType.LapisBlock; + mappings[146] = ItemType.Sandstone; + mappings[147] = ItemType.ChiseledSandstone; + mappings[148] = ItemType.CutSandstone; + mappings[149] = ItemType.Cobweb; + mappings[150] = ItemType.Grass; + mappings[151] = ItemType.Fern; + mappings[152] = ItemType.Azalea; + mappings[153] = ItemType.FloweringAzalea; + mappings[154] = ItemType.DeadBush; + mappings[155] = ItemType.Seagrass; + mappings[156] = ItemType.SeaPickle; + mappings[157] = ItemType.WhiteWool; + mappings[158] = ItemType.OrangeWool; + mappings[159] = ItemType.MagentaWool; + mappings[160] = ItemType.LightBlueWool; + mappings[161] = ItemType.YellowWool; + mappings[162] = ItemType.LimeWool; + mappings[163] = ItemType.PinkWool; + mappings[164] = ItemType.GrayWool; + mappings[165] = ItemType.LightGrayWool; + mappings[166] = ItemType.CyanWool; + mappings[167] = ItemType.PurpleWool; + mappings[168] = ItemType.BlueWool; + mappings[169] = ItemType.BrownWool; + mappings[170] = ItemType.GreenWool; + mappings[171] = ItemType.RedWool; + mappings[172] = ItemType.BlackWool; + mappings[173] = ItemType.Dandelion; + mappings[174] = ItemType.Poppy; + mappings[175] = ItemType.BlueOrchid; + mappings[176] = ItemType.Allium; + mappings[177] = ItemType.AzureBluet; + mappings[178] = ItemType.RedTulip; + mappings[179] = ItemType.OrangeTulip; + mappings[180] = ItemType.WhiteTulip; + mappings[181] = ItemType.PinkTulip; + mappings[182] = ItemType.OxeyeDaisy; + mappings[183] = ItemType.Cornflower; + mappings[184] = ItemType.LilyOfTheValley; + mappings[185] = ItemType.WitherRose; + mappings[186] = ItemType.SporeBlossom; + mappings[187] = ItemType.BrownMushroom; + mappings[188] = ItemType.RedMushroom; + mappings[189] = ItemType.CrimsonFungus; + mappings[190] = ItemType.WarpedFungus; + mappings[191] = ItemType.CrimsonRoots; + mappings[192] = ItemType.WarpedRoots; + mappings[193] = ItemType.NetherSprouts; + mappings[194] = ItemType.WeepingVines; + mappings[195] = ItemType.TwistingVines; + mappings[196] = ItemType.SugarCane; + mappings[197] = ItemType.Kelp; + mappings[198] = ItemType.MossCarpet; + mappings[199] = ItemType.MossBlock; + mappings[200] = ItemType.HangingRoots; + mappings[201] = ItemType.BigDripleaf; + mappings[202] = ItemType.SmallDripleaf; + mappings[203] = ItemType.Bamboo; + mappings[204] = ItemType.OakSlab; + mappings[205] = ItemType.SpruceSlab; + mappings[206] = ItemType.BirchSlab; + mappings[207] = ItemType.JungleSlab; + mappings[208] = ItemType.AcaciaSlab; + mappings[209] = ItemType.DarkOakSlab; + mappings[210] = ItemType.CrimsonSlab; + mappings[211] = ItemType.WarpedSlab; + mappings[212] = ItemType.StoneSlab; + mappings[213] = ItemType.SmoothStoneSlab; + mappings[214] = ItemType.SandstoneSlab; + mappings[215] = ItemType.CutSandstoneSlab; + mappings[216] = ItemType.PetrifiedOakSlab; + mappings[217] = ItemType.CobblestoneSlab; + mappings[218] = ItemType.BrickSlab; + mappings[219] = ItemType.StoneBrickSlab; + mappings[220] = ItemType.NetherBrickSlab; + mappings[221] = ItemType.QuartzSlab; + mappings[222] = ItemType.RedSandstoneSlab; + mappings[223] = ItemType.CutRedSandstoneSlab; + mappings[224] = ItemType.PurpurSlab; + mappings[225] = ItemType.PrismarineSlab; + mappings[226] = ItemType.PrismarineBrickSlab; + mappings[227] = ItemType.DarkPrismarineSlab; + mappings[228] = ItemType.SmoothQuartz; + mappings[229] = ItemType.SmoothRedSandstone; + mappings[230] = ItemType.SmoothSandstone; + mappings[231] = ItemType.SmoothStone; + mappings[232] = ItemType.Bricks; + mappings[233] = ItemType.Bookshelf; + mappings[234] = ItemType.MossyCobblestone; + mappings[235] = ItemType.Obsidian; + mappings[236] = ItemType.Torch; + mappings[237] = ItemType.EndRod; + mappings[238] = ItemType.ChorusPlant; + mappings[239] = ItemType.ChorusFlower; + mappings[240] = ItemType.PurpurBlock; + mappings[241] = ItemType.PurpurPillar; + mappings[242] = ItemType.PurpurStairs; + mappings[243] = ItemType.Spawner; + mappings[244] = ItemType.OakStairs; + mappings[245] = ItemType.Chest; + mappings[246] = ItemType.CraftingTable; + mappings[247] = ItemType.Farmland; + mappings[248] = ItemType.Furnace; + mappings[249] = ItemType.Ladder; + mappings[250] = ItemType.CobblestoneStairs; + mappings[251] = ItemType.Snow; + mappings[252] = ItemType.Ice; + mappings[253] = ItemType.SnowBlock; + mappings[254] = ItemType.Cactus; + mappings[255] = ItemType.Clay; + mappings[256] = ItemType.Jukebox; + mappings[257] = ItemType.OakFence; + mappings[258] = ItemType.SpruceFence; + mappings[259] = ItemType.BirchFence; + mappings[260] = ItemType.JungleFence; + mappings[261] = ItemType.AcaciaFence; + mappings[262] = ItemType.DarkOakFence; + mappings[263] = ItemType.CrimsonFence; + mappings[264] = ItemType.WarpedFence; + mappings[265] = ItemType.Pumpkin; + mappings[266] = ItemType.CarvedPumpkin; + mappings[267] = ItemType.JackOLantern; + mappings[268] = ItemType.Netherrack; + mappings[269] = ItemType.SoulSand; + mappings[270] = ItemType.SoulSoil; + mappings[271] = ItemType.Basalt; + mappings[272] = ItemType.PolishedBasalt; + mappings[273] = ItemType.SmoothBasalt; + mappings[274] = ItemType.SoulTorch; + mappings[275] = ItemType.Glowstone; + mappings[276] = ItemType.InfestedStone; + mappings[277] = ItemType.InfestedCobblestone; + mappings[278] = ItemType.InfestedStoneBricks; + mappings[279] = ItemType.InfestedMossyStoneBricks; + mappings[280] = ItemType.InfestedCrackedStoneBricks; + mappings[281] = ItemType.InfestedChiseledStoneBricks; + mappings[282] = ItemType.InfestedDeepslate; + mappings[283] = ItemType.StoneBricks; + mappings[284] = ItemType.MossyStoneBricks; + mappings[285] = ItemType.CrackedStoneBricks; + mappings[286] = ItemType.ChiseledStoneBricks; + mappings[287] = ItemType.DeepslateBricks; + mappings[288] = ItemType.CrackedDeepslateBricks; + mappings[289] = ItemType.DeepslateTiles; + mappings[290] = ItemType.CrackedDeepslateTiles; + mappings[291] = ItemType.ChiseledDeepslate; + mappings[292] = ItemType.BrownMushroomBlock; + mappings[293] = ItemType.RedMushroomBlock; + mappings[294] = ItemType.MushroomStem; + mappings[295] = ItemType.IronBars; + mappings[296] = ItemType.Chain; + mappings[297] = ItemType.GlassPane; + mappings[298] = ItemType.Melon; + mappings[299] = ItemType.Vine; + mappings[300] = ItemType.GlowLichen; + mappings[301] = ItemType.BrickStairs; + mappings[302] = ItemType.StoneBrickStairs; + mappings[303] = ItemType.Mycelium; + mappings[304] = ItemType.LilyPad; + mappings[305] = ItemType.NetherBricks; + mappings[306] = ItemType.CrackedNetherBricks; + mappings[307] = ItemType.ChiseledNetherBricks; + mappings[308] = ItemType.NetherBrickFence; + mappings[309] = ItemType.NetherBrickStairs; + mappings[310] = ItemType.EnchantingTable; + mappings[311] = ItemType.EndPortalFrame; + mappings[312] = ItemType.EndStone; + mappings[313] = ItemType.EndStoneBricks; + mappings[314] = ItemType.DragonEgg; + mappings[315] = ItemType.SandstoneStairs; + mappings[316] = ItemType.EnderChest; + mappings[317] = ItemType.EmeraldBlock; + mappings[318] = ItemType.SpruceStairs; + mappings[319] = ItemType.BirchStairs; + mappings[320] = ItemType.JungleStairs; + mappings[321] = ItemType.CrimsonStairs; + mappings[322] = ItemType.WarpedStairs; + mappings[323] = ItemType.CommandBlock; + mappings[324] = ItemType.Beacon; + mappings[325] = ItemType.CobblestoneWall; + mappings[326] = ItemType.MossyCobblestoneWall; + mappings[327] = ItemType.BrickWall; + mappings[328] = ItemType.PrismarineWall; + mappings[329] = ItemType.RedSandstoneWall; + mappings[330] = ItemType.MossyStoneBrickWall; + mappings[331] = ItemType.GraniteWall; + mappings[332] = ItemType.StoneBrickWall; + mappings[333] = ItemType.NetherBrickWall; + mappings[334] = ItemType.AndesiteWall; + mappings[335] = ItemType.RedNetherBrickWall; + mappings[336] = ItemType.SandstoneWall; + mappings[337] = ItemType.EndStoneBrickWall; + mappings[338] = ItemType.DioriteWall; + mappings[339] = ItemType.BlackstoneWall; + mappings[340] = ItemType.PolishedBlackstoneWall; + mappings[341] = ItemType.PolishedBlackstoneBrickWall; + mappings[342] = ItemType.CobbledDeepslateWall; + mappings[343] = ItemType.PolishedDeepslateWall; + mappings[344] = ItemType.DeepslateBrickWall; + mappings[345] = ItemType.DeepslateTileWall; + mappings[346] = ItemType.Anvil; + mappings[347] = ItemType.ChippedAnvil; + mappings[348] = ItemType.DamagedAnvil; + mappings[349] = ItemType.ChiseledQuartzBlock; + mappings[350] = ItemType.QuartzBlock; + mappings[351] = ItemType.QuartzBricks; + mappings[352] = ItemType.QuartzPillar; + mappings[353] = ItemType.QuartzStairs; + mappings[354] = ItemType.WhiteTerracotta; + mappings[355] = ItemType.OrangeTerracotta; + mappings[356] = ItemType.MagentaTerracotta; + mappings[357] = ItemType.LightBlueTerracotta; + mappings[358] = ItemType.YellowTerracotta; + mappings[359] = ItemType.LimeTerracotta; + mappings[360] = ItemType.PinkTerracotta; + mappings[361] = ItemType.GrayTerracotta; + mappings[362] = ItemType.LightGrayTerracotta; + mappings[363] = ItemType.CyanTerracotta; + mappings[364] = ItemType.PurpleTerracotta; + mappings[365] = ItemType.BlueTerracotta; + mappings[366] = ItemType.BrownTerracotta; + mappings[367] = ItemType.GreenTerracotta; + mappings[368] = ItemType.RedTerracotta; + mappings[369] = ItemType.BlackTerracotta; + mappings[370] = ItemType.Barrier; + mappings[371] = ItemType.Light; + mappings[372] = ItemType.HayBlock; + mappings[373] = ItemType.WhiteCarpet; + mappings[374] = ItemType.OrangeCarpet; + mappings[375] = ItemType.MagentaCarpet; + mappings[376] = ItemType.LightBlueCarpet; + mappings[377] = ItemType.YellowCarpet; + mappings[378] = ItemType.LimeCarpet; + mappings[379] = ItemType.PinkCarpet; + mappings[380] = ItemType.GrayCarpet; + mappings[381] = ItemType.LightGrayCarpet; + mappings[382] = ItemType.CyanCarpet; + mappings[383] = ItemType.PurpleCarpet; + mappings[384] = ItemType.BlueCarpet; + mappings[385] = ItemType.BrownCarpet; + mappings[386] = ItemType.GreenCarpet; + mappings[387] = ItemType.RedCarpet; + mappings[388] = ItemType.BlackCarpet; + mappings[389] = ItemType.Terracotta; + mappings[390] = ItemType.PackedIce; + mappings[391] = ItemType.AcaciaStairs; + mappings[392] = ItemType.DarkOakStairs; + mappings[393] = ItemType.GrassPath; + mappings[394] = ItemType.Sunflower; + mappings[395] = ItemType.Lilac; + mappings[396] = ItemType.RoseBush; + mappings[397] = ItemType.Peony; + mappings[398] = ItemType.TallGrass; + mappings[399] = ItemType.LargeFern; + mappings[400] = ItemType.WhiteStainedGlass; + mappings[401] = ItemType.OrangeStainedGlass; + mappings[402] = ItemType.MagentaStainedGlass; + mappings[403] = ItemType.LightBlueStainedGlass; + mappings[404] = ItemType.YellowStainedGlass; + mappings[405] = ItemType.LimeStainedGlass; + mappings[406] = ItemType.PinkStainedGlass; + mappings[407] = ItemType.GrayStainedGlass; + mappings[408] = ItemType.LightGrayStainedGlass; + mappings[409] = ItemType.CyanStainedGlass; + mappings[410] = ItemType.PurpleStainedGlass; + mappings[411] = ItemType.BlueStainedGlass; + mappings[412] = ItemType.BrownStainedGlass; + mappings[413] = ItemType.GreenStainedGlass; + mappings[414] = ItemType.RedStainedGlass; + mappings[415] = ItemType.BlackStainedGlass; + mappings[416] = ItemType.WhiteStainedGlassPane; + mappings[417] = ItemType.OrangeStainedGlassPane; + mappings[418] = ItemType.MagentaStainedGlassPane; + mappings[419] = ItemType.LightBlueStainedGlassPane; + mappings[420] = ItemType.YellowStainedGlassPane; + mappings[421] = ItemType.LimeStainedGlassPane; + mappings[422] = ItemType.PinkStainedGlassPane; + mappings[423] = ItemType.GrayStainedGlassPane; + mappings[424] = ItemType.LightGrayStainedGlassPane; + mappings[425] = ItemType.CyanStainedGlassPane; + mappings[426] = ItemType.PurpleStainedGlassPane; + mappings[427] = ItemType.BlueStainedGlassPane; + mappings[428] = ItemType.BrownStainedGlassPane; + mappings[429] = ItemType.GreenStainedGlassPane; + mappings[430] = ItemType.RedStainedGlassPane; + mappings[431] = ItemType.BlackStainedGlassPane; + mappings[432] = ItemType.Prismarine; + mappings[433] = ItemType.PrismarineBricks; + mappings[434] = ItemType.DarkPrismarine; + mappings[435] = ItemType.PrismarineStairs; + mappings[436] = ItemType.PrismarineBrickStairs; + mappings[437] = ItemType.DarkPrismarineStairs; + mappings[438] = ItemType.SeaLantern; + mappings[439] = ItemType.RedSandstone; + mappings[440] = ItemType.ChiseledRedSandstone; + mappings[441] = ItemType.CutRedSandstone; + mappings[442] = ItemType.RedSandstoneStairs; + mappings[443] = ItemType.RepeatingCommandBlock; + mappings[444] = ItemType.ChainCommandBlock; + mappings[445] = ItemType.MagmaBlock; + mappings[446] = ItemType.NetherWartBlock; + mappings[447] = ItemType.WarpedWartBlock; + mappings[448] = ItemType.RedNetherBricks; + mappings[449] = ItemType.BoneBlock; + mappings[450] = ItemType.StructureVoid; + mappings[451] = ItemType.ShulkerBox; + mappings[452] = ItemType.WhiteShulkerBox; + mappings[453] = ItemType.OrangeShulkerBox; + mappings[454] = ItemType.MagentaShulkerBox; + mappings[455] = ItemType.LightBlueShulkerBox; + mappings[456] = ItemType.YellowShulkerBox; + mappings[457] = ItemType.LimeShulkerBox; + mappings[458] = ItemType.PinkShulkerBox; + mappings[459] = ItemType.GrayShulkerBox; + mappings[460] = ItemType.LightGrayShulkerBox; + mappings[461] = ItemType.CyanShulkerBox; + mappings[462] = ItemType.PurpleShulkerBox; + mappings[463] = ItemType.BlueShulkerBox; + mappings[464] = ItemType.BrownShulkerBox; + mappings[465] = ItemType.GreenShulkerBox; + mappings[466] = ItemType.RedShulkerBox; + mappings[467] = ItemType.BlackShulkerBox; + mappings[468] = ItemType.WhiteGlazedTerracotta; + mappings[469] = ItemType.OrangeGlazedTerracotta; + mappings[470] = ItemType.MagentaGlazedTerracotta; + mappings[471] = ItemType.LightBlueGlazedTerracotta; + mappings[472] = ItemType.YellowGlazedTerracotta; + mappings[473] = ItemType.LimeGlazedTerracotta; + mappings[474] = ItemType.PinkGlazedTerracotta; + mappings[475] = ItemType.GrayGlazedTerracotta; + mappings[476] = ItemType.LightGrayGlazedTerracotta; + mappings[477] = ItemType.CyanGlazedTerracotta; + mappings[478] = ItemType.PurpleGlazedTerracotta; + mappings[479] = ItemType.BlueGlazedTerracotta; + mappings[480] = ItemType.BrownGlazedTerracotta; + mappings[481] = ItemType.GreenGlazedTerracotta; + mappings[482] = ItemType.RedGlazedTerracotta; + mappings[483] = ItemType.BlackGlazedTerracotta; + mappings[484] = ItemType.WhiteConcrete; + mappings[485] = ItemType.OrangeConcrete; + mappings[486] = ItemType.MagentaConcrete; + mappings[487] = ItemType.LightBlueConcrete; + mappings[488] = ItemType.YellowConcrete; + mappings[489] = ItemType.LimeConcrete; + mappings[490] = ItemType.PinkConcrete; + mappings[491] = ItemType.GrayConcrete; + mappings[492] = ItemType.LightGrayConcrete; + mappings[493] = ItemType.CyanConcrete; + mappings[494] = ItemType.PurpleConcrete; + mappings[495] = ItemType.BlueConcrete; + mappings[496] = ItemType.BrownConcrete; + mappings[497] = ItemType.GreenConcrete; + mappings[498] = ItemType.RedConcrete; + mappings[499] = ItemType.BlackConcrete; + mappings[500] = ItemType.WhiteConcretePowder; + mappings[501] = ItemType.OrangeConcretePowder; + mappings[502] = ItemType.MagentaConcretePowder; + mappings[503] = ItemType.LightBlueConcretePowder; + mappings[504] = ItemType.YellowConcretePowder; + mappings[505] = ItemType.LimeConcretePowder; + mappings[506] = ItemType.PinkConcretePowder; + mappings[507] = ItemType.GrayConcretePowder; + mappings[508] = ItemType.LightGrayConcretePowder; + mappings[509] = ItemType.CyanConcretePowder; + mappings[510] = ItemType.PurpleConcretePowder; + mappings[511] = ItemType.BlueConcretePowder; + mappings[512] = ItemType.BrownConcretePowder; + mappings[513] = ItemType.GreenConcretePowder; + mappings[514] = ItemType.RedConcretePowder; + mappings[515] = ItemType.BlackConcretePowder; + mappings[516] = ItemType.TurtleEgg; + mappings[517] = ItemType.DeadTubeCoralBlock; + mappings[518] = ItemType.DeadBrainCoralBlock; + mappings[519] = ItemType.DeadBubbleCoralBlock; + mappings[520] = ItemType.DeadFireCoralBlock; + mappings[521] = ItemType.DeadHornCoralBlock; + mappings[522] = ItemType.TubeCoralBlock; + mappings[523] = ItemType.BrainCoralBlock; + mappings[524] = ItemType.BubbleCoralBlock; + mappings[525] = ItemType.FireCoralBlock; + mappings[526] = ItemType.HornCoralBlock; + mappings[527] = ItemType.TubeCoral; + mappings[528] = ItemType.BrainCoral; + mappings[529] = ItemType.BubbleCoral; + mappings[530] = ItemType.FireCoral; + mappings[531] = ItemType.HornCoral; + mappings[532] = ItemType.DeadBrainCoral; + mappings[533] = ItemType.DeadBubbleCoral; + mappings[534] = ItemType.DeadFireCoral; + mappings[535] = ItemType.DeadHornCoral; + mappings[536] = ItemType.DeadTubeCoral; + mappings[537] = ItemType.TubeCoralFan; + mappings[538] = ItemType.BrainCoralFan; + mappings[539] = ItemType.BubbleCoralFan; + mappings[540] = ItemType.FireCoralFan; + mappings[541] = ItemType.HornCoralFan; + mappings[542] = ItemType.DeadTubeCoralFan; + mappings[543] = ItemType.DeadBrainCoralFan; + mappings[544] = ItemType.DeadBubbleCoralFan; + mappings[545] = ItemType.DeadFireCoralFan; + mappings[546] = ItemType.DeadHornCoralFan; + mappings[547] = ItemType.BlueIce; + mappings[548] = ItemType.Conduit; + mappings[549] = ItemType.PolishedGraniteStairs; + mappings[550] = ItemType.SmoothRedSandstoneStairs; + mappings[551] = ItemType.MossyStoneBrickStairs; + mappings[552] = ItemType.PolishedDioriteStairs; + mappings[553] = ItemType.MossyCobblestoneStairs; + mappings[554] = ItemType.EndStoneBrickStairs; + mappings[555] = ItemType.StoneStairs; + mappings[556] = ItemType.SmoothSandstoneStairs; + mappings[557] = ItemType.SmoothQuartzStairs; + mappings[558] = ItemType.GraniteStairs; + mappings[559] = ItemType.AndesiteStairs; + mappings[560] = ItemType.RedNetherBrickStairs; + mappings[561] = ItemType.PolishedAndesiteStairs; + mappings[562] = ItemType.DioriteStairs; + mappings[563] = ItemType.CobbledDeepslateStairs; + mappings[564] = ItemType.PolishedDeepslateStairs; + mappings[565] = ItemType.DeepslateBrickStairs; + mappings[566] = ItemType.DeepslateTileStairs; + mappings[567] = ItemType.PolishedGraniteSlab; + mappings[568] = ItemType.SmoothRedSandstoneSlab; + mappings[569] = ItemType.MossyStoneBrickSlab; + mappings[570] = ItemType.PolishedDioriteSlab; + mappings[571] = ItemType.MossyCobblestoneSlab; + mappings[572] = ItemType.EndStoneBrickSlab; + mappings[573] = ItemType.SmoothSandstoneSlab; + mappings[574] = ItemType.SmoothQuartzSlab; + mappings[575] = ItemType.GraniteSlab; + mappings[576] = ItemType.AndesiteSlab; + mappings[577] = ItemType.RedNetherBrickSlab; + mappings[578] = ItemType.PolishedAndesiteSlab; + mappings[579] = ItemType.DioriteSlab; + mappings[580] = ItemType.CobbledDeepslateSlab; + mappings[581] = ItemType.PolishedDeepslateSlab; + mappings[582] = ItemType.DeepslateBrickSlab; + mappings[583] = ItemType.DeepslateTileSlab; + mappings[584] = ItemType.Scaffolding; + mappings[585] = ItemType.Redstone; + mappings[586] = ItemType.RedstoneTorch; + mappings[587] = ItemType.RedstoneBlock; + mappings[588] = ItemType.Repeater; + mappings[589] = ItemType.Comparator; + mappings[590] = ItemType.Piston; + mappings[591] = ItemType.StickyPiston; + mappings[592] = ItemType.SlimeBlock; + mappings[593] = ItemType.HoneyBlock; + mappings[594] = ItemType.Observer; + mappings[595] = ItemType.Hopper; + mappings[596] = ItemType.Dispenser; + mappings[597] = ItemType.Dropper; + mappings[598] = ItemType.Lectern; + mappings[599] = ItemType.Target; + mappings[600] = ItemType.Lever; + mappings[601] = ItemType.LightningRod; + mappings[602] = ItemType.DaylightDetector; + mappings[603] = ItemType.SculkSensor; + mappings[604] = ItemType.TripwireHook; + mappings[605] = ItemType.TrappedChest; + mappings[606] = ItemType.Tnt; + mappings[607] = ItemType.RedstoneLamp; + mappings[608] = ItemType.NoteBlock; + mappings[609] = ItemType.StoneButton; + mappings[610] = ItemType.PolishedBlackstoneButton; + mappings[611] = ItemType.OakButton; + mappings[612] = ItemType.SpruceButton; + mappings[613] = ItemType.BirchButton; + mappings[614] = ItemType.JungleButton; + mappings[615] = ItemType.AcaciaButton; + mappings[616] = ItemType.DarkOakButton; + mappings[617] = ItemType.CrimsonButton; + mappings[618] = ItemType.WarpedButton; + mappings[619] = ItemType.StonePressurePlate; + mappings[620] = ItemType.PolishedBlackstonePressurePlate; + mappings[621] = ItemType.LightWeightedPressurePlate; + mappings[622] = ItemType.HeavyWeightedPressurePlate; + mappings[623] = ItemType.OakPressurePlate; + mappings[624] = ItemType.SprucePressurePlate; + mappings[625] = ItemType.BirchPressurePlate; + mappings[626] = ItemType.JunglePressurePlate; + mappings[627] = ItemType.AcaciaPressurePlate; + mappings[628] = ItemType.DarkOakPressurePlate; + mappings[629] = ItemType.CrimsonPressurePlate; + mappings[630] = ItemType.WarpedPressurePlate; + mappings[631] = ItemType.IronDoor; + mappings[632] = ItemType.OakDoor; + mappings[633] = ItemType.SpruceDoor; + mappings[634] = ItemType.BirchDoor; + mappings[635] = ItemType.JungleDoor; + mappings[636] = ItemType.AcaciaDoor; + mappings[637] = ItemType.DarkOakDoor; + mappings[638] = ItemType.CrimsonDoor; + mappings[639] = ItemType.WarpedDoor; + mappings[640] = ItemType.IronTrapdoor; + mappings[641] = ItemType.OakTrapdoor; + mappings[642] = ItemType.SpruceTrapdoor; + mappings[643] = ItemType.BirchTrapdoor; + mappings[644] = ItemType.JungleTrapdoor; + mappings[645] = ItemType.AcaciaTrapdoor; + mappings[646] = ItemType.DarkOakTrapdoor; + mappings[647] = ItemType.CrimsonTrapdoor; + mappings[648] = ItemType.WarpedTrapdoor; + mappings[649] = ItemType.OakFenceGate; + mappings[650] = ItemType.SpruceFenceGate; + mappings[651] = ItemType.BirchFenceGate; + mappings[652] = ItemType.JungleFenceGate; + mappings[653] = ItemType.AcaciaFenceGate; + mappings[654] = ItemType.DarkOakFenceGate; + mappings[655] = ItemType.CrimsonFenceGate; + mappings[656] = ItemType.WarpedFenceGate; + mappings[657] = ItemType.PoweredRail; + mappings[658] = ItemType.DetectorRail; + mappings[659] = ItemType.Rail; + mappings[660] = ItemType.ActivatorRail; + mappings[661] = ItemType.Saddle; + mappings[662] = ItemType.Minecart; + mappings[663] = ItemType.ChestMinecart; + mappings[664] = ItemType.FurnaceMinecart; + mappings[665] = ItemType.TntMinecart; + mappings[666] = ItemType.HopperMinecart; + mappings[667] = ItemType.CarrotOnAStick; + mappings[668] = ItemType.WarpedFungusOnAStick; + mappings[669] = ItemType.Elytra; + mappings[670] = ItemType.OakBoat; + mappings[671] = ItemType.SpruceBoat; + mappings[672] = ItemType.BirchBoat; + mappings[673] = ItemType.JungleBoat; + mappings[674] = ItemType.AcaciaBoat; + mappings[675] = ItemType.DarkOakBoat; + mappings[676] = ItemType.StructureBlock; + mappings[677] = ItemType.Jigsaw; + mappings[678] = ItemType.TurtleHelmet; + mappings[679] = ItemType.Scute; + mappings[680] = ItemType.FlintAndSteel; + mappings[681] = ItemType.Apple; + mappings[682] = ItemType.Bow; + mappings[683] = ItemType.Arrow; + mappings[684] = ItemType.Coal; + mappings[685] = ItemType.Charcoal; + mappings[686] = ItemType.Diamond; + mappings[687] = ItemType.Emerald; + mappings[688] = ItemType.LapisLazuli; + mappings[689] = ItemType.Quartz; + mappings[690] = ItemType.AmethystShard; + mappings[691] = ItemType.RawIron; + mappings[692] = ItemType.IronIngot; + mappings[693] = ItemType.RawCopper; + mappings[694] = ItemType.CopperIngot; + mappings[695] = ItemType.RawGold; + mappings[696] = ItemType.GoldIngot; + mappings[697] = ItemType.NetheriteIngot; + mappings[698] = ItemType.NetheriteScrap; + mappings[699] = ItemType.WoodenSword; + mappings[700] = ItemType.WoodenShovel; + mappings[701] = ItemType.WoodenPickaxe; + mappings[702] = ItemType.WoodenAxe; + mappings[703] = ItemType.WoodenHoe; + mappings[704] = ItemType.StoneSword; + mappings[705] = ItemType.StoneShovel; + mappings[706] = ItemType.StonePickaxe; + mappings[707] = ItemType.StoneAxe; + mappings[708] = ItemType.StoneHoe; + mappings[709] = ItemType.GoldenSword; + mappings[710] = ItemType.GoldenShovel; + mappings[711] = ItemType.GoldenPickaxe; + mappings[712] = ItemType.GoldenAxe; + mappings[713] = ItemType.GoldenHoe; + mappings[714] = ItemType.IronSword; + mappings[715] = ItemType.IronShovel; + mappings[716] = ItemType.IronPickaxe; + mappings[717] = ItemType.IronAxe; + mappings[718] = ItemType.IronHoe; + mappings[719] = ItemType.DiamondSword; + mappings[720] = ItemType.DiamondShovel; + mappings[721] = ItemType.DiamondPickaxe; + mappings[722] = ItemType.DiamondAxe; + mappings[723] = ItemType.DiamondHoe; + mappings[724] = ItemType.NetheriteSword; + mappings[725] = ItemType.NetheriteShovel; + mappings[726] = ItemType.NetheritePickaxe; + mappings[727] = ItemType.NetheriteAxe; + mappings[728] = ItemType.NetheriteHoe; + mappings[729] = ItemType.Stick; + mappings[730] = ItemType.Bowl; + mappings[731] = ItemType.MushroomStew; + mappings[732] = ItemType.String; + mappings[733] = ItemType.Feather; + mappings[734] = ItemType.Gunpowder; + mappings[735] = ItemType.WheatSeeds; + mappings[736] = ItemType.Wheat; + mappings[737] = ItemType.Bread; + mappings[738] = ItemType.LeatherHelmet; + mappings[739] = ItemType.LeatherChestplate; + mappings[740] = ItemType.LeatherLeggings; + mappings[741] = ItemType.LeatherBoots; + mappings[742] = ItemType.ChainmailHelmet; + mappings[743] = ItemType.ChainmailChestplate; + mappings[744] = ItemType.ChainmailLeggings; + mappings[745] = ItemType.ChainmailBoots; + mappings[746] = ItemType.IronHelmet; + mappings[747] = ItemType.IronChestplate; + mappings[748] = ItemType.IronLeggings; + mappings[749] = ItemType.IronBoots; + mappings[750] = ItemType.DiamondHelmet; + mappings[751] = ItemType.DiamondChestplate; + mappings[752] = ItemType.DiamondLeggings; + mappings[753] = ItemType.DiamondBoots; + mappings[754] = ItemType.GoldenHelmet; + mappings[755] = ItemType.GoldenChestplate; + mappings[756] = ItemType.GoldenLeggings; + mappings[757] = ItemType.GoldenBoots; + mappings[758] = ItemType.NetheriteHelmet; + mappings[759] = ItemType.NetheriteChestplate; + mappings[760] = ItemType.NetheriteLeggings; + mappings[761] = ItemType.NetheriteBoots; + mappings[762] = ItemType.Flint; + mappings[763] = ItemType.Porkchop; + mappings[764] = ItemType.CookedPorkchop; + mappings[765] = ItemType.Painting; + mappings[766] = ItemType.GoldenApple; + mappings[767] = ItemType.EnchantedGoldenApple; + mappings[768] = ItemType.OakSign; + mappings[769] = ItemType.SpruceSign; + mappings[770] = ItemType.BirchSign; + mappings[771] = ItemType.JungleSign; + mappings[772] = ItemType.AcaciaSign; + mappings[773] = ItemType.DarkOakSign; + mappings[774] = ItemType.CrimsonSign; + mappings[775] = ItemType.WarpedSign; + mappings[776] = ItemType.Bucket; + mappings[777] = ItemType.WaterBucket; + mappings[778] = ItemType.LavaBucket; + mappings[779] = ItemType.PowderSnowBucket; + mappings[780] = ItemType.Snowball; + mappings[781] = ItemType.Leather; + mappings[782] = ItemType.MilkBucket; + mappings[783] = ItemType.PufferfishBucket; + mappings[784] = ItemType.SalmonBucket; + mappings[785] = ItemType.CodBucket; + mappings[786] = ItemType.TropicalFishBucket; + mappings[787] = ItemType.AxolotlBucket; + mappings[788] = ItemType.Brick; + mappings[789] = ItemType.ClayBall; + mappings[790] = ItemType.DriedKelpBlock; + mappings[791] = ItemType.Paper; + mappings[792] = ItemType.Book; + mappings[793] = ItemType.SlimeBall; + mappings[794] = ItemType.Egg; + mappings[795] = ItemType.Compass; + mappings[796] = ItemType.Bundle; + mappings[797] = ItemType.FishingRod; + mappings[798] = ItemType.Clock; + mappings[799] = ItemType.Spyglass; + mappings[800] = ItemType.GlowstoneDust; + mappings[801] = ItemType.Cod; + mappings[802] = ItemType.Salmon; + mappings[803] = ItemType.TropicalFish; + mappings[804] = ItemType.Pufferfish; + mappings[805] = ItemType.CookedCod; + mappings[806] = ItemType.CookedSalmon; + mappings[807] = ItemType.InkSac; + mappings[808] = ItemType.GlowInkSac; + mappings[809] = ItemType.CocoaBeans; + mappings[810] = ItemType.WhiteDye; + mappings[811] = ItemType.OrangeDye; + mappings[812] = ItemType.MagentaDye; + mappings[813] = ItemType.LightBlueDye; + mappings[814] = ItemType.YellowDye; + mappings[815] = ItemType.LimeDye; + mappings[816] = ItemType.PinkDye; + mappings[817] = ItemType.GrayDye; + mappings[818] = ItemType.LightGrayDye; + mappings[819] = ItemType.CyanDye; + mappings[820] = ItemType.PurpleDye; + mappings[821] = ItemType.BlueDye; + mappings[822] = ItemType.BrownDye; + mappings[823] = ItemType.GreenDye; + mappings[824] = ItemType.RedDye; + mappings[825] = ItemType.BlackDye; + mappings[826] = ItemType.BoneMeal; + mappings[827] = ItemType.Bone; + mappings[828] = ItemType.Sugar; + mappings[829] = ItemType.Cake; + mappings[830] = ItemType.WhiteBed; + mappings[831] = ItemType.OrangeBed; + mappings[832] = ItemType.MagentaBed; + mappings[833] = ItemType.LightBlueBed; + mappings[834] = ItemType.YellowBed; + mappings[835] = ItemType.LimeBed; + mappings[836] = ItemType.PinkBed; + mappings[837] = ItemType.GrayBed; + mappings[838] = ItemType.LightGrayBed; + mappings[839] = ItemType.CyanBed; + mappings[840] = ItemType.PurpleBed; + mappings[841] = ItemType.BlueBed; + mappings[842] = ItemType.BrownBed; + mappings[843] = ItemType.GreenBed; + mappings[844] = ItemType.RedBed; + mappings[845] = ItemType.BlackBed; + mappings[846] = ItemType.Cookie; + mappings[847] = ItemType.FilledMap; + mappings[848] = ItemType.Shears; + mappings[849] = ItemType.MelonSlice; + mappings[850] = ItemType.DriedKelp; + mappings[851] = ItemType.PumpkinSeeds; + mappings[852] = ItemType.MelonSeeds; + mappings[853] = ItemType.Beef; + mappings[854] = ItemType.CookedBeef; + mappings[855] = ItemType.Chicken; + mappings[856] = ItemType.CookedChicken; + mappings[857] = ItemType.RottenFlesh; + mappings[858] = ItemType.EnderPearl; + mappings[859] = ItemType.BlazeRod; + mappings[860] = ItemType.GhastTear; + mappings[861] = ItemType.GoldNugget; + mappings[862] = ItemType.NetherWart; + mappings[863] = ItemType.Potion; + mappings[864] = ItemType.GlassBottle; + mappings[865] = ItemType.SpiderEye; + mappings[866] = ItemType.FermentedSpiderEye; + mappings[867] = ItemType.BlazePowder; + mappings[868] = ItemType.MagmaCream; + mappings[869] = ItemType.BrewingStand; + mappings[870] = ItemType.Cauldron; + mappings[871] = ItemType.EnderEye; + mappings[872] = ItemType.GlisteringMelonSlice; + mappings[873] = ItemType.AxolotlSpawnEgg; + mappings[874] = ItemType.BatSpawnEgg; + mappings[875] = ItemType.BeeSpawnEgg; + mappings[876] = ItemType.BlazeSpawnEgg; + mappings[877] = ItemType.CatSpawnEgg; + mappings[878] = ItemType.CaveSpiderSpawnEgg; + mappings[879] = ItemType.ChickenSpawnEgg; + mappings[880] = ItemType.CodSpawnEgg; + mappings[881] = ItemType.CowSpawnEgg; + mappings[882] = ItemType.CreeperSpawnEgg; + mappings[883] = ItemType.DolphinSpawnEgg; + mappings[884] = ItemType.DonkeySpawnEgg; + mappings[885] = ItemType.DrownedSpawnEgg; + mappings[886] = ItemType.ElderGuardianSpawnEgg; + mappings[887] = ItemType.EndermanSpawnEgg; + mappings[888] = ItemType.EndermiteSpawnEgg; + mappings[889] = ItemType.EvokerSpawnEgg; + mappings[890] = ItemType.FoxSpawnEgg; + mappings[891] = ItemType.GhastSpawnEgg; + mappings[892] = ItemType.GlowSquidSpawnEgg; + mappings[893] = ItemType.GoatSpawnEgg; + mappings[894] = ItemType.GuardianSpawnEgg; + mappings[895] = ItemType.HoglinSpawnEgg; + mappings[896] = ItemType.HorseSpawnEgg; + mappings[897] = ItemType.HuskSpawnEgg; + mappings[898] = ItemType.LlamaSpawnEgg; + mappings[899] = ItemType.MagmaCubeSpawnEgg; + mappings[900] = ItemType.MooshroomSpawnEgg; + mappings[901] = ItemType.MuleSpawnEgg; + mappings[902] = ItemType.OcelotSpawnEgg; + mappings[903] = ItemType.PandaSpawnEgg; + mappings[904] = ItemType.ParrotSpawnEgg; + mappings[905] = ItemType.PhantomSpawnEgg; + mappings[906] = ItemType.PigSpawnEgg; + mappings[907] = ItemType.PiglinSpawnEgg; + mappings[908] = ItemType.PiglinBruteSpawnEgg; + mappings[909] = ItemType.PillagerSpawnEgg; + mappings[910] = ItemType.PolarBearSpawnEgg; + mappings[911] = ItemType.PufferfishSpawnEgg; + mappings[912] = ItemType.RabbitSpawnEgg; + mappings[913] = ItemType.RavagerSpawnEgg; + mappings[914] = ItemType.SalmonSpawnEgg; + mappings[915] = ItemType.SheepSpawnEgg; + mappings[916] = ItemType.ShulkerSpawnEgg; + mappings[917] = ItemType.SilverfishSpawnEgg; + mappings[918] = ItemType.SkeletonSpawnEgg; + mappings[919] = ItemType.SkeletonHorseSpawnEgg; + mappings[920] = ItemType.SlimeSpawnEgg; + mappings[921] = ItemType.SpiderSpawnEgg; + mappings[922] = ItemType.SquidSpawnEgg; + mappings[923] = ItemType.StraySpawnEgg; + mappings[924] = ItemType.StriderSpawnEgg; + mappings[925] = ItemType.TraderLlamaSpawnEgg; + mappings[926] = ItemType.TropicalFishSpawnEgg; + mappings[927] = ItemType.TurtleSpawnEgg; + mappings[928] = ItemType.VexSpawnEgg; + mappings[929] = ItemType.VillagerSpawnEgg; + mappings[930] = ItemType.VindicatorSpawnEgg; + mappings[931] = ItemType.WanderingTraderSpawnEgg; + mappings[932] = ItemType.WitchSpawnEgg; + mappings[933] = ItemType.WitherSkeletonSpawnEgg; + mappings[934] = ItemType.WolfSpawnEgg; + mappings[935] = ItemType.ZoglinSpawnEgg; + mappings[936] = ItemType.ZombieSpawnEgg; + mappings[937] = ItemType.ZombieHorseSpawnEgg; + mappings[938] = ItemType.ZombieVillagerSpawnEgg; + mappings[939] = ItemType.ZombifiedPiglinSpawnEgg; + mappings[940] = ItemType.ExperienceBottle; + mappings[941] = ItemType.FireCharge; + mappings[942] = ItemType.WritableBook; + mappings[943] = ItemType.WrittenBook; + mappings[944] = ItemType.ItemFrame; + mappings[945] = ItemType.GlowItemFrame; + mappings[946] = ItemType.FlowerPot; + mappings[947] = ItemType.Carrot; + mappings[948] = ItemType.Potato; + mappings[949] = ItemType.BakedPotato; + mappings[950] = ItemType.PoisonousPotato; + mappings[951] = ItemType.Map; + mappings[952] = ItemType.GoldenCarrot; + mappings[953] = ItemType.SkeletonSkull; + mappings[954] = ItemType.WitherSkeletonSkull; + mappings[955] = ItemType.PlayerHead; + mappings[956] = ItemType.ZombieHead; + mappings[957] = ItemType.CreeperHead; + mappings[958] = ItemType.DragonHead; + mappings[959] = ItemType.NetherStar; + mappings[960] = ItemType.PumpkinPie; + mappings[961] = ItemType.FireworkRocket; + mappings[962] = ItemType.FireworkStar; + mappings[963] = ItemType.EnchantedBook; + mappings[964] = ItemType.NetherBrick; + mappings[965] = ItemType.PrismarineShard; + mappings[966] = ItemType.PrismarineCrystals; + mappings[967] = ItemType.Rabbit; + mappings[968] = ItemType.CookedRabbit; + mappings[969] = ItemType.RabbitStew; + mappings[970] = ItemType.RabbitFoot; + mappings[971] = ItemType.RabbitHide; + mappings[972] = ItemType.ArmorStand; + mappings[973] = ItemType.IronHorseArmor; + mappings[974] = ItemType.GoldenHorseArmor; + mappings[975] = ItemType.DiamondHorseArmor; + mappings[976] = ItemType.LeatherHorseArmor; + mappings[977] = ItemType.Lead; + mappings[978] = ItemType.NameTag; + mappings[979] = ItemType.CommandBlockMinecart; + mappings[980] = ItemType.Mutton; + mappings[981] = ItemType.CookedMutton; + mappings[982] = ItemType.WhiteBanner; + mappings[983] = ItemType.OrangeBanner; + mappings[984] = ItemType.MagentaBanner; + mappings[985] = ItemType.LightBlueBanner; + mappings[986] = ItemType.YellowBanner; + mappings[987] = ItemType.LimeBanner; + mappings[988] = ItemType.PinkBanner; + mappings[989] = ItemType.GrayBanner; + mappings[990] = ItemType.LightGrayBanner; + mappings[991] = ItemType.CyanBanner; + mappings[992] = ItemType.PurpleBanner; + mappings[993] = ItemType.BlueBanner; + mappings[994] = ItemType.BrownBanner; + mappings[995] = ItemType.GreenBanner; + mappings[996] = ItemType.RedBanner; + mappings[997] = ItemType.BlackBanner; + mappings[998] = ItemType.EndCrystal; + mappings[999] = ItemType.ChorusFruit; + mappings[1000] = ItemType.PoppedChorusFruit; + mappings[1001] = ItemType.Beetroot; + mappings[1002] = ItemType.BeetrootSeeds; + mappings[1003] = ItemType.BeetrootSoup; + mappings[1004] = ItemType.DragonBreath; + mappings[1005] = ItemType.SplashPotion; + mappings[1006] = ItemType.SpectralArrow; + mappings[1007] = ItemType.TippedArrow; + mappings[1008] = ItemType.LingeringPotion; + mappings[1009] = ItemType.Shield; + mappings[1010] = ItemType.TotemOfUndying; + mappings[1011] = ItemType.ShulkerShell; + mappings[1012] = ItemType.IronNugget; + mappings[1013] = ItemType.KnowledgeBook; + mappings[1014] = ItemType.DebugStick; + mappings[1015] = ItemType.MusicDisc13; + mappings[1016] = ItemType.MusicDiscCat; + mappings[1017] = ItemType.MusicDiscBlocks; + mappings[1018] = ItemType.MusicDiscChirp; + mappings[1019] = ItemType.MusicDiscFar; + mappings[1020] = ItemType.MusicDiscMall; + mappings[1021] = ItemType.MusicDiscMellohi; + mappings[1022] = ItemType.MusicDiscStal; + mappings[1023] = ItemType.MusicDiscStrad; + mappings[1024] = ItemType.MusicDiscWard; + mappings[1025] = ItemType.MusicDisc11; + mappings[1026] = ItemType.MusicDiscWait; + mappings[1027] = ItemType.MusicDiscPigstep; + mappings[1028] = ItemType.Trident; + mappings[1029] = ItemType.PhantomMembrane; + mappings[1030] = ItemType.NautilusShell; + mappings[1031] = ItemType.HeartOfTheSea; + mappings[1032] = ItemType.Crossbow; + mappings[1033] = ItemType.SuspiciousStew; + mappings[1034] = ItemType.Loom; + mappings[1035] = ItemType.FlowerBannerPattern; + mappings[1036] = ItemType.CreeperBannerPattern; + mappings[1037] = ItemType.SkullBannerPattern; + mappings[1038] = ItemType.MojangBannerPattern; + mappings[1039] = ItemType.GlobeBannerPattern; + mappings[1040] = ItemType.PiglinBannerPattern; + mappings[1041] = ItemType.Composter; + mappings[1042] = ItemType.Barrel; + mappings[1043] = ItemType.Smoker; + mappings[1044] = ItemType.BlastFurnace; + mappings[1045] = ItemType.CartographyTable; + mappings[1046] = ItemType.FletchingTable; + mappings[1047] = ItemType.Grindstone; + mappings[1048] = ItemType.SmithingTable; + mappings[1049] = ItemType.Stonecutter; + mappings[1050] = ItemType.Bell; + mappings[1051] = ItemType.Lantern; + mappings[1052] = ItemType.SoulLantern; + mappings[1053] = ItemType.SweetBerries; + mappings[1054] = ItemType.GlowBerries; + mappings[1055] = ItemType.Campfire; + mappings[1056] = ItemType.SoulCampfire; + mappings[1057] = ItemType.Shroomlight; + mappings[1058] = ItemType.Honeycomb; + mappings[1059] = ItemType.BeeNest; + mappings[1060] = ItemType.Beehive; + mappings[1061] = ItemType.HoneyBottle; + mappings[1062] = ItemType.HoneycombBlock; + mappings[1063] = ItemType.Lodestone; + mappings[1064] = ItemType.CryingObsidian; + mappings[1065] = ItemType.Blackstone; + mappings[1066] = ItemType.BlackstoneSlab; + mappings[1067] = ItemType.BlackstoneStairs; + mappings[1068] = ItemType.GildedBlackstone; + mappings[1069] = ItemType.PolishedBlackstone; + mappings[1070] = ItemType.PolishedBlackstoneSlab; + mappings[1071] = ItemType.PolishedBlackstoneStairs; + mappings[1072] = ItemType.ChiseledPolishedBlackstone; + mappings[1073] = ItemType.PolishedBlackstoneBricks; + mappings[1074] = ItemType.PolishedBlackstoneBrickSlab; + mappings[1075] = ItemType.PolishedBlackstoneBrickStairs; + mappings[1076] = ItemType.CrackedPolishedBlackstoneBricks; + mappings[1077] = ItemType.RespawnAnchor; + mappings[1078] = ItemType.Candle; + mappings[1079] = ItemType.WhiteCandle; + mappings[1080] = ItemType.OrangeCandle; + mappings[1081] = ItemType.MagentaCandle; + mappings[1082] = ItemType.LightBlueCandle; + mappings[1083] = ItemType.YellowCandle; + mappings[1084] = ItemType.LimeCandle; + mappings[1085] = ItemType.PinkCandle; + mappings[1086] = ItemType.GrayCandle; + mappings[1087] = ItemType.LightGrayCandle; + mappings[1088] = ItemType.CyanCandle; + mappings[1089] = ItemType.PurpleCandle; + mappings[1090] = ItemType.BlueCandle; + mappings[1091] = ItemType.BrownCandle; + mappings[1092] = ItemType.GreenCandle; + mappings[1093] = ItemType.RedCandle; + mappings[1094] = ItemType.BlackCandle; + mappings[1095] = ItemType.SmallAmethystBud; + mappings[1096] = ItemType.MediumAmethystBud; + mappings[1097] = ItemType.LargeAmethystBud; + mappings[1098] = ItemType.AmethystCluster; + mappings[1099] = ItemType.PointedDripstone; + } + + protected override Dictionary GetDict() + { + return mappings; + } + } +} diff --git a/MinecraftClient/Inventory/ItemPalettes/ItemPalette118.cs b/MinecraftClient/Inventory/ItemPalettes/ItemPalette118.cs new file mode 100644 index 00000000..0e4577eb --- /dev/null +++ b/MinecraftClient/Inventory/ItemPalettes/ItemPalette118.cs @@ -0,0 +1,1120 @@ +using System; +using System.Collections.Generic; + +namespace MinecraftClient.Inventory.ItemPalettes +{ + public class ItemPalette118 : ItemPalette + { + private static Dictionary mappings = new Dictionary(); + + static ItemPalette118() + { + mappings[0] = ItemType.Air; + mappings[1] = ItemType.Stone; + mappings[2] = ItemType.Granite; + mappings[3] = ItemType.PolishedGranite; + mappings[4] = ItemType.Diorite; + mappings[5] = ItemType.PolishedDiorite; + mappings[6] = ItemType.Andesite; + mappings[7] = ItemType.PolishedAndesite; + mappings[8] = ItemType.Deepslate; + mappings[9] = ItemType.CobbledDeepslate; + mappings[10] = ItemType.PolishedDeepslate; + mappings[11] = ItemType.Calcite; + mappings[12] = ItemType.Tuff; + mappings[13] = ItemType.DripstoneBlock; + mappings[14] = ItemType.GrassBlock; + mappings[15] = ItemType.Dirt; + mappings[16] = ItemType.CoarseDirt; + mappings[17] = ItemType.Podzol; + mappings[18] = ItemType.RootedDirt; + mappings[19] = ItemType.CrimsonNylium; + mappings[20] = ItemType.WarpedNylium; + mappings[21] = ItemType.Cobblestone; + mappings[22] = ItemType.OakPlanks; + mappings[23] = ItemType.SprucePlanks; + mappings[24] = ItemType.BirchPlanks; + mappings[25] = ItemType.JunglePlanks; + mappings[26] = ItemType.AcaciaPlanks; + mappings[27] = ItemType.DarkOakPlanks; + mappings[28] = ItemType.CrimsonPlanks; + mappings[29] = ItemType.WarpedPlanks; + mappings[30] = ItemType.OakSapling; + mappings[31] = ItemType.SpruceSapling; + mappings[32] = ItemType.BirchSapling; + mappings[33] = ItemType.JungleSapling; + mappings[34] = ItemType.AcaciaSapling; + mappings[35] = ItemType.DarkOakSapling; + mappings[36] = ItemType.Bedrock; + mappings[37] = ItemType.Sand; + mappings[38] = ItemType.RedSand; + mappings[39] = ItemType.Gravel; + mappings[40] = ItemType.CoalOre; + mappings[41] = ItemType.DeepslateCoalOre; + mappings[42] = ItemType.IronOre; + mappings[43] = ItemType.DeepslateIronOre; + mappings[44] = ItemType.CopperOre; + mappings[45] = ItemType.DeepslateCopperOre; + mappings[46] = ItemType.GoldOre; + mappings[47] = ItemType.DeepslateGoldOre; + mappings[48] = ItemType.RedstoneOre; + mappings[49] = ItemType.DeepslateRedstoneOre; + mappings[50] = ItemType.EmeraldOre; + mappings[51] = ItemType.DeepslateEmeraldOre; + mappings[52] = ItemType.LapisOre; + mappings[53] = ItemType.DeepslateLapisOre; + mappings[54] = ItemType.DiamondOre; + mappings[55] = ItemType.DeepslateDiamondOre; + mappings[56] = ItemType.NetherGoldOre; + mappings[57] = ItemType.NetherQuartzOre; + mappings[58] = ItemType.AncientDebris; + mappings[59] = ItemType.CoalBlock; + mappings[60] = ItemType.RawIronBlock; + mappings[61] = ItemType.RawCopperBlock; + mappings[62] = ItemType.RawGoldBlock; + mappings[63] = ItemType.AmethystBlock; + mappings[64] = ItemType.BuddingAmethyst; + mappings[65] = ItemType.IronBlock; + mappings[66] = ItemType.CopperBlock; + mappings[67] = ItemType.GoldBlock; + mappings[68] = ItemType.DiamondBlock; + mappings[69] = ItemType.NetheriteBlock; + mappings[70] = ItemType.ExposedCopper; + mappings[71] = ItemType.WeatheredCopper; + mappings[72] = ItemType.OxidizedCopper; + mappings[73] = ItemType.CutCopper; + mappings[74] = ItemType.ExposedCutCopper; + mappings[75] = ItemType.WeatheredCutCopper; + mappings[76] = ItemType.OxidizedCutCopper; + mappings[77] = ItemType.CutCopperStairs; + mappings[78] = ItemType.ExposedCutCopperStairs; + mappings[79] = ItemType.WeatheredCutCopperStairs; + mappings[80] = ItemType.OxidizedCutCopperStairs; + mappings[81] = ItemType.CutCopperSlab; + mappings[82] = ItemType.ExposedCutCopperSlab; + mappings[83] = ItemType.WeatheredCutCopperSlab; + mappings[84] = ItemType.OxidizedCutCopperSlab; + mappings[85] = ItemType.WaxedCopperBlock; + mappings[86] = ItemType.WaxedExposedCopper; + mappings[87] = ItemType.WaxedWeatheredCopper; + mappings[88] = ItemType.WaxedOxidizedCopper; + mappings[89] = ItemType.WaxedCutCopper; + mappings[90] = ItemType.WaxedExposedCutCopper; + mappings[91] = ItemType.WaxedWeatheredCutCopper; + mappings[92] = ItemType.WaxedOxidizedCutCopper; + mappings[93] = ItemType.WaxedCutCopperStairs; + mappings[94] = ItemType.WaxedExposedCutCopperStairs; + mappings[95] = ItemType.WaxedWeatheredCutCopperStairs; + mappings[96] = ItemType.WaxedOxidizedCutCopperStairs; + mappings[97] = ItemType.WaxedCutCopperSlab; + mappings[98] = ItemType.WaxedExposedCutCopperSlab; + mappings[99] = ItemType.WaxedWeatheredCutCopperSlab; + mappings[100] = ItemType.WaxedOxidizedCutCopperSlab; + mappings[101] = ItemType.OakLog; + mappings[102] = ItemType.SpruceLog; + mappings[103] = ItemType.BirchLog; + mappings[104] = ItemType.JungleLog; + mappings[105] = ItemType.AcaciaLog; + mappings[106] = ItemType.DarkOakLog; + mappings[107] = ItemType.CrimsonStem; + mappings[108] = ItemType.WarpedStem; + mappings[109] = ItemType.StrippedOakLog; + mappings[110] = ItemType.StrippedSpruceLog; + mappings[111] = ItemType.StrippedBirchLog; + mappings[112] = ItemType.StrippedJungleLog; + mappings[113] = ItemType.StrippedAcaciaLog; + mappings[114] = ItemType.StrippedDarkOakLog; + mappings[115] = ItemType.StrippedCrimsonStem; + mappings[116] = ItemType.StrippedWarpedStem; + mappings[117] = ItemType.StrippedOakWood; + mappings[118] = ItemType.StrippedSpruceWood; + mappings[119] = ItemType.StrippedBirchWood; + mappings[120] = ItemType.StrippedJungleWood; + mappings[121] = ItemType.StrippedAcaciaWood; + mappings[122] = ItemType.StrippedDarkOakWood; + mappings[123] = ItemType.StrippedCrimsonHyphae; + mappings[124] = ItemType.StrippedWarpedHyphae; + mappings[125] = ItemType.OakWood; + mappings[126] = ItemType.SpruceWood; + mappings[127] = ItemType.BirchWood; + mappings[128] = ItemType.JungleWood; + mappings[129] = ItemType.AcaciaWood; + mappings[130] = ItemType.DarkOakWood; + mappings[131] = ItemType.CrimsonHyphae; + mappings[132] = ItemType.WarpedHyphae; + mappings[133] = ItemType.OakLeaves; + mappings[134] = ItemType.SpruceLeaves; + mappings[135] = ItemType.BirchLeaves; + mappings[136] = ItemType.JungleLeaves; + mappings[137] = ItemType.AcaciaLeaves; + mappings[138] = ItemType.DarkOakLeaves; + mappings[139] = ItemType.AzaleaLeaves; + mappings[140] = ItemType.FloweringAzaleaLeaves; + mappings[141] = ItemType.Sponge; + mappings[142] = ItemType.WetSponge; + mappings[143] = ItemType.Glass; + mappings[144] = ItemType.TintedGlass; + mappings[145] = ItemType.LapisBlock; + mappings[146] = ItemType.Sandstone; + mappings[147] = ItemType.ChiseledSandstone; + mappings[148] = ItemType.CutSandstone; + mappings[149] = ItemType.Cobweb; + mappings[150] = ItemType.Grass; + mappings[151] = ItemType.Fern; + mappings[152] = ItemType.Azalea; + mappings[153] = ItemType.FloweringAzalea; + mappings[154] = ItemType.DeadBush; + mappings[155] = ItemType.Seagrass; + mappings[156] = ItemType.SeaPickle; + mappings[157] = ItemType.WhiteWool; + mappings[158] = ItemType.OrangeWool; + mappings[159] = ItemType.MagentaWool; + mappings[160] = ItemType.LightBlueWool; + mappings[161] = ItemType.YellowWool; + mappings[162] = ItemType.LimeWool; + mappings[163] = ItemType.PinkWool; + mappings[164] = ItemType.GrayWool; + mappings[165] = ItemType.LightGrayWool; + mappings[166] = ItemType.CyanWool; + mappings[167] = ItemType.PurpleWool; + mappings[168] = ItemType.BlueWool; + mappings[169] = ItemType.BrownWool; + mappings[170] = ItemType.GreenWool; + mappings[171] = ItemType.RedWool; + mappings[172] = ItemType.BlackWool; + mappings[173] = ItemType.Dandelion; + mappings[174] = ItemType.Poppy; + mappings[175] = ItemType.BlueOrchid; + mappings[176] = ItemType.Allium; + mappings[177] = ItemType.AzureBluet; + mappings[178] = ItemType.RedTulip; + mappings[179] = ItemType.OrangeTulip; + mappings[180] = ItemType.WhiteTulip; + mappings[181] = ItemType.PinkTulip; + mappings[182] = ItemType.OxeyeDaisy; + mappings[183] = ItemType.Cornflower; + mappings[184] = ItemType.LilyOfTheValley; + mappings[185] = ItemType.WitherRose; + mappings[186] = ItemType.SporeBlossom; + mappings[187] = ItemType.BrownMushroom; + mappings[188] = ItemType.RedMushroom; + mappings[189] = ItemType.CrimsonFungus; + mappings[190] = ItemType.WarpedFungus; + mappings[191] = ItemType.CrimsonRoots; + mappings[192] = ItemType.WarpedRoots; + mappings[193] = ItemType.NetherSprouts; + mappings[194] = ItemType.WeepingVines; + mappings[195] = ItemType.TwistingVines; + mappings[196] = ItemType.SugarCane; + mappings[197] = ItemType.Kelp; + mappings[198] = ItemType.MossCarpet; + mappings[199] = ItemType.MossBlock; + mappings[200] = ItemType.HangingRoots; + mappings[201] = ItemType.BigDripleaf; + mappings[202] = ItemType.SmallDripleaf; + mappings[203] = ItemType.Bamboo; + mappings[204] = ItemType.OakSlab; + mappings[205] = ItemType.SpruceSlab; + mappings[206] = ItemType.BirchSlab; + mappings[207] = ItemType.JungleSlab; + mappings[208] = ItemType.AcaciaSlab; + mappings[209] = ItemType.DarkOakSlab; + mappings[210] = ItemType.CrimsonSlab; + mappings[211] = ItemType.WarpedSlab; + mappings[212] = ItemType.StoneSlab; + mappings[213] = ItemType.SmoothStoneSlab; + mappings[214] = ItemType.SandstoneSlab; + mappings[215] = ItemType.CutSandstoneSlab; + mappings[216] = ItemType.PetrifiedOakSlab; + mappings[217] = ItemType.CobblestoneSlab; + mappings[218] = ItemType.BrickSlab; + mappings[219] = ItemType.StoneBrickSlab; + mappings[220] = ItemType.NetherBrickSlab; + mappings[221] = ItemType.QuartzSlab; + mappings[222] = ItemType.RedSandstoneSlab; + mappings[223] = ItemType.CutRedSandstoneSlab; + mappings[224] = ItemType.PurpurSlab; + mappings[225] = ItemType.PrismarineSlab; + mappings[226] = ItemType.PrismarineBrickSlab; + mappings[227] = ItemType.DarkPrismarineSlab; + mappings[228] = ItemType.SmoothQuartz; + mappings[229] = ItemType.SmoothRedSandstone; + mappings[230] = ItemType.SmoothSandstone; + mappings[231] = ItemType.SmoothStone; + mappings[232] = ItemType.Bricks; + mappings[233] = ItemType.Bookshelf; + mappings[234] = ItemType.MossyCobblestone; + mappings[235] = ItemType.Obsidian; + mappings[236] = ItemType.Torch; + mappings[237] = ItemType.EndRod; + mappings[238] = ItemType.ChorusPlant; + mappings[239] = ItemType.ChorusFlower; + mappings[240] = ItemType.PurpurBlock; + mappings[241] = ItemType.PurpurPillar; + mappings[242] = ItemType.PurpurStairs; + mappings[243] = ItemType.Spawner; + mappings[244] = ItemType.OakStairs; + mappings[245] = ItemType.Chest; + mappings[246] = ItemType.CraftingTable; + mappings[247] = ItemType.Farmland; + mappings[248] = ItemType.Furnace; + mappings[249] = ItemType.Ladder; + mappings[250] = ItemType.CobblestoneStairs; + mappings[251] = ItemType.Snow; + mappings[252] = ItemType.Ice; + mappings[253] = ItemType.SnowBlock; + mappings[254] = ItemType.Cactus; + mappings[255] = ItemType.Clay; + mappings[256] = ItemType.Jukebox; + mappings[257] = ItemType.OakFence; + mappings[258] = ItemType.SpruceFence; + mappings[259] = ItemType.BirchFence; + mappings[260] = ItemType.JungleFence; + mappings[261] = ItemType.AcaciaFence; + mappings[262] = ItemType.DarkOakFence; + mappings[263] = ItemType.CrimsonFence; + mappings[264] = ItemType.WarpedFence; + mappings[265] = ItemType.Pumpkin; + mappings[266] = ItemType.CarvedPumpkin; + mappings[267] = ItemType.JackOLantern; + mappings[268] = ItemType.Netherrack; + mappings[269] = ItemType.SoulSand; + mappings[270] = ItemType.SoulSoil; + mappings[271] = ItemType.Basalt; + mappings[272] = ItemType.PolishedBasalt; + mappings[273] = ItemType.SmoothBasalt; + mappings[274] = ItemType.SoulTorch; + mappings[275] = ItemType.Glowstone; + mappings[276] = ItemType.InfestedStone; + mappings[277] = ItemType.InfestedCobblestone; + mappings[278] = ItemType.InfestedStoneBricks; + mappings[279] = ItemType.InfestedMossyStoneBricks; + mappings[280] = ItemType.InfestedCrackedStoneBricks; + mappings[281] = ItemType.InfestedChiseledStoneBricks; + mappings[282] = ItemType.InfestedDeepslate; + mappings[283] = ItemType.StoneBricks; + mappings[284] = ItemType.MossyStoneBricks; + mappings[285] = ItemType.CrackedStoneBricks; + mappings[286] = ItemType.ChiseledStoneBricks; + mappings[287] = ItemType.DeepslateBricks; + mappings[288] = ItemType.CrackedDeepslateBricks; + mappings[289] = ItemType.DeepslateTiles; + mappings[290] = ItemType.CrackedDeepslateTiles; + mappings[291] = ItemType.ChiseledDeepslate; + mappings[292] = ItemType.BrownMushroomBlock; + mappings[293] = ItemType.RedMushroomBlock; + mappings[294] = ItemType.MushroomStem; + mappings[295] = ItemType.IronBars; + mappings[296] = ItemType.Chain; + mappings[297] = ItemType.GlassPane; + mappings[298] = ItemType.Melon; + mappings[299] = ItemType.Vine; + mappings[300] = ItemType.GlowLichen; + mappings[301] = ItemType.BrickStairs; + mappings[302] = ItemType.StoneBrickStairs; + mappings[303] = ItemType.Mycelium; + mappings[304] = ItemType.LilyPad; + mappings[305] = ItemType.NetherBricks; + mappings[306] = ItemType.CrackedNetherBricks; + mappings[307] = ItemType.ChiseledNetherBricks; + mappings[308] = ItemType.NetherBrickFence; + mappings[309] = ItemType.NetherBrickStairs; + mappings[310] = ItemType.EnchantingTable; + mappings[311] = ItemType.EndPortalFrame; + mappings[312] = ItemType.EndStone; + mappings[313] = ItemType.EndStoneBricks; + mappings[314] = ItemType.DragonEgg; + mappings[315] = ItemType.SandstoneStairs; + mappings[316] = ItemType.EnderChest; + mappings[317] = ItemType.EmeraldBlock; + mappings[318] = ItemType.SpruceStairs; + mappings[319] = ItemType.BirchStairs; + mappings[320] = ItemType.JungleStairs; + mappings[321] = ItemType.CrimsonStairs; + mappings[322] = ItemType.WarpedStairs; + mappings[323] = ItemType.CommandBlock; + mappings[324] = ItemType.Beacon; + mappings[325] = ItemType.CobblestoneWall; + mappings[326] = ItemType.MossyCobblestoneWall; + mappings[327] = ItemType.BrickWall; + mappings[328] = ItemType.PrismarineWall; + mappings[329] = ItemType.RedSandstoneWall; + mappings[330] = ItemType.MossyStoneBrickWall; + mappings[331] = ItemType.GraniteWall; + mappings[332] = ItemType.StoneBrickWall; + mappings[333] = ItemType.NetherBrickWall; + mappings[334] = ItemType.AndesiteWall; + mappings[335] = ItemType.RedNetherBrickWall; + mappings[336] = ItemType.SandstoneWall; + mappings[337] = ItemType.EndStoneBrickWall; + mappings[338] = ItemType.DioriteWall; + mappings[339] = ItemType.BlackstoneWall; + mappings[340] = ItemType.PolishedBlackstoneWall; + mappings[341] = ItemType.PolishedBlackstoneBrickWall; + mappings[342] = ItemType.CobbledDeepslateWall; + mappings[343] = ItemType.PolishedDeepslateWall; + mappings[344] = ItemType.DeepslateBrickWall; + mappings[345] = ItemType.DeepslateTileWall; + mappings[346] = ItemType.Anvil; + mappings[347] = ItemType.ChippedAnvil; + mappings[348] = ItemType.DamagedAnvil; + mappings[349] = ItemType.ChiseledQuartzBlock; + mappings[350] = ItemType.QuartzBlock; + mappings[351] = ItemType.QuartzBricks; + mappings[352] = ItemType.QuartzPillar; + mappings[353] = ItemType.QuartzStairs; + mappings[354] = ItemType.WhiteTerracotta; + mappings[355] = ItemType.OrangeTerracotta; + mappings[356] = ItemType.MagentaTerracotta; + mappings[357] = ItemType.LightBlueTerracotta; + mappings[358] = ItemType.YellowTerracotta; + mappings[359] = ItemType.LimeTerracotta; + mappings[360] = ItemType.PinkTerracotta; + mappings[361] = ItemType.GrayTerracotta; + mappings[362] = ItemType.LightGrayTerracotta; + mappings[363] = ItemType.CyanTerracotta; + mappings[364] = ItemType.PurpleTerracotta; + mappings[365] = ItemType.BlueTerracotta; + mappings[366] = ItemType.BrownTerracotta; + mappings[367] = ItemType.GreenTerracotta; + mappings[368] = ItemType.RedTerracotta; + mappings[369] = ItemType.BlackTerracotta; + mappings[370] = ItemType.Barrier; + mappings[371] = ItemType.Light; + mappings[372] = ItemType.HayBlock; + mappings[373] = ItemType.WhiteCarpet; + mappings[374] = ItemType.OrangeCarpet; + mappings[375] = ItemType.MagentaCarpet; + mappings[376] = ItemType.LightBlueCarpet; + mappings[377] = ItemType.YellowCarpet; + mappings[378] = ItemType.LimeCarpet; + mappings[379] = ItemType.PinkCarpet; + mappings[380] = ItemType.GrayCarpet; + mappings[381] = ItemType.LightGrayCarpet; + mappings[382] = ItemType.CyanCarpet; + mappings[383] = ItemType.PurpleCarpet; + mappings[384] = ItemType.BlueCarpet; + mappings[385] = ItemType.BrownCarpet; + mappings[386] = ItemType.GreenCarpet; + mappings[387] = ItemType.RedCarpet; + mappings[388] = ItemType.BlackCarpet; + mappings[389] = ItemType.Terracotta; + mappings[390] = ItemType.PackedIce; + mappings[391] = ItemType.AcaciaStairs; + mappings[392] = ItemType.DarkOakStairs; + mappings[393] = ItemType.GrassPath; + mappings[394] = ItemType.Sunflower; + mappings[395] = ItemType.Lilac; + mappings[396] = ItemType.RoseBush; + mappings[397] = ItemType.Peony; + mappings[398] = ItemType.TallGrass; + mappings[399] = ItemType.LargeFern; + mappings[400] = ItemType.WhiteStainedGlass; + mappings[401] = ItemType.OrangeStainedGlass; + mappings[402] = ItemType.MagentaStainedGlass; + mappings[403] = ItemType.LightBlueStainedGlass; + mappings[404] = ItemType.YellowStainedGlass; + mappings[405] = ItemType.LimeStainedGlass; + mappings[406] = ItemType.PinkStainedGlass; + mappings[407] = ItemType.GrayStainedGlass; + mappings[408] = ItemType.LightGrayStainedGlass; + mappings[409] = ItemType.CyanStainedGlass; + mappings[410] = ItemType.PurpleStainedGlass; + mappings[411] = ItemType.BlueStainedGlass; + mappings[412] = ItemType.BrownStainedGlass; + mappings[413] = ItemType.GreenStainedGlass; + mappings[414] = ItemType.RedStainedGlass; + mappings[415] = ItemType.BlackStainedGlass; + mappings[416] = ItemType.WhiteStainedGlassPane; + mappings[417] = ItemType.OrangeStainedGlassPane; + mappings[418] = ItemType.MagentaStainedGlassPane; + mappings[419] = ItemType.LightBlueStainedGlassPane; + mappings[420] = ItemType.YellowStainedGlassPane; + mappings[421] = ItemType.LimeStainedGlassPane; + mappings[422] = ItemType.PinkStainedGlassPane; + mappings[423] = ItemType.GrayStainedGlassPane; + mappings[424] = ItemType.LightGrayStainedGlassPane; + mappings[425] = ItemType.CyanStainedGlassPane; + mappings[426] = ItemType.PurpleStainedGlassPane; + mappings[427] = ItemType.BlueStainedGlassPane; + mappings[428] = ItemType.BrownStainedGlassPane; + mappings[429] = ItemType.GreenStainedGlassPane; + mappings[430] = ItemType.RedStainedGlassPane; + mappings[431] = ItemType.BlackStainedGlassPane; + mappings[432] = ItemType.Prismarine; + mappings[433] = ItemType.PrismarineBricks; + mappings[434] = ItemType.DarkPrismarine; + mappings[435] = ItemType.PrismarineStairs; + mappings[436] = ItemType.PrismarineBrickStairs; + mappings[437] = ItemType.DarkPrismarineStairs; + mappings[438] = ItemType.SeaLantern; + mappings[439] = ItemType.RedSandstone; + mappings[440] = ItemType.ChiseledRedSandstone; + mappings[441] = ItemType.CutRedSandstone; + mappings[442] = ItemType.RedSandstoneStairs; + mappings[443] = ItemType.RepeatingCommandBlock; + mappings[444] = ItemType.ChainCommandBlock; + mappings[445] = ItemType.MagmaBlock; + mappings[446] = ItemType.NetherWartBlock; + mappings[447] = ItemType.WarpedWartBlock; + mappings[448] = ItemType.RedNetherBricks; + mappings[449] = ItemType.BoneBlock; + mappings[450] = ItemType.StructureVoid; + mappings[451] = ItemType.ShulkerBox; + mappings[452] = ItemType.WhiteShulkerBox; + mappings[453] = ItemType.OrangeShulkerBox; + mappings[454] = ItemType.MagentaShulkerBox; + mappings[455] = ItemType.LightBlueShulkerBox; + mappings[456] = ItemType.YellowShulkerBox; + mappings[457] = ItemType.LimeShulkerBox; + mappings[458] = ItemType.PinkShulkerBox; + mappings[459] = ItemType.GrayShulkerBox; + mappings[460] = ItemType.LightGrayShulkerBox; + mappings[461] = ItemType.CyanShulkerBox; + mappings[462] = ItemType.PurpleShulkerBox; + mappings[463] = ItemType.BlueShulkerBox; + mappings[464] = ItemType.BrownShulkerBox; + mappings[465] = ItemType.GreenShulkerBox; + mappings[466] = ItemType.RedShulkerBox; + mappings[467] = ItemType.BlackShulkerBox; + mappings[468] = ItemType.WhiteGlazedTerracotta; + mappings[469] = ItemType.OrangeGlazedTerracotta; + mappings[470] = ItemType.MagentaGlazedTerracotta; + mappings[471] = ItemType.LightBlueGlazedTerracotta; + mappings[472] = ItemType.YellowGlazedTerracotta; + mappings[473] = ItemType.LimeGlazedTerracotta; + mappings[474] = ItemType.PinkGlazedTerracotta; + mappings[475] = ItemType.GrayGlazedTerracotta; + mappings[476] = ItemType.LightGrayGlazedTerracotta; + mappings[477] = ItemType.CyanGlazedTerracotta; + mappings[478] = ItemType.PurpleGlazedTerracotta; + mappings[479] = ItemType.BlueGlazedTerracotta; + mappings[480] = ItemType.BrownGlazedTerracotta; + mappings[481] = ItemType.GreenGlazedTerracotta; + mappings[482] = ItemType.RedGlazedTerracotta; + mappings[483] = ItemType.BlackGlazedTerracotta; + mappings[484] = ItemType.WhiteConcrete; + mappings[485] = ItemType.OrangeConcrete; + mappings[486] = ItemType.MagentaConcrete; + mappings[487] = ItemType.LightBlueConcrete; + mappings[488] = ItemType.YellowConcrete; + mappings[489] = ItemType.LimeConcrete; + mappings[490] = ItemType.PinkConcrete; + mappings[491] = ItemType.GrayConcrete; + mappings[492] = ItemType.LightGrayConcrete; + mappings[493] = ItemType.CyanConcrete; + mappings[494] = ItemType.PurpleConcrete; + mappings[495] = ItemType.BlueConcrete; + mappings[496] = ItemType.BrownConcrete; + mappings[497] = ItemType.GreenConcrete; + mappings[498] = ItemType.RedConcrete; + mappings[499] = ItemType.BlackConcrete; + mappings[500] = ItemType.WhiteConcretePowder; + mappings[501] = ItemType.OrangeConcretePowder; + mappings[502] = ItemType.MagentaConcretePowder; + mappings[503] = ItemType.LightBlueConcretePowder; + mappings[504] = ItemType.YellowConcretePowder; + mappings[505] = ItemType.LimeConcretePowder; + mappings[506] = ItemType.PinkConcretePowder; + mappings[507] = ItemType.GrayConcretePowder; + mappings[508] = ItemType.LightGrayConcretePowder; + mappings[509] = ItemType.CyanConcretePowder; + mappings[510] = ItemType.PurpleConcretePowder; + mappings[511] = ItemType.BlueConcretePowder; + mappings[512] = ItemType.BrownConcretePowder; + mappings[513] = ItemType.GreenConcretePowder; + mappings[514] = ItemType.RedConcretePowder; + mappings[515] = ItemType.BlackConcretePowder; + mappings[516] = ItemType.TurtleEgg; + mappings[517] = ItemType.DeadTubeCoralBlock; + mappings[518] = ItemType.DeadBrainCoralBlock; + mappings[519] = ItemType.DeadBubbleCoralBlock; + mappings[520] = ItemType.DeadFireCoralBlock; + mappings[521] = ItemType.DeadHornCoralBlock; + mappings[522] = ItemType.TubeCoralBlock; + mappings[523] = ItemType.BrainCoralBlock; + mappings[524] = ItemType.BubbleCoralBlock; + mappings[525] = ItemType.FireCoralBlock; + mappings[526] = ItemType.HornCoralBlock; + mappings[527] = ItemType.TubeCoral; + mappings[528] = ItemType.BrainCoral; + mappings[529] = ItemType.BubbleCoral; + mappings[530] = ItemType.FireCoral; + mappings[531] = ItemType.HornCoral; + mappings[532] = ItemType.DeadBrainCoral; + mappings[533] = ItemType.DeadBubbleCoral; + mappings[534] = ItemType.DeadFireCoral; + mappings[535] = ItemType.DeadHornCoral; + mappings[536] = ItemType.DeadTubeCoral; + mappings[537] = ItemType.TubeCoralFan; + mappings[538] = ItemType.BrainCoralFan; + mappings[539] = ItemType.BubbleCoralFan; + mappings[540] = ItemType.FireCoralFan; + mappings[541] = ItemType.HornCoralFan; + mappings[542] = ItemType.DeadTubeCoralFan; + mappings[543] = ItemType.DeadBrainCoralFan; + mappings[544] = ItemType.DeadBubbleCoralFan; + mappings[545] = ItemType.DeadFireCoralFan; + mappings[546] = ItemType.DeadHornCoralFan; + mappings[547] = ItemType.BlueIce; + mappings[548] = ItemType.Conduit; + mappings[549] = ItemType.PolishedGraniteStairs; + mappings[550] = ItemType.SmoothRedSandstoneStairs; + mappings[551] = ItemType.MossyStoneBrickStairs; + mappings[552] = ItemType.PolishedDioriteStairs; + mappings[553] = ItemType.MossyCobblestoneStairs; + mappings[554] = ItemType.EndStoneBrickStairs; + mappings[555] = ItemType.StoneStairs; + mappings[556] = ItemType.SmoothSandstoneStairs; + mappings[557] = ItemType.SmoothQuartzStairs; + mappings[558] = ItemType.GraniteStairs; + mappings[559] = ItemType.AndesiteStairs; + mappings[560] = ItemType.RedNetherBrickStairs; + mappings[561] = ItemType.PolishedAndesiteStairs; + mappings[562] = ItemType.DioriteStairs; + mappings[563] = ItemType.CobbledDeepslateStairs; + mappings[564] = ItemType.PolishedDeepslateStairs; + mappings[565] = ItemType.DeepslateBrickStairs; + mappings[566] = ItemType.DeepslateTileStairs; + mappings[567] = ItemType.PolishedGraniteSlab; + mappings[568] = ItemType.SmoothRedSandstoneSlab; + mappings[569] = ItemType.MossyStoneBrickSlab; + mappings[570] = ItemType.PolishedDioriteSlab; + mappings[571] = ItemType.MossyCobblestoneSlab; + mappings[572] = ItemType.EndStoneBrickSlab; + mappings[573] = ItemType.SmoothSandstoneSlab; + mappings[574] = ItemType.SmoothQuartzSlab; + mappings[575] = ItemType.GraniteSlab; + mappings[576] = ItemType.AndesiteSlab; + mappings[577] = ItemType.RedNetherBrickSlab; + mappings[578] = ItemType.PolishedAndesiteSlab; + mappings[579] = ItemType.DioriteSlab; + mappings[580] = ItemType.CobbledDeepslateSlab; + mappings[581] = ItemType.PolishedDeepslateSlab; + mappings[582] = ItemType.DeepslateBrickSlab; + mappings[583] = ItemType.DeepslateTileSlab; + mappings[584] = ItemType.Scaffolding; + mappings[585] = ItemType.Redstone; + mappings[586] = ItemType.RedstoneTorch; + mappings[587] = ItemType.RedstoneBlock; + mappings[588] = ItemType.Repeater; + mappings[589] = ItemType.Comparator; + mappings[590] = ItemType.Piston; + mappings[591] = ItemType.StickyPiston; + mappings[592] = ItemType.SlimeBlock; + mappings[593] = ItemType.HoneyBlock; + mappings[594] = ItemType.Observer; + mappings[595] = ItemType.Hopper; + mappings[596] = ItemType.Dispenser; + mappings[597] = ItemType.Dropper; + mappings[598] = ItemType.Lectern; + mappings[599] = ItemType.Target; + mappings[600] = ItemType.Lever; + mappings[601] = ItemType.LightningRod; + mappings[602] = ItemType.DaylightDetector; + mappings[603] = ItemType.SculkSensor; + mappings[604] = ItemType.TripwireHook; + mappings[605] = ItemType.TrappedChest; + mappings[606] = ItemType.Tnt; + mappings[607] = ItemType.RedstoneLamp; + mappings[608] = ItemType.NoteBlock; + mappings[609] = ItemType.StoneButton; + mappings[610] = ItemType.PolishedBlackstoneButton; + mappings[611] = ItemType.OakButton; + mappings[612] = ItemType.SpruceButton; + mappings[613] = ItemType.BirchButton; + mappings[614] = ItemType.JungleButton; + mappings[615] = ItemType.AcaciaButton; + mappings[616] = ItemType.DarkOakButton; + mappings[617] = ItemType.CrimsonButton; + mappings[618] = ItemType.WarpedButton; + mappings[619] = ItemType.StonePressurePlate; + mappings[620] = ItemType.PolishedBlackstonePressurePlate; + mappings[621] = ItemType.LightWeightedPressurePlate; + mappings[622] = ItemType.HeavyWeightedPressurePlate; + mappings[623] = ItemType.OakPressurePlate; + mappings[624] = ItemType.SprucePressurePlate; + mappings[625] = ItemType.BirchPressurePlate; + mappings[626] = ItemType.JunglePressurePlate; + mappings[627] = ItemType.AcaciaPressurePlate; + mappings[628] = ItemType.DarkOakPressurePlate; + mappings[629] = ItemType.CrimsonPressurePlate; + mappings[630] = ItemType.WarpedPressurePlate; + mappings[631] = ItemType.IronDoor; + mappings[632] = ItemType.OakDoor; + mappings[633] = ItemType.SpruceDoor; + mappings[634] = ItemType.BirchDoor; + mappings[635] = ItemType.JungleDoor; + mappings[636] = ItemType.AcaciaDoor; + mappings[637] = ItemType.DarkOakDoor; + mappings[638] = ItemType.CrimsonDoor; + mappings[639] = ItemType.WarpedDoor; + mappings[640] = ItemType.IronTrapdoor; + mappings[641] = ItemType.OakTrapdoor; + mappings[642] = ItemType.SpruceTrapdoor; + mappings[643] = ItemType.BirchTrapdoor; + mappings[644] = ItemType.JungleTrapdoor; + mappings[645] = ItemType.AcaciaTrapdoor; + mappings[646] = ItemType.DarkOakTrapdoor; + mappings[647] = ItemType.CrimsonTrapdoor; + mappings[648] = ItemType.WarpedTrapdoor; + mappings[649] = ItemType.OakFenceGate; + mappings[650] = ItemType.SpruceFenceGate; + mappings[651] = ItemType.BirchFenceGate; + mappings[652] = ItemType.JungleFenceGate; + mappings[653] = ItemType.AcaciaFenceGate; + mappings[654] = ItemType.DarkOakFenceGate; + mappings[655] = ItemType.CrimsonFenceGate; + mappings[656] = ItemType.WarpedFenceGate; + mappings[657] = ItemType.PoweredRail; + mappings[658] = ItemType.DetectorRail; + mappings[659] = ItemType.Rail; + mappings[660] = ItemType.ActivatorRail; + mappings[661] = ItemType.Saddle; + mappings[662] = ItemType.Minecart; + mappings[663] = ItemType.ChestMinecart; + mappings[664] = ItemType.FurnaceMinecart; + mappings[665] = ItemType.TntMinecart; + mappings[666] = ItemType.HopperMinecart; + mappings[667] = ItemType.CarrotOnAStick; + mappings[668] = ItemType.WarpedFungusOnAStick; + mappings[669] = ItemType.Elytra; + mappings[670] = ItemType.OakBoat; + mappings[671] = ItemType.SpruceBoat; + mappings[672] = ItemType.BirchBoat; + mappings[673] = ItemType.JungleBoat; + mappings[674] = ItemType.AcaciaBoat; + mappings[675] = ItemType.DarkOakBoat; + mappings[676] = ItemType.StructureBlock; + mappings[677] = ItemType.Jigsaw; + mappings[678] = ItemType.TurtleHelmet; + mappings[679] = ItemType.Scute; + mappings[680] = ItemType.FlintAndSteel; + mappings[681] = ItemType.Apple; + mappings[682] = ItemType.Bow; + mappings[683] = ItemType.Arrow; + mappings[684] = ItemType.Coal; + mappings[685] = ItemType.Charcoal; + mappings[686] = ItemType.Diamond; + mappings[687] = ItemType.Emerald; + mappings[688] = ItemType.LapisLazuli; + mappings[689] = ItemType.Quartz; + mappings[690] = ItemType.AmethystShard; + mappings[691] = ItemType.RawIron; + mappings[692] = ItemType.IronIngot; + mappings[693] = ItemType.RawCopper; + mappings[694] = ItemType.CopperIngot; + mappings[695] = ItemType.RawGold; + mappings[696] = ItemType.GoldIngot; + mappings[697] = ItemType.NetheriteIngot; + mappings[698] = ItemType.NetheriteScrap; + mappings[699] = ItemType.WoodenSword; + mappings[700] = ItemType.WoodenShovel; + mappings[701] = ItemType.WoodenPickaxe; + mappings[702] = ItemType.WoodenAxe; + mappings[703] = ItemType.WoodenHoe; + mappings[704] = ItemType.StoneSword; + mappings[705] = ItemType.StoneShovel; + mappings[706] = ItemType.StonePickaxe; + mappings[707] = ItemType.StoneAxe; + mappings[708] = ItemType.StoneHoe; + mappings[709] = ItemType.GoldenSword; + mappings[710] = ItemType.GoldenShovel; + mappings[711] = ItemType.GoldenPickaxe; + mappings[712] = ItemType.GoldenAxe; + mappings[713] = ItemType.GoldenHoe; + mappings[714] = ItemType.IronSword; + mappings[715] = ItemType.IronShovel; + mappings[716] = ItemType.IronPickaxe; + mappings[717] = ItemType.IronAxe; + mappings[718] = ItemType.IronHoe; + mappings[719] = ItemType.DiamondSword; + mappings[720] = ItemType.DiamondShovel; + mappings[721] = ItemType.DiamondPickaxe; + mappings[722] = ItemType.DiamondAxe; + mappings[723] = ItemType.DiamondHoe; + mappings[724] = ItemType.NetheriteSword; + mappings[725] = ItemType.NetheriteShovel; + mappings[726] = ItemType.NetheritePickaxe; + mappings[727] = ItemType.NetheriteAxe; + mappings[728] = ItemType.NetheriteHoe; + mappings[729] = ItemType.Stick; + mappings[730] = ItemType.Bowl; + mappings[731] = ItemType.MushroomStew; + mappings[732] = ItemType.String; + mappings[733] = ItemType.Feather; + mappings[734] = ItemType.Gunpowder; + mappings[735] = ItemType.WheatSeeds; + mappings[736] = ItemType.Wheat; + mappings[737] = ItemType.Bread; + mappings[738] = ItemType.LeatherHelmet; + mappings[739] = ItemType.LeatherChestplate; + mappings[740] = ItemType.LeatherLeggings; + mappings[741] = ItemType.LeatherBoots; + mappings[742] = ItemType.ChainmailHelmet; + mappings[743] = ItemType.ChainmailChestplate; + mappings[744] = ItemType.ChainmailLeggings; + mappings[745] = ItemType.ChainmailBoots; + mappings[746] = ItemType.IronHelmet; + mappings[747] = ItemType.IronChestplate; + mappings[748] = ItemType.IronLeggings; + mappings[749] = ItemType.IronBoots; + mappings[750] = ItemType.DiamondHelmet; + mappings[751] = ItemType.DiamondChestplate; + mappings[752] = ItemType.DiamondLeggings; + mappings[753] = ItemType.DiamondBoots; + mappings[754] = ItemType.GoldenHelmet; + mappings[755] = ItemType.GoldenChestplate; + mappings[756] = ItemType.GoldenLeggings; + mappings[757] = ItemType.GoldenBoots; + mappings[758] = ItemType.NetheriteHelmet; + mappings[759] = ItemType.NetheriteChestplate; + mappings[760] = ItemType.NetheriteLeggings; + mappings[761] = ItemType.NetheriteBoots; + mappings[762] = ItemType.Flint; + mappings[763] = ItemType.Porkchop; + mappings[764] = ItemType.CookedPorkchop; + mappings[765] = ItemType.Painting; + mappings[766] = ItemType.GoldenApple; + mappings[767] = ItemType.EnchantedGoldenApple; + mappings[768] = ItemType.OakSign; + mappings[769] = ItemType.SpruceSign; + mappings[770] = ItemType.BirchSign; + mappings[771] = ItemType.JungleSign; + mappings[772] = ItemType.AcaciaSign; + mappings[773] = ItemType.DarkOakSign; + mappings[774] = ItemType.CrimsonSign; + mappings[775] = ItemType.WarpedSign; + mappings[776] = ItemType.Bucket; + mappings[777] = ItemType.WaterBucket; + mappings[778] = ItemType.LavaBucket; + mappings[779] = ItemType.PowderSnowBucket; + mappings[780] = ItemType.Snowball; + mappings[781] = ItemType.Leather; + mappings[782] = ItemType.MilkBucket; + mappings[783] = ItemType.PufferfishBucket; + mappings[784] = ItemType.SalmonBucket; + mappings[785] = ItemType.CodBucket; + mappings[786] = ItemType.TropicalFishBucket; + mappings[787] = ItemType.AxolotlBucket; + mappings[788] = ItemType.Brick; + mappings[789] = ItemType.ClayBall; + mappings[790] = ItemType.DriedKelpBlock; + mappings[791] = ItemType.Paper; + mappings[792] = ItemType.Book; + mappings[793] = ItemType.SlimeBall; + mappings[794] = ItemType.Egg; + mappings[795] = ItemType.Compass; + mappings[796] = ItemType.Bundle; + mappings[797] = ItemType.FishingRod; + mappings[798] = ItemType.Clock; + mappings[799] = ItemType.Spyglass; + mappings[800] = ItemType.GlowstoneDust; + mappings[801] = ItemType.Cod; + mappings[802] = ItemType.Salmon; + mappings[803] = ItemType.TropicalFish; + mappings[804] = ItemType.Pufferfish; + mappings[805] = ItemType.CookedCod; + mappings[806] = ItemType.CookedSalmon; + mappings[807] = ItemType.InkSac; + mappings[808] = ItemType.GlowInkSac; + mappings[809] = ItemType.CocoaBeans; + mappings[810] = ItemType.WhiteDye; + mappings[811] = ItemType.OrangeDye; + mappings[812] = ItemType.MagentaDye; + mappings[813] = ItemType.LightBlueDye; + mappings[814] = ItemType.YellowDye; + mappings[815] = ItemType.LimeDye; + mappings[816] = ItemType.PinkDye; + mappings[817] = ItemType.GrayDye; + mappings[818] = ItemType.LightGrayDye; + mappings[819] = ItemType.CyanDye; + mappings[820] = ItemType.PurpleDye; + mappings[821] = ItemType.BlueDye; + mappings[822] = ItemType.BrownDye; + mappings[823] = ItemType.GreenDye; + mappings[824] = ItemType.RedDye; + mappings[825] = ItemType.BlackDye; + mappings[826] = ItemType.BoneMeal; + mappings[827] = ItemType.Bone; + mappings[828] = ItemType.Sugar; + mappings[829] = ItemType.Cake; + mappings[830] = ItemType.WhiteBed; + mappings[831] = ItemType.OrangeBed; + mappings[832] = ItemType.MagentaBed; + mappings[833] = ItemType.LightBlueBed; + mappings[834] = ItemType.YellowBed; + mappings[835] = ItemType.LimeBed; + mappings[836] = ItemType.PinkBed; + mappings[837] = ItemType.GrayBed; + mappings[838] = ItemType.LightGrayBed; + mappings[839] = ItemType.CyanBed; + mappings[840] = ItemType.PurpleBed; + mappings[841] = ItemType.BlueBed; + mappings[842] = ItemType.BrownBed; + mappings[843] = ItemType.GreenBed; + mappings[844] = ItemType.RedBed; + mappings[845] = ItemType.BlackBed; + mappings[846] = ItemType.Cookie; + mappings[847] = ItemType.FilledMap; + mappings[848] = ItemType.Shears; + mappings[849] = ItemType.MelonSlice; + mappings[850] = ItemType.DriedKelp; + mappings[851] = ItemType.PumpkinSeeds; + mappings[852] = ItemType.MelonSeeds; + mappings[853] = ItemType.Beef; + mappings[854] = ItemType.CookedBeef; + mappings[855] = ItemType.Chicken; + mappings[856] = ItemType.CookedChicken; + mappings[857] = ItemType.RottenFlesh; + mappings[858] = ItemType.EnderPearl; + mappings[859] = ItemType.BlazeRod; + mappings[860] = ItemType.GhastTear; + mappings[861] = ItemType.GoldNugget; + mappings[862] = ItemType.NetherWart; + mappings[863] = ItemType.Potion; + mappings[864] = ItemType.GlassBottle; + mappings[865] = ItemType.SpiderEye; + mappings[866] = ItemType.FermentedSpiderEye; + mappings[867] = ItemType.BlazePowder; + mappings[868] = ItemType.MagmaCream; + mappings[869] = ItemType.BrewingStand; + mappings[870] = ItemType.Cauldron; + mappings[871] = ItemType.EnderEye; + mappings[872] = ItemType.GlisteringMelonSlice; + mappings[873] = ItemType.AxolotlSpawnEgg; + mappings[874] = ItemType.BatSpawnEgg; + mappings[875] = ItemType.BeeSpawnEgg; + mappings[876] = ItemType.BlazeSpawnEgg; + mappings[877] = ItemType.CatSpawnEgg; + mappings[878] = ItemType.CaveSpiderSpawnEgg; + mappings[879] = ItemType.ChickenSpawnEgg; + mappings[880] = ItemType.CodSpawnEgg; + mappings[881] = ItemType.CowSpawnEgg; + mappings[882] = ItemType.CreeperSpawnEgg; + mappings[883] = ItemType.DolphinSpawnEgg; + mappings[884] = ItemType.DonkeySpawnEgg; + mappings[885] = ItemType.DrownedSpawnEgg; + mappings[886] = ItemType.ElderGuardianSpawnEgg; + mappings[887] = ItemType.EndermanSpawnEgg; + mappings[888] = ItemType.EndermiteSpawnEgg; + mappings[889] = ItemType.EvokerSpawnEgg; + mappings[890] = ItemType.FoxSpawnEgg; + mappings[891] = ItemType.GhastSpawnEgg; + mappings[892] = ItemType.GlowSquidSpawnEgg; + mappings[893] = ItemType.GoatSpawnEgg; + mappings[894] = ItemType.GuardianSpawnEgg; + mappings[895] = ItemType.HoglinSpawnEgg; + mappings[896] = ItemType.HorseSpawnEgg; + mappings[897] = ItemType.HuskSpawnEgg; + mappings[898] = ItemType.LlamaSpawnEgg; + mappings[899] = ItemType.MagmaCubeSpawnEgg; + mappings[900] = ItemType.MooshroomSpawnEgg; + mappings[901] = ItemType.MuleSpawnEgg; + mappings[902] = ItemType.OcelotSpawnEgg; + mappings[903] = ItemType.PandaSpawnEgg; + mappings[904] = ItemType.ParrotSpawnEgg; + mappings[905] = ItemType.PhantomSpawnEgg; + mappings[906] = ItemType.PigSpawnEgg; + mappings[907] = ItemType.PiglinSpawnEgg; + mappings[908] = ItemType.PiglinBruteSpawnEgg; + mappings[909] = ItemType.PillagerSpawnEgg; + mappings[910] = ItemType.PolarBearSpawnEgg; + mappings[911] = ItemType.PufferfishSpawnEgg; + mappings[912] = ItemType.RabbitSpawnEgg; + mappings[913] = ItemType.RavagerSpawnEgg; + mappings[914] = ItemType.SalmonSpawnEgg; + mappings[915] = ItemType.SheepSpawnEgg; + mappings[916] = ItemType.ShulkerSpawnEgg; + mappings[917] = ItemType.SilverfishSpawnEgg; + mappings[918] = ItemType.SkeletonSpawnEgg; + mappings[919] = ItemType.SkeletonHorseSpawnEgg; + mappings[920] = ItemType.SlimeSpawnEgg; + mappings[921] = ItemType.SpiderSpawnEgg; + mappings[922] = ItemType.SquidSpawnEgg; + mappings[923] = ItemType.StraySpawnEgg; + mappings[924] = ItemType.StriderSpawnEgg; + mappings[925] = ItemType.TraderLlamaSpawnEgg; + mappings[926] = ItemType.TropicalFishSpawnEgg; + mappings[927] = ItemType.TurtleSpawnEgg; + mappings[928] = ItemType.VexSpawnEgg; + mappings[929] = ItemType.VillagerSpawnEgg; + mappings[930] = ItemType.VindicatorSpawnEgg; + mappings[931] = ItemType.WanderingTraderSpawnEgg; + mappings[932] = ItemType.WitchSpawnEgg; + mappings[933] = ItemType.WitherSkeletonSpawnEgg; + mappings[934] = ItemType.WolfSpawnEgg; + mappings[935] = ItemType.ZoglinSpawnEgg; + mappings[936] = ItemType.ZombieSpawnEgg; + mappings[937] = ItemType.ZombieHorseSpawnEgg; + mappings[938] = ItemType.ZombieVillagerSpawnEgg; + mappings[939] = ItemType.ZombifiedPiglinSpawnEgg; + mappings[940] = ItemType.ExperienceBottle; + mappings[941] = ItemType.FireCharge; + mappings[942] = ItemType.WritableBook; + mappings[943] = ItemType.WrittenBook; + mappings[944] = ItemType.ItemFrame; + mappings[945] = ItemType.GlowItemFrame; + mappings[946] = ItemType.FlowerPot; + mappings[947] = ItemType.Carrot; + mappings[948] = ItemType.Potato; + mappings[949] = ItemType.BakedPotato; + mappings[950] = ItemType.PoisonousPotato; + mappings[951] = ItemType.Map; + mappings[952] = ItemType.GoldenCarrot; + mappings[953] = ItemType.SkeletonSkull; + mappings[954] = ItemType.WitherSkeletonSkull; + mappings[955] = ItemType.PlayerHead; + mappings[956] = ItemType.ZombieHead; + mappings[957] = ItemType.CreeperHead; + mappings[958] = ItemType.DragonHead; + mappings[959] = ItemType.NetherStar; + mappings[960] = ItemType.PumpkinPie; + mappings[961] = ItemType.FireworkRocket; + mappings[962] = ItemType.FireworkStar; + mappings[963] = ItemType.EnchantedBook; + mappings[964] = ItemType.NetherBrick; + mappings[965] = ItemType.PrismarineShard; + mappings[966] = ItemType.PrismarineCrystals; + mappings[967] = ItemType.Rabbit; + mappings[968] = ItemType.CookedRabbit; + mappings[969] = ItemType.RabbitStew; + mappings[970] = ItemType.RabbitFoot; + mappings[971] = ItemType.RabbitHide; + mappings[972] = ItemType.ArmorStand; + mappings[973] = ItemType.IronHorseArmor; + mappings[974] = ItemType.GoldenHorseArmor; + mappings[975] = ItemType.DiamondHorseArmor; + mappings[976] = ItemType.LeatherHorseArmor; + mappings[977] = ItemType.Lead; + mappings[978] = ItemType.NameTag; + mappings[979] = ItemType.CommandBlockMinecart; + mappings[980] = ItemType.Mutton; + mappings[981] = ItemType.CookedMutton; + mappings[982] = ItemType.WhiteBanner; + mappings[983] = ItemType.OrangeBanner; + mappings[984] = ItemType.MagentaBanner; + mappings[985] = ItemType.LightBlueBanner; + mappings[986] = ItemType.YellowBanner; + mappings[987] = ItemType.LimeBanner; + mappings[988] = ItemType.PinkBanner; + mappings[989] = ItemType.GrayBanner; + mappings[990] = ItemType.LightGrayBanner; + mappings[991] = ItemType.CyanBanner; + mappings[992] = ItemType.PurpleBanner; + mappings[993] = ItemType.BlueBanner; + mappings[994] = ItemType.BrownBanner; + mappings[995] = ItemType.GreenBanner; + mappings[996] = ItemType.RedBanner; + mappings[997] = ItemType.BlackBanner; + mappings[998] = ItemType.EndCrystal; + mappings[999] = ItemType.ChorusFruit; + mappings[1000] = ItemType.PoppedChorusFruit; + mappings[1001] = ItemType.Beetroot; + mappings[1002] = ItemType.BeetrootSeeds; + mappings[1003] = ItemType.BeetrootSoup; + mappings[1004] = ItemType.DragonBreath; + mappings[1005] = ItemType.SplashPotion; + mappings[1006] = ItemType.SpectralArrow; + mappings[1007] = ItemType.TippedArrow; + mappings[1008] = ItemType.LingeringPotion; + mappings[1009] = ItemType.Shield; + mappings[1010] = ItemType.TotemOfUndying; + mappings[1011] = ItemType.ShulkerShell; + mappings[1012] = ItemType.IronNugget; + mappings[1013] = ItemType.KnowledgeBook; + mappings[1014] = ItemType.DebugStick; + mappings[1015] = ItemType.MusicDisc13; + mappings[1016] = ItemType.MusicDiscCat; + mappings[1017] = ItemType.MusicDiscBlocks; + mappings[1018] = ItemType.MusicDiscChirp; + mappings[1019] = ItemType.MusicDiscFar; + mappings[1020] = ItemType.MusicDiscMall; + mappings[1021] = ItemType.MusicDiscMellohi; + mappings[1022] = ItemType.MusicDiscStal; + mappings[1023] = ItemType.MusicDiscStrad; + mappings[1024] = ItemType.MusicDiscWard; + mappings[1025] = ItemType.MusicDisc11; + mappings[1026] = ItemType.MusicDiscWait; + mappings[1027] = ItemType.MusicDiscOtherside; + mappings[1028] = ItemType.MusicDiscPigstep; + mappings[1029] = ItemType.Trident; + mappings[1030] = ItemType.PhantomMembrane; + mappings[1031] = ItemType.NautilusShell; + mappings[1032] = ItemType.HeartOfTheSea; + mappings[1033] = ItemType.Crossbow; + mappings[1034] = ItemType.SuspiciousStew; + mappings[1035] = ItemType.Loom; + mappings[1036] = ItemType.FlowerBannerPattern; + mappings[1037] = ItemType.CreeperBannerPattern; + mappings[1038] = ItemType.SkullBannerPattern; + mappings[1039] = ItemType.MojangBannerPattern; + mappings[1040] = ItemType.GlobeBannerPattern; + mappings[1041] = ItemType.PiglinBannerPattern; + mappings[1042] = ItemType.Composter; + mappings[1043] = ItemType.Barrel; + mappings[1044] = ItemType.Smoker; + mappings[1045] = ItemType.BlastFurnace; + mappings[1046] = ItemType.CartographyTable; + mappings[1047] = ItemType.FletchingTable; + mappings[1048] = ItemType.Grindstone; + mappings[1049] = ItemType.SmithingTable; + mappings[1050] = ItemType.Stonecutter; + mappings[1051] = ItemType.Bell; + mappings[1052] = ItemType.Lantern; + mappings[1053] = ItemType.SoulLantern; + mappings[1054] = ItemType.SweetBerries; + mappings[1055] = ItemType.GlowBerries; + mappings[1056] = ItemType.Campfire; + mappings[1057] = ItemType.SoulCampfire; + mappings[1058] = ItemType.Shroomlight; + mappings[1059] = ItemType.Honeycomb; + mappings[1060] = ItemType.BeeNest; + mappings[1061] = ItemType.Beehive; + mappings[1062] = ItemType.HoneyBottle; + mappings[1063] = ItemType.HoneycombBlock; + mappings[1064] = ItemType.Lodestone; + mappings[1065] = ItemType.CryingObsidian; + mappings[1066] = ItemType.Blackstone; + mappings[1067] = ItemType.BlackstoneSlab; + mappings[1068] = ItemType.BlackstoneStairs; + mappings[1069] = ItemType.GildedBlackstone; + mappings[1070] = ItemType.PolishedBlackstone; + mappings[1071] = ItemType.PolishedBlackstoneSlab; + mappings[1072] = ItemType.PolishedBlackstoneStairs; + mappings[1073] = ItemType.ChiseledPolishedBlackstone; + mappings[1074] = ItemType.PolishedBlackstoneBricks; + mappings[1075] = ItemType.PolishedBlackstoneBrickSlab; + mappings[1076] = ItemType.PolishedBlackstoneBrickStairs; + mappings[1077] = ItemType.CrackedPolishedBlackstoneBricks; + mappings[1078] = ItemType.RespawnAnchor; + mappings[1079] = ItemType.Candle; + mappings[1080] = ItemType.WhiteCandle; + mappings[1081] = ItemType.OrangeCandle; + mappings[1082] = ItemType.MagentaCandle; + mappings[1083] = ItemType.LightBlueCandle; + mappings[1084] = ItemType.YellowCandle; + mappings[1085] = ItemType.LimeCandle; + mappings[1086] = ItemType.PinkCandle; + mappings[1087] = ItemType.GrayCandle; + mappings[1088] = ItemType.LightGrayCandle; + mappings[1089] = ItemType.CyanCandle; + mappings[1090] = ItemType.PurpleCandle; + mappings[1091] = ItemType.BlueCandle; + mappings[1092] = ItemType.BrownCandle; + mappings[1093] = ItemType.GreenCandle; + mappings[1094] = ItemType.RedCandle; + mappings[1095] = ItemType.BlackCandle; + mappings[1096] = ItemType.SmallAmethystBud; + mappings[1097] = ItemType.MediumAmethystBud; + mappings[1098] = ItemType.LargeAmethystBud; + mappings[1099] = ItemType.AmethystCluster; + mappings[1100] = ItemType.PointedDripstone; + } + + protected override Dictionary GetDict() + { + return mappings; + } + } +} diff --git a/MinecraftClient/Inventory/ItemType.cs b/MinecraftClient/Inventory/ItemType.cs index ed37efff..abb8ce58 100644 --- a/MinecraftClient/Inventory/ItemType.cs +++ b/MinecraftClient/Inventory/ItemType.cs @@ -14,7 +14,7 @@ namespace MinecraftClient.Inventory { Unknown = -2, // Unsupported item type (Forge mod custom item...) Null = -1, // Unspecified item type (Used in the network protocol) - + AcaciaBoat, AcaciaButton, AcaciaDoor, @@ -33,6 +33,9 @@ namespace MinecraftClient.Inventory ActivatorRail, Air, Allium, + AmethystBlock, + AmethystCluster, + AmethystShard, AncientDebris, Andesite, AndesiteSlab, @@ -42,6 +45,10 @@ namespace MinecraftClient.Inventory Apple, ArmorStand, Arrow, + AxolotlBucket, + AxolotlSpawnEgg, + Azalea, + AzaleaLeaves, AzureBluet, BakedPotato, Bamboo, @@ -51,14 +58,15 @@ namespace MinecraftClient.Inventory BatSpawnEgg, Beacon, Bedrock, - Beef, - Beehive, BeeNest, BeeSpawnEgg, + Beef, + Beehive, Beetroot, BeetrootSeeds, BeetrootSoup, Bell, + BigDripleaf, BirchBoat, BirchButton, BirchDoor, @@ -76,6 +84,7 @@ namespace MinecraftClient.Inventory BirchWood, BlackBanner, BlackBed, + BlackCandle, BlackCarpet, BlackConcrete, BlackConcretePowder, @@ -84,18 +93,19 @@ namespace MinecraftClient.Inventory BlackShulkerBox, BlackStainedGlass, BlackStainedGlassPane, + BlackTerracotta, + BlackWool, Blackstone, BlackstoneSlab, BlackstoneStairs, BlackstoneWall, - BlackTerracotta, - BlackWool, BlastFurnace, BlazePowder, BlazeRod, BlazeSpawnEgg, BlueBanner, BlueBed, + BlueCandle, BlueCarpet, BlueConcrete, BlueConcretePowder, @@ -121,12 +131,13 @@ namespace MinecraftClient.Inventory Bread, BrewingStand, Brick, - Bricks, BrickSlab, BrickStairs, BrickWall, + Bricks, BrownBanner, BrownBed, + BrownCandle, BrownCarpet, BrownConcrete, BrownConcretePowder, @@ -143,9 +154,13 @@ namespace MinecraftClient.Inventory BubbleCoralBlock, BubbleCoralFan, Bucket, + BuddingAmethyst, + Bundle, Cactus, Cake, + Calcite, Campfire, + Candle, Carrot, CarrotOnAStick, CartographyTable, @@ -165,6 +180,7 @@ namespace MinecraftClient.Inventory Chicken, ChickenSpawnEgg, ChippedAnvil, + ChiseledDeepslate, ChiseledNetherBricks, ChiseledPolishedBlackstone, ChiseledQuartzBlock, @@ -181,6 +197,10 @@ namespace MinecraftClient.Inventory CoalBlock, CoalOre, CoarseDirt, + CobbledDeepslate, + CobbledDeepslateSlab, + CobbledDeepslateStairs, + CobbledDeepslateWall, Cobblestone, CobblestoneSlab, CobblestoneStairs, @@ -204,8 +224,13 @@ namespace MinecraftClient.Inventory CookedRabbit, CookedSalmon, Cookie, + CopperBlock, + CopperIngot, + CopperOre, Cornflower, CowSpawnEgg, + CrackedDeepslateBricks, + CrackedDeepslateTiles, CrackedNetherBricks, CrackedPolishedBlackstoneBricks, CrackedStoneBricks, @@ -230,12 +255,16 @@ namespace MinecraftClient.Inventory CrimsonTrapdoor, Crossbow, CryingObsidian, + CutCopper, + CutCopperSlab, + CutCopperStairs, CutRedSandstone, CutRedSandstoneSlab, CutSandstone, CutSandstoneSlab, CyanBanner, CyanBed, + CyanCandle, CyanCarpet, CyanConcrete, CyanConcretePowder, @@ -284,6 +313,23 @@ namespace MinecraftClient.Inventory DeadTubeCoralBlock, DeadTubeCoralFan, DebugStick, + Deepslate, + DeepslateBrickSlab, + DeepslateBrickStairs, + DeepslateBrickWall, + DeepslateBricks, + DeepslateCoalOre, + DeepslateCopperOre, + DeepslateDiamondOre, + DeepslateEmeraldOre, + DeepslateGoldOre, + DeepslateIronOre, + DeepslateLapisOre, + DeepslateRedstoneOre, + DeepslateTileSlab, + DeepslateTileStairs, + DeepslateTileWall, + DeepslateTiles, DetectorRail, Diamond, DiamondAxe, @@ -311,6 +357,7 @@ namespace MinecraftClient.Inventory DragonHead, DriedKelp, DriedKelpBlock, + DripstoneBlock, Dropper, DrownedSpawnEgg, Egg, @@ -323,20 +370,24 @@ namespace MinecraftClient.Inventory EnchantedGoldenApple, EnchantingTable, EndCrystal, - EnderChest, - EnderEye, - EndermanSpawnEgg, - EndermiteSpawnEgg, - EnderPearl, EndPortalFrame, EndRod, EndStone, - EndStoneBricks, EndStoneBrickSlab, EndStoneBrickStairs, EndStoneBrickWall, + EndStoneBricks, + EnderChest, + EnderEye, + EnderPearl, + EndermanSpawnEgg, + EndermiteSpawnEgg, EvokerSpawnEgg, ExperienceBottle, + ExposedCopper, + ExposedCutCopper, + ExposedCutCopperSlab, + ExposedCutCopperStairs, Farmland, Feather, FermentedSpiderEye, @@ -354,6 +405,8 @@ namespace MinecraftClient.Inventory FlintAndSteel, FlowerBannerPattern, FlowerPot, + FloweringAzalea, + FloweringAzaleaLeaves, FoxSpawnEgg, Furnace, FurnaceMinecart, @@ -365,9 +418,18 @@ namespace MinecraftClient.Inventory GlassPane, GlisteringMelonSlice, GlobeBannerPattern, + GlowBerries, + GlowInkSac, + GlowItemFrame, + GlowLichen, + GlowSquidSpawnEgg, Glowstone, GlowstoneDust, + GoatSpawnEgg, GoldBlock, + GoldIngot, + GoldNugget, + GoldOre, GoldenApple, GoldenAxe, GoldenBoots, @@ -380,9 +442,6 @@ namespace MinecraftClient.Inventory GoldenPickaxe, GoldenShovel, GoldenSword, - GoldIngot, - GoldNugget, - GoldOre, Granite, GraniteSlab, GraniteStairs, @@ -393,6 +452,7 @@ namespace MinecraftClient.Inventory Gravel, GrayBanner, GrayBed, + GrayCandle, GrayCarpet, GrayConcrete, GrayConcretePowder, @@ -405,6 +465,7 @@ namespace MinecraftClient.Inventory GrayWool, GreenBanner, GreenBed, + GreenCandle, GreenCarpet, GreenConcrete, GreenConcretePowder, @@ -418,6 +479,7 @@ namespace MinecraftClient.Inventory Grindstone, GuardianSpawnEgg, Gunpowder, + HangingRoots, HayBlock, HeartOfTheSea, HeavyWeightedPressurePlate, @@ -437,6 +499,7 @@ namespace MinecraftClient.Inventory InfestedChiseledStoneBricks, InfestedCobblestone, InfestedCrackedStoneBricks, + InfestedDeepslate, InfestedMossyStoneBricks, InfestedStone, InfestedStoneBricks, @@ -484,6 +547,7 @@ namespace MinecraftClient.Inventory LapisBlock, LapisLazuli, LapisOre, + LargeAmethystBud, LargeFern, LavaBucket, Lead, @@ -495,8 +559,10 @@ namespace MinecraftClient.Inventory LeatherLeggings, Lectern, Lever, + Light, LightBlueBanner, LightBlueBed, + LightBlueCandle, LightBlueCarpet, LightBlueConcrete, LightBlueConcretePowder, @@ -509,6 +575,7 @@ namespace MinecraftClient.Inventory LightBlueWool, LightGrayBanner, LightGrayBed, + LightGrayCandle, LightGrayCarpet, LightGrayConcrete, LightGrayConcretePowder, @@ -520,11 +587,13 @@ namespace MinecraftClient.Inventory LightGrayTerracotta, LightGrayWool, LightWeightedPressurePlate, + LightningRod, Lilac, LilyOfTheValley, LilyPad, LimeBanner, LimeBed, + LimeCandle, LimeCarpet, LimeConcrete, LimeConcretePowder, @@ -541,6 +610,7 @@ namespace MinecraftClient.Inventory Loom, MagentaBanner, MagentaBed, + MagentaCandle, MagentaCarpet, MagentaConcrete, MagentaConcretePowder, @@ -555,6 +625,7 @@ namespace MinecraftClient.Inventory MagmaCream, MagmaCubeSpawnEgg, Map, + MediumAmethystBud, Melon, MelonSeeds, MelonSlice, @@ -562,14 +633,16 @@ namespace MinecraftClient.Inventory Minecart, MojangBannerPattern, MooshroomSpawnEgg, + MossBlock, + MossCarpet, MossyCobblestone, MossyCobblestoneSlab, MossyCobblestoneStairs, MossyCobblestoneWall, - MossyStoneBricks, MossyStoneBrickSlab, MossyStoneBrickStairs, MossyStoneBrickWall, + MossyStoneBricks, MuleSpawnEgg, MushroomStem, MushroomStew, @@ -581,6 +654,7 @@ namespace MinecraftClient.Inventory MusicDiscFar, MusicDiscMall, MusicDiscMellohi, + MusicDiscOtherside, MusicDiscPigstep, MusicDiscStal, MusicDiscStrad, @@ -592,11 +666,16 @@ namespace MinecraftClient.Inventory NautilusShell, NetherBrick, NetherBrickFence, - NetherBricks, NetherBrickSlab, NetherBrickStairs, NetherBrickWall, + NetherBricks, NetherGoldOre, + NetherQuartzOre, + NetherSprouts, + NetherStar, + NetherWart, + NetherWartBlock, NetheriteAxe, NetheriteBlock, NetheriteBoots, @@ -609,12 +688,7 @@ namespace MinecraftClient.Inventory NetheriteScrap, NetheriteShovel, NetheriteSword, - NetherQuartzOre, Netherrack, - NetherSprouts, - NetherStar, - NetherWart, - NetherWartBlock, NoteBlock, OakBoat, OakButton, @@ -636,6 +710,7 @@ namespace MinecraftClient.Inventory OcelotSpawnEgg, OrangeBanner, OrangeBed, + OrangeCandle, OrangeCarpet, OrangeConcrete, OrangeConcretePowder, @@ -648,6 +723,10 @@ namespace MinecraftClient.Inventory OrangeTulip, OrangeWool, OxeyeDaisy, + OxidizedCopper, + OxidizedCutCopper, + OxidizedCutCopperSlab, + OxidizedCutCopperStairs, PackedIce, Painting, PandaSpawnEgg, @@ -657,13 +736,14 @@ namespace MinecraftClient.Inventory PetrifiedOakSlab, PhantomMembrane, PhantomSpawnEgg, + PigSpawnEgg, PiglinBannerPattern, PiglinBruteSpawnEgg, PiglinSpawnEgg, - PigSpawnEgg, PillagerSpawnEgg, PinkBanner, PinkBed, + PinkCandle, PinkCarpet, PinkConcrete, PinkConcretePowder, @@ -678,6 +758,7 @@ namespace MinecraftClient.Inventory Piston, PlayerHead, Podzol, + PointedDripstone, PoisonousPotato, PolarBearSpawnEgg, PolishedAndesite, @@ -685,15 +766,19 @@ namespace MinecraftClient.Inventory PolishedAndesiteStairs, PolishedBasalt, PolishedBlackstone, - PolishedBlackstoneBricks, PolishedBlackstoneBrickSlab, PolishedBlackstoneBrickStairs, PolishedBlackstoneBrickWall, + PolishedBlackstoneBricks, PolishedBlackstoneButton, PolishedBlackstonePressurePlate, PolishedBlackstoneSlab, PolishedBlackstoneStairs, PolishedBlackstoneWall, + PolishedDeepslate, + PolishedDeepslateSlab, + PolishedDeepslateStairs, + PolishedDeepslateWall, PolishedDiorite, PolishedDioriteSlab, PolishedDioriteStairs, @@ -705,11 +790,12 @@ namespace MinecraftClient.Inventory Porkchop, Potato, Potion, + PowderSnowBucket, PoweredRail, Prismarine, - PrismarineBricks, PrismarineBrickSlab, PrismarineBrickStairs, + PrismarineBricks, PrismarineCrystals, PrismarineShard, PrismarineSlab, @@ -723,6 +809,7 @@ namespace MinecraftClient.Inventory PumpkinSeeds, PurpleBanner, PurpleBed, + PurpleCandle, PurpleCarpet, PurpleConcrete, PurpleConcretePowder, @@ -750,8 +837,15 @@ namespace MinecraftClient.Inventory RabbitStew, Rail, RavagerSpawnEgg, + RawCopper, + RawCopperBlock, + RawGold, + RawGoldBlock, + RawIron, + RawIronBlock, RedBanner, RedBed, + RedCandle, RedCarpet, RedConcrete, RedConcretePowder, @@ -759,10 +853,10 @@ namespace MinecraftClient.Inventory RedGlazedTerracotta, RedMushroom, RedMushroomBlock, - RedNetherBricks, RedNetherBrickSlab, RedNetherBrickStairs, RedNetherBrickWall, + RedNetherBricks, RedSand, RedSandstone, RedSandstoneSlab, @@ -771,17 +865,18 @@ namespace MinecraftClient.Inventory RedShulkerBox, RedStainedGlass, RedStainedGlassPane, + RedTerracotta, + RedTulip, + RedWool, Redstone, RedstoneBlock, RedstoneLamp, RedstoneOre, RedstoneTorch, - RedTerracotta, - RedTulip, - RedWool, Repeater, RepeatingCommandBlock, RespawnAnchor, + RootedDirt, RoseBush, RottenFlesh, Saddle, @@ -794,10 +889,11 @@ namespace MinecraftClient.Inventory SandstoneStairs, SandstoneWall, Scaffolding, + SculkSensor, Scute, - Seagrass, SeaLantern, SeaPickle, + Seagrass, Shears, SheepSpawnEgg, Shield, @@ -813,8 +909,11 @@ namespace MinecraftClient.Inventory SlimeBall, SlimeBlock, SlimeSpawnEgg, + SmallAmethystBud, + SmallDripleaf, SmithingTable, Smoker, + SmoothBasalt, SmoothQuartz, SmoothQuartzSlab, SmoothQuartzStairs, @@ -827,8 +926,8 @@ namespace MinecraftClient.Inventory SmoothStone, SmoothStoneSlab, Snow, - Snowball, SnowBlock, + Snowball, SoulCampfire, SoulLantern, SoulSand, @@ -840,6 +939,7 @@ namespace MinecraftClient.Inventory SpiderSpawnEgg, SplashPotion, Sponge, + SporeBlossom, SpruceBoat, SpruceButton, SpruceDoor, @@ -855,17 +955,17 @@ namespace MinecraftClient.Inventory SpruceStairs, SpruceTrapdoor, SpruceWood, + Spyglass, SquidSpawnEgg, Stick, StickyPiston, Stone, StoneAxe, - StoneBricks, StoneBrickSlab, StoneBrickStairs, StoneBrickWall, + StoneBricks, StoneButton, - Stonecutter, StoneHoe, StonePickaxe, StonePressurePlate, @@ -873,6 +973,7 @@ namespace MinecraftClient.Inventory StoneSlab, StoneStairs, StoneSword, + Stonecutter, StraySpawnEgg, StriderSpawnEgg, String, @@ -902,6 +1003,7 @@ namespace MinecraftClient.Inventory TallGrass, Target, Terracotta, + TintedGlass, TippedArrow, Tnt, TntMinecart, @@ -917,6 +1019,7 @@ namespace MinecraftClient.Inventory TubeCoral, TubeCoralBlock, TubeCoralFan, + Tuff, TurtleEgg, TurtleHelmet, TurtleSpawnEgg, @@ -944,12 +1047,33 @@ namespace MinecraftClient.Inventory WarpedTrapdoor, WarpedWartBlock, WaterBucket, + WaxedCopperBlock, + WaxedCutCopper, + WaxedCutCopperSlab, + WaxedCutCopperStairs, + WaxedExposedCopper, + WaxedExposedCutCopper, + WaxedExposedCutCopperSlab, + WaxedExposedCutCopperStairs, + WaxedOxidizedCopper, + WaxedOxidizedCutCopper, + WaxedOxidizedCutCopperSlab, + WaxedOxidizedCutCopperStairs, + WaxedWeatheredCopper, + WaxedWeatheredCutCopper, + WaxedWeatheredCutCopperSlab, + WaxedWeatheredCutCopperStairs, + WeatheredCopper, + WeatheredCutCopper, + WeatheredCutCopperSlab, + WeatheredCutCopperStairs, WeepingVines, WetSponge, Wheat, WheatSeeds, WhiteBanner, WhiteBed, + WhiteCandle, WhiteCarpet, WhiteConcrete, WhiteConcretePowder, @@ -975,6 +1099,7 @@ namespace MinecraftClient.Inventory WrittenBook, YellowBanner, YellowBed, + YellowCandle, YellowCarpet, YellowConcrete, YellowConcretePowder, @@ -990,6 +1115,6 @@ namespace MinecraftClient.Inventory ZombieHorseSpawnEgg, ZombieSpawnEgg, ZombieVillagerSpawnEgg, - ZombifiedPiglinSpawnEgg, + ZombifiedPiglinSpawnEgg } } diff --git a/MinecraftClient/Inventory/ItemTypeExtensions.cs b/MinecraftClient/Inventory/ItemTypeExtensions.cs index 09d9b8e4..5c1c8ac4 100644 --- a/MinecraftClient/Inventory/ItemTypeExtensions.cs +++ b/MinecraftClient/Inventory/ItemTypeExtensions.cs @@ -50,11 +50,13 @@ namespace MinecraftClient.Inventory ItemType[] t = { ItemType.AcaciaBoat, + ItemType.AxolotlBucket, ItemType.BirchBoat, ItemType.BlackBed, ItemType.BlackShulkerBox, ItemType.BlueBed, ItemType.BlueShulkerBox, + ItemType.Bundle, ItemType.Bow, ItemType.BrownBed, ItemType.BrownShulkerBox, @@ -142,6 +144,7 @@ namespace MinecraftClient.Inventory ItemType.MusicDiscFar, ItemType.MusicDiscMall, ItemType.MusicDiscMellohi, + ItemType.MusicDiscOtherside, ItemType.MusicDiscStal, ItemType.MusicDiscStrad, ItemType.MusicDiscWait, @@ -152,6 +155,7 @@ namespace MinecraftClient.Inventory ItemType.PinkBed, ItemType.PinkShulkerBox, ItemType.Potion, + ItemType.PowderSnowBucket, ItemType.PufferfishBucket, ItemType.PurpleBed, ItemType.PurpleShulkerBox, @@ -166,6 +170,7 @@ namespace MinecraftClient.Inventory ItemType.SkullBannerPattern, ItemType.SplashPotion, ItemType.SpruceBoat, + ItemType.Spyglass, ItemType.StoneAxe, ItemType.StoneHoe, ItemType.StonePickaxe, diff --git a/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs b/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs index 5dca47a3..e4563b7d 100644 --- a/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs +++ b/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs @@ -23,6 +23,17 @@ namespace MinecraftClient.Mapping.BlockPalettes /// public static class BlockPaletteGenerator { + /// + /// Generate mapping from Minecraft blocks.json + /// + /// path to blocks.json + /// java -cp minecraft_server.jar net.minecraft.data.Main --reports + /// state => block name mappings + public static void GenerateBlockPallete(string blocksJsonFile) + { + BlockPaletteGenerator.JsonToClass(blocksJsonFile, "Palette", "Material"); + } + /// /// Generate mapping from Minecraft blocks.json /// @@ -33,6 +44,9 @@ namespace MinecraftClient.Mapping.BlockPalettes /// state => block name mappings public static void JsonToClass(string blocksJsonFile, string outputClass, string outputEnum = null) { + string outputPalettePath = Path.Combine(Path.GetDirectoryName(blocksJsonFile), outputClass + "XXX.cs"); + string outputEnumPath = Path.Combine(Path.GetDirectoryName(blocksJsonFile), outputEnum + "XXX.cs"); + HashSet knownStates = new HashSet(); Dictionary> blocks = new Dictionary>(); @@ -70,7 +84,7 @@ namespace MinecraftClient.Mapping.BlockPalettes "", "namespace MinecraftClient.Mapping.BlockPalettes", "{", - " public class PaletteXXX : PaletteMapping", + " public class PaletteXXX : BlockPalette", " {", " private static Dictionary materials = new Dictionary();", "", @@ -121,7 +135,7 @@ namespace MinecraftClient.Mapping.BlockPalettes "}" }); - File.WriteAllLines(outputClass, outFile); + File.WriteAllLines(outputPalettePath, outFile); if (outputEnum != null) { @@ -138,7 +152,7 @@ namespace MinecraftClient.Mapping.BlockPalettes " }", "}" }); - File.WriteAllLines(outputEnum, outFile); + File.WriteAllLines(outputEnumPath, outFile); } } } diff --git a/MinecraftClient/Mapping/BlockPalettes/Palette117.cs b/MinecraftClient/Mapping/BlockPalettes/Palette117.cs new file mode 100644 index 00000000..6a8f78c6 --- /dev/null +++ b/MinecraftClient/Mapping/BlockPalettes/Palette117.cs @@ -0,0 +1,1468 @@ +using System; +using System.Collections.Generic; + +namespace MinecraftClient.Mapping.BlockPalettes +{ + public class Palette117 : BlockPalette + { + private static Dictionary materials = new Dictionary(); + + static Palette117() + { + materials[0] = Material.Air; + materials[1] = Material.Stone; + materials[2] = Material.Granite; + materials[3] = Material.PolishedGranite; + materials[4] = Material.Diorite; + materials[5] = Material.PolishedDiorite; + materials[6] = Material.Andesite; + materials[7] = Material.PolishedAndesite; + for (int i = 8; i <= 9; i++) + materials[i] = Material.GrassBlock; + materials[10] = Material.Dirt; + materials[11] = Material.CoarseDirt; + for (int i = 12; i <= 13; i++) + materials[i] = Material.Podzol; + materials[14] = Material.Cobblestone; + materials[15] = Material.OakPlanks; + materials[16] = Material.SprucePlanks; + materials[17] = Material.BirchPlanks; + materials[18] = Material.JunglePlanks; + materials[19] = Material.AcaciaPlanks; + materials[20] = Material.DarkOakPlanks; + for (int i = 21; i <= 22; i++) + materials[i] = Material.OakSapling; + for (int i = 23; i <= 24; i++) + materials[i] = Material.SpruceSapling; + for (int i = 25; i <= 26; i++) + materials[i] = Material.BirchSapling; + for (int i = 27; i <= 28; i++) + materials[i] = Material.JungleSapling; + for (int i = 29; i <= 30; i++) + materials[i] = Material.AcaciaSapling; + for (int i = 31; i <= 32; i++) + materials[i] = Material.DarkOakSapling; + materials[33] = Material.Bedrock; + for (int i = 34; i <= 49; i++) + materials[i] = Material.Water; + for (int i = 50; i <= 65; i++) + materials[i] = Material.Lava; + materials[66] = Material.Sand; + materials[67] = Material.RedSand; + materials[68] = Material.Gravel; + materials[69] = Material.GoldOre; + materials[70] = Material.DeepslateGoldOre; + materials[71] = Material.IronOre; + materials[72] = Material.DeepslateIronOre; + materials[73] = Material.CoalOre; + materials[74] = Material.DeepslateCoalOre; + materials[75] = Material.NetherGoldOre; + for (int i = 76; i <= 78; i++) + materials[i] = Material.OakLog; + for (int i = 79; i <= 81; i++) + materials[i] = Material.SpruceLog; + for (int i = 82; i <= 84; i++) + materials[i] = Material.BirchLog; + for (int i = 85; i <= 87; i++) + materials[i] = Material.JungleLog; + for (int i = 88; i <= 90; i++) + materials[i] = Material.AcaciaLog; + for (int i = 91; i <= 93; i++) + materials[i] = Material.DarkOakLog; + for (int i = 94; i <= 96; i++) + materials[i] = Material.StrippedSpruceLog; + for (int i = 97; i <= 99; i++) + materials[i] = Material.StrippedBirchLog; + for (int i = 100; i <= 102; i++) + materials[i] = Material.StrippedJungleLog; + for (int i = 103; i <= 105; i++) + materials[i] = Material.StrippedAcaciaLog; + for (int i = 106; i <= 108; i++) + materials[i] = Material.StrippedDarkOakLog; + for (int i = 109; i <= 111; i++) + materials[i] = Material.StrippedOakLog; + for (int i = 112; i <= 114; i++) + materials[i] = Material.OakWood; + for (int i = 115; i <= 117; i++) + materials[i] = Material.SpruceWood; + for (int i = 118; i <= 120; i++) + materials[i] = Material.BirchWood; + for (int i = 121; i <= 123; i++) + materials[i] = Material.JungleWood; + for (int i = 124; i <= 126; i++) + materials[i] = Material.AcaciaWood; + for (int i = 127; i <= 129; i++) + materials[i] = Material.DarkOakWood; + for (int i = 130; i <= 132; i++) + materials[i] = Material.StrippedOakWood; + for (int i = 133; i <= 135; i++) + materials[i] = Material.StrippedSpruceWood; + for (int i = 136; i <= 138; i++) + materials[i] = Material.StrippedBirchWood; + for (int i = 139; i <= 141; i++) + materials[i] = Material.StrippedJungleWood; + for (int i = 142; i <= 144; i++) + materials[i] = Material.StrippedAcaciaWood; + for (int i = 145; i <= 147; i++) + materials[i] = Material.StrippedDarkOakWood; + for (int i = 148; i <= 161; i++) + materials[i] = Material.OakLeaves; + for (int i = 162; i <= 175; i++) + materials[i] = Material.SpruceLeaves; + for (int i = 176; i <= 189; i++) + materials[i] = Material.BirchLeaves; + for (int i = 190; i <= 203; i++) + materials[i] = Material.JungleLeaves; + for (int i = 204; i <= 217; i++) + materials[i] = Material.AcaciaLeaves; + for (int i = 218; i <= 231; i++) + materials[i] = Material.DarkOakLeaves; + for (int i = 232; i <= 245; i++) + materials[i] = Material.AzaleaLeaves; + for (int i = 246; i <= 259; i++) + materials[i] = Material.FloweringAzaleaLeaves; + materials[260] = Material.Sponge; + materials[261] = Material.WetSponge; + materials[262] = Material.Glass; + materials[263] = Material.LapisOre; + materials[264] = Material.DeepslateLapisOre; + materials[265] = Material.LapisBlock; + for (int i = 266; i <= 277; i++) + materials[i] = Material.Dispenser; + materials[278] = Material.Sandstone; + materials[279] = Material.ChiseledSandstone; + materials[280] = Material.CutSandstone; + for (int i = 281; i <= 1080; i++) + materials[i] = Material.NoteBlock; + for (int i = 1081; i <= 1096; i++) + materials[i] = Material.WhiteBed; + for (int i = 1097; i <= 1112; i++) + materials[i] = Material.OrangeBed; + for (int i = 1113; i <= 1128; i++) + materials[i] = Material.MagentaBed; + for (int i = 1129; i <= 1144; i++) + materials[i] = Material.LightBlueBed; + for (int i = 1145; i <= 1160; i++) + materials[i] = Material.YellowBed; + for (int i = 1161; i <= 1176; i++) + materials[i] = Material.LimeBed; + for (int i = 1177; i <= 1192; i++) + materials[i] = Material.PinkBed; + for (int i = 1193; i <= 1208; i++) + materials[i] = Material.GrayBed; + for (int i = 1209; i <= 1224; i++) + materials[i] = Material.LightGrayBed; + for (int i = 1225; i <= 1240; i++) + materials[i] = Material.CyanBed; + for (int i = 1241; i <= 1256; i++) + materials[i] = Material.PurpleBed; + for (int i = 1257; i <= 1272; i++) + materials[i] = Material.BlueBed; + for (int i = 1273; i <= 1288; i++) + materials[i] = Material.BrownBed; + for (int i = 1289; i <= 1304; i++) + materials[i] = Material.GreenBed; + for (int i = 1305; i <= 1320; i++) + materials[i] = Material.RedBed; + for (int i = 1321; i <= 1336; i++) + materials[i] = Material.BlackBed; + for (int i = 1337; i <= 1360; i++) + materials[i] = Material.PoweredRail; + for (int i = 1361; i <= 1384; i++) + materials[i] = Material.DetectorRail; + for (int i = 1385; i <= 1396; i++) + materials[i] = Material.StickyPiston; + materials[1397] = Material.Cobweb; + materials[1398] = Material.Grass; + materials[1399] = Material.Fern; + materials[1400] = Material.DeadBush; + materials[1401] = Material.Seagrass; + for (int i = 1402; i <= 1403; i++) + materials[i] = Material.TallSeagrass; + for (int i = 1404; i <= 1415; i++) + materials[i] = Material.Piston; + for (int i = 1416; i <= 1439; i++) + materials[i] = Material.PistonHead; + materials[1440] = Material.WhiteWool; + materials[1441] = Material.OrangeWool; + materials[1442] = Material.MagentaWool; + materials[1443] = Material.LightBlueWool; + materials[1444] = Material.YellowWool; + materials[1445] = Material.LimeWool; + materials[1446] = Material.PinkWool; + materials[1447] = Material.GrayWool; + materials[1448] = Material.LightGrayWool; + materials[1449] = Material.CyanWool; + materials[1450] = Material.PurpleWool; + materials[1451] = Material.BlueWool; + materials[1452] = Material.BrownWool; + materials[1453] = Material.GreenWool; + materials[1454] = Material.RedWool; + materials[1455] = Material.BlackWool; + for (int i = 1456; i <= 1467; i++) + materials[i] = Material.MovingPiston; + materials[1468] = Material.Dandelion; + materials[1469] = Material.Poppy; + materials[1470] = Material.BlueOrchid; + materials[1471] = Material.Allium; + materials[1472] = Material.AzureBluet; + materials[1473] = Material.RedTulip; + materials[1474] = Material.OrangeTulip; + materials[1475] = Material.WhiteTulip; + materials[1476] = Material.PinkTulip; + materials[1477] = Material.OxeyeDaisy; + materials[1478] = Material.Cornflower; + materials[1479] = Material.WitherRose; + materials[1480] = Material.LilyOfTheValley; + materials[1481] = Material.BrownMushroom; + materials[1482] = Material.RedMushroom; + materials[1483] = Material.GoldBlock; + materials[1484] = Material.IronBlock; + materials[1485] = Material.Bricks; + for (int i = 1486; i <= 1487; i++) + materials[i] = Material.Tnt; + materials[1488] = Material.Bookshelf; + materials[1489] = Material.MossyCobblestone; + materials[1490] = Material.Obsidian; + materials[1491] = Material.Torch; + for (int i = 1492; i <= 1495; i++) + materials[i] = Material.WallTorch; + for (int i = 1496; i <= 2007; i++) + materials[i] = Material.Fire; + materials[2008] = Material.SoulFire; + materials[2009] = Material.Spawner; + for (int i = 2010; i <= 2089; i++) + materials[i] = Material.OakStairs; + for (int i = 2090; i <= 2113; i++) + materials[i] = Material.Chest; + for (int i = 2114; i <= 3409; i++) + materials[i] = Material.RedstoneWire; + materials[3410] = Material.DiamondOre; + materials[3411] = Material.DeepslateDiamondOre; + materials[3412] = Material.DiamondBlock; + materials[3413] = Material.CraftingTable; + for (int i = 3414; i <= 3421; i++) + materials[i] = Material.Wheat; + for (int i = 3422; i <= 3429; i++) + materials[i] = Material.Farmland; + for (int i = 3430; i <= 3437; i++) + materials[i] = Material.Furnace; + for (int i = 3438; i <= 3469; i++) + materials[i] = Material.OakSign; + for (int i = 3470; i <= 3501; i++) + materials[i] = Material.SpruceSign; + for (int i = 3502; i <= 3533; i++) + materials[i] = Material.BirchSign; + for (int i = 3534; i <= 3565; i++) + materials[i] = Material.AcaciaSign; + for (int i = 3566; i <= 3597; i++) + materials[i] = Material.JungleSign; + for (int i = 3598; i <= 3629; i++) + materials[i] = Material.DarkOakSign; + for (int i = 3630; i <= 3693; i++) + materials[i] = Material.OakDoor; + for (int i = 3694; i <= 3701; i++) + materials[i] = Material.Ladder; + for (int i = 3702; i <= 3721; i++) + materials[i] = Material.Rail; + for (int i = 3722; i <= 3801; i++) + materials[i] = Material.CobblestoneStairs; + for (int i = 3802; i <= 3809; i++) + materials[i] = Material.OakWallSign; + for (int i = 3810; i <= 3817; i++) + materials[i] = Material.SpruceWallSign; + for (int i = 3818; i <= 3825; i++) + materials[i] = Material.BirchWallSign; + for (int i = 3826; i <= 3833; i++) + materials[i] = Material.AcaciaWallSign; + for (int i = 3834; i <= 3841; i++) + materials[i] = Material.JungleWallSign; + for (int i = 3842; i <= 3849; i++) + materials[i] = Material.DarkOakWallSign; + for (int i = 3850; i <= 3873; i++) + materials[i] = Material.Lever; + for (int i = 3874; i <= 3875; i++) + materials[i] = Material.StonePressurePlate; + for (int i = 3876; i <= 3939; i++) + materials[i] = Material.IronDoor; + for (int i = 3940; i <= 3941; i++) + materials[i] = Material.OakPressurePlate; + for (int i = 3942; i <= 3943; i++) + materials[i] = Material.SprucePressurePlate; + for (int i = 3944; i <= 3945; i++) + materials[i] = Material.BirchPressurePlate; + for (int i = 3946; i <= 3947; i++) + materials[i] = Material.JunglePressurePlate; + for (int i = 3948; i <= 3949; i++) + materials[i] = Material.AcaciaPressurePlate; + for (int i = 3950; i <= 3951; i++) + materials[i] = Material.DarkOakPressurePlate; + for (int i = 3952; i <= 3953; i++) + materials[i] = Material.RedstoneOre; + for (int i = 3954; i <= 3955; i++) + materials[i] = Material.DeepslateRedstoneOre; + for (int i = 3956; i <= 3957; i++) + materials[i] = Material.RedstoneTorch; + for (int i = 3958; i <= 3965; i++) + materials[i] = Material.RedstoneWallTorch; + for (int i = 3966; i <= 3989; i++) + materials[i] = Material.StoneButton; + for (int i = 3990; i <= 3997; i++) + materials[i] = Material.Snow; + materials[3998] = Material.Ice; + materials[3999] = Material.SnowBlock; + for (int i = 4000; i <= 4015; i++) + materials[i] = Material.Cactus; + materials[4016] = Material.Clay; + for (int i = 4017; i <= 4032; i++) + materials[i] = Material.SugarCane; + for (int i = 4033; i <= 4034; i++) + materials[i] = Material.Jukebox; + for (int i = 4035; i <= 4066; i++) + materials[i] = Material.OakFence; + materials[4067] = Material.Pumpkin; + materials[4068] = Material.Netherrack; + materials[4069] = Material.SoulSand; + materials[4070] = Material.SoulSoil; + for (int i = 4071; i <= 4073; i++) + materials[i] = Material.Basalt; + for (int i = 4074; i <= 4076; i++) + materials[i] = Material.PolishedBasalt; + materials[4077] = Material.SoulTorch; + for (int i = 4078; i <= 4081; i++) + materials[i] = Material.SoulWallTorch; + materials[4082] = Material.Glowstone; + for (int i = 4083; i <= 4084; i++) + materials[i] = Material.NetherPortal; + for (int i = 4085; i <= 4088; i++) + materials[i] = Material.CarvedPumpkin; + for (int i = 4089; i <= 4092; i++) + materials[i] = Material.JackOLantern; + for (int i = 4093; i <= 4099; i++) + materials[i] = Material.Cake; + for (int i = 4100; i <= 4163; i++) + materials[i] = Material.Repeater; + materials[4164] = Material.WhiteStainedGlass; + materials[4165] = Material.OrangeStainedGlass; + materials[4166] = Material.MagentaStainedGlass; + materials[4167] = Material.LightBlueStainedGlass; + materials[4168] = Material.YellowStainedGlass; + materials[4169] = Material.LimeStainedGlass; + materials[4170] = Material.PinkStainedGlass; + materials[4171] = Material.GrayStainedGlass; + materials[4172] = Material.LightGrayStainedGlass; + materials[4173] = Material.CyanStainedGlass; + materials[4174] = Material.PurpleStainedGlass; + materials[4175] = Material.BlueStainedGlass; + materials[4176] = Material.BrownStainedGlass; + materials[4177] = Material.GreenStainedGlass; + materials[4178] = Material.RedStainedGlass; + materials[4179] = Material.BlackStainedGlass; + for (int i = 4180; i <= 4243; i++) + materials[i] = Material.OakTrapdoor; + for (int i = 4244; i <= 4307; i++) + materials[i] = Material.SpruceTrapdoor; + for (int i = 4308; i <= 4371; i++) + materials[i] = Material.BirchTrapdoor; + for (int i = 4372; i <= 4435; i++) + materials[i] = Material.JungleTrapdoor; + for (int i = 4436; i <= 4499; i++) + materials[i] = Material.AcaciaTrapdoor; + for (int i = 4500; i <= 4563; i++) + materials[i] = Material.DarkOakTrapdoor; + materials[4564] = Material.StoneBricks; + materials[4565] = Material.MossyStoneBricks; + materials[4566] = Material.CrackedStoneBricks; + materials[4567] = Material.ChiseledStoneBricks; + materials[4568] = Material.InfestedStone; + materials[4569] = Material.InfestedCobblestone; + materials[4570] = Material.InfestedStoneBricks; + materials[4571] = Material.InfestedMossyStoneBricks; + materials[4572] = Material.InfestedCrackedStoneBricks; + materials[4573] = Material.InfestedChiseledStoneBricks; + for (int i = 4574; i <= 4637; i++) + materials[i] = Material.BrownMushroomBlock; + for (int i = 4638; i <= 4701; i++) + materials[i] = Material.RedMushroomBlock; + for (int i = 4702; i <= 4765; i++) + materials[i] = Material.MushroomStem; + for (int i = 4766; i <= 4797; i++) + materials[i] = Material.IronBars; + for (int i = 4798; i <= 4803; i++) + materials[i] = Material.Chain; + for (int i = 4804; i <= 4835; i++) + materials[i] = Material.GlassPane; + materials[4836] = Material.Melon; + for (int i = 4837; i <= 4840; i++) + materials[i] = Material.AttachedPumpkinStem; + for (int i = 4841; i <= 4844; i++) + materials[i] = Material.AttachedMelonStem; + for (int i = 4845; i <= 4852; i++) + materials[i] = Material.PumpkinStem; + for (int i = 4853; i <= 4860; i++) + materials[i] = Material.MelonStem; + for (int i = 4861; i <= 4892; i++) + materials[i] = Material.Vine; + for (int i = 4893; i <= 5020; i++) + materials[i] = Material.GlowLichen; + for (int i = 5021; i <= 5052; i++) + materials[i] = Material.OakFenceGate; + for (int i = 5053; i <= 5132; i++) + materials[i] = Material.BrickStairs; + for (int i = 5133; i <= 5212; i++) + materials[i] = Material.StoneBrickStairs; + for (int i = 5213; i <= 5214; i++) + materials[i] = Material.Mycelium; + materials[5215] = Material.LilyPad; + materials[5216] = Material.NetherBricks; + for (int i = 5217; i <= 5248; i++) + materials[i] = Material.NetherBrickFence; + for (int i = 5249; i <= 5328; i++) + materials[i] = Material.NetherBrickStairs; + for (int i = 5329; i <= 5332; i++) + materials[i] = Material.NetherWart; + materials[5333] = Material.EnchantingTable; + for (int i = 5334; i <= 5341; i++) + materials[i] = Material.BrewingStand; + materials[5342] = Material.Cauldron; + for (int i = 5343; i <= 5345; i++) + materials[i] = Material.WaterCauldron; + materials[5346] = Material.LavaCauldron; + for (int i = 5347; i <= 5349; i++) + materials[i] = Material.PowderSnowCauldron; + materials[5350] = Material.EndPortal; + for (int i = 5351; i <= 5358; i++) + materials[i] = Material.EndPortalFrame; + materials[5359] = Material.EndStone; + materials[5360] = Material.DragonEgg; + for (int i = 5361; i <= 5362; i++) + materials[i] = Material.RedstoneLamp; + for (int i = 5363; i <= 5374; i++) + materials[i] = Material.Cocoa; + for (int i = 5375; i <= 5454; i++) + materials[i] = Material.SandstoneStairs; + materials[5455] = Material.EmeraldOre; + materials[5456] = Material.DeepslateEmeraldOre; + for (int i = 5457; i <= 5464; i++) + materials[i] = Material.EnderChest; + for (int i = 5465; i <= 5480; i++) + materials[i] = Material.TripwireHook; + for (int i = 5481; i <= 5608; i++) + materials[i] = Material.Tripwire; + materials[5609] = Material.EmeraldBlock; + for (int i = 5610; i <= 5689; i++) + materials[i] = Material.SpruceStairs; + for (int i = 5690; i <= 5769; i++) + materials[i] = Material.BirchStairs; + for (int i = 5770; i <= 5849; i++) + materials[i] = Material.JungleStairs; + for (int i = 5850; i <= 5861; i++) + materials[i] = Material.CommandBlock; + materials[5862] = Material.Beacon; + for (int i = 5863; i <= 6186; i++) + materials[i] = Material.CobblestoneWall; + for (int i = 6187; i <= 6510; i++) + materials[i] = Material.MossyCobblestoneWall; + materials[6511] = Material.FlowerPot; + materials[6512] = Material.PottedOakSapling; + materials[6513] = Material.PottedSpruceSapling; + materials[6514] = Material.PottedBirchSapling; + materials[6515] = Material.PottedJungleSapling; + materials[6516] = Material.PottedAcaciaSapling; + materials[6517] = Material.PottedDarkOakSapling; + materials[6518] = Material.PottedFern; + materials[6519] = Material.PottedDandelion; + materials[6520] = Material.PottedPoppy; + materials[6521] = Material.PottedBlueOrchid; + materials[6522] = Material.PottedAllium; + materials[6523] = Material.PottedAzureBluet; + materials[6524] = Material.PottedRedTulip; + materials[6525] = Material.PottedOrangeTulip; + materials[6526] = Material.PottedWhiteTulip; + materials[6527] = Material.PottedPinkTulip; + materials[6528] = Material.PottedOxeyeDaisy; + materials[6529] = Material.PottedCornflower; + materials[6530] = Material.PottedLilyOfTheValley; + materials[6531] = Material.PottedWitherRose; + materials[6532] = Material.PottedRedMushroom; + materials[6533] = Material.PottedBrownMushroom; + materials[6534] = Material.PottedDeadBush; + materials[6535] = Material.PottedCactus; + for (int i = 6536; i <= 6543; i++) + materials[i] = Material.Carrots; + for (int i = 6544; i <= 6551; i++) + materials[i] = Material.Potatoes; + for (int i = 6552; i <= 6575; i++) + materials[i] = Material.OakButton; + for (int i = 6576; i <= 6599; i++) + materials[i] = Material.SpruceButton; + for (int i = 6600; i <= 6623; i++) + materials[i] = Material.BirchButton; + for (int i = 6624; i <= 6647; i++) + materials[i] = Material.JungleButton; + for (int i = 6648; i <= 6671; i++) + materials[i] = Material.AcaciaButton; + for (int i = 6672; i <= 6695; i++) + materials[i] = Material.DarkOakButton; + for (int i = 6696; i <= 6711; i++) + materials[i] = Material.SkeletonSkull; + for (int i = 6712; i <= 6715; i++) + materials[i] = Material.SkeletonWallSkull; + for (int i = 6716; i <= 6731; i++) + materials[i] = Material.WitherSkeletonSkull; + for (int i = 6732; i <= 6735; i++) + materials[i] = Material.WitherSkeletonWallSkull; + for (int i = 6736; i <= 6751; i++) + materials[i] = Material.ZombieHead; + for (int i = 6752; i <= 6755; i++) + materials[i] = Material.ZombieWallHead; + for (int i = 6756; i <= 6771; i++) + materials[i] = Material.PlayerHead; + for (int i = 6772; i <= 6775; i++) + materials[i] = Material.PlayerWallHead; + for (int i = 6776; i <= 6791; i++) + materials[i] = Material.CreeperHead; + for (int i = 6792; i <= 6795; i++) + materials[i] = Material.CreeperWallHead; + for (int i = 6796; i <= 6811; i++) + materials[i] = Material.DragonHead; + for (int i = 6812; i <= 6815; i++) + materials[i] = Material.DragonWallHead; + for (int i = 6816; i <= 6819; i++) + materials[i] = Material.Anvil; + for (int i = 6820; i <= 6823; i++) + materials[i] = Material.ChippedAnvil; + for (int i = 6824; i <= 6827; i++) + materials[i] = Material.DamagedAnvil; + for (int i = 6828; i <= 6851; i++) + materials[i] = Material.TrappedChest; + for (int i = 6852; i <= 6867; i++) + materials[i] = Material.LightWeightedPressurePlate; + for (int i = 6868; i <= 6883; i++) + materials[i] = Material.HeavyWeightedPressurePlate; + for (int i = 6884; i <= 6899; i++) + materials[i] = Material.Comparator; + for (int i = 6900; i <= 6931; i++) + materials[i] = Material.DaylightDetector; + materials[6932] = Material.RedstoneBlock; + materials[6933] = Material.NetherQuartzOre; + for (int i = 6934; i <= 6943; i++) + materials[i] = Material.Hopper; + materials[6944] = Material.QuartzBlock; + materials[6945] = Material.ChiseledQuartzBlock; + for (int i = 6946; i <= 6948; i++) + materials[i] = Material.QuartzPillar; + for (int i = 6949; i <= 7028; i++) + materials[i] = Material.QuartzStairs; + for (int i = 7029; i <= 7052; i++) + materials[i] = Material.ActivatorRail; + for (int i = 7053; i <= 7064; i++) + materials[i] = Material.Dropper; + materials[7065] = Material.WhiteTerracotta; + materials[7066] = Material.OrangeTerracotta; + materials[7067] = Material.MagentaTerracotta; + materials[7068] = Material.LightBlueTerracotta; + materials[7069] = Material.YellowTerracotta; + materials[7070] = Material.LimeTerracotta; + materials[7071] = Material.PinkTerracotta; + materials[7072] = Material.GrayTerracotta; + materials[7073] = Material.LightGrayTerracotta; + materials[7074] = Material.CyanTerracotta; + materials[7075] = Material.PurpleTerracotta; + materials[7076] = Material.BlueTerracotta; + materials[7077] = Material.BrownTerracotta; + materials[7078] = Material.GreenTerracotta; + materials[7079] = Material.RedTerracotta; + materials[7080] = Material.BlackTerracotta; + for (int i = 7081; i <= 7112; i++) + materials[i] = Material.WhiteStainedGlassPane; + for (int i = 7113; i <= 7144; i++) + materials[i] = Material.OrangeStainedGlassPane; + for (int i = 7145; i <= 7176; i++) + materials[i] = Material.MagentaStainedGlassPane; + for (int i = 7177; i <= 7208; i++) + materials[i] = Material.LightBlueStainedGlassPane; + for (int i = 7209; i <= 7240; i++) + materials[i] = Material.YellowStainedGlassPane; + for (int i = 7241; i <= 7272; i++) + materials[i] = Material.LimeStainedGlassPane; + for (int i = 7273; i <= 7304; i++) + materials[i] = Material.PinkStainedGlassPane; + for (int i = 7305; i <= 7336; i++) + materials[i] = Material.GrayStainedGlassPane; + for (int i = 7337; i <= 7368; i++) + materials[i] = Material.LightGrayStainedGlassPane; + for (int i = 7369; i <= 7400; i++) + materials[i] = Material.CyanStainedGlassPane; + for (int i = 7401; i <= 7432; i++) + materials[i] = Material.PurpleStainedGlassPane; + for (int i = 7433; i <= 7464; i++) + materials[i] = Material.BlueStainedGlassPane; + for (int i = 7465; i <= 7496; i++) + materials[i] = Material.BrownStainedGlassPane; + for (int i = 7497; i <= 7528; i++) + materials[i] = Material.GreenStainedGlassPane; + for (int i = 7529; i <= 7560; i++) + materials[i] = Material.RedStainedGlassPane; + for (int i = 7561; i <= 7592; i++) + materials[i] = Material.BlackStainedGlassPane; + for (int i = 7593; i <= 7672; i++) + materials[i] = Material.AcaciaStairs; + for (int i = 7673; i <= 7752; i++) + materials[i] = Material.DarkOakStairs; + materials[7753] = Material.SlimeBlock; + materials[7754] = Material.Barrier; + for (int i = 7755; i <= 7786; i++) + materials[i] = Material.Light; + for (int i = 7787; i <= 7850; i++) + materials[i] = Material.IronTrapdoor; + materials[7851] = Material.Prismarine; + materials[7852] = Material.PrismarineBricks; + materials[7853] = Material.DarkPrismarine; + for (int i = 7854; i <= 7933; i++) + materials[i] = Material.PrismarineStairs; + for (int i = 7934; i <= 8013; i++) + materials[i] = Material.PrismarineBrickStairs; + for (int i = 8014; i <= 8093; i++) + materials[i] = Material.DarkPrismarineStairs; + for (int i = 8094; i <= 8099; i++) + materials[i] = Material.PrismarineSlab; + for (int i = 8100; i <= 8105; i++) + materials[i] = Material.PrismarineBrickSlab; + for (int i = 8106; i <= 8111; i++) + materials[i] = Material.DarkPrismarineSlab; + materials[8112] = Material.SeaLantern; + for (int i = 8113; i <= 8115; i++) + materials[i] = Material.HayBlock; + materials[8116] = Material.WhiteCarpet; + materials[8117] = Material.OrangeCarpet; + materials[8118] = Material.MagentaCarpet; + materials[8119] = Material.LightBlueCarpet; + materials[8120] = Material.YellowCarpet; + materials[8121] = Material.LimeCarpet; + materials[8122] = Material.PinkCarpet; + materials[8123] = Material.GrayCarpet; + materials[8124] = Material.LightGrayCarpet; + materials[8125] = Material.CyanCarpet; + materials[8126] = Material.PurpleCarpet; + materials[8127] = Material.BlueCarpet; + materials[8128] = Material.BrownCarpet; + materials[8129] = Material.GreenCarpet; + materials[8130] = Material.RedCarpet; + materials[8131] = Material.BlackCarpet; + materials[8132] = Material.Terracotta; + materials[8133] = Material.CoalBlock; + materials[8134] = Material.PackedIce; + for (int i = 8135; i <= 8136; i++) + materials[i] = Material.Sunflower; + for (int i = 8137; i <= 8138; i++) + materials[i] = Material.Lilac; + for (int i = 8139; i <= 8140; i++) + materials[i] = Material.RoseBush; + for (int i = 8141; i <= 8142; i++) + materials[i] = Material.Peony; + for (int i = 8143; i <= 8144; i++) + materials[i] = Material.TallGrass; + for (int i = 8145; i <= 8146; i++) + materials[i] = Material.LargeFern; + for (int i = 8147; i <= 8162; i++) + materials[i] = Material.WhiteBanner; + for (int i = 8163; i <= 8178; i++) + materials[i] = Material.OrangeBanner; + for (int i = 8179; i <= 8194; i++) + materials[i] = Material.MagentaBanner; + for (int i = 8195; i <= 8210; i++) + materials[i] = Material.LightBlueBanner; + for (int i = 8211; i <= 8226; i++) + materials[i] = Material.YellowBanner; + for (int i = 8227; i <= 8242; i++) + materials[i] = Material.LimeBanner; + for (int i = 8243; i <= 8258; i++) + materials[i] = Material.PinkBanner; + for (int i = 8259; i <= 8274; i++) + materials[i] = Material.GrayBanner; + for (int i = 8275; i <= 8290; i++) + materials[i] = Material.LightGrayBanner; + for (int i = 8291; i <= 8306; i++) + materials[i] = Material.CyanBanner; + for (int i = 8307; i <= 8322; i++) + materials[i] = Material.PurpleBanner; + for (int i = 8323; i <= 8338; i++) + materials[i] = Material.BlueBanner; + for (int i = 8339; i <= 8354; i++) + materials[i] = Material.BrownBanner; + for (int i = 8355; i <= 8370; i++) + materials[i] = Material.GreenBanner; + for (int i = 8371; i <= 8386; i++) + materials[i] = Material.RedBanner; + for (int i = 8387; i <= 8402; i++) + materials[i] = Material.BlackBanner; + for (int i = 8403; i <= 8406; i++) + materials[i] = Material.WhiteWallBanner; + for (int i = 8407; i <= 8410; i++) + materials[i] = Material.OrangeWallBanner; + for (int i = 8411; i <= 8414; i++) + materials[i] = Material.MagentaWallBanner; + for (int i = 8415; i <= 8418; i++) + materials[i] = Material.LightBlueWallBanner; + for (int i = 8419; i <= 8422; i++) + materials[i] = Material.YellowWallBanner; + for (int i = 8423; i <= 8426; i++) + materials[i] = Material.LimeWallBanner; + for (int i = 8427; i <= 8430; i++) + materials[i] = Material.PinkWallBanner; + for (int i = 8431; i <= 8434; i++) + materials[i] = Material.GrayWallBanner; + for (int i = 8435; i <= 8438; i++) + materials[i] = Material.LightGrayWallBanner; + for (int i = 8439; i <= 8442; i++) + materials[i] = Material.CyanWallBanner; + for (int i = 8443; i <= 8446; i++) + materials[i] = Material.PurpleWallBanner; + for (int i = 8447; i <= 8450; i++) + materials[i] = Material.BlueWallBanner; + for (int i = 8451; i <= 8454; i++) + materials[i] = Material.BrownWallBanner; + for (int i = 8455; i <= 8458; i++) + materials[i] = Material.GreenWallBanner; + for (int i = 8459; i <= 8462; i++) + materials[i] = Material.RedWallBanner; + for (int i = 8463; i <= 8466; i++) + materials[i] = Material.BlackWallBanner; + materials[8467] = Material.RedSandstone; + materials[8468] = Material.ChiseledRedSandstone; + materials[8469] = Material.CutRedSandstone; + for (int i = 8470; i <= 8549; i++) + materials[i] = Material.RedSandstoneStairs; + for (int i = 8550; i <= 8555; i++) + materials[i] = Material.OakSlab; + for (int i = 8556; i <= 8561; i++) + materials[i] = Material.SpruceSlab; + for (int i = 8562; i <= 8567; i++) + materials[i] = Material.BirchSlab; + for (int i = 8568; i <= 8573; i++) + materials[i] = Material.JungleSlab; + for (int i = 8574; i <= 8579; i++) + materials[i] = Material.AcaciaSlab; + for (int i = 8580; i <= 8585; i++) + materials[i] = Material.DarkOakSlab; + for (int i = 8586; i <= 8591; i++) + materials[i] = Material.StoneSlab; + for (int i = 8592; i <= 8597; i++) + materials[i] = Material.SmoothStoneSlab; + for (int i = 8598; i <= 8603; i++) + materials[i] = Material.SandstoneSlab; + for (int i = 8604; i <= 8609; i++) + materials[i] = Material.CutSandstoneSlab; + for (int i = 8610; i <= 8615; i++) + materials[i] = Material.PetrifiedOakSlab; + for (int i = 8616; i <= 8621; i++) + materials[i] = Material.CobblestoneSlab; + for (int i = 8622; i <= 8627; i++) + materials[i] = Material.BrickSlab; + for (int i = 8628; i <= 8633; i++) + materials[i] = Material.StoneBrickSlab; + for (int i = 8634; i <= 8639; i++) + materials[i] = Material.NetherBrickSlab; + for (int i = 8640; i <= 8645; i++) + materials[i] = Material.QuartzSlab; + for (int i = 8646; i <= 8651; i++) + materials[i] = Material.RedSandstoneSlab; + for (int i = 8652; i <= 8657; i++) + materials[i] = Material.CutRedSandstoneSlab; + for (int i = 8658; i <= 8663; i++) + materials[i] = Material.PurpurSlab; + materials[8664] = Material.SmoothStone; + materials[8665] = Material.SmoothSandstone; + materials[8666] = Material.SmoothQuartz; + materials[8667] = Material.SmoothRedSandstone; + for (int i = 8668; i <= 8699; i++) + materials[i] = Material.SpruceFenceGate; + for (int i = 8700; i <= 8731; i++) + materials[i] = Material.BirchFenceGate; + for (int i = 8732; i <= 8763; i++) + materials[i] = Material.JungleFenceGate; + for (int i = 8764; i <= 8795; i++) + materials[i] = Material.AcaciaFenceGate; + for (int i = 8796; i <= 8827; i++) + materials[i] = Material.DarkOakFenceGate; + for (int i = 8828; i <= 8859; i++) + materials[i] = Material.SpruceFence; + for (int i = 8860; i <= 8891; i++) + materials[i] = Material.BirchFence; + for (int i = 8892; i <= 8923; i++) + materials[i] = Material.JungleFence; + for (int i = 8924; i <= 8955; i++) + materials[i] = Material.AcaciaFence; + for (int i = 8956; i <= 8987; i++) + materials[i] = Material.DarkOakFence; + for (int i = 8988; i <= 9051; i++) + materials[i] = Material.SpruceDoor; + for (int i = 9052; i <= 9115; i++) + materials[i] = Material.BirchDoor; + for (int i = 9116; i <= 9179; i++) + materials[i] = Material.JungleDoor; + for (int i = 9180; i <= 9243; i++) + materials[i] = Material.AcaciaDoor; + for (int i = 9244; i <= 9307; i++) + materials[i] = Material.DarkOakDoor; + for (int i = 9308; i <= 9313; i++) + materials[i] = Material.EndRod; + for (int i = 9314; i <= 9377; i++) + materials[i] = Material.ChorusPlant; + for (int i = 9378; i <= 9383; i++) + materials[i] = Material.ChorusFlower; + materials[9384] = Material.PurpurBlock; + for (int i = 9385; i <= 9387; i++) + materials[i] = Material.PurpurPillar; + for (int i = 9388; i <= 9467; i++) + materials[i] = Material.PurpurStairs; + materials[9468] = Material.EndStoneBricks; + for (int i = 9469; i <= 9472; i++) + materials[i] = Material.Beetroots; + materials[9473] = Material.GrassPath; + materials[9474] = Material.EndGateway; + for (int i = 9475; i <= 9486; i++) + materials[i] = Material.RepeatingCommandBlock; + for (int i = 9487; i <= 9498; i++) + materials[i] = Material.ChainCommandBlock; + for (int i = 9499; i <= 9502; i++) + materials[i] = Material.FrostedIce; + materials[9503] = Material.MagmaBlock; + materials[9504] = Material.NetherWartBlock; + materials[9505] = Material.RedNetherBricks; + for (int i = 9506; i <= 9508; i++) + materials[i] = Material.BoneBlock; + materials[9509] = Material.StructureVoid; + for (int i = 9510; i <= 9521; i++) + materials[i] = Material.Observer; + for (int i = 9522; i <= 9527; i++) + materials[i] = Material.ShulkerBox; + for (int i = 9528; i <= 9533; i++) + materials[i] = Material.WhiteShulkerBox; + for (int i = 9534; i <= 9539; i++) + materials[i] = Material.OrangeShulkerBox; + for (int i = 9540; i <= 9545; i++) + materials[i] = Material.MagentaShulkerBox; + for (int i = 9546; i <= 9551; i++) + materials[i] = Material.LightBlueShulkerBox; + for (int i = 9552; i <= 9557; i++) + materials[i] = Material.YellowShulkerBox; + for (int i = 9558; i <= 9563; i++) + materials[i] = Material.LimeShulkerBox; + for (int i = 9564; i <= 9569; i++) + materials[i] = Material.PinkShulkerBox; + for (int i = 9570; i <= 9575; i++) + materials[i] = Material.GrayShulkerBox; + for (int i = 9576; i <= 9581; i++) + materials[i] = Material.LightGrayShulkerBox; + for (int i = 9582; i <= 9587; i++) + materials[i] = Material.CyanShulkerBox; + for (int i = 9588; i <= 9593; i++) + materials[i] = Material.PurpleShulkerBox; + for (int i = 9594; i <= 9599; i++) + materials[i] = Material.BlueShulkerBox; + for (int i = 9600; i <= 9605; i++) + materials[i] = Material.BrownShulkerBox; + for (int i = 9606; i <= 9611; i++) + materials[i] = Material.GreenShulkerBox; + for (int i = 9612; i <= 9617; i++) + materials[i] = Material.RedShulkerBox; + for (int i = 9618; i <= 9623; i++) + materials[i] = Material.BlackShulkerBox; + for (int i = 9624; i <= 9627; i++) + materials[i] = Material.WhiteGlazedTerracotta; + for (int i = 9628; i <= 9631; i++) + materials[i] = Material.OrangeGlazedTerracotta; + for (int i = 9632; i <= 9635; i++) + materials[i] = Material.MagentaGlazedTerracotta; + for (int i = 9636; i <= 9639; i++) + materials[i] = Material.LightBlueGlazedTerracotta; + for (int i = 9640; i <= 9643; i++) + materials[i] = Material.YellowGlazedTerracotta; + for (int i = 9644; i <= 9647; i++) + materials[i] = Material.LimeGlazedTerracotta; + for (int i = 9648; i <= 9651; i++) + materials[i] = Material.PinkGlazedTerracotta; + for (int i = 9652; i <= 9655; i++) + materials[i] = Material.GrayGlazedTerracotta; + for (int i = 9656; i <= 9659; i++) + materials[i] = Material.LightGrayGlazedTerracotta; + for (int i = 9660; i <= 9663; i++) + materials[i] = Material.CyanGlazedTerracotta; + for (int i = 9664; i <= 9667; i++) + materials[i] = Material.PurpleGlazedTerracotta; + for (int i = 9668; i <= 9671; i++) + materials[i] = Material.BlueGlazedTerracotta; + for (int i = 9672; i <= 9675; i++) + materials[i] = Material.BrownGlazedTerracotta; + for (int i = 9676; i <= 9679; i++) + materials[i] = Material.GreenGlazedTerracotta; + for (int i = 9680; i <= 9683; i++) + materials[i] = Material.RedGlazedTerracotta; + for (int i = 9684; i <= 9687; i++) + materials[i] = Material.BlackGlazedTerracotta; + materials[9688] = Material.WhiteConcrete; + materials[9689] = Material.OrangeConcrete; + materials[9690] = Material.MagentaConcrete; + materials[9691] = Material.LightBlueConcrete; + materials[9692] = Material.YellowConcrete; + materials[9693] = Material.LimeConcrete; + materials[9694] = Material.PinkConcrete; + materials[9695] = Material.GrayConcrete; + materials[9696] = Material.LightGrayConcrete; + materials[9697] = Material.CyanConcrete; + materials[9698] = Material.PurpleConcrete; + materials[9699] = Material.BlueConcrete; + materials[9700] = Material.BrownConcrete; + materials[9701] = Material.GreenConcrete; + materials[9702] = Material.RedConcrete; + materials[9703] = Material.BlackConcrete; + materials[9704] = Material.WhiteConcretePowder; + materials[9705] = Material.OrangeConcretePowder; + materials[9706] = Material.MagentaConcretePowder; + materials[9707] = Material.LightBlueConcretePowder; + materials[9708] = Material.YellowConcretePowder; + materials[9709] = Material.LimeConcretePowder; + materials[9710] = Material.PinkConcretePowder; + materials[9711] = Material.GrayConcretePowder; + materials[9712] = Material.LightGrayConcretePowder; + materials[9713] = Material.CyanConcretePowder; + materials[9714] = Material.PurpleConcretePowder; + materials[9715] = Material.BlueConcretePowder; + materials[9716] = Material.BrownConcretePowder; + materials[9717] = Material.GreenConcretePowder; + materials[9718] = Material.RedConcretePowder; + materials[9719] = Material.BlackConcretePowder; + for (int i = 9720; i <= 9745; i++) + materials[i] = Material.Kelp; + materials[9746] = Material.KelpPlant; + materials[9747] = Material.DriedKelpBlock; + for (int i = 9748; i <= 9759; i++) + materials[i] = Material.TurtleEgg; + materials[9760] = Material.DeadTubeCoralBlock; + materials[9761] = Material.DeadBrainCoralBlock; + materials[9762] = Material.DeadBubbleCoralBlock; + materials[9763] = Material.DeadFireCoralBlock; + materials[9764] = Material.DeadHornCoralBlock; + materials[9765] = Material.TubeCoralBlock; + materials[9766] = Material.BrainCoralBlock; + materials[9767] = Material.BubbleCoralBlock; + materials[9768] = Material.FireCoralBlock; + materials[9769] = Material.HornCoralBlock; + for (int i = 9770; i <= 9771; i++) + materials[i] = Material.DeadTubeCoral; + for (int i = 9772; i <= 9773; i++) + materials[i] = Material.DeadBrainCoral; + for (int i = 9774; i <= 9775; i++) + materials[i] = Material.DeadBubbleCoral; + for (int i = 9776; i <= 9777; i++) + materials[i] = Material.DeadFireCoral; + for (int i = 9778; i <= 9779; i++) + materials[i] = Material.DeadHornCoral; + for (int i = 9780; i <= 9781; i++) + materials[i] = Material.TubeCoral; + for (int i = 9782; i <= 9783; i++) + materials[i] = Material.BrainCoral; + for (int i = 9784; i <= 9785; i++) + materials[i] = Material.BubbleCoral; + for (int i = 9786; i <= 9787; i++) + materials[i] = Material.FireCoral; + for (int i = 9788; i <= 9789; i++) + materials[i] = Material.HornCoral; + for (int i = 9790; i <= 9791; i++) + materials[i] = Material.DeadTubeCoralFan; + for (int i = 9792; i <= 9793; i++) + materials[i] = Material.DeadBrainCoralFan; + for (int i = 9794; i <= 9795; i++) + materials[i] = Material.DeadBubbleCoralFan; + for (int i = 9796; i <= 9797; i++) + materials[i] = Material.DeadFireCoralFan; + for (int i = 9798; i <= 9799; i++) + materials[i] = Material.DeadHornCoralFan; + for (int i = 9800; i <= 9801; i++) + materials[i] = Material.TubeCoralFan; + for (int i = 9802; i <= 9803; i++) + materials[i] = Material.BrainCoralFan; + for (int i = 9804; i <= 9805; i++) + materials[i] = Material.BubbleCoralFan; + for (int i = 9806; i <= 9807; i++) + materials[i] = Material.FireCoralFan; + for (int i = 9808; i <= 9809; i++) + materials[i] = Material.HornCoralFan; + for (int i = 9810; i <= 9817; i++) + materials[i] = Material.DeadTubeCoralWallFan; + for (int i = 9818; i <= 9825; i++) + materials[i] = Material.DeadBrainCoralWallFan; + for (int i = 9826; i <= 9833; i++) + materials[i] = Material.DeadBubbleCoralWallFan; + for (int i = 9834; i <= 9841; i++) + materials[i] = Material.DeadFireCoralWallFan; + for (int i = 9842; i <= 9849; i++) + materials[i] = Material.DeadHornCoralWallFan; + for (int i = 9850; i <= 9857; i++) + materials[i] = Material.TubeCoralWallFan; + for (int i = 9858; i <= 9865; i++) + materials[i] = Material.BrainCoralWallFan; + for (int i = 9866; i <= 9873; i++) + materials[i] = Material.BubbleCoralWallFan; + for (int i = 9874; i <= 9881; i++) + materials[i] = Material.FireCoralWallFan; + for (int i = 9882; i <= 9889; i++) + materials[i] = Material.HornCoralWallFan; + for (int i = 9890; i <= 9897; i++) + materials[i] = Material.SeaPickle; + materials[9898] = Material.BlueIce; + for (int i = 9899; i <= 9900; i++) + materials[i] = Material.Conduit; + materials[9901] = Material.BambooSapling; + for (int i = 9902; i <= 9913; i++) + materials[i] = Material.Bamboo; + materials[9914] = Material.PottedBamboo; + materials[9915] = Material.VoidAir; + materials[9916] = Material.CaveAir; + for (int i = 9917; i <= 9918; i++) + materials[i] = Material.BubbleColumn; + for (int i = 9919; i <= 9998; i++) + materials[i] = Material.PolishedGraniteStairs; + for (int i = 9999; i <= 10078; i++) + materials[i] = Material.SmoothRedSandstoneStairs; + for (int i = 10079; i <= 10158; i++) + materials[i] = Material.MossyStoneBrickStairs; + for (int i = 10159; i <= 10238; i++) + materials[i] = Material.PolishedDioriteStairs; + for (int i = 10239; i <= 10318; i++) + materials[i] = Material.MossyCobblestoneStairs; + for (int i = 10319; i <= 10398; i++) + materials[i] = Material.EndStoneBrickStairs; + for (int i = 10399; i <= 10478; i++) + materials[i] = Material.StoneStairs; + for (int i = 10479; i <= 10558; i++) + materials[i] = Material.SmoothSandstoneStairs; + for (int i = 10559; i <= 10638; i++) + materials[i] = Material.SmoothQuartzStairs; + for (int i = 10639; i <= 10718; i++) + materials[i] = Material.GraniteStairs; + for (int i = 10719; i <= 10798; i++) + materials[i] = Material.AndesiteStairs; + for (int i = 10799; i <= 10878; i++) + materials[i] = Material.RedNetherBrickStairs; + for (int i = 10879; i <= 10958; i++) + materials[i] = Material.PolishedAndesiteStairs; + for (int i = 10959; i <= 11038; i++) + materials[i] = Material.DioriteStairs; + for (int i = 11039; i <= 11044; i++) + materials[i] = Material.PolishedGraniteSlab; + for (int i = 11045; i <= 11050; i++) + materials[i] = Material.SmoothRedSandstoneSlab; + for (int i = 11051; i <= 11056; i++) + materials[i] = Material.MossyStoneBrickSlab; + for (int i = 11057; i <= 11062; i++) + materials[i] = Material.PolishedDioriteSlab; + for (int i = 11063; i <= 11068; i++) + materials[i] = Material.MossyCobblestoneSlab; + for (int i = 11069; i <= 11074; i++) + materials[i] = Material.EndStoneBrickSlab; + for (int i = 11075; i <= 11080; i++) + materials[i] = Material.SmoothSandstoneSlab; + for (int i = 11081; i <= 11086; i++) + materials[i] = Material.SmoothQuartzSlab; + for (int i = 11087; i <= 11092; i++) + materials[i] = Material.GraniteSlab; + for (int i = 11093; i <= 11098; i++) + materials[i] = Material.AndesiteSlab; + for (int i = 11099; i <= 11104; i++) + materials[i] = Material.RedNetherBrickSlab; + for (int i = 11105; i <= 11110; i++) + materials[i] = Material.PolishedAndesiteSlab; + for (int i = 11111; i <= 11116; i++) + materials[i] = Material.DioriteSlab; + for (int i = 11117; i <= 11440; i++) + materials[i] = Material.BrickWall; + for (int i = 11441; i <= 11764; i++) + materials[i] = Material.PrismarineWall; + for (int i = 11765; i <= 12088; i++) + materials[i] = Material.RedSandstoneWall; + for (int i = 12089; i <= 12412; i++) + materials[i] = Material.MossyStoneBrickWall; + for (int i = 12413; i <= 12736; i++) + materials[i] = Material.GraniteWall; + for (int i = 12737; i <= 13060; i++) + materials[i] = Material.StoneBrickWall; + for (int i = 13061; i <= 13384; i++) + materials[i] = Material.NetherBrickWall; + for (int i = 13385; i <= 13708; i++) + materials[i] = Material.AndesiteWall; + for (int i = 13709; i <= 14032; i++) + materials[i] = Material.RedNetherBrickWall; + for (int i = 14033; i <= 14356; i++) + materials[i] = Material.SandstoneWall; + for (int i = 14357; i <= 14680; i++) + materials[i] = Material.EndStoneBrickWall; + for (int i = 14681; i <= 15004; i++) + materials[i] = Material.DioriteWall; + for (int i = 15005; i <= 15036; i++) + materials[i] = Material.Scaffolding; + for (int i = 15037; i <= 15040; i++) + materials[i] = Material.Loom; + for (int i = 15041; i <= 15052; i++) + materials[i] = Material.Barrel; + for (int i = 15053; i <= 15060; i++) + materials[i] = Material.Smoker; + for (int i = 15061; i <= 15068; i++) + materials[i] = Material.BlastFurnace; + materials[15069] = Material.CartographyTable; + materials[15070] = Material.FletchingTable; + for (int i = 15071; i <= 15082; i++) + materials[i] = Material.Grindstone; + for (int i = 15083; i <= 15098; i++) + materials[i] = Material.Lectern; + materials[15099] = Material.SmithingTable; + for (int i = 15100; i <= 15103; i++) + materials[i] = Material.Stonecutter; + for (int i = 15104; i <= 15135; i++) + materials[i] = Material.Bell; + for (int i = 15136; i <= 15139; i++) + materials[i] = Material.Lantern; + for (int i = 15140; i <= 15143; i++) + materials[i] = Material.SoulLantern; + for (int i = 15144; i <= 15175; i++) + materials[i] = Material.Campfire; + for (int i = 15176; i <= 15207; i++) + materials[i] = Material.SoulCampfire; + for (int i = 15208; i <= 15211; i++) + materials[i] = Material.SweetBerryBush; + for (int i = 15212; i <= 15214; i++) + materials[i] = Material.WarpedStem; + for (int i = 15215; i <= 15217; i++) + materials[i] = Material.StrippedWarpedStem; + for (int i = 15218; i <= 15220; i++) + materials[i] = Material.WarpedHyphae; + for (int i = 15221; i <= 15223; i++) + materials[i] = Material.StrippedWarpedHyphae; + materials[15224] = Material.WarpedNylium; + materials[15225] = Material.WarpedFungus; + materials[15226] = Material.WarpedWartBlock; + materials[15227] = Material.WarpedRoots; + materials[15228] = Material.NetherSprouts; + for (int i = 15229; i <= 15231; i++) + materials[i] = Material.CrimsonStem; + for (int i = 15232; i <= 15234; i++) + materials[i] = Material.StrippedCrimsonStem; + for (int i = 15235; i <= 15237; i++) + materials[i] = Material.CrimsonHyphae; + for (int i = 15238; i <= 15240; i++) + materials[i] = Material.StrippedCrimsonHyphae; + materials[15241] = Material.CrimsonNylium; + materials[15242] = Material.CrimsonFungus; + materials[15243] = Material.Shroomlight; + for (int i = 15244; i <= 15269; i++) + materials[i] = Material.WeepingVines; + materials[15270] = Material.WeepingVinesPlant; + for (int i = 15271; i <= 15296; i++) + materials[i] = Material.TwistingVines; + materials[15297] = Material.TwistingVinesPlant; + materials[15298] = Material.CrimsonRoots; + materials[15299] = Material.CrimsonPlanks; + materials[15300] = Material.WarpedPlanks; + for (int i = 15301; i <= 15306; i++) + materials[i] = Material.CrimsonSlab; + for (int i = 15307; i <= 15312; i++) + materials[i] = Material.WarpedSlab; + for (int i = 15313; i <= 15314; i++) + materials[i] = Material.CrimsonPressurePlate; + for (int i = 15315; i <= 15316; i++) + materials[i] = Material.WarpedPressurePlate; + for (int i = 15317; i <= 15348; i++) + materials[i] = Material.CrimsonFence; + for (int i = 15349; i <= 15380; i++) + materials[i] = Material.WarpedFence; + for (int i = 15381; i <= 15444; i++) + materials[i] = Material.CrimsonTrapdoor; + for (int i = 15445; i <= 15508; i++) + materials[i] = Material.WarpedTrapdoor; + for (int i = 15509; i <= 15540; i++) + materials[i] = Material.CrimsonFenceGate; + for (int i = 15541; i <= 15572; i++) + materials[i] = Material.WarpedFenceGate; + for (int i = 15573; i <= 15652; i++) + materials[i] = Material.CrimsonStairs; + for (int i = 15653; i <= 15732; i++) + materials[i] = Material.WarpedStairs; + for (int i = 15733; i <= 15756; i++) + materials[i] = Material.CrimsonButton; + for (int i = 15757; i <= 15780; i++) + materials[i] = Material.WarpedButton; + for (int i = 15781; i <= 15844; i++) + materials[i] = Material.CrimsonDoor; + for (int i = 15845; i <= 15908; i++) + materials[i] = Material.WarpedDoor; + for (int i = 15909; i <= 15940; i++) + materials[i] = Material.CrimsonSign; + for (int i = 15941; i <= 15972; i++) + materials[i] = Material.WarpedSign; + for (int i = 15973; i <= 15980; i++) + materials[i] = Material.CrimsonWallSign; + for (int i = 15981; i <= 15988; i++) + materials[i] = Material.WarpedWallSign; + for (int i = 15989; i <= 15992; i++) + materials[i] = Material.StructureBlock; + for (int i = 15993; i <= 16004; i++) + materials[i] = Material.Jigsaw; + for (int i = 16005; i <= 16013; i++) + materials[i] = Material.Composter; + for (int i = 16014; i <= 16029; i++) + materials[i] = Material.Target; + for (int i = 16030; i <= 16053; i++) + materials[i] = Material.BeeNest; + for (int i = 16054; i <= 16077; i++) + materials[i] = Material.Beehive; + materials[16078] = Material.HoneyBlock; + materials[16079] = Material.HoneycombBlock; + materials[16080] = Material.NetheriteBlock; + materials[16081] = Material.AncientDebris; + materials[16082] = Material.CryingObsidian; + for (int i = 16083; i <= 16087; i++) + materials[i] = Material.RespawnAnchor; + materials[16088] = Material.PottedCrimsonFungus; + materials[16089] = Material.PottedWarpedFungus; + materials[16090] = Material.PottedCrimsonRoots; + materials[16091] = Material.PottedWarpedRoots; + materials[16092] = Material.Lodestone; + materials[16093] = Material.Blackstone; + for (int i = 16094; i <= 16173; i++) + materials[i] = Material.BlackstoneStairs; + for (int i = 16174; i <= 16497; i++) + materials[i] = Material.BlackstoneWall; + for (int i = 16498; i <= 16503; i++) + materials[i] = Material.BlackstoneSlab; + materials[16504] = Material.PolishedBlackstone; + materials[16505] = Material.PolishedBlackstoneBricks; + materials[16506] = Material.CrackedPolishedBlackstoneBricks; + materials[16507] = Material.ChiseledPolishedBlackstone; + for (int i = 16508; i <= 16513; i++) + materials[i] = Material.PolishedBlackstoneBrickSlab; + for (int i = 16514; i <= 16593; i++) + materials[i] = Material.PolishedBlackstoneBrickStairs; + for (int i = 16594; i <= 16917; i++) + materials[i] = Material.PolishedBlackstoneBrickWall; + materials[16918] = Material.GildedBlackstone; + for (int i = 16919; i <= 16998; i++) + materials[i] = Material.PolishedBlackstoneStairs; + for (int i = 16999; i <= 17004; i++) + materials[i] = Material.PolishedBlackstoneSlab; + for (int i = 17005; i <= 17006; i++) + materials[i] = Material.PolishedBlackstonePressurePlate; + for (int i = 17007; i <= 17030; i++) + materials[i] = Material.PolishedBlackstoneButton; + for (int i = 17031; i <= 17354; i++) + materials[i] = Material.PolishedBlackstoneWall; + materials[17355] = Material.ChiseledNetherBricks; + materials[17356] = Material.CrackedNetherBricks; + materials[17357] = Material.QuartzBricks; + for (int i = 17358; i <= 17373; i++) + materials[i] = Material.Candle; + for (int i = 17374; i <= 17389; i++) + materials[i] = Material.WhiteCandle; + for (int i = 17390; i <= 17405; i++) + materials[i] = Material.OrangeCandle; + for (int i = 17406; i <= 17421; i++) + materials[i] = Material.MagentaCandle; + for (int i = 17422; i <= 17437; i++) + materials[i] = Material.LightBlueCandle; + for (int i = 17438; i <= 17453; i++) + materials[i] = Material.YellowCandle; + for (int i = 17454; i <= 17469; i++) + materials[i] = Material.LimeCandle; + for (int i = 17470; i <= 17485; i++) + materials[i] = Material.PinkCandle; + for (int i = 17486; i <= 17501; i++) + materials[i] = Material.GrayCandle; + for (int i = 17502; i <= 17517; i++) + materials[i] = Material.LightGrayCandle; + for (int i = 17518; i <= 17533; i++) + materials[i] = Material.CyanCandle; + for (int i = 17534; i <= 17549; i++) + materials[i] = Material.PurpleCandle; + for (int i = 17550; i <= 17565; i++) + materials[i] = Material.BlueCandle; + for (int i = 17566; i <= 17581; i++) + materials[i] = Material.BrownCandle; + for (int i = 17582; i <= 17597; i++) + materials[i] = Material.GreenCandle; + for (int i = 17598; i <= 17613; i++) + materials[i] = Material.RedCandle; + for (int i = 17614; i <= 17629; i++) + materials[i] = Material.BlackCandle; + for (int i = 17630; i <= 17631; i++) + materials[i] = Material.CandleCake; + for (int i = 17632; i <= 17633; i++) + materials[i] = Material.WhiteCandleCake; + for (int i = 17634; i <= 17635; i++) + materials[i] = Material.OrangeCandleCake; + for (int i = 17636; i <= 17637; i++) + materials[i] = Material.MagentaCandleCake; + for (int i = 17638; i <= 17639; i++) + materials[i] = Material.LightBlueCandleCake; + for (int i = 17640; i <= 17641; i++) + materials[i] = Material.YellowCandleCake; + for (int i = 17642; i <= 17643; i++) + materials[i] = Material.LimeCandleCake; + for (int i = 17644; i <= 17645; i++) + materials[i] = Material.PinkCandleCake; + for (int i = 17646; i <= 17647; i++) + materials[i] = Material.GrayCandleCake; + for (int i = 17648; i <= 17649; i++) + materials[i] = Material.LightGrayCandleCake; + for (int i = 17650; i <= 17651; i++) + materials[i] = Material.CyanCandleCake; + for (int i = 17652; i <= 17653; i++) + materials[i] = Material.PurpleCandleCake; + for (int i = 17654; i <= 17655; i++) + materials[i] = Material.BlueCandleCake; + for (int i = 17656; i <= 17657; i++) + materials[i] = Material.BrownCandleCake; + for (int i = 17658; i <= 17659; i++) + materials[i] = Material.GreenCandleCake; + for (int i = 17660; i <= 17661; i++) + materials[i] = Material.RedCandleCake; + for (int i = 17662; i <= 17663; i++) + materials[i] = Material.BlackCandleCake; + materials[17664] = Material.AmethystBlock; + materials[17665] = Material.BuddingAmethyst; + for (int i = 17666; i <= 17677; i++) + materials[i] = Material.AmethystCluster; + for (int i = 17678; i <= 17689; i++) + materials[i] = Material.LargeAmethystBud; + for (int i = 17690; i <= 17701; i++) + materials[i] = Material.MediumAmethystBud; + for (int i = 17702; i <= 17713; i++) + materials[i] = Material.SmallAmethystBud; + materials[17714] = Material.Tuff; + materials[17715] = Material.Calcite; + materials[17716] = Material.TintedGlass; + materials[17717] = Material.PowderSnow; + for (int i = 17718; i <= 17813; i++) + materials[i] = Material.SculkSensor; + materials[17814] = Material.OxidizedCopper; + materials[17815] = Material.WeatheredCopper; + materials[17816] = Material.ExposedCopper; + materials[17817] = Material.CopperBlock; + materials[17818] = Material.CopperOre; + materials[17819] = Material.DeepslateCopperOre; + materials[17820] = Material.OxidizedCutCopper; + materials[17821] = Material.WeatheredCutCopper; + materials[17822] = Material.ExposedCutCopper; + materials[17823] = Material.CutCopper; + for (int i = 17824; i <= 17903; i++) + materials[i] = Material.OxidizedCutCopperStairs; + for (int i = 17904; i <= 17983; i++) + materials[i] = Material.WeatheredCutCopperStairs; + for (int i = 17984; i <= 18063; i++) + materials[i] = Material.ExposedCutCopperStairs; + for (int i = 18064; i <= 18143; i++) + materials[i] = Material.CutCopperStairs; + for (int i = 18144; i <= 18149; i++) + materials[i] = Material.OxidizedCutCopperSlab; + for (int i = 18150; i <= 18155; i++) + materials[i] = Material.WeatheredCutCopperSlab; + for (int i = 18156; i <= 18161; i++) + materials[i] = Material.ExposedCutCopperSlab; + for (int i = 18162; i <= 18167; i++) + materials[i] = Material.CutCopperSlab; + materials[18168] = Material.WaxedCopperBlock; + materials[18169] = Material.WaxedWeatheredCopper; + materials[18170] = Material.WaxedExposedCopper; + materials[18171] = Material.WaxedOxidizedCopper; + materials[18172] = Material.WaxedOxidizedCutCopper; + materials[18173] = Material.WaxedWeatheredCutCopper; + materials[18174] = Material.WaxedExposedCutCopper; + materials[18175] = Material.WaxedCutCopper; + for (int i = 18176; i <= 18255; i++) + materials[i] = Material.WaxedOxidizedCutCopperStairs; + for (int i = 18256; i <= 18335; i++) + materials[i] = Material.WaxedWeatheredCutCopperStairs; + for (int i = 18336; i <= 18415; i++) + materials[i] = Material.WaxedExposedCutCopperStairs; + for (int i = 18416; i <= 18495; i++) + materials[i] = Material.WaxedCutCopperStairs; + for (int i = 18496; i <= 18501; i++) + materials[i] = Material.WaxedOxidizedCutCopperSlab; + for (int i = 18502; i <= 18507; i++) + materials[i] = Material.WaxedWeatheredCutCopperSlab; + for (int i = 18508; i <= 18513; i++) + materials[i] = Material.WaxedExposedCutCopperSlab; + for (int i = 18514; i <= 18519; i++) + materials[i] = Material.WaxedCutCopperSlab; + for (int i = 18520; i <= 18543; i++) + materials[i] = Material.LightningRod; + for (int i = 18544; i <= 18563; i++) + materials[i] = Material.PointedDripstone; + materials[18564] = Material.DripstoneBlock; + for (int i = 18565; i <= 18616; i++) + materials[i] = Material.CaveVines; + for (int i = 18617; i <= 18618; i++) + materials[i] = Material.CaveVinesPlant; + materials[18619] = Material.SporeBlossom; + materials[18620] = Material.Azalea; + materials[18621] = Material.FloweringAzalea; + materials[18622] = Material.MossCarpet; + materials[18623] = Material.MossBlock; + for (int i = 18624; i <= 18655; i++) + materials[i] = Material.BigDripleaf; + for (int i = 18656; i <= 18663; i++) + materials[i] = Material.BigDripleafStem; + for (int i = 18664; i <= 18679; i++) + materials[i] = Material.SmallDripleaf; + for (int i = 18680; i <= 18681; i++) + materials[i] = Material.HangingRoots; + materials[18682] = Material.RootedDirt; + for (int i = 18683; i <= 18685; i++) + materials[i] = Material.Deepslate; + materials[18686] = Material.CobbledDeepslate; + for (int i = 18687; i <= 18766; i++) + materials[i] = Material.CobbledDeepslateStairs; + for (int i = 18767; i <= 18772; i++) + materials[i] = Material.CobbledDeepslateSlab; + for (int i = 18773; i <= 19096; i++) + materials[i] = Material.CobbledDeepslateWall; + materials[19097] = Material.PolishedDeepslate; + for (int i = 19098; i <= 19177; i++) + materials[i] = Material.PolishedDeepslateStairs; + for (int i = 19178; i <= 19183; i++) + materials[i] = Material.PolishedDeepslateSlab; + for (int i = 19184; i <= 19507; i++) + materials[i] = Material.PolishedDeepslateWall; + materials[19508] = Material.DeepslateTiles; + for (int i = 19509; i <= 19588; i++) + materials[i] = Material.DeepslateTileStairs; + for (int i = 19589; i <= 19594; i++) + materials[i] = Material.DeepslateTileSlab; + for (int i = 19595; i <= 19918; i++) + materials[i] = Material.DeepslateTileWall; + materials[19919] = Material.DeepslateBricks; + for (int i = 19920; i <= 19999; i++) + materials[i] = Material.DeepslateBrickStairs; + for (int i = 20000; i <= 20005; i++) + materials[i] = Material.DeepslateBrickSlab; + for (int i = 20006; i <= 20329; i++) + materials[i] = Material.DeepslateBrickWall; + materials[20330] = Material.ChiseledDeepslate; + materials[20331] = Material.CrackedDeepslateBricks; + materials[20332] = Material.CrackedDeepslateTiles; + for (int i = 20333; i <= 20335; i++) + materials[i] = Material.InfestedDeepslate; + materials[20336] = Material.SmoothBasalt; + materials[20337] = Material.RawIronBlock; + materials[20338] = Material.RawCopperBlock; + materials[20339] = Material.RawGoldBlock; + materials[20340] = Material.PottedAzaleaBush; + materials[20341] = Material.PottedFloweringAzaleaBush; + } + + protected override Dictionary GetDict() + { + return materials; + } + } +} diff --git a/MinecraftClient/Mapping/EntityPalettes/EntityPalette117.cs b/MinecraftClient/Mapping/EntityPalettes/EntityPalette117.cs new file mode 100644 index 00000000..65d9272a --- /dev/null +++ b/MinecraftClient/Mapping/EntityPalettes/EntityPalette117.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; + +namespace MinecraftClient.Mapping.EntityPalettes +{ + public class EntityPalette117 : EntityPalette + { + private static Dictionary mappings = new Dictionary(); + + static EntityPalette117() + { + mappings[0] = EntityType.AreaEffectCloud; + mappings[1] = EntityType.ArmorStand; + mappings[2] = EntityType.Arrow; + mappings[3] = EntityType.Axolotl; + mappings[4] = EntityType.Bat; + mappings[5] = EntityType.Bee; + mappings[6] = EntityType.Blaze; + mappings[7] = EntityType.Boat; + mappings[8] = EntityType.Cat; + mappings[9] = EntityType.CaveSpider; + mappings[10] = EntityType.Chicken; + mappings[11] = EntityType.Cod; + mappings[12] = EntityType.Cow; + mappings[13] = EntityType.Creeper; + mappings[14] = EntityType.Dolphin; + mappings[15] = EntityType.Donkey; + mappings[16] = EntityType.DragonFireball; + mappings[17] = EntityType.Drowned; + mappings[18] = EntityType.ElderGuardian; + mappings[19] = EntityType.EndCrystal; + mappings[20] = EntityType.EnderDragon; + mappings[21] = EntityType.Enderman; + mappings[22] = EntityType.Endermite; + mappings[23] = EntityType.Evoker; + mappings[24] = EntityType.EvokerFangs; + mappings[25] = EntityType.ExperienceOrb; + mappings[26] = EntityType.EyeOfEnder; + mappings[27] = EntityType.FallingBlock; + mappings[28] = EntityType.FireworkRocket; + mappings[29] = EntityType.Fox; + mappings[30] = EntityType.Ghast; + mappings[31] = EntityType.Giant; + mappings[32] = EntityType.GlowItemFrame; + mappings[33] = EntityType.GlowSquid; + mappings[34] = EntityType.Goat; + mappings[35] = EntityType.Guardian; + mappings[36] = EntityType.Hoglin; + mappings[37] = EntityType.Horse; + mappings[38] = EntityType.Husk; + mappings[39] = EntityType.Illusioner; + mappings[40] = EntityType.IronGolem; + mappings[41] = EntityType.Item; + mappings[42] = EntityType.ItemFrame; + mappings[43] = EntityType.Fireball; + mappings[44] = EntityType.LeashKnot; + mappings[45] = EntityType.LightningBolt; + mappings[46] = EntityType.Llama; + mappings[47] = EntityType.LlamaSpit; + mappings[48] = EntityType.MagmaCube; + mappings[49] = EntityType.Marker; + mappings[50] = EntityType.Minecart; + mappings[51] = EntityType.ChestMinecart; + mappings[52] = EntityType.CommandBlockMinecart; + mappings[53] = EntityType.FurnaceMinecart; + mappings[54] = EntityType.HopperMinecart; + mappings[55] = EntityType.SpawnerMinecart; + mappings[56] = EntityType.TntMinecart; + mappings[57] = EntityType.Mule; + mappings[58] = EntityType.Mooshroom; + mappings[59] = EntityType.Ocelot; + mappings[60] = EntityType.Painting; + mappings[61] = EntityType.Panda; + mappings[62] = EntityType.Parrot; + mappings[63] = EntityType.Phantom; + mappings[64] = EntityType.Pig; + mappings[65] = EntityType.Piglin; + mappings[66] = EntityType.PiglinBrute; + mappings[67] = EntityType.Pillager; + mappings[68] = EntityType.PolarBear; + mappings[69] = EntityType.Tnt; + mappings[70] = EntityType.Pufferfish; + mappings[71] = EntityType.Rabbit; + mappings[72] = EntityType.Ravager; + mappings[73] = EntityType.Salmon; + mappings[74] = EntityType.Sheep; + mappings[75] = EntityType.Shulker; + mappings[76] = EntityType.ShulkerBullet; + mappings[77] = EntityType.Silverfish; + mappings[78] = EntityType.Skeleton; + mappings[79] = EntityType.SkeletonHorse; + mappings[80] = EntityType.Slime; + mappings[81] = EntityType.SmallFireball; + mappings[82] = EntityType.SnowGolem; + mappings[83] = EntityType.Snowball; + mappings[84] = EntityType.SpectralArrow; + mappings[85] = EntityType.Spider; + mappings[86] = EntityType.Squid; + mappings[87] = EntityType.Stray; + mappings[88] = EntityType.Strider; + mappings[89] = EntityType.Egg; + mappings[90] = EntityType.EnderPearl; + mappings[91] = EntityType.ExperienceBottle; + mappings[92] = EntityType.Potion; + mappings[93] = EntityType.Trident; + mappings[94] = EntityType.TraderLlama; + mappings[95] = EntityType.TropicalFish; + mappings[96] = EntityType.Turtle; + mappings[97] = EntityType.Vex; + mappings[98] = EntityType.Villager; + mappings[99] = EntityType.Vindicator; + mappings[100] = EntityType.WanderingTrader; + mappings[101] = EntityType.Witch; + mappings[102] = EntityType.Wither; + mappings[103] = EntityType.WitherSkeleton; + mappings[104] = EntityType.WitherSkull; + mappings[105] = EntityType.Wolf; + mappings[106] = EntityType.Zoglin; + mappings[107] = EntityType.Zombie; + mappings[108] = EntityType.ZombieHorse; + mappings[109] = EntityType.ZombieVillager; + mappings[110] = EntityType.ZombifiedPiglin; + mappings[111] = EntityType.Player; + mappings[112] = EntityType.FishingBobber; + } + + protected override Dictionary GetDict() + { + return mappings; + } + } +} diff --git a/MinecraftClient/Mapping/EntityType.cs b/MinecraftClient/Mapping/EntityType.cs index b2d62b55..8f7678f1 100644 --- a/MinecraftClient/Mapping/EntityType.cs +++ b/MinecraftClient/Mapping/EntityType.cs @@ -17,59 +17,62 @@ namespace MinecraftClient.Mapping AreaEffectCloud, ArmorStand, Arrow, + Axolotl, Bat, Bee, Blaze, Boat, Cat, CaveSpider, - ChestMinecart, Chicken, Cod, - CommandBlockMinecart, Cow, Creeper, Dolphin, Donkey, DragonFireball, Drowned, - Egg, ElderGuardian, EndCrystal, EnderDragon, Enderman, Endermite, - EnderPearl, Evoker, EvokerFangs, - ExperienceBottle, ExperienceOrb, EyeOfEnder, FallingBlock, - Fireball, FireworkRocket, - FishingBobber, Fox, - FurnaceMinecart, Ghast, Giant, + GlowItemFrame, + GlowSquid, + Goat, Guardian, Hoglin, - HopperMinecart, Horse, Husk, Illusioner, IronGolem, Item, ItemFrame, + Fireball, LeashKnot, LightningBolt, Llama, LlamaSpit, MagmaCube, + Marker, Minecart, - Mooshroom, + ChestMinecart, + CommandBlockMinecart, + FurnaceMinecart, + HopperMinecart, + SpawnerMinecart, + TntMinecart, Mule, + Mooshroom, Ocelot, Painting, Panda, @@ -79,9 +82,8 @@ namespace MinecraftClient.Mapping Piglin, PiglinBrute, Pillager, - Player, PolarBear, - Potion, + Tnt, Pufferfish, Rabbit, Ravager, @@ -94,18 +96,19 @@ namespace MinecraftClient.Mapping SkeletonHorse, Slime, SmallFireball, - Snowball, SnowGolem, - SpawnerMinecart, + Snowball, SpectralArrow, Spider, Squid, Stray, Strider, - Tnt, - TntMinecart, - TraderLlama, + Egg, + EnderPearl, + ExperienceBottle, + Potion, Trident, + TraderLlama, TropicalFish, Turtle, Vex, @@ -122,5 +125,7 @@ namespace MinecraftClient.Mapping ZombieHorse, ZombieVillager, ZombifiedPiglin, + Player, + FishingBobber, } } diff --git a/MinecraftClient/Mapping/EntityTypeExtensions.cs b/MinecraftClient/Mapping/EntityTypeExtensions.cs index 6e3029dd..a467b3ad 100644 --- a/MinecraftClient/Mapping/EntityTypeExtensions.cs +++ b/MinecraftClient/Mapping/EntityTypeExtensions.cs @@ -62,6 +62,7 @@ namespace MinecraftClient.Mapping { switch (e) { + case EntityType.GlowItemFrame: case EntityType.Item: case EntityType.ItemFrame: case EntityType.EyeOfEnder: diff --git a/MinecraftClient/Mapping/Material.cs b/MinecraftClient/Mapping/Material.cs index f695a6e4..99c51a5b 100644 --- a/MinecraftClient/Mapping/Material.cs +++ b/MinecraftClient/Mapping/Material.cs @@ -46,8 +46,11 @@ RedSand, Gravel, GoldOre, + DeepslateGoldOre, IronOre, + DeepslateIronOre, CoalOre, + DeepslateCoalOre, NetherGoldOre, OakLog, SpruceLog, @@ -79,10 +82,13 @@ JungleLeaves, AcaciaLeaves, DarkOakLeaves, + AzaleaLeaves, + FloweringAzaleaLeaves, Sponge, WetSponge, Glass, LapisOre, + DeepslateLapisOre, LapisBlock, Dispenser, Sandstone, @@ -164,6 +170,7 @@ Chest, RedstoneWire, DiamondOre, + DeepslateDiamondOre, DiamondBlock, CraftingTable, Wheat, @@ -195,6 +202,7 @@ AcaciaPressurePlate, DarkOakPressurePlate, RedstoneOre, + DeepslateRedstoneOre, RedstoneTorch, RedstoneWallTorch, StoneButton, @@ -264,6 +272,7 @@ PumpkinStem, MelonStem, Vine, + GlowLichen, OakFenceGate, BrickStairs, StoneBrickStairs, @@ -276,6 +285,9 @@ EnchantingTable, BrewingStand, Cauldron, + WaterCauldron, + LavaCauldron, + PowderSnowCauldron, EndPortal, EndPortalFrame, EndStone, @@ -284,6 +296,7 @@ Cocoa, SandstoneStairs, EmeraldOre, + DeepslateEmeraldOre, EnderChest, TripwireHook, Tripwire, @@ -393,6 +406,7 @@ DarkOakStairs, SlimeBlock, Barrier, + Light, IronTrapdoor, Prismarine, PrismarineBricks, @@ -777,5 +791,126 @@ ChiseledNetherBricks, CrackedNetherBricks, QuartzBricks, + Candle, + WhiteCandle, + OrangeCandle, + MagentaCandle, + LightBlueCandle, + YellowCandle, + LimeCandle, + PinkCandle, + GrayCandle, + LightGrayCandle, + CyanCandle, + PurpleCandle, + BlueCandle, + BrownCandle, + GreenCandle, + RedCandle, + BlackCandle, + CandleCake, + WhiteCandleCake, + OrangeCandleCake, + MagentaCandleCake, + LightBlueCandleCake, + YellowCandleCake, + LimeCandleCake, + PinkCandleCake, + GrayCandleCake, + LightGrayCandleCake, + CyanCandleCake, + PurpleCandleCake, + BlueCandleCake, + BrownCandleCake, + GreenCandleCake, + RedCandleCake, + BlackCandleCake, + AmethystBlock, + BuddingAmethyst, + AmethystCluster, + LargeAmethystBud, + MediumAmethystBud, + SmallAmethystBud, + Tuff, + Calcite, + TintedGlass, + PowderSnow, + SculkSensor, + OxidizedCopper, + WeatheredCopper, + ExposedCopper, + CopperBlock, + CopperOre, + DeepslateCopperOre, + OxidizedCutCopper, + WeatheredCutCopper, + ExposedCutCopper, + CutCopper, + OxidizedCutCopperStairs, + WeatheredCutCopperStairs, + ExposedCutCopperStairs, + CutCopperStairs, + OxidizedCutCopperSlab, + WeatheredCutCopperSlab, + ExposedCutCopperSlab, + CutCopperSlab, + WaxedCopperBlock, + WaxedWeatheredCopper, + WaxedExposedCopper, + WaxedOxidizedCopper, + WaxedOxidizedCutCopper, + WaxedWeatheredCutCopper, + WaxedExposedCutCopper, + WaxedCutCopper, + WaxedOxidizedCutCopperStairs, + WaxedWeatheredCutCopperStairs, + WaxedExposedCutCopperStairs, + WaxedCutCopperStairs, + WaxedOxidizedCutCopperSlab, + WaxedWeatheredCutCopperSlab, + WaxedExposedCutCopperSlab, + WaxedCutCopperSlab, + LightningRod, + PointedDripstone, + DripstoneBlock, + CaveVines, + CaveVinesPlant, + SporeBlossom, + Azalea, + FloweringAzalea, + MossCarpet, + MossBlock, + BigDripleaf, + BigDripleafStem, + SmallDripleaf, + HangingRoots, + RootedDirt, + Deepslate, + CobbledDeepslate, + CobbledDeepslateStairs, + CobbledDeepslateSlab, + CobbledDeepslateWall, + PolishedDeepslate, + PolishedDeepslateStairs, + PolishedDeepslateSlab, + PolishedDeepslateWall, + DeepslateTiles, + DeepslateTileStairs, + DeepslateTileSlab, + DeepslateTileWall, + DeepslateBricks, + DeepslateBrickStairs, + DeepslateBrickSlab, + DeepslateBrickWall, + ChiseledDeepslate, + CrackedDeepslateBricks, + CrackedDeepslateTiles, + InfestedDeepslate, + SmoothBasalt, + RawIronBlock, + RawCopperBlock, + RawGoldBlock, + PottedAzaleaBush, + PottedFloweringAzaleaBush, } } diff --git a/MinecraftClient/Mapping/Material2Tool.cs b/MinecraftClient/Mapping/Material2Tool.cs index 0a3fe8db..6ab60c17 100644 --- a/MinecraftClient/Mapping/Material2Tool.cs +++ b/MinecraftClient/Mapping/Material2Tool.cs @@ -43,8 +43,13 @@ namespace MinecraftClient.Mapping Material.BrownShulkerBox, Material.BrownTerracotta, Material.Cauldron, + Material.WaterCauldron, + Material.LavaCauldron, + Material.PowderSnowCauldron, Material.Chain, + Material.Calcite, Material.ChippedAnvil, + Material.ChiseledDeepslate, Material.ChiseledNetherBricks, Material.ChiseledPolishedBlackstone, Material.ChiseledQuartzBlock, @@ -53,11 +58,17 @@ namespace MinecraftClient.Mapping Material.ChiseledStoneBricks, Material.CoalBlock, Material.CoalOre, + Material.CobbledDeepslateSlab, + Material.CobbledDeepslateStairs, + Material.CobbledDeepslateWall, + Material.CobbledDeepslate, Material.Cobblestone, Material.CobblestoneSlab, Material.CobblestoneStairs, Material.CobblestoneWall, Material.Conduit, + Material.CrackedDeepslateBricks, + Material.CrackedDeepslateTiles, Material.CrackedNetherBricks, Material.CrackedPolishedBlackstoneBricks, Material.CrackedStoneBricks, @@ -74,11 +85,22 @@ namespace MinecraftClient.Mapping Material.DarkPrismarine, Material.DarkPrismarineSlab, Material.DarkPrismarineStairs, + Material.Deepslate, + Material.DeepslateBrickSlab, + Material.DeepslateBrickStairs, + Material.DeepslateBricks, + Material.DeepslateBrickWall, + Material.DeepslateCoalOre, + Material.DeepslateTileSlab, + Material.DeepslateTileStairs, + Material.DeepslateTiles, + Material.DeepslateTileWall, Material.DetectorRail, Material.Diorite, Material.DioriteSlab, Material.DioriteStairs, Material.DioriteWall, + Material.DripstoneBlock, Material.Dispenser, Material.Dropper, Material.EnchantingTable, @@ -160,6 +182,7 @@ namespace MinecraftClient.Mapping Material.PinkShulkerBox, Material.PinkTerracotta, Material.Piston, + Material.PointedDripstone, Material.PolishedAndesite, Material.PolishedAndesiteSlab, Material.PolishedAndesiteStairs, @@ -221,6 +244,7 @@ namespace MinecraftClient.Mapping Material.SandstoneWall, Material.ShulkerBox, Material.Smoker, + Material.SmoothBasalt, Material.SmoothQuartz, Material.SmoothQuartzSlab, Material.SmoothQuartzStairs, @@ -245,6 +269,7 @@ namespace MinecraftClient.Mapping Material.StoneStairs, Material.Stonecutter, Material.Terracotta, + Material.Tuff, Material.WarpedNylium, Material.WhiteConcrete, Material.WhiteGlazedTerracotta, @@ -253,26 +278,70 @@ namespace MinecraftClient.Mapping Material.YellowConcrete, Material.YellowGlazedTerracotta, Material.YellowShulkerBox, - Material.YellowTerracotta + Material.YellowTerracotta, }; // Minable by Stone, iron, diamond, netherite. private static readonly List pickaxeTier1 = new List() { + Material.CopperOre, + Material.CopperBlock, + Material.CutCopperSlab, + Material.CutCopperStairs, + Material.CutCopper, + Material.DeepslateCopperOre, + Material.DeepslateIronOre, + Material.DeepslateLapisOre, + Material.ExposedCopper, + Material.ExposedCutCopperSlab, + Material.ExposedCutCopperStairs, + Material.ExposedCutCopper, Material.IronBlock, Material.IronOre, Material.LapisBlock, Material.LapisOre, + Material.LightningRod, + Material.OxidizedCopper, + Material.OxidizedCutCopperSlab, + Material.OxidizedCutCopperStairs, + Material.OxidizedCutCopper, + Material.RawCopperBlock, + Material.RawIronBlock, Material.Terracotta, + Material.WaxedCopperBlock, + Material.WaxedCutCopperSlab, + Material.WaxedCutCopperStairs, + Material.WaxedCutCopper, + Material.WaxedExposedCopper, + Material.WaxedExposedCutCopperSlab, + Material.WaxedExposedCutCopperStairs, + Material.WaxedExposedCutCopper, + Material.WaxedOxidizedCopper, + Material.WaxedOxidizedCutCopperSlab, + Material.WaxedOxidizedCutCopperStairs, + Material.WaxedOxidizedCutCopper, + Material.WaxedWeatheredCopper, + Material.WaxedWeatheredCutCopperSlab, + Material.WaxedWeatheredCutCopperStairs, + Material.WaxedWeatheredCutCopper, + Material.WeatheredCopper, + Material.WeatheredCutCopperSlab, + Material.WeatheredCutCopperStairs, + Material.WeatheredCutCopper, }; // Minable by Iron, diamond, netherite. private static readonly List pickaxeTier2 = new List() { + Material.DeepslateDiamondOre, + Material.DeepslateEmeraldOre, + Material.DeepslateGoldOre, + Material.DeepslateRedstoneOre, Material.DiamondBlock, Material.DiamondOre, Material.EmeraldBlock, Material.EmeraldOre, Material.GoldBlock, Material.GoldOre, + Material.RawGoldBlock, Material.RedstoneOre, }; // Minable by Diamond, Netherite. @@ -314,13 +383,14 @@ namespace MinecraftClient.Mapping Material.PurpleConcretePowder, Material.RedConcretePowder, Material.RedSand, + Material.RootedDirt, Material.Sand, Material.Snow, Material.SnowBlock, Material.SoulSand, Material.SoulSoil, Material.WhiteConcretePowder, - Material.YellowConcretePowder + Material.YellowConcretePowder, }; // Every axe can mine every block (speed difference). private static readonly List axe = new List() @@ -341,6 +411,7 @@ namespace MinecraftClient.Mapping Material.Barrel, Material.BeeNest, Material.Beehive, + Material.BigDripleaf, Material.BirchButton, Material.BirchDoor, Material.BirchFence, @@ -504,12 +575,13 @@ namespace MinecraftClient.Mapping Material.WhiteBanner, Material.WhiteWallBanner, Material.YellowBanner, - Material.YellowWallBanner + Material.YellowWallBanner, }; // Every block a shear can mine. private static readonly List shears = new List() { Material.AcaciaLeaves, + Material.AzaleaLeaves, Material.BirchLeaves, Material.BlackWool, Material.BlueWool, @@ -517,6 +589,7 @@ namespace MinecraftClient.Mapping Material.Cobweb, Material.CyanWool, Material.DarkOakLeaves, + Material.FloweringAzaleaLeaves, Material.GrayWool, Material.GreenWool, Material.JungleLeaves, @@ -539,6 +612,7 @@ namespace MinecraftClient.Mapping Material.Bamboo, Material.Cobweb, Material.InfestedChiseledStoneBricks, + Material.InfestedDeepslate, Material.InfestedCobblestone, Material.InfestedCrackedStoneBricks, Material.InfestedMossyStoneBricks, @@ -553,8 +627,10 @@ namespace MinecraftClient.Mapping Material.DarkOakLeaves, Material.HayBlock, Material.JungleLeaves, + Material.MossBlock, Material.NetherWartBlock, Material.OakLeaves, + Material.SculkSensor, Material.Shroomlight, Material.Sponge, Material.SpruceLeaves, diff --git a/MinecraftClient/Mapping/MaterialExtensions.cs b/MinecraftClient/Mapping/MaterialExtensions.cs index 166a090b..391097f6 100644 --- a/MinecraftClient/Mapping/MaterialExtensions.cs +++ b/MinecraftClient/Mapping/MaterialExtensions.cs @@ -74,6 +74,8 @@ namespace MinecraftClient.Mapping case Material.JungleLeaves: case Material.AcaciaLeaves: case Material.DarkOakLeaves: + case Material.AzaleaLeaves: + case Material.FloweringAzaleaLeaves: case Material.Sponge: case Material.WetSponge: case Material.Glass: @@ -202,6 +204,9 @@ namespace MinecraftClient.Mapping case Material.EnchantingTable: case Material.BrewingStand: case Material.Cauldron: + case Material.WaterCauldron: + case Material.LavaCauldron: + case Material.PowderSnowCauldron: case Material.EndPortalFrame: case Material.EndStone: case Material.DragonEgg: @@ -518,6 +523,119 @@ namespace MinecraftClient.Mapping case Material.Beehive: case Material.HoneyBlock: case Material.HoneycombBlock: + case Material.Candle: + case Material.WhiteCandle: + case Material.OrangeCandle: + case Material.MagentaCandle: + case Material.LightBlueCandle: + case Material.YellowCandle: + case Material.LimeCandle: + case Material.PinkCandle: + case Material.GrayCandle: + case Material.LightGrayCandle: + case Material.CyanCandle: + case Material.PurpleCandle: + case Material.BlueCandle: + case Material.BrownCandle: + case Material.GreenCandle: + case Material.RedCandle: + case Material.BlackCandle: + case Material.CandleCake: + case Material.WhiteCandleCake: + case Material.OrangeCandleCake: + case Material.MagentaCandleCake: + case Material.LightBlueCandleCake: + case Material.YellowCandleCake: + case Material.LimeCandleCake: + case Material.PinkCandleCake: + case Material.GrayCandleCake: + case Material.LightGrayCandleCake: + case Material.CyanCandleCake: + case Material.PurpleCandleCake: + case Material.BlueCandleCake: + case Material.BrownCandleCake: + case Material.GreenCandleCake: + case Material.RedCandleCake: + case Material.BlackCandleCake: + case Material.AmethystBlock: + case Material.BuddingAmethyst: + case Material.AmethystCluster: + case Material.LargeAmethystBud: + case Material.MediumAmethystBud: + case Material.SmallAmethystBud: + case Material.Tuff: + case Material.Calcite: + case Material.TintedGlass: + case Material.SculkSensor: + case Material.OxidizedCopper: + case Material.WeatheredCopper: + case Material.ExposedCopper: + case Material.CopperBlock: + case Material.CopperOre: + case Material.DeepslateCopperOre: + case Material.OxidizedCutCopper: + case Material.WeatheredCutCopper: + case Material.ExposedCutCopper: + case Material.CutCopper: + case Material.OxidizedCutCopperStairs: + case Material.WeatheredCutCopperStairs: + case Material.ExposedCutCopperStairs: + case Material.CutCopperStairs: + case Material.OxidizedCutCopperSlab: + case Material.WeatheredCutCopperSlab: + case Material.ExposedCutCopperSlab: + case Material.CutCopperSlab: + case Material.WaxedCopperBlock: + case Material.WaxedWeatheredCopper: + case Material.WaxedExposedCopper: + case Material.WaxedOxidizedCopper: + case Material.WaxedOxidizedCutCopper: + case Material.WaxedWeatheredCutCopper: + case Material.WaxedExposedCutCopper: + case Material.WaxedCutCopper: + case Material.WaxedOxidizedCutCopperStairs: + case Material.WaxedWeatheredCutCopperStairs: + case Material.WaxedExposedCutCopperStairs: + case Material.WaxedCutCopperStairs: + case Material.WaxedOxidizedCutCopperSlab: + case Material.WaxedWeatheredCutCopperSlab: + case Material.WaxedExposedCutCopperSlab: + case Material.WaxedCutCopperSlab: + case Material.LightningRod: + case Material.PointedDripstone: + case Material.DripstoneBlock: + case Material.Azalea: + case Material.FloweringAzalea: + case Material.MossCarpet: + case Material.MossBlock: + case Material.RootedDirt: + case Material.Deepslate: + case Material.CobbledDeepslate: + case Material.CobbledDeepslateStairs: + case Material.CobbledDeepslateSlab: + case Material.CobbledDeepslateWall: + case Material.PolishedDeepslate: + case Material.PolishedDeepslateStairs: + case Material.PolishedDeepslateSlab: + case Material.PolishedDeepslateWall: + case Material.DeepslateTiles: + case Material.DeepslateTileStairs: + case Material.DeepslateTileSlab: + case Material.DeepslateTileWall: + case Material.DeepslateBricks: + case Material.DeepslateBrickStairs: + case Material.DeepslateBrickSlab: + case Material.DeepslateBrickWall: + case Material.ChiseledDeepslate: + case Material.CrackedDeepslateBricks: + case Material.CrackedDeepslateTiles: + case Material.InfestedDeepslate: + case Material.SmoothBasalt: + case Material.RawIronBlock: + case Material.RawCopperBlock: + case Material.RawGoldBlock: + case Material.PottedAzaleaBush: + case Material.PottedFloweringAzaleaBush: return true; default: return false; @@ -538,6 +656,7 @@ namespace MinecraftClient.Mapping case Material.Lava: case Material.MagmaBlock: case Material.Campfire: + case Material.PowderSnow: return true; default: return false; diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 814f71c9..d104601e 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -140,6 +140,8 @@ + + @@ -152,6 +154,7 @@ + @@ -162,6 +165,7 @@ + diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index 12626569..f2de846c 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; @@ -7,6 +8,9 @@ using System.Reflection; using System.Threading; using MinecraftClient.Protocol.Handlers.Forge; using MinecraftClient.Protocol.Session; +using MinecraftClient.Mapping.EntityPalettes; +using MinecraftClient.Mapping.BlockPalettes; +using MinecraftClient.Inventory.ItemPalettes; using MinecraftClient.WinAPI; namespace MinecraftClient @@ -109,6 +113,80 @@ namespace MinecraftClient return; } + if (args.Contains("--generate")) + { + string dataGenerator = ""; + string dataPath = ""; + + foreach (string argument in args) + { + if (argument.StartsWith("--") && !argument.Contains("--generate")) + { + if (!argument.Contains("=")) + throw new ArgumentException(Translations.Get("error.setting.argument_syntax", argument)); + + string[] argParts = argument.Substring(2).Split('='); + string argName = argParts[0].Trim(); + string argValue = argParts[1].Replace("\"", "").Trim(); + + if(argName == "data-path") { + Console.WriteLine(dataPath); + dataPath = argValue; + } + + if(argName == "data-generator") { + dataGenerator = argValue; + } + } + } + + if (string.IsNullOrEmpty(dataGenerator) || !(dataGenerator.ToLower().Equals("entity") || dataGenerator.ToLower().Equals("item") || dataGenerator.ToLower().Equals("block"))) + { + Console.WriteLine(Translations.Get("error.generator.invalid")); + Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --data-generator="); + return; + } + + if (string.IsNullOrEmpty(dataPath)) + { + Console.WriteLine(Translations.Get("error.missing.argument", "--data-path")); + Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --generate-entity-pallete --data-path=\"\""); + return; + } + + if(!File.Exists(dataPath)) + { + Console.WriteLine(Translations.Get("error.generator.path", dataPath)); + return; + } + + if(!dataPath.EndsWith(".json")) + { + Console.WriteLine(Translations.Get("error.generator.json", dataPath)); + return; + } + + Console.WriteLine(Translations.Get("mcc.generator.generating", dataGenerator, dataPath)); + + switch (dataGenerator) + { + case "entity": + EntityPaletteGenerator.GenerateEntityTypes(dataPath); + break; + + case "item": + ItemPaletteGenerator.GenerateItemType(dataPath); + break; + + case "block": + BlockPaletteGenerator.GenerateBlockPallete(dataPath); + break; + } + + Console.WriteLine(Translations.Get("mcc.generator.done", dataGenerator, dataPath)); + return; + } + try { Settings.LoadArguments(args); diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 5df75536..39805911 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -87,19 +87,19 @@ namespace MinecraftClient.Protocol.Handlers this.packetPalette = new PacketTypeHandler(protocolVersion, forgeInfo != null).GetTypeHandler(); this.log = handler.GetLogger(); - if (handler.GetTerrainEnabled() && protocolversion > MC1165Version) + if (handler.GetTerrainEnabled() && protocolversion > MC1181Version) { log.Error(Translations.Get("extra.terrainandmovement_disabled")); handler.SetTerrainEnabled(false); } - if (handler.GetInventoryEnabled() && (protocolversion < MC110Version || protocolversion > MC1165Version)) + if (handler.GetInventoryEnabled() && (protocolversion < MC110Version || protocolversion > MC1181Version)) { log.Error(Translations.Get("extra.inventory_disabled")); handler.SetInventoryEnabled(false); } - if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1165Version)) + if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1181Version)) { log.Error(Translations.Get("extra.entity_disabled")); handler.SetEntityHandlingEnabled(false); @@ -108,9 +108,11 @@ namespace MinecraftClient.Protocol.Handlers // Block palette if (protocolversion >= MC113Version) { - if (protocolVersion > MC1165Version && handler.GetTerrainEnabled()) + if (protocolVersion > MC1181Version && handler.GetTerrainEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.block")); - if (protocolVersion >= MC116Version) + if (protocolVersion == MC1181Version) + Block.Palette = new Palette117(); + else if (protocolVersion >= MC116Version) Block.Palette = new Palette116(); else if (protocolVersion >= MC115Version) Block.Palette = new Palette115(); @@ -123,9 +125,11 @@ namespace MinecraftClient.Protocol.Handlers // Entity palette if (protocolversion >= MC113Version) { - if (protocolversion > MC1165Version && handler.GetEntityHandlingEnabled()) + if (protocolversion > MC1181Version && handler.GetEntityHandlingEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.entity")); - if (protocolversion >= MC1162Version) + if (protocolversion >= MC117Version) + entityPalette = new EntityPalette117(); + else if (protocolversion >= MC1162Version) entityPalette = new EntityPalette1162(); else if (protocolversion >= MC116Version) entityPalette = new EntityPalette1161(); @@ -138,11 +142,15 @@ namespace MinecraftClient.Protocol.Handlers else entityPalette = new EntityPalette112(); // Item palette - if (protocolversion >= MC116Version) + if (protocolversion >= MC1162Version) { - if (protocolversion > MC1165Version && handler.GetInventoryEnabled()) + if (protocolversion > MC1181Version && handler.GetInventoryEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.item")); - if (protocolversion >= MC1162Version) + if (protocolversion == MC1181Version) + itemPalette = new ItemPalette118(); + else if (protocolversion >= MC117Version) + itemPalette = new ItemPalette117(); + else if (protocolversion >= MC1162Version) itemPalette = new ItemPalette1162(); else itemPalette = new ItemPalette1161(); } @@ -212,6 +220,7 @@ namespace MinecraftClient.Protocol.Handlers packetData.Clear(); int size = dataTypes.ReadNextVarIntRAW(socketWrapper); //Packet size byte[] rawpacket = socketWrapper.ReadDataRAW(size); //Packet contents + for (int i = 0; i < rawpacket.Length; i++) packetData.Enqueue(rawpacket[i]); @@ -824,7 +833,8 @@ namespace MinecraftClient.Protocol.Handlers if (handler.GetInventoryEnabled()) { byte windowId = dataTypes.ReadNextByte(packetData); - short elements = dataTypes.ReadNextShort(packetData); + int stateId = dataTypes.ReadNextVarInt(packetData); + int elements = dataTypes.ReadNextVarInt(packetData); Dictionary inventorySlots = new Dictionary(); for (short slotId = 0; slotId < elements; slotId++) { @@ -839,6 +849,7 @@ namespace MinecraftClient.Protocol.Handlers if (handler.GetInventoryEnabled()) { byte windowID = dataTypes.ReadNextByte(packetData); + int stateId = dataTypes.ReadNextVarInt(packetData); short slotID = dataTypes.ReadNextShort(packetData); Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); handler.OnSetSlot(windowID, slotID, item); From a5848f637b5c05eb7116055ca59ebf940c60ef89 Mon Sep 17 00:00:00 2001 From: Dusan Milutinovic Date: Sun, 13 Feb 2022 15:00:32 +0100 Subject: [PATCH 02/26] Fixed a crash on older versions --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 39805911..a4bb1b93 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -833,7 +833,12 @@ namespace MinecraftClient.Protocol.Handlers if (handler.GetInventoryEnabled()) { byte windowId = dataTypes.ReadNextByte(packetData); - int stateId = dataTypes.ReadNextVarInt(packetData); + + int stateId = -1; + + if(protocolversion >= MC1181Version) + stateId = dataTypes.ReadNextVarInt(packetData); + int elements = dataTypes.ReadNextVarInt(packetData); Dictionary inventorySlots = new Dictionary(); for (short slotId = 0; slotId < elements; slotId++) @@ -849,7 +854,12 @@ namespace MinecraftClient.Protocol.Handlers if (handler.GetInventoryEnabled()) { byte windowID = dataTypes.ReadNextByte(packetData); - int stateId = dataTypes.ReadNextVarInt(packetData); + + int stateId = -1; + + if(protocolversion >= MC1181Version) + stateId = dataTypes.ReadNextVarInt(packetData); + short slotID = dataTypes.ReadNextShort(packetData); Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); handler.OnSetSlot(windowID, slotID, item); From 9d3357eeee1cceef7968d6769d333b0b79d394ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Tue, 28 Jun 2022 13:45:23 +0200 Subject: [PATCH 03/26] Fixed requested changes in the review. Except: Container (TODO) --- MinecraftClient/Inventory/ItemType.cs | 2 +- .../BlockPalettes/BlockPaletteGenerator.cs | 2 +- MinecraftClient/Mapping/EntityType.cs | 34 +- MinecraftClient/Mapping/Material.cs | 1760 ++++++++--------- MinecraftClient/Mapping/Material2Tool.cs | 40 +- MinecraftClient/Program.cs | 36 +- .../Protocol/Handlers/Protocol18.cs | 1726 ++++++++-------- MinecraftClient/Resources/lang/en.ini | 8 +- 8 files changed, 1809 insertions(+), 1799 deletions(-) diff --git a/MinecraftClient/Inventory/ItemType.cs b/MinecraftClient/Inventory/ItemType.cs index abb8ce58..062e93e3 100644 --- a/MinecraftClient/Inventory/ItemType.cs +++ b/MinecraftClient/Inventory/ItemType.cs @@ -1115,6 +1115,6 @@ namespace MinecraftClient.Inventory ZombieHorseSpawnEgg, ZombieSpawnEgg, ZombieVillagerSpawnEgg, - ZombifiedPiglinSpawnEgg + ZombifiedPiglinSpawnEgg, } } diff --git a/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs b/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs index e4563b7d..831b3abe 100644 --- a/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs +++ b/MinecraftClient/Mapping/BlockPalettes/BlockPaletteGenerator.cs @@ -29,7 +29,7 @@ namespace MinecraftClient.Mapping.BlockPalettes /// path to blocks.json /// java -cp minecraft_server.jar net.minecraft.data.Main --reports /// state => block name mappings - public static void GenerateBlockPallete(string blocksJsonFile) + public static void GenerateBlockPalette(string blocksJsonFile) { BlockPaletteGenerator.JsonToClass(blocksJsonFile, "Palette", "Material"); } diff --git a/MinecraftClient/Mapping/EntityType.cs b/MinecraftClient/Mapping/EntityType.cs index 8f7678f1..a0368e98 100644 --- a/MinecraftClient/Mapping/EntityType.cs +++ b/MinecraftClient/Mapping/EntityType.cs @@ -24,26 +24,34 @@ namespace MinecraftClient.Mapping Boat, Cat, CaveSpider, + ChestMinecart, Chicken, Cod, + CommandBlockMinecart, Cow, Creeper, Dolphin, Donkey, DragonFireball, Drowned, + Egg, ElderGuardian, EndCrystal, EnderDragon, Enderman, Endermite, + EnderPearl, Evoker, EvokerFangs, + ExperienceBottle, ExperienceOrb, EyeOfEnder, FallingBlock, + Fireball, FireworkRocket, + FishingBobber, Fox, + FurnaceMinecart, Ghast, Giant, GlowItemFrame, @@ -51,13 +59,13 @@ namespace MinecraftClient.Mapping Goat, Guardian, Hoglin, + HopperMinecart, Horse, Husk, Illusioner, IronGolem, Item, ItemFrame, - Fireball, LeashKnot, LightningBolt, Llama, @@ -65,14 +73,8 @@ namespace MinecraftClient.Mapping MagmaCube, Marker, Minecart, - ChestMinecart, - CommandBlockMinecart, - FurnaceMinecart, - HopperMinecart, - SpawnerMinecart, - TntMinecart, - Mule, Mooshroom, + Mule, Ocelot, Painting, Panda, @@ -82,8 +84,9 @@ namespace MinecraftClient.Mapping Piglin, PiglinBrute, Pillager, + Player, PolarBear, - Tnt, + Potion, Pufferfish, Rabbit, Ravager, @@ -96,19 +99,18 @@ namespace MinecraftClient.Mapping SkeletonHorse, Slime, SmallFireball, - SnowGolem, Snowball, + SnowGolem, + SpawnerMinecart, SpectralArrow, Spider, Squid, Stray, Strider, - Egg, - EnderPearl, - ExperienceBottle, - Potion, - Trident, + Tnt, + TntMinecart, TraderLlama, + Trident, TropicalFish, Turtle, Vex, @@ -125,7 +127,5 @@ namespace MinecraftClient.Mapping ZombieHorse, ZombieVillager, ZombifiedPiglin, - Player, - FishingBobber, } } diff --git a/MinecraftClient/Mapping/Material.cs b/MinecraftClient/Mapping/Material.cs index 99c51a5b..ea5cc704 100644 --- a/MinecraftClient/Mapping/Material.cs +++ b/MinecraftClient/Mapping/Material.cs @@ -14,903 +14,903 @@ /// public enum Material { - Air, - Stone, - Granite, - PolishedGranite, - Diorite, - PolishedDiorite, - Andesite, - PolishedAndesite, - GrassBlock, - Dirt, - CoarseDirt, - Podzol, - Cobblestone, - OakPlanks, - SprucePlanks, - BirchPlanks, - JunglePlanks, - AcaciaPlanks, - DarkOakPlanks, - OakSapling, - SpruceSapling, - BirchSapling, - JungleSapling, - AcaciaSapling, - DarkOakSapling, - Bedrock, - Water, - Lava, - Sand, - RedSand, - Gravel, - GoldOre, - DeepslateGoldOre, - IronOre, - DeepslateIronOre, - CoalOre, - DeepslateCoalOre, - NetherGoldOre, - OakLog, - SpruceLog, - BirchLog, - JungleLog, - AcaciaLog, - DarkOakLog, - StrippedSpruceLog, - StrippedBirchLog, - StrippedJungleLog, - StrippedAcaciaLog, - StrippedDarkOakLog, - StrippedOakLog, - OakWood, - SpruceWood, - BirchWood, - JungleWood, - AcaciaWood, - DarkOakWood, - StrippedOakWood, - StrippedSpruceWood, - StrippedBirchWood, - StrippedJungleWood, - StrippedAcaciaWood, - StrippedDarkOakWood, - OakLeaves, - SpruceLeaves, - BirchLeaves, - JungleLeaves, - AcaciaLeaves, - DarkOakLeaves, - AzaleaLeaves, - FloweringAzaleaLeaves, - Sponge, - WetSponge, - Glass, - LapisOre, - DeepslateLapisOre, - LapisBlock, - Dispenser, - Sandstone, - ChiseledSandstone, - CutSandstone, - NoteBlock, - WhiteBed, - OrangeBed, - MagentaBed, - LightBlueBed, - YellowBed, - LimeBed, - PinkBed, - GrayBed, - LightGrayBed, - CyanBed, - PurpleBed, - BlueBed, - BrownBed, - GreenBed, - RedBed, - BlackBed, - PoweredRail, - DetectorRail, - StickyPiston, - Cobweb, - Grass, - Fern, - DeadBush, - Seagrass, - TallSeagrass, - Piston, - PistonHead, - WhiteWool, - OrangeWool, - MagentaWool, - LightBlueWool, - YellowWool, - LimeWool, - PinkWool, - GrayWool, - LightGrayWool, - CyanWool, - PurpleWool, - BlueWool, - BrownWool, - GreenWool, - RedWool, - BlackWool, - MovingPiston, - Dandelion, - Poppy, - BlueOrchid, - Allium, - AzureBluet, - RedTulip, - OrangeTulip, - WhiteTulip, - PinkTulip, - OxeyeDaisy, - Cornflower, - WitherRose, - LilyOfTheValley, - BrownMushroom, - RedMushroom, - GoldBlock, - IronBlock, - Bricks, - Tnt, - Bookshelf, - MossyCobblestone, - Obsidian, - Torch, - WallTorch, - Fire, - SoulFire, - Spawner, - OakStairs, - Chest, - RedstoneWire, - DiamondOre, - DeepslateDiamondOre, - DiamondBlock, - CraftingTable, - Wheat, - Farmland, - Furnace, - OakSign, - SpruceSign, - BirchSign, - AcaciaSign, - JungleSign, - DarkOakSign, - OakDoor, - Ladder, - Rail, - CobblestoneStairs, - OakWallSign, - SpruceWallSign, - BirchWallSign, - AcaciaWallSign, - JungleWallSign, - DarkOakWallSign, - Lever, - StonePressurePlate, - IronDoor, - OakPressurePlate, - SprucePressurePlate, - BirchPressurePlate, - JunglePressurePlate, - AcaciaPressurePlate, - DarkOakPressurePlate, - RedstoneOre, - DeepslateRedstoneOre, - RedstoneTorch, - RedstoneWallTorch, - StoneButton, - Snow, - Ice, - SnowBlock, - Cactus, - Clay, - SugarCane, - Jukebox, - OakFence, - Pumpkin, - Netherrack, - SoulSand, - SoulSoil, - Basalt, - PolishedBasalt, - SoulTorch, - SoulWallTorch, - Glowstone, - NetherPortal, - CarvedPumpkin, - JackOLantern, - Cake, - Repeater, - WhiteStainedGlass, - OrangeStainedGlass, - MagentaStainedGlass, - LightBlueStainedGlass, - YellowStainedGlass, - LimeStainedGlass, - PinkStainedGlass, - GrayStainedGlass, - LightGrayStainedGlass, - CyanStainedGlass, - PurpleStainedGlass, - BlueStainedGlass, - BrownStainedGlass, - GreenStainedGlass, - RedStainedGlass, - BlackStainedGlass, - OakTrapdoor, - SpruceTrapdoor, - BirchTrapdoor, - JungleTrapdoor, - AcaciaTrapdoor, - DarkOakTrapdoor, - StoneBricks, - MossyStoneBricks, - CrackedStoneBricks, - ChiseledStoneBricks, - InfestedStone, - InfestedCobblestone, - InfestedStoneBricks, - InfestedMossyStoneBricks, - InfestedCrackedStoneBricks, - InfestedChiseledStoneBricks, - BrownMushroomBlock, - RedMushroomBlock, - MushroomStem, - IronBars, - Chain, - GlassPane, - Melon, - AttachedPumpkinStem, - AttachedMelonStem, - PumpkinStem, - MelonStem, - Vine, - GlowLichen, - OakFenceGate, - BrickStairs, - StoneBrickStairs, - Mycelium, - LilyPad, - NetherBricks, - NetherBrickFence, - NetherBrickStairs, - NetherWart, - EnchantingTable, - BrewingStand, - Cauldron, - WaterCauldron, - LavaCauldron, - PowderSnowCauldron, - EndPortal, - EndPortalFrame, - EndStone, - DragonEgg, - RedstoneLamp, - Cocoa, - SandstoneStairs, - EmeraldOre, - DeepslateEmeraldOre, - EnderChest, - TripwireHook, - Tripwire, - EmeraldBlock, - SpruceStairs, - BirchStairs, - JungleStairs, - CommandBlock, - Beacon, - CobblestoneWall, - MossyCobblestoneWall, - FlowerPot, - PottedOakSapling, - PottedSpruceSapling, - PottedBirchSapling, - PottedJungleSapling, - PottedAcaciaSapling, - PottedDarkOakSapling, - PottedFern, - PottedDandelion, - PottedPoppy, - PottedBlueOrchid, - PottedAllium, - PottedAzureBluet, - PottedRedTulip, - PottedOrangeTulip, - PottedWhiteTulip, - PottedPinkTulip, - PottedOxeyeDaisy, - PottedCornflower, - PottedLilyOfTheValley, - PottedWitherRose, - PottedRedMushroom, - PottedBrownMushroom, - PottedDeadBush, - PottedCactus, - Carrots, - Potatoes, - OakButton, - SpruceButton, - BirchButton, - JungleButton, AcaciaButton, - DarkOakButton, - SkeletonSkull, - SkeletonWallSkull, - WitherSkeletonSkull, - WitherSkeletonWallSkull, - ZombieHead, - ZombieWallHead, - PlayerHead, - PlayerWallHead, - CreeperHead, - CreeperWallHead, - DragonHead, - DragonWallHead, - Anvil, - ChippedAnvil, - DamagedAnvil, - TrappedChest, - LightWeightedPressurePlate, - HeavyWeightedPressurePlate, - Comparator, - DaylightDetector, - RedstoneBlock, - NetherQuartzOre, - Hopper, - QuartzBlock, - ChiseledQuartzBlock, - QuartzPillar, - QuartzStairs, - ActivatorRail, - Dropper, - WhiteTerracotta, - OrangeTerracotta, - MagentaTerracotta, - LightBlueTerracotta, - YellowTerracotta, - LimeTerracotta, - PinkTerracotta, - GrayTerracotta, - LightGrayTerracotta, - CyanTerracotta, - PurpleTerracotta, - BlueTerracotta, - BrownTerracotta, - GreenTerracotta, - RedTerracotta, - BlackTerracotta, - WhiteStainedGlassPane, - OrangeStainedGlassPane, - MagentaStainedGlassPane, - LightBlueStainedGlassPane, - YellowStainedGlassPane, - LimeStainedGlassPane, - PinkStainedGlassPane, - GrayStainedGlassPane, - LightGrayStainedGlassPane, - CyanStainedGlassPane, - PurpleStainedGlassPane, - BlueStainedGlassPane, - BrownStainedGlassPane, - GreenStainedGlassPane, - RedStainedGlassPane, - BlackStainedGlassPane, - AcaciaStairs, - DarkOakStairs, - SlimeBlock, - Barrier, - Light, - IronTrapdoor, - Prismarine, - PrismarineBricks, - DarkPrismarine, - PrismarineStairs, - PrismarineBrickStairs, - DarkPrismarineStairs, - PrismarineSlab, - PrismarineBrickSlab, - DarkPrismarineSlab, - SeaLantern, - HayBlock, - WhiteCarpet, - OrangeCarpet, - MagentaCarpet, - LightBlueCarpet, - YellowCarpet, - LimeCarpet, - PinkCarpet, - GrayCarpet, - LightGrayCarpet, - CyanCarpet, - PurpleCarpet, - BlueCarpet, - BrownCarpet, - GreenCarpet, - RedCarpet, - BlackCarpet, - Terracotta, - CoalBlock, - PackedIce, - Sunflower, - Lilac, - RoseBush, - Peony, - TallGrass, - LargeFern, - WhiteBanner, - OrangeBanner, - MagentaBanner, - LightBlueBanner, - YellowBanner, - LimeBanner, - PinkBanner, - GrayBanner, - LightGrayBanner, - CyanBanner, - PurpleBanner, - BlueBanner, - BrownBanner, - GreenBanner, - RedBanner, - BlackBanner, - WhiteWallBanner, - OrangeWallBanner, - MagentaWallBanner, - LightBlueWallBanner, - YellowWallBanner, - LimeWallBanner, - PinkWallBanner, - GrayWallBanner, - LightGrayWallBanner, - CyanWallBanner, - PurpleWallBanner, - BlueWallBanner, - BrownWallBanner, - GreenWallBanner, - RedWallBanner, - BlackWallBanner, - RedSandstone, - ChiseledRedSandstone, - CutRedSandstone, - RedSandstoneStairs, - OakSlab, - SpruceSlab, - BirchSlab, - JungleSlab, - AcaciaSlab, - DarkOakSlab, - StoneSlab, - SmoothStoneSlab, - SandstoneSlab, - CutSandstoneSlab, - PetrifiedOakSlab, - CobblestoneSlab, - BrickSlab, - StoneBrickSlab, - NetherBrickSlab, - QuartzSlab, - RedSandstoneSlab, - CutRedSandstoneSlab, - PurpurSlab, - SmoothStone, - SmoothSandstone, - SmoothQuartz, - SmoothRedSandstone, - SpruceFenceGate, - BirchFenceGate, - JungleFenceGate, - AcaciaFenceGate, - DarkOakFenceGate, - SpruceFence, - BirchFence, - JungleFence, - AcaciaFence, - DarkOakFence, - SpruceDoor, - BirchDoor, - JungleDoor, AcaciaDoor, - DarkOakDoor, - EndRod, - ChorusPlant, - ChorusFlower, - PurpurBlock, - PurpurPillar, - PurpurStairs, - EndStoneBricks, - Beetroots, - GrassPath, - EndGateway, - RepeatingCommandBlock, - ChainCommandBlock, - FrostedIce, - MagmaBlock, - NetherWartBlock, - RedNetherBricks, - BoneBlock, - StructureVoid, - Observer, - ShulkerBox, - WhiteShulkerBox, - OrangeShulkerBox, - MagentaShulkerBox, - LightBlueShulkerBox, - YellowShulkerBox, - LimeShulkerBox, - PinkShulkerBox, - GrayShulkerBox, - LightGrayShulkerBox, - CyanShulkerBox, - PurpleShulkerBox, - BlueShulkerBox, - BrownShulkerBox, - GreenShulkerBox, - RedShulkerBox, - BlackShulkerBox, - WhiteGlazedTerracotta, - OrangeGlazedTerracotta, - MagentaGlazedTerracotta, - LightBlueGlazedTerracotta, - YellowGlazedTerracotta, - LimeGlazedTerracotta, - PinkGlazedTerracotta, - GrayGlazedTerracotta, - LightGrayGlazedTerracotta, - CyanGlazedTerracotta, - PurpleGlazedTerracotta, - BlueGlazedTerracotta, - BrownGlazedTerracotta, - GreenGlazedTerracotta, - RedGlazedTerracotta, - BlackGlazedTerracotta, - WhiteConcrete, - OrangeConcrete, - MagentaConcrete, - LightBlueConcrete, - YellowConcrete, - LimeConcrete, - PinkConcrete, - GrayConcrete, - LightGrayConcrete, - CyanConcrete, - PurpleConcrete, - BlueConcrete, - BrownConcrete, - GreenConcrete, - RedConcrete, - BlackConcrete, - WhiteConcretePowder, - OrangeConcretePowder, - MagentaConcretePowder, - LightBlueConcretePowder, - YellowConcretePowder, - LimeConcretePowder, - PinkConcretePowder, - GrayConcretePowder, - LightGrayConcretePowder, - CyanConcretePowder, - PurpleConcretePowder, - BlueConcretePowder, - BrownConcretePowder, - GreenConcretePowder, - RedConcretePowder, - BlackConcretePowder, - Kelp, - KelpPlant, - DriedKelpBlock, - TurtleEgg, - DeadTubeCoralBlock, - DeadBrainCoralBlock, - DeadBubbleCoralBlock, - DeadFireCoralBlock, - DeadHornCoralBlock, - TubeCoralBlock, - BrainCoralBlock, - BubbleCoralBlock, - FireCoralBlock, - HornCoralBlock, - DeadTubeCoral, - DeadBrainCoral, - DeadBubbleCoral, - DeadFireCoral, - DeadHornCoral, - TubeCoral, - BrainCoral, - BubbleCoral, - FireCoral, - HornCoral, - DeadTubeCoralFan, - DeadBrainCoralFan, - DeadBubbleCoralFan, - DeadFireCoralFan, - DeadHornCoralFan, - TubeCoralFan, - BrainCoralFan, - BubbleCoralFan, - FireCoralFan, - HornCoralFan, - DeadTubeCoralWallFan, - DeadBrainCoralWallFan, - DeadBubbleCoralWallFan, - DeadFireCoralWallFan, - DeadHornCoralWallFan, - TubeCoralWallFan, - BrainCoralWallFan, - BubbleCoralWallFan, - FireCoralWallFan, - HornCoralWallFan, - SeaPickle, - BlueIce, - Conduit, - BambooSapling, - Bamboo, - PottedBamboo, - VoidAir, - CaveAir, - BubbleColumn, - PolishedGraniteStairs, - SmoothRedSandstoneStairs, - MossyStoneBrickStairs, - PolishedDioriteStairs, - MossyCobblestoneStairs, - EndStoneBrickStairs, - StoneStairs, - SmoothSandstoneStairs, - SmoothQuartzStairs, - GraniteStairs, - AndesiteStairs, - RedNetherBrickStairs, - PolishedAndesiteStairs, - DioriteStairs, - PolishedGraniteSlab, - SmoothRedSandstoneSlab, - MossyStoneBrickSlab, - PolishedDioriteSlab, - MossyCobblestoneSlab, - EndStoneBrickSlab, - SmoothSandstoneSlab, - SmoothQuartzSlab, - GraniteSlab, - AndesiteSlab, - RedNetherBrickSlab, - PolishedAndesiteSlab, - DioriteSlab, - BrickWall, - PrismarineWall, - RedSandstoneWall, - MossyStoneBrickWall, - GraniteWall, - StoneBrickWall, - NetherBrickWall, - AndesiteWall, - RedNetherBrickWall, - SandstoneWall, - EndStoneBrickWall, - DioriteWall, - Scaffolding, - Loom, - Barrel, - Smoker, - BlastFurnace, - CartographyTable, - FletchingTable, - Grindstone, - Lectern, - SmithingTable, - Stonecutter, - Bell, - Lantern, - SoulLantern, - Campfire, - SoulCampfire, - SweetBerryBush, - WarpedStem, - StrippedWarpedStem, - WarpedHyphae, - StrippedWarpedHyphae, - WarpedNylium, - WarpedFungus, - WarpedWartBlock, - WarpedRoots, - NetherSprouts, - CrimsonStem, - StrippedCrimsonStem, - CrimsonHyphae, - StrippedCrimsonHyphae, - CrimsonNylium, - CrimsonFungus, - Shroomlight, - WeepingVines, - WeepingVinesPlant, - TwistingVines, - TwistingVinesPlant, - CrimsonRoots, - CrimsonPlanks, - WarpedPlanks, - CrimsonSlab, - WarpedSlab, - CrimsonPressurePlate, - WarpedPressurePlate, - CrimsonFence, - WarpedFence, - CrimsonTrapdoor, - WarpedTrapdoor, - CrimsonFenceGate, - WarpedFenceGate, - CrimsonStairs, - WarpedStairs, - CrimsonButton, - WarpedButton, - CrimsonDoor, - WarpedDoor, - CrimsonSign, - WarpedSign, - CrimsonWallSign, - WarpedWallSign, - StructureBlock, - Jigsaw, - Composter, - Target, - BeeNest, - Beehive, - HoneyBlock, - HoneycombBlock, - NetheriteBlock, + AcaciaFence, + AcaciaFenceGate, + AcaciaLeaves, + AcaciaLog, + AcaciaPlanks, + AcaciaPressurePlate, + AcaciaSapling, + AcaciaSign, + AcaciaSlab, + AcaciaStairs, + AcaciaTrapdoor, + AcaciaWallSign, + AcaciaWood, + ActivatorRail, + Air, + Allium, + AmethystBlock, + AmethystCluster, AncientDebris, - CryingObsidian, - RespawnAnchor, - PottedCrimsonFungus, - PottedWarpedFungus, - PottedCrimsonRoots, - PottedWarpedRoots, - Lodestone, + Andesite, + AndesiteSlab, + AndesiteStairs, + AndesiteWall, + Anvil, + AttachedMelonStem, + AttachedPumpkinStem, + Azalea, + AzaleaLeaves, + AzureBluet, + Bamboo, + BambooSapling, + Barrel, + Barrier, + Basalt, + Beacon, + Bedrock, + Beehive, + BeeNest, + Beetroots, + Bell, + BigDripleaf, + BigDripleafStem, + BirchButton, + BirchDoor, + BirchFence, + BirchFenceGate, + BirchLeaves, + BirchLog, + BirchPlanks, + BirchPressurePlate, + BirchSapling, + BirchSign, + BirchSlab, + BirchStairs, + BirchTrapdoor, + BirchWallSign, + BirchWood, + BlackBanner, + BlackBed, + BlackCandle, + BlackCandleCake, + BlackCarpet, + BlackConcrete, + BlackConcretePowder, + BlackGlazedTerracotta, + BlackShulkerBox, + BlackStainedGlass, + BlackStainedGlassPane, Blackstone, + BlackstoneSlab, BlackstoneStairs, BlackstoneWall, - BlackstoneSlab, + BlackTerracotta, + BlackWallBanner, + BlackWool, + BlastFurnace, + BlueBanner, + BlueBed, + BlueCandle, + BlueCandleCake, + BlueCarpet, + BlueConcrete, + BlueConcretePowder, + BlueGlazedTerracotta, + BlueIce, + BlueOrchid, + BlueShulkerBox, + BlueStainedGlass, + BlueStainedGlassPane, + BlueTerracotta, + BlueWallBanner, + BlueWool, + BoneBlock, + Bookshelf, + BrainCoral, + BrainCoralBlock, + BrainCoralFan, + BrainCoralWallFan, + BrewingStand, + Bricks, + BrickSlab, + BrickStairs, + BrickWall, + BrownBanner, + BrownBed, + BrownCandle, + BrownCandleCake, + BrownCarpet, + BrownConcrete, + BrownConcretePowder, + BrownGlazedTerracotta, + BrownMushroom, + BrownMushroomBlock, + BrownShulkerBox, + BrownStainedGlass, + BrownStainedGlassPane, + BrownTerracotta, + BrownWallBanner, + BrownWool, + BubbleColumn, + BubbleCoral, + BubbleCoralBlock, + BubbleCoralFan, + BubbleCoralWallFan, + BuddingAmethyst, + Cactus, + Cake, + Calcite, + Campfire, + Candle, + CandleCake, + Carrots, + CartographyTable, + CarvedPumpkin, + Cauldron, + CaveAir, + CaveVines, + CaveVinesPlant, + Chain, + ChainCommandBlock, + Chest, + ChippedAnvil, + ChiseledDeepslate, + ChiseledNetherBricks, + ChiseledPolishedBlackstone, + ChiseledQuartzBlock, + ChiseledRedSandstone, + ChiseledSandstone, + ChiseledStoneBricks, + ChorusFlower, + ChorusPlant, + Clay, + CoalBlock, + CoalOre, + CoarseDirt, + CobbledDeepslate, + CobbledDeepslateSlab, + CobbledDeepslateStairs, + CobbledDeepslateWall, + Cobblestone, + CobblestoneSlab, + CobblestoneStairs, + CobblestoneWall, + Cobweb, + Cocoa, + CommandBlock, + Comparator, + Composter, + Conduit, + CopperBlock, + CopperOre, + Cornflower, + CrackedDeepslateBricks, + CrackedDeepslateTiles, + CrackedNetherBricks, + CrackedPolishedBlackstoneBricks, + CrackedStoneBricks, + CraftingTable, + CreeperHead, + CreeperWallHead, + CrimsonButton, + CrimsonDoor, + CrimsonFence, + CrimsonFenceGate, + CrimsonFungus, + CrimsonHyphae, + CrimsonNylium, + CrimsonPlanks, + CrimsonPressurePlate, + CrimsonRoots, + CrimsonSign, + CrimsonSlab, + CrimsonStairs, + CrimsonStem, + CrimsonTrapdoor, + CrimsonWallSign, + CryingObsidian, + CutCopper, + CutCopperSlab, + CutCopperStairs, + CutRedSandstone, + CutRedSandstoneSlab, + CutSandstone, + CutSandstoneSlab, + CyanBanner, + CyanBed, + CyanCandle, + CyanCandleCake, + CyanCarpet, + CyanConcrete, + CyanConcretePowder, + CyanGlazedTerracotta, + CyanShulkerBox, + CyanStainedGlass, + CyanStainedGlassPane, + CyanTerracotta, + CyanWallBanner, + CyanWool, + DamagedAnvil, + Dandelion, + DarkOakButton, + DarkOakDoor, + DarkOakFence, + DarkOakFenceGate, + DarkOakLeaves, + DarkOakLog, + DarkOakPlanks, + DarkOakPressurePlate, + DarkOakSapling, + DarkOakSign, + DarkOakSlab, + DarkOakStairs, + DarkOakTrapdoor, + DarkOakWallSign, + DarkOakWood, + DarkPrismarine, + DarkPrismarineSlab, + DarkPrismarineStairs, + DaylightDetector, + DeadBrainCoral, + DeadBrainCoralBlock, + DeadBrainCoralFan, + DeadBrainCoralWallFan, + DeadBubbleCoral, + DeadBubbleCoralBlock, + DeadBubbleCoralFan, + DeadBubbleCoralWallFan, + DeadBush, + DeadFireCoral, + DeadFireCoralBlock, + DeadFireCoralFan, + DeadFireCoralWallFan, + DeadHornCoral, + DeadHornCoralBlock, + DeadHornCoralFan, + DeadHornCoralWallFan, + DeadTubeCoral, + DeadTubeCoralBlock, + DeadTubeCoralFan, + DeadTubeCoralWallFan, + Deepslate, + DeepslateBricks, + DeepslateBrickSlab, + DeepslateBrickStairs, + DeepslateBrickWall, + DeepslateCoalOre, + DeepslateCopperOre, + DeepslateDiamondOre, + DeepslateEmeraldOre, + DeepslateGoldOre, + DeepslateIronOre, + DeepslateLapisOre, + DeepslateRedstoneOre, + DeepslateTiles, + DeepslateTileSlab, + DeepslateTileStairs, + DeepslateTileWall, + DetectorRail, + DiamondBlock, + DiamondOre, + Diorite, + DioriteSlab, + DioriteStairs, + DioriteWall, + Dirt, + Dispenser, + DragonEgg, + DragonHead, + DragonWallHead, + DriedKelpBlock, + DripstoneBlock, + Dropper, + EmeraldBlock, + EmeraldOre, + EnchantingTable, + EnderChest, + EndGateway, + EndPortal, + EndPortalFrame, + EndRod, + EndStone, + EndStoneBricks, + EndStoneBrickSlab, + EndStoneBrickStairs, + EndStoneBrickWall, + ExposedCopper, + ExposedCutCopper, + ExposedCutCopperSlab, + ExposedCutCopperStairs, + Farmland, + Fern, + Fire, + FireCoral, + FireCoralBlock, + FireCoralFan, + FireCoralWallFan, + FletchingTable, + FloweringAzalea, + FloweringAzaleaLeaves, + FlowerPot, + FrostedIce, + Furnace, + GildedBlackstone, + Glass, + GlassPane, + GlowLichen, + Glowstone, + GoldBlock, + GoldOre, + Granite, + GraniteSlab, + GraniteStairs, + GraniteWall, + Grass, + GrassBlock, + GrassPath, + Gravel, + GrayBanner, + GrayBed, + GrayCandle, + GrayCandleCake, + GrayCarpet, + GrayConcrete, + GrayConcretePowder, + GrayGlazedTerracotta, + GrayShulkerBox, + GrayStainedGlass, + GrayStainedGlassPane, + GrayTerracotta, + GrayWallBanner, + GrayWool, + GreenBanner, + GreenBed, + GreenCandle, + GreenCandleCake, + GreenCarpet, + GreenConcrete, + GreenConcretePowder, + GreenGlazedTerracotta, + GreenShulkerBox, + GreenStainedGlass, + GreenStainedGlassPane, + GreenTerracotta, + GreenWallBanner, + GreenWool, + Grindstone, + HangingRoots, + HayBlock, + HeavyWeightedPressurePlate, + HoneyBlock, + HoneycombBlock, + Hopper, + HornCoral, + HornCoralBlock, + HornCoralFan, + HornCoralWallFan, + Ice, + InfestedChiseledStoneBricks, + InfestedCobblestone, + InfestedCrackedStoneBricks, + InfestedDeepslate, + InfestedMossyStoneBricks, + InfestedStone, + InfestedStoneBricks, + IronBars, + IronBlock, + IronDoor, + IronOre, + IronTrapdoor, + JackOLantern, + Jigsaw, + Jukebox, + JungleButton, + JungleDoor, + JungleFence, + JungleFenceGate, + JungleLeaves, + JungleLog, + JunglePlanks, + JunglePressurePlate, + JungleSapling, + JungleSign, + JungleSlab, + JungleStairs, + JungleTrapdoor, + JungleWallSign, + JungleWood, + Kelp, + KelpPlant, + Ladder, + Lantern, + LapisBlock, + LapisOre, + LargeAmethystBud, + LargeFern, + Lava, + LavaCauldron, + Lectern, + Lever, + Light, + LightBlueBanner, + LightBlueBed, + LightBlueCandle, + LightBlueCandleCake, + LightBlueCarpet, + LightBlueConcrete, + LightBlueConcretePowder, + LightBlueGlazedTerracotta, + LightBlueShulkerBox, + LightBlueStainedGlass, + LightBlueStainedGlassPane, + LightBlueTerracotta, + LightBlueWallBanner, + LightBlueWool, + LightGrayBanner, + LightGrayBed, + LightGrayCandle, + LightGrayCandleCake, + LightGrayCarpet, + LightGrayConcrete, + LightGrayConcretePowder, + LightGrayGlazedTerracotta, + LightGrayShulkerBox, + LightGrayStainedGlass, + LightGrayStainedGlassPane, + LightGrayTerracotta, + LightGrayWallBanner, + LightGrayWool, + LightningRod, + LightWeightedPressurePlate, + Lilac, + LilyOfTheValley, + LilyPad, + LimeBanner, + LimeBed, + LimeCandle, + LimeCandleCake, + LimeCarpet, + LimeConcrete, + LimeConcretePowder, + LimeGlazedTerracotta, + LimeShulkerBox, + LimeStainedGlass, + LimeStainedGlassPane, + LimeTerracotta, + LimeWallBanner, + LimeWool, + Lodestone, + Loom, + MagentaBanner, + MagentaBed, + MagentaCandle, + MagentaCandleCake, + MagentaCarpet, + MagentaConcrete, + MagentaConcretePowder, + MagentaGlazedTerracotta, + MagentaShulkerBox, + MagentaStainedGlass, + MagentaStainedGlassPane, + MagentaTerracotta, + MagentaWallBanner, + MagentaWool, + MagmaBlock, + MediumAmethystBud, + Melon, + MelonStem, + MossBlock, + MossCarpet, + MossyCobblestone, + MossyCobblestoneSlab, + MossyCobblestoneStairs, + MossyCobblestoneWall, + MossyStoneBricks, + MossyStoneBrickSlab, + MossyStoneBrickStairs, + MossyStoneBrickWall, + MovingPiston, + MushroomStem, + Mycelium, + NetherBrickFence, + NetherBricks, + NetherBrickSlab, + NetherBrickStairs, + NetherBrickWall, + NetherGoldOre, + NetheriteBlock, + NetherPortal, + NetherQuartzOre, + Netherrack, + NetherSprouts, + NetherWart, + NetherWartBlock, + NoteBlock, + OakButton, + OakDoor, + OakFence, + OakFenceGate, + OakLeaves, + OakLog, + OakPlanks, + OakPressurePlate, + OakSapling, + OakSign, + OakSlab, + OakStairs, + OakTrapdoor, + OakWallSign, + OakWood, + Observer, + Obsidian, + OrangeBanner, + OrangeBed, + OrangeCandle, + OrangeCandleCake, + OrangeCarpet, + OrangeConcrete, + OrangeConcretePowder, + OrangeGlazedTerracotta, + OrangeShulkerBox, + OrangeStainedGlass, + OrangeStainedGlassPane, + OrangeTerracotta, + OrangeTulip, + OrangeWallBanner, + OrangeWool, + OxeyeDaisy, + OxidizedCopper, + OxidizedCutCopper, + OxidizedCutCopperSlab, + OxidizedCutCopperStairs, + PackedIce, + Peony, + PetrifiedOakSlab, + PinkBanner, + PinkBed, + PinkCandle, + PinkCandleCake, + PinkCarpet, + PinkConcrete, + PinkConcretePowder, + PinkGlazedTerracotta, + PinkShulkerBox, + PinkStainedGlass, + PinkStainedGlassPane, + PinkTerracotta, + PinkTulip, + PinkWallBanner, + PinkWool, + Piston, + PistonHead, + PlayerHead, + PlayerWallHead, + Podzol, + PointedDripstone, + PolishedAndesite, + PolishedAndesiteSlab, + PolishedAndesiteStairs, + PolishedBasalt, PolishedBlackstone, PolishedBlackstoneBricks, - CrackedPolishedBlackstoneBricks, - ChiseledPolishedBlackstone, PolishedBlackstoneBrickSlab, PolishedBlackstoneBrickStairs, PolishedBlackstoneBrickWall, - GildedBlackstone, - PolishedBlackstoneStairs, - PolishedBlackstoneSlab, - PolishedBlackstonePressurePlate, PolishedBlackstoneButton, + PolishedBlackstonePressurePlate, + PolishedBlackstoneSlab, + PolishedBlackstoneStairs, PolishedBlackstoneWall, - ChiseledNetherBricks, - CrackedNetherBricks, - QuartzBricks, - Candle, - WhiteCandle, - OrangeCandle, - MagentaCandle, - LightBlueCandle, - YellowCandle, - LimeCandle, - PinkCandle, - GrayCandle, - LightGrayCandle, - CyanCandle, - PurpleCandle, - BlueCandle, - BrownCandle, - GreenCandle, - RedCandle, - BlackCandle, - CandleCake, - WhiteCandleCake, - OrangeCandleCake, - MagentaCandleCake, - LightBlueCandleCake, - YellowCandleCake, - LimeCandleCake, - PinkCandleCake, - GrayCandleCake, - LightGrayCandleCake, - CyanCandleCake, - PurpleCandleCake, - BlueCandleCake, - BrownCandleCake, - GreenCandleCake, - RedCandleCake, - BlackCandleCake, - AmethystBlock, - BuddingAmethyst, - AmethystCluster, - LargeAmethystBud, - MediumAmethystBud, - SmallAmethystBud, - Tuff, - Calcite, - TintedGlass, - PowderSnow, - SculkSensor, - OxidizedCopper, - WeatheredCopper, - ExposedCopper, - CopperBlock, - CopperOre, - DeepslateCopperOre, - OxidizedCutCopper, - WeatheredCutCopper, - ExposedCutCopper, - CutCopper, - OxidizedCutCopperStairs, - WeatheredCutCopperStairs, - ExposedCutCopperStairs, - CutCopperStairs, - OxidizedCutCopperSlab, - WeatheredCutCopperSlab, - ExposedCutCopperSlab, - CutCopperSlab, - WaxedCopperBlock, - WaxedWeatheredCopper, - WaxedExposedCopper, - WaxedOxidizedCopper, - WaxedOxidizedCutCopper, - WaxedWeatheredCutCopper, - WaxedExposedCutCopper, - WaxedCutCopper, - WaxedOxidizedCutCopperStairs, - WaxedWeatheredCutCopperStairs, - WaxedExposedCutCopperStairs, - WaxedCutCopperStairs, - WaxedOxidizedCutCopperSlab, - WaxedWeatheredCutCopperSlab, - WaxedExposedCutCopperSlab, - WaxedCutCopperSlab, - LightningRod, - PointedDripstone, - DripstoneBlock, - CaveVines, - CaveVinesPlant, - SporeBlossom, - Azalea, - FloweringAzalea, - MossCarpet, - MossBlock, - BigDripleaf, - BigDripleafStem, - SmallDripleaf, - HangingRoots, - RootedDirt, - Deepslate, - CobbledDeepslate, - CobbledDeepslateStairs, - CobbledDeepslateSlab, - CobbledDeepslateWall, PolishedDeepslate, - PolishedDeepslateStairs, PolishedDeepslateSlab, + PolishedDeepslateStairs, PolishedDeepslateWall, - DeepslateTiles, - DeepslateTileStairs, - DeepslateTileSlab, - DeepslateTileWall, - DeepslateBricks, - DeepslateBrickStairs, - DeepslateBrickSlab, - DeepslateBrickWall, - ChiseledDeepslate, - CrackedDeepslateBricks, - CrackedDeepslateTiles, - InfestedDeepslate, - SmoothBasalt, - RawIronBlock, + PolishedDiorite, + PolishedDioriteSlab, + PolishedDioriteStairs, + PolishedGranite, + PolishedGraniteSlab, + PolishedGraniteStairs, + Poppy, + Potatoes, + PottedAcaciaSapling, + PottedAllium, + PottedAzaleaBush, + PottedAzureBluet, + PottedBamboo, + PottedBirchSapling, + PottedBlueOrchid, + PottedBrownMushroom, + PottedCactus, + PottedCornflower, + PottedCrimsonFungus, + PottedCrimsonRoots, + PottedDandelion, + PottedDarkOakSapling, + PottedDeadBush, + PottedFern, + PottedFloweringAzaleaBush, + PottedJungleSapling, + PottedLilyOfTheValley, + PottedOakSapling, + PottedOrangeTulip, + PottedOxeyeDaisy, + PottedPinkTulip, + PottedPoppy, + PottedRedMushroom, + PottedRedTulip, + PottedSpruceSapling, + PottedWarpedFungus, + PottedWarpedRoots, + PottedWhiteTulip, + PottedWitherRose, + PowderSnow, + PowderSnowCauldron, + PoweredRail, + Prismarine, + PrismarineBricks, + PrismarineBrickSlab, + PrismarineBrickStairs, + PrismarineSlab, + PrismarineStairs, + PrismarineWall, + Pumpkin, + PumpkinStem, + PurpleBanner, + PurpleBed, + PurpleCandle, + PurpleCandleCake, + PurpleCarpet, + PurpleConcrete, + PurpleConcretePowder, + PurpleGlazedTerracotta, + PurpleShulkerBox, + PurpleStainedGlass, + PurpleStainedGlassPane, + PurpleTerracotta, + PurpleWallBanner, + PurpleWool, + PurpurBlock, + PurpurPillar, + PurpurSlab, + PurpurStairs, + QuartzBlock, + QuartzBricks, + QuartzPillar, + QuartzSlab, + QuartzStairs, + Rail, RawCopperBlock, RawGoldBlock, - PottedAzaleaBush, - PottedFloweringAzaleaBush, + RawIronBlock, + RedBanner, + RedBed, + RedCandle, + RedCandleCake, + RedCarpet, + RedConcrete, + RedConcretePowder, + RedGlazedTerracotta, + RedMushroom, + RedMushroomBlock, + RedNetherBricks, + RedNetherBrickSlab, + RedNetherBrickStairs, + RedNetherBrickWall, + RedSand, + RedSandstone, + RedSandstoneSlab, + RedSandstoneStairs, + RedSandstoneWall, + RedShulkerBox, + RedStainedGlass, + RedStainedGlassPane, + RedstoneBlock, + RedstoneLamp, + RedstoneOre, + RedstoneTorch, + RedstoneWallTorch, + RedstoneWire, + RedTerracotta, + RedTulip, + RedWallBanner, + RedWool, + Repeater, + RepeatingCommandBlock, + RespawnAnchor, + RootedDirt, + RoseBush, + Sand, + Sandstone, + SandstoneSlab, + SandstoneStairs, + SandstoneWall, + Scaffolding, + SculkSensor, + Seagrass, + SeaLantern, + SeaPickle, + Shroomlight, + ShulkerBox, + SkeletonSkull, + SkeletonWallSkull, + SlimeBlock, + SmallAmethystBud, + SmallDripleaf, + SmithingTable, + Smoker, + SmoothBasalt, + SmoothQuartz, + SmoothQuartzSlab, + SmoothQuartzStairs, + SmoothRedSandstone, + SmoothRedSandstoneSlab, + SmoothRedSandstoneStairs, + SmoothSandstone, + SmoothSandstoneSlab, + SmoothSandstoneStairs, + SmoothStone, + SmoothStoneSlab, + Snow, + SnowBlock, + SoulCampfire, + SoulFire, + SoulLantern, + SoulSand, + SoulSoil, + SoulTorch, + SoulWallTorch, + Spawner, + Sponge, + SporeBlossom, + SpruceButton, + SpruceDoor, + SpruceFence, + SpruceFenceGate, + SpruceLeaves, + SpruceLog, + SprucePlanks, + SprucePressurePlate, + SpruceSapling, + SpruceSign, + SpruceSlab, + SpruceStairs, + SpruceTrapdoor, + SpruceWallSign, + SpruceWood, + StickyPiston, + Stone, + StoneBricks, + StoneBrickSlab, + StoneBrickStairs, + StoneBrickWall, + StoneButton, + Stonecutter, + StonePressurePlate, + StoneSlab, + StoneStairs, + StrippedAcaciaLog, + StrippedAcaciaWood, + StrippedBirchLog, + StrippedBirchWood, + StrippedCrimsonHyphae, + StrippedCrimsonStem, + StrippedDarkOakLog, + StrippedDarkOakWood, + StrippedJungleLog, + StrippedJungleWood, + StrippedOakLog, + StrippedOakWood, + StrippedSpruceLog, + StrippedSpruceWood, + StrippedWarpedHyphae, + StrippedWarpedStem, + StructureBlock, + StructureVoid, + SugarCane, + Sunflower, + SweetBerryBush, + TallGrass, + TallSeagrass, + Target, + Terracotta, + TintedGlass, + Tnt, + Torch, + TrappedChest, + Tripwire, + TripwireHook, + TubeCoral, + TubeCoralBlock, + TubeCoralFan, + TubeCoralWallFan, + Tuff, + TurtleEgg, + TwistingVines, + TwistingVinesPlant, + Vine, + VoidAir, + WallTorch, + WarpedButton, + WarpedDoor, + WarpedFence, + WarpedFenceGate, + WarpedFungus, + WarpedHyphae, + WarpedNylium, + WarpedPlanks, + WarpedPressurePlate, + WarpedRoots, + WarpedSign, + WarpedSlab, + WarpedStairs, + WarpedStem, + WarpedTrapdoor, + WarpedWallSign, + WarpedWartBlock, + Water, + WaterCauldron, + WaxedCopperBlock, + WaxedCutCopper, + WaxedCutCopperSlab, + WaxedCutCopperStairs, + WaxedExposedCopper, + WaxedExposedCutCopper, + WaxedExposedCutCopperSlab, + WaxedExposedCutCopperStairs, + WaxedOxidizedCopper, + WaxedOxidizedCutCopper, + WaxedOxidizedCutCopperSlab, + WaxedOxidizedCutCopperStairs, + WaxedWeatheredCopper, + WaxedWeatheredCutCopper, + WaxedWeatheredCutCopperSlab, + WaxedWeatheredCutCopperStairs, + WeatheredCopper, + WeatheredCutCopper, + WeatheredCutCopperSlab, + WeatheredCutCopperStairs, + WeepingVines, + WeepingVinesPlant, + WetSponge, + Wheat, + WhiteBanner, + WhiteBed, + WhiteCandle, + WhiteCandleCake, + WhiteCarpet, + WhiteConcrete, + WhiteConcretePowder, + WhiteGlazedTerracotta, + WhiteShulkerBox, + WhiteStainedGlass, + WhiteStainedGlassPane, + WhiteTerracotta, + WhiteTulip, + WhiteWallBanner, + WhiteWool, + WitherRose, + WitherSkeletonSkull, + WitherSkeletonWallSkull, + YellowBanner, + YellowBed, + YellowCandle, + YellowCandleCake, + YellowCarpet, + YellowConcrete, + YellowConcretePowder, + YellowGlazedTerracotta, + YellowShulkerBox, + YellowStainedGlass, + YellowStainedGlassPane, + YellowTerracotta, + YellowWallBanner, + YellowWool, + ZombieHead, + ZombieWallHead, } } diff --git a/MinecraftClient/Mapping/Material2Tool.cs b/MinecraftClient/Mapping/Material2Tool.cs index 6ab60c17..d8433808 100644 --- a/MinecraftClient/Mapping/Material2Tool.cs +++ b/MinecraftClient/Mapping/Material2Tool.cs @@ -42,12 +42,9 @@ namespace MinecraftClient.Mapping Material.BrownGlazedTerracotta, Material.BrownShulkerBox, Material.BrownTerracotta, - Material.Cauldron, - Material.WaterCauldron, - Material.LavaCauldron, - Material.PowderSnowCauldron, - Material.Chain, Material.Calcite, + Material.Cauldron, + Material.Chain, Material.ChippedAnvil, Material.ChiseledDeepslate, Material.ChiseledNetherBricks, @@ -58,10 +55,10 @@ namespace MinecraftClient.Mapping Material.ChiseledStoneBricks, Material.CoalBlock, Material.CoalOre, + Material.CobbledDeepslate, Material.CobbledDeepslateSlab, Material.CobbledDeepslateStairs, Material.CobbledDeepslateWall, - Material.CobbledDeepslate, Material.Cobblestone, Material.CobblestoneSlab, Material.CobblestoneStairs, @@ -88,20 +85,20 @@ namespace MinecraftClient.Mapping Material.Deepslate, Material.DeepslateBrickSlab, Material.DeepslateBrickStairs, - Material.DeepslateBricks, Material.DeepslateBrickWall, + Material.DeepslateBricks, Material.DeepslateCoalOre, Material.DeepslateTileSlab, Material.DeepslateTileStairs, - Material.DeepslateTiles, Material.DeepslateTileWall, + Material.DeepslateTiles, Material.DetectorRail, Material.Diorite, Material.DioriteSlab, Material.DioriteStairs, Material.DioriteWall, - Material.DripstoneBlock, Material.Dispenser, + Material.DripstoneBlock, Material.Dropper, Material.EnchantingTable, Material.EndRod, @@ -135,6 +132,7 @@ namespace MinecraftClient.Mapping Material.IronDoor, Material.IronTrapdoor, Material.Lantern, + Material.LavaCauldron, Material.LightBlueConcrete, Material.LightBlueGlazedTerracotta, Material.LightBlueShulkerBox, @@ -203,6 +201,7 @@ namespace MinecraftClient.Mapping Material.PolishedGranite, Material.PolishedGraniteSlab, Material.PolishedGraniteStairs, + Material.PowderSnowCauldron, Material.PoweredRail, Material.Prismarine, Material.PrismarineBrickSlab, @@ -271,6 +270,7 @@ namespace MinecraftClient.Mapping Material.Terracotta, Material.Tuff, Material.WarpedNylium, + Material.WaterCauldron, Material.WhiteConcrete, Material.WhiteGlazedTerracotta, Material.WhiteShulkerBox, @@ -641,7 +641,7 @@ namespace MinecraftClient.Mapping // Liquids private static readonly List bucket = new List() { - Material.Lava, + Material.Lava, Material.Water }; @@ -673,7 +673,7 @@ namespace MinecraftClient.Mapping { if (pickaxeTier0.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheritePickaxe, ItemType.DiamondPickaxe, @@ -685,7 +685,7 @@ namespace MinecraftClient.Mapping } else if (pickaxeTier1.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheritePickaxe, ItemType.DiamondPickaxe, @@ -696,7 +696,7 @@ namespace MinecraftClient.Mapping } else if (pickaxeTier2.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheritePickaxe, ItemType.DiamondPickaxe, @@ -705,7 +705,7 @@ namespace MinecraftClient.Mapping } else if (pickaxeTier3.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheritePickaxe, ItemType.DiamondPickaxe, @@ -713,7 +713,7 @@ namespace MinecraftClient.Mapping } else if (shovel.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheriteShovel, ItemType.DiamondShovel, @@ -725,7 +725,7 @@ namespace MinecraftClient.Mapping } else if (axe.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheriteAxe, ItemType.DiamondAxe, @@ -737,14 +737,14 @@ namespace MinecraftClient.Mapping } else if (shears.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.Shears, }; } else if (sword.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheriteSword, ItemType.DiamondSword, @@ -756,7 +756,7 @@ namespace MinecraftClient.Mapping } else if (hoe.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.NetheriteHoe, ItemType.DiamondHoe, @@ -768,7 +768,7 @@ namespace MinecraftClient.Mapping } else if (bucket.Contains(block)) { - return new ItemType[] + return new ItemType[] { ItemType.Bucket, }; diff --git a/MinecraftClient/Program.cs b/MinecraftClient/Program.cs index d5ab0c4a..93486d35 100644 --- a/MinecraftClient/Program.cs +++ b/MinecraftClient/Program.cs @@ -16,7 +16,7 @@ using MinecraftClient.WinAPI; namespace MinecraftClient { /// - /// Minecraft Console Client by the MCC Team (c) 2012-2021. + /// Minecraft Console Client by the MCC Team (c) 2012-2022. /// Allows to connect to any Minecraft server, send and receive text, automated scripts. /// This source code is released under the CDDL 1.0 License. /// @@ -124,17 +124,19 @@ namespace MinecraftClient { if (!argument.Contains("=")) throw new ArgumentException(Translations.Get("error.setting.argument_syntax", argument)); - + string[] argParts = argument.Substring(2).Split('='); string argName = argParts[0].Trim(); string argValue = argParts[1].Replace("\"", "").Trim(); - if(argName == "data-path") { + if (argName == "data-path") + { Console.WriteLine(dataPath); dataPath = argValue; } - if(argName == "data-generator") { + if (argName == "data-generator") + { dataGenerator = argValue; } } @@ -143,24 +145,24 @@ namespace MinecraftClient if (string.IsNullOrEmpty(dataGenerator) || !(dataGenerator.ToLower().Equals("entity") || dataGenerator.ToLower().Equals("item") || dataGenerator.ToLower().Equals("block"))) { Console.WriteLine(Translations.Get("error.generator.invalid")); - Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --data-generator="); + Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --data-generator= --data-path=\"\""); return; } if (string.IsNullOrEmpty(dataPath)) { Console.WriteLine(Translations.Get("error.missing.argument", "--data-path")); - Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --generate-entity-pallete --data-path=\"\""); + Console.WriteLine(Translations.Get("error.usage") + " MinecraftClient.exe --data-generator= --data-path=\"\""); return; } - if(!File.Exists(dataPath)) + if (!File.Exists(dataPath)) { Console.WriteLine(Translations.Get("error.generator.path", dataPath)); return; } - if(!dataPath.EndsWith(".json")) + if (!dataPath.EndsWith(".json")) { Console.WriteLine(Translations.Get("error.generator.json", dataPath)); return; @@ -170,16 +172,16 @@ namespace MinecraftClient switch (dataGenerator) { - case "entity": + case "entity": EntityPaletteGenerator.GenerateEntityTypes(dataPath); break; - case "item": + case "item": ItemPaletteGenerator.GenerateItemType(dataPath); break; - case "block": - BlockPaletteGenerator.GenerateBlockPallete(dataPath); + case "block": + BlockPaletteGenerator.GenerateBlockPalette(dataPath); break; } @@ -226,7 +228,7 @@ namespace MinecraftClient Console.Write(ConsoleIO.BasicIO ? Translations.Get("mcc.login_basic_io") + "\n" : Translations.Get("mcc.login")); Settings.Login = Console.ReadLine(); } - if (Settings.Password == "" + if (Settings.Password == "" && (Settings.SessionCaching == CacheType.None || !SessionCache.Contains(Settings.Login.ToLower())) && !useBrowser) { @@ -234,14 +236,14 @@ namespace MinecraftClient } // Setup exit cleaning code - ExitCleanUp.Add(delegate () + ExitCleanUp.Add(delegate () { // Do NOT use Program.Exit() as creating new Thread cause program to freeze if (client != null) { client.Disconnect(); ConsoleIO.Reset(); } if (offlinePrompt != null) { offlinePrompt.Abort(); offlinePrompt = null; ConsoleIO.Reset(); } if (Settings.playerHeadAsIcon) { ConsoleIcon.revertToMCCIcon(); } }); - + startupargs = args; InitializeClient(); @@ -294,8 +296,8 @@ namespace MinecraftClient { result = ProtocolHandler.MicrosoftLoginRefresh(session.RefreshToken, out session); } - if (result != ProtocolHandler.LoginResult.Success - && Settings.Password == "" + if (result != ProtocolHandler.LoginResult.Success + && Settings.Password == "" && Settings.AccountType == ProtocolHandler.AccountType.Mojang) RequestPassword(); } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index ae36ed66..e8ed9d4b 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -88,19 +88,19 @@ namespace MinecraftClient.Protocol.Handlers this.packetPalette = new PacketTypeHandler(protocolVersion, forgeInfo != null).GetTypeHandler(); this.log = handler.GetLogger(); - if (handler.GetTerrainEnabled() && protocolversion > MC1181Version) + if (handler.GetTerrainEnabled() && protocolversion > MC1182Version) { log.Error(Translations.Get("extra.terrainandmovement_disabled")); handler.SetTerrainEnabled(false); } - if (handler.GetInventoryEnabled() && (protocolversion < MC110Version || protocolversion > MC1181Version)) + if (handler.GetInventoryEnabled() && (protocolversion < MC110Version || protocolversion > MC1182Version)) { log.Error(Translations.Get("extra.inventory_disabled")); handler.SetInventoryEnabled(false); } - if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1181Version)) + if (handler.GetEntityHandlingEnabled() && (protocolversion < MC110Version || protocolversion > MC1182Version)) { log.Error(Translations.Get("extra.entity_disabled")); handler.SetEntityHandlingEnabled(false); @@ -109,9 +109,9 @@ namespace MinecraftClient.Protocol.Handlers // Block palette if (protocolversion >= MC113Version) { - if (protocolVersion > MC1181Version && handler.GetTerrainEnabled()) + if (protocolVersion > MC1182Version && handler.GetTerrainEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.block")); - if (protocolVersion == MC1181Version) + if (protocolVersion >= MC1181Version) Block.Palette = new Palette117(); else if (protocolVersion >= MC116Version) Block.Palette = new Palette116(); @@ -126,10 +126,10 @@ namespace MinecraftClient.Protocol.Handlers // Entity palette if (protocolversion >= MC113Version) { - if (protocolversion > MC1181Version && handler.GetEntityHandlingEnabled()) + if (protocolversion > MC1182Version && handler.GetEntityHandlingEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.entity")); - if (protocolversion >= MC117Version) - entityPalette = new EntityPalette117(); + if (protocolversion >= MC117Version) + entityPalette = new EntityPalette117(); else if (protocolversion >= MC1162Version) entityPalette = new EntityPalette1162(); else if (protocolversion >= MC116Version) @@ -145,9 +145,9 @@ namespace MinecraftClient.Protocol.Handlers // Item palette if (protocolversion >= MC1162Version) { - if (protocolversion > MC1181Version && handler.GetInventoryEnabled()) + if (protocolversion > MC1182Version && handler.GetInventoryEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.item")); - if (protocolversion == MC1181Version) + if (protocolversion >= MC1181Version) itemPalette = new ItemPalette118(); else if (protocolversion >= MC117Version) itemPalette = new ItemPalette117(); @@ -280,887 +280,889 @@ namespace MinecraftClient.Protocol.Handlers } // Regular in-game packets else switch (packetPalette.GetIncommingTypeById(packetID)) - { - case PacketTypesIn.KeepAlive: - SendPacket(PacketTypesOut.KeepAlive, packetData); - handler.OnServerKeepAlive(); - break; - case PacketTypesIn.JoinGame: - handler.OnGameJoined(); - int playerEntityID = dataTypes.ReadNextInt(packetData); - handler.OnReceivePlayerEntityID(playerEntityID); + { + case PacketTypesIn.KeepAlive: + SendPacket(PacketTypesOut.KeepAlive, packetData); + handler.OnServerKeepAlive(); + break; + case PacketTypesIn.JoinGame: + handler.OnGameJoined(); + int playerEntityID = dataTypes.ReadNextInt(packetData); + handler.OnReceivePlayerEntityID(playerEntityID); - if (protocolversion >= MC1162Version) - dataTypes.ReadNextBool(packetData); // Is hardcore - 1.16.2 and above - - handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData)); - - if (protocolversion >= MC116Version) - { - dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above - int worldCount = dataTypes.ReadNextVarInt(packetData); // World Count - 1.16 and above - for (int i = 0; i < worldCount; i++) - dataTypes.ReadNextString(packetData); // World Names - 1.16 and above - dataTypes.ReadNextNbt(packetData); // Dimension Codec - 1.16 and above - } - - //Current dimension - String identifier in 1.16, varInt below 1.16, byte below 1.9.1 - if (protocolversion >= MC116Version) - { if (protocolversion >= MC1162Version) - dataTypes.ReadNextNbt(packetData); + dataTypes.ReadNextBool(packetData); // Is hardcore - 1.16.2 and above + + handler.OnGamemodeUpdate(Guid.Empty, dataTypes.ReadNextByte(packetData)); + + if (protocolversion >= MC116Version) + { + dataTypes.ReadNextByte(packetData); // Previous Gamemode - 1.16 and above + int worldCount = dataTypes.ReadNextVarInt(packetData); // World Count - 1.16 and above + for (int i = 0; i < worldCount; i++) + dataTypes.ReadNextString(packetData); // World Names - 1.16 and above + dataTypes.ReadNextNbt(packetData); // Dimension Codec - 1.16 and above + } + + //Current dimension - String identifier in 1.16, varInt below 1.16, byte below 1.9.1 + if (protocolversion >= MC116Version) + { + if (protocolversion >= MC1162Version) + dataTypes.ReadNextNbt(packetData); + else + dataTypes.ReadNextString(packetData); + // TODO handle dimensions for 1.16+, needed for terrain handling + // TODO this data give min and max y which will be needed for chunk collumn handling + this.currentDimension = 0; + } + else if (protocolversion >= MC191Version) + this.currentDimension = dataTypes.ReadNextInt(packetData); else - dataTypes.ReadNextString(packetData); - // TODO handle dimensions for 1.16+, needed for terrain handling - // TODO this data give min and max y which will be needed for chunk collumn handling - this.currentDimension = 0; - } - else if (protocolversion >= MC191Version) - this.currentDimension = dataTypes.ReadNextInt(packetData); - else - this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData); + this.currentDimension = (sbyte)dataTypes.ReadNextByte(packetData); - if (protocolversion < MC114Version) - dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below - if (protocolversion >= MC116Version) - dataTypes.ReadNextString(packetData); // World Name - 1.16 and above - if (protocolversion >= MC115Version) - dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above + if (protocolversion < MC114Version) + dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below + if (protocolversion >= MC116Version) + dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + if (protocolversion >= MC115Version) + dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above - if (protocolversion >= MC1162Version) - dataTypes.ReadNextVarInt(packetData); // Max Players - 1.16.2 and above - else - dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below - - if (protocolversion < MC116Version) - dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below - if (protocolversion >= MC114Version) - dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above - if (protocolversion >= MC1181Version) - dataTypes.ReadNextVarInt(packetData); // Simulation Distance - 1.18 and above - if (protocolversion >= MC18Version) - dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above - if (protocolversion >= MC115Version) - dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above - - if (protocolversion >= MC116Version) - { - dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above - dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above - } - break; - case PacketTypesIn.ChatMessage: - string message = dataTypes.ReadNextString(packetData); - if (protocolversion >= MC18Version) - { - //Hide system messages or xp bar messages? - byte messageType = dataTypes.ReadNextByte(packetData); - if ((messageType == 1 && !Settings.DisplaySystemMessages) - || (messageType == 2 && !Settings.DisplayXPBarMessages)) - break; - } - handler.OnTextReceived(message, true); - break; - case PacketTypesIn.Respawn: - if (protocolversion >= MC116Version) - { - // TODO handle dimensions for 1.16+, needed for terrain handling if (protocolversion >= MC1162Version) - dataTypes.ReadNextNbt(packetData); + dataTypes.ReadNextVarInt(packetData); // Max Players - 1.16.2 and above else - dataTypes.ReadNextString(packetData); - this.currentDimension = 0; - } - else - { - // 1.15 and below - this.currentDimension = dataTypes.ReadNextInt(packetData); - } - if (protocolversion >= MC116Version) - dataTypes.ReadNextString(packetData); // World Name - 1.16 and above - if (protocolversion < MC114Version) - dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below - if (protocolversion >= MC115Version) - dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above - dataTypes.ReadNextByte(packetData); // Gamemode - if (protocolversion >= MC116Version) - dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above - if (protocolversion < MC116Version) - dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below - if (protocolversion >= MC116Version) - { - dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above - dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above - dataTypes.ReadNextBool(packetData); // Copy metadata - 1.16 and above - } - handler.OnRespawn(); - break; - case PacketTypesIn.PlayerPositionAndLook: - // These always need to be read, since we need the field after them for teleport confirm - double x = dataTypes.ReadNextDouble(packetData); - double y = dataTypes.ReadNextDouble(packetData); - double z = dataTypes.ReadNextDouble(packetData); - float yaw = dataTypes.ReadNextFloat(packetData); - float pitch = dataTypes.ReadNextFloat(packetData); - byte locMask = dataTypes.ReadNextByte(packetData); + dataTypes.ReadNextByte(packetData); // Max Players - 1.16.1 and below - // entity handling require player pos for distance calculating - if (handler.GetTerrainEnabled() || handler.GetEntityHandlingEnabled()) - { + if (protocolversion < MC116Version) + dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below + if (protocolversion >= MC114Version) + dataTypes.ReadNextVarInt(packetData); // View distance - 1.14 and above + if (protocolversion >= MC1181Version) + dataTypes.ReadNextVarInt(packetData); // Simulation Distance - 1.18 and above + if (protocolversion >= MC18Version) + dataTypes.ReadNextBool(packetData); // Reduced debug info - 1.8 and above + if (protocolversion >= MC115Version) + dataTypes.ReadNextBool(packetData); // Enable respawn screen - 1.15 and above + + if (protocolversion >= MC116Version) + { + dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above + dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above + } + break; + case PacketTypesIn.ChatMessage: + string message = dataTypes.ReadNextString(packetData); if (protocolversion >= MC18Version) { - Location location = handler.GetCurrentLocation(); - location.X = (locMask & 1 << 0) != 0 ? location.X + x : x; - location.Y = (locMask & 1 << 1) != 0 ? location.Y + y : y; - location.Z = (locMask & 1 << 2) != 0 ? location.Z + z : z; - handler.UpdateLocation(location, yaw, pitch); + //Hide system messages or xp bar messages? + byte messageType = dataTypes.ReadNextByte(packetData); + if ((messageType == 1 && !Settings.DisplaySystemMessages) + || (messageType == 2 && !Settings.DisplayXPBarMessages)) + break; } - else handler.UpdateLocation(new Location(x, y, z), yaw, pitch); - } - - if (protocolversion >= MC19Version) - { - int teleportID = dataTypes.ReadNextVarInt(packetData); - // Teleport confirm packet - SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID)); - } - - if (protocolversion >= MC117Version) dataTypes.ReadNextBool(packetData); - break; - case PacketTypesIn.ChunkData: //TODO implement for 1.17, bit mask is not limited to 0-15 anymore - if (handler.GetTerrainEnabled()) - { - int chunkX = dataTypes.ReadNextInt(packetData); - int chunkZ = dataTypes.ReadNextInt(packetData); - bool chunksContinuous = dataTypes.ReadNextBool(packetData); - if (protocolversion >= MC116Version && protocolversion <= MC1161Version) - dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only - ushort chunkMask = protocolversion >= MC19Version - ? (ushort)dataTypes.ReadNextVarInt(packetData) - : dataTypes.ReadNextUShort(packetData); - if (protocolversion < MC18Version) + handler.OnTextReceived(message, true); + break; + case PacketTypesIn.Respawn: + if (protocolversion >= MC116Version) { - ushort addBitmap = dataTypes.ReadNextUShort(packetData); - int compressedDataSize = dataTypes.ReadNextInt(packetData); - byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData); - byte[] decompressed = ZlibUtils.Decompress(compressed); - new Task(() => { - pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, addBitmap, currentDimension == 0, chunksContinuous, currentDimension, new Queue(decompressed)); - }).Start(); - } - else - { - if (protocolversion >= MC114Version) - dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above - int biomesLength = 0; + // TODO handle dimensions for 1.16+, needed for terrain handling if (protocolversion >= MC1162Version) - if (chunksContinuous) - biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above - if (protocolversion >= MC115Version && chunksContinuous) - { - if (protocolversion >= MC1162Version) - { - for (int i = 0; i < biomesLength; i++) - { - // Biomes - 1.16.2 and above - // Don't use ReadNextVarInt because it cost too much time - dataTypes.SkipNextVarInt(packetData); - } - } - else dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above - } - int dataSize = dataTypes.ReadNextVarInt(packetData); - new Task(() => { - pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, currentDimension, packetData); - }).Start(); - } - } - break; - case PacketTypesIn.MapData: - int mapid = dataTypes.ReadNextVarInt(packetData); - byte scale = dataTypes.ReadNextByte(packetData); - bool trackingposition = protocolversion >= MC117Version ? false : dataTypes.ReadNextBool(packetData); - bool locked = false; - if (protocolversion >= MC114Version) - { - locked = dataTypes.ReadNextBool(packetData); - } - if (protocolversion >= MC117Version) - { - trackingposition = dataTypes.ReadNextBool(packetData); - } - int iconcount = dataTypes.ReadNextVarInt(packetData); - handler.OnMapData(mapid, scale, trackingposition, locked, iconcount); - break; - case PacketTypesIn.TradeList: - if ((protocolversion >= MC114Version) && (handler.GetInventoryEnabled())) - { - // MC 1.14 or greater - int windowID = dataTypes.ReadNextVarInt(packetData); - int size = dataTypes.ReadNextByte(packetData); - List trades = new List(); - for (int tradeId = 0; tradeId < size; tradeId++) - { - VillagerTrade trade = dataTypes.ReadNextTrade(packetData, itemPalette); - trades.Add(trade); - } - VillagerInfo villagerInfo = new VillagerInfo() - { - Level = dataTypes.ReadNextVarInt(packetData), - Experience = dataTypes.ReadNextVarInt(packetData), - IsRegularVillager = dataTypes.ReadNextBool(packetData), - CanRestock = dataTypes.ReadNextBool(packetData) - }; - handler.OnTradeList(windowID, trades, villagerInfo); - } - break; - case PacketTypesIn.Title: - if (protocolversion >= MC18Version) - { - int action2 = dataTypes.ReadNextVarInt(packetData); - string titletext = String.Empty; - string subtitletext = String.Empty; - string actionbartext = String.Empty; - string json = String.Empty; - int fadein = -1; - int stay = -1; - int fadeout = -1; - if (protocolversion >= MC110Version) - { - if (action2 == 0) - { - json = titletext; - titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); - } - else if (action2 == 1) - { - json = subtitletext; - subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); - } - else if (action2 == 2) - { - json = actionbartext; - actionbartext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); - } - else if (action2 == 3) - { - fadein = dataTypes.ReadNextInt(packetData); - stay = dataTypes.ReadNextInt(packetData); - fadeout = dataTypes.ReadNextInt(packetData); - } + dataTypes.ReadNextNbt(packetData); + else + dataTypes.ReadNextString(packetData); + this.currentDimension = 0; } else { - if (action2 == 0) - { - json = titletext; - titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); - } - else if (action2 == 1) - { - json = subtitletext; - subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); - } - else if (action2 == 2) - { - fadein = dataTypes.ReadNextInt(packetData); - stay = dataTypes.ReadNextInt(packetData); - fadeout = dataTypes.ReadNextInt(packetData); - } + // 1.15 and below + this.currentDimension = dataTypes.ReadNextInt(packetData); } - handler.OnTitle(action2, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json); - } - break; - case PacketTypesIn.MultiBlockChange: - if (handler.GetTerrainEnabled()) - { - if (protocolversion >= MC1162Version) + if (protocolversion >= MC116Version) + dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + if (protocolversion < MC114Version) + dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below + if (protocolversion >= MC115Version) + dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above + dataTypes.ReadNextByte(packetData); // Gamemode + if (protocolversion >= MC116Version) + dataTypes.ReadNextByte(packetData); // Previous Game mode - 1.16 and above + if (protocolversion < MC116Version) + dataTypes.ReadNextString(packetData); // Level Type - 1.15 and below + if (protocolversion >= MC116Version) { - long chunkSection = dataTypes.ReadNextLong(packetData); - int sectionX = (int)(chunkSection >> 42); - int sectionY = (int)((chunkSection << 44) >> 44); - int sectionZ = (int)((chunkSection << 22) >> 42); - dataTypes.ReadNextBool(packetData); // Useless boolean - int blocksSize = dataTypes.ReadNextVarInt(packetData); - for (int i = 0; i < blocksSize; i++) - { - ulong block = (ulong)dataTypes.ReadNextVarLong(packetData); - int blockId = (int)(block >> 12); - int localX = (int)((block >> 8) & 0x0F); - int localZ = (int)((block >> 4) & 0x0F); - int localY = (int)(block & 0x0F); + dataTypes.ReadNextBool(packetData); // Is Debug - 1.16 and above + dataTypes.ReadNextBool(packetData); // Is Flat - 1.16 and above + dataTypes.ReadNextBool(packetData); // Copy metadata - 1.16 and above + } + handler.OnRespawn(); + break; + case PacketTypesIn.PlayerPositionAndLook: + // These always need to be read, since we need the field after them for teleport confirm + double x = dataTypes.ReadNextDouble(packetData); + double y = dataTypes.ReadNextDouble(packetData); + double z = dataTypes.ReadNextDouble(packetData); + float yaw = dataTypes.ReadNextFloat(packetData); + float pitch = dataTypes.ReadNextFloat(packetData); + byte locMask = dataTypes.ReadNextByte(packetData); - Block b = new Block((ushort)blockId); - int blockX = (sectionX * 16) + localX; - int blockY = (sectionY * 16) + localY; - int blockZ = (sectionZ * 16) + localZ; - var l = new Location(blockX, blockY, blockZ); - handler.GetWorld().SetBlock(l, b); + // entity handling require player pos for distance calculating + if (handler.GetTerrainEnabled() || handler.GetEntityHandlingEnabled()) + { + if (protocolversion >= MC18Version) + { + Location location = handler.GetCurrentLocation(); + location.X = (locMask & 1 << 0) != 0 ? location.X + x : x; + location.Y = (locMask & 1 << 1) != 0 ? location.Y + y : y; + location.Z = (locMask & 1 << 2) != 0 ? location.Z + z : z; + handler.UpdateLocation(location, yaw, pitch); } + else handler.UpdateLocation(new Location(x, y, z), yaw, pitch); } - else + + if (protocolversion >= MC19Version) + { + int teleportID = dataTypes.ReadNextVarInt(packetData); + // Teleport confirm packet + SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID)); + } + + if (protocolversion >= MC117Version) dataTypes.ReadNextBool(packetData); + break; + case PacketTypesIn.ChunkData: //TODO implement for 1.17, bit mask is not limited to 0-15 anymore + if (handler.GetTerrainEnabled()) { int chunkX = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData); - int recordCount = protocolversion < MC18Version - ? (int)dataTypes.ReadNextShort(packetData) - : dataTypes.ReadNextVarInt(packetData); - - for (int i = 0; i < recordCount; i++) + bool chunksContinuous = dataTypes.ReadNextBool(packetData); + if (protocolversion >= MC116Version && protocolversion <= MC1161Version) + dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only + ushort chunkMask = protocolversion >= MC19Version + ? (ushort)dataTypes.ReadNextVarInt(packetData) + : dataTypes.ReadNextUShort(packetData); + if (protocolversion < MC18Version) { - byte locationXZ; - ushort blockIdMeta; - int blockY; - - if (protocolversion < MC18Version) + ushort addBitmap = dataTypes.ReadNextUShort(packetData); + int compressedDataSize = dataTypes.ReadNextInt(packetData); + byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData); + byte[] decompressed = ZlibUtils.Decompress(compressed); + new Task(() => { - blockIdMeta = dataTypes.ReadNextUShort(packetData); - blockY = (ushort)dataTypes.ReadNextByte(packetData); - locationXZ = dataTypes.ReadNextByte(packetData); - } - else - { - locationXZ = dataTypes.ReadNextByte(packetData); - blockY = (ushort)dataTypes.ReadNextByte(packetData); - blockIdMeta = (ushort)dataTypes.ReadNextVarInt(packetData); - } - - int blockX = locationXZ >> 4; - int blockZ = locationXZ & 0x0F; - Block block = new Block(blockIdMeta); - handler.GetWorld().SetBlock(new Location(chunkX, chunkZ, blockX, blockY, blockZ), block); + pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, addBitmap, currentDimension == 0, chunksContinuous, currentDimension, new Queue(decompressed)); + }).Start(); } - } - } - break; - case PacketTypesIn.BlockChange: - if (handler.GetTerrainEnabled()) - { - if (protocolversion < MC18Version) - { - int blockX = dataTypes.ReadNextInt(packetData); - int blockY = dataTypes.ReadNextByte(packetData); - int blockZ = dataTypes.ReadNextInt(packetData); - short blockId = (short)dataTypes.ReadNextVarInt(packetData); - byte blockMeta = dataTypes.ReadNextByte(packetData); - handler.GetWorld().SetBlock(new Location(blockX, blockY, blockZ), new Block(blockId, blockMeta)); - } - else - { - handler.GetWorld().SetBlock(dataTypes.ReadNextLocation(packetData), new Block((ushort)dataTypes.ReadNextVarInt(packetData))); - } - } - break; - case PacketTypesIn.MapChunkBulk: - if (protocolversion < MC19Version && handler.GetTerrainEnabled()) - { - int chunkCount; - bool hasSkyLight; - Queue chunkData = packetData; - - //Read global fields - if (protocolversion < MC18Version) - { - chunkCount = dataTypes.ReadNextShort(packetData); - int compressedDataSize = dataTypes.ReadNextInt(packetData); - hasSkyLight = dataTypes.ReadNextBool(packetData); - byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData); - byte[] decompressed = ZlibUtils.Decompress(compressed); - chunkData = new Queue(decompressed); - } - else - { - hasSkyLight = dataTypes.ReadNextBool(packetData); - chunkCount = dataTypes.ReadNextVarInt(packetData); - } - - //Read chunk records - int[] chunkXs = new int[chunkCount]; - int[] chunkZs = new int[chunkCount]; - ushort[] chunkMasks = new ushort[chunkCount]; - ushort[] addBitmaps = new ushort[chunkCount]; - for (int chunkColumnNo = 0; chunkColumnNo < chunkCount; chunkColumnNo++) - { - chunkXs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); - chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); - chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData); - addBitmaps[chunkColumnNo] = protocolversion < MC18Version - ? dataTypes.ReadNextUShort(packetData) - : (ushort)0; - } - - //Process chunk records - for (int chunkColumnNo = 0; chunkColumnNo < chunkCount; chunkColumnNo++) - pTerrain.ProcessChunkColumnData(chunkXs[chunkColumnNo], chunkZs[chunkColumnNo], chunkMasks[chunkColumnNo], addBitmaps[chunkColumnNo], hasSkyLight, true, currentDimension, chunkData); - } - break; - case PacketTypesIn.UnloadChunk: - if (protocolversion >= MC19Version && handler.GetTerrainEnabled()) - { - int chunkX = dataTypes.ReadNextInt(packetData); - int chunkZ = dataTypes.ReadNextInt(packetData); - handler.GetWorld()[chunkX, chunkZ] = null; - } - break; - case PacketTypesIn.PlayerInfo: - if (protocolversion >= MC18Version) - { - int action = dataTypes.ReadNextVarInt(packetData); - int numActions = dataTypes.ReadNextVarInt(packetData); - for (int i = 0; i < numActions; i++) - { - Guid uuid = dataTypes.ReadNextUUID(packetData); - switch (action) + else { - case 0x00: //Player Join - string name = dataTypes.ReadNextString(packetData); - int propNum = dataTypes.ReadNextVarInt(packetData); - for (int p = 0; p < propNum; p++) + if (protocolversion >= MC114Version) + dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above + int biomesLength = 0; + if (protocolversion >= MC1162Version) + if (chunksContinuous) + biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above + if (protocolversion >= MC115Version && chunksContinuous) + { + if (protocolversion >= MC1162Version) { - string key = dataTypes.ReadNextString(packetData); - string val = dataTypes.ReadNextString(packetData); - if (dataTypes.ReadNextBool(packetData)) - dataTypes.ReadNextString(packetData); + for (int i = 0; i < biomesLength; i++) + { + // Biomes - 1.16.2 and above + // Don't use ReadNextVarInt because it cost too much time + dataTypes.SkipNextVarInt(packetData); + } } - handler.OnGamemodeUpdate(uuid, dataTypes.ReadNextVarInt(packetData)); - dataTypes.ReadNextVarInt(packetData); - if (dataTypes.ReadNextBool(packetData)) - dataTypes.ReadNextString(packetData); - handler.OnPlayerJoin(uuid, name); - break; - case 0x01: //Update gamemode - handler.OnGamemodeUpdate(uuid, dataTypes.ReadNextVarInt(packetData)); - break; - case 0x02: //Update latency - int latency = dataTypes.ReadNextVarInt(packetData); - handler.OnLatencyUpdate(uuid, latency); //Update latency; - break; - case 0x03: //Update display name - if (dataTypes.ReadNextBool(packetData)) - dataTypes.ReadNextString(packetData); - break; - case 0x04: //Player Leave - handler.OnPlayerLeave(uuid); - break; - default: - //Unknown player list item type - break; + else dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above + } + int dataSize = dataTypes.ReadNextVarInt(packetData); + new Task(() => + { + pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, currentDimension, packetData); + }).Start(); } } - } - else //MC 1.7.X does not provide UUID in tab-list updates - { - string name = dataTypes.ReadNextString(packetData); - bool online = dataTypes.ReadNextBool(packetData); - short ping = dataTypes.ReadNextShort(packetData); - Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray()); - if (online) - handler.OnPlayerJoin(FakeUUID, name); - else handler.OnPlayerLeave(FakeUUID); - } - break; - case PacketTypesIn.TabComplete: - if (protocolversion >= MC113Version) - { - autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData); - dataTypes.ReadNextVarInt(packetData); // Start of text to replace - dataTypes.ReadNextVarInt(packetData); // Length of text to replace - } - - int autocomplete_count = dataTypes.ReadNextVarInt(packetData); - autocomplete_result.Clear(); - - for (int i = 0; i < autocomplete_count; i++) - { - autocomplete_result.Add(dataTypes.ReadNextString(packetData)); - if (protocolversion >= MC113Version) + break; + case PacketTypesIn.MapData: + int mapid = dataTypes.ReadNextVarInt(packetData); + byte scale = dataTypes.ReadNextByte(packetData); + bool trackingposition = protocolversion >= MC117Version ? false : dataTypes.ReadNextBool(packetData); + bool locked = false; + if (protocolversion >= MC114Version) { - // Skip optional tooltip for each tab-complete result - if (dataTypes.ReadNextBool(packetData)) - dataTypes.ReadNextString(packetData); + locked = dataTypes.ReadNextBool(packetData); } - } - - autocomplete_received = true; - break; - case PacketTypesIn.PluginMessage: - String channel = dataTypes.ReadNextString(packetData); - // Length is unneeded as the whole remaining packetData is the entire payload of the packet. - if (protocolversion < MC18Version) - pForge.ReadNextVarShort(packetData); - handler.OnPluginChannelMessage(channel, packetData.ToArray()); - return pForge.HandlePluginMessage(channel, packetData, ref currentDimension); - case PacketTypesIn.Disconnect: - handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData))); - return false; - case PacketTypesIn.SetCompression: - if (protocolversion >= MC18Version && protocolversion < MC19Version) - compression_treshold = dataTypes.ReadNextVarInt(packetData); - break; - case PacketTypesIn.OpenWindow: - if (handler.GetInventoryEnabled()) - { - if (protocolversion < MC114Version) + if (protocolversion >= MC117Version) { - // MC 1.13 or lower - byte windowID = dataTypes.ReadNextByte(packetData); - string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper(); - ContainerTypeOld inventoryType = (ContainerTypeOld)Enum.Parse(typeof(ContainerTypeOld), type); - string title = dataTypes.ReadNextString(packetData); - byte slots = dataTypes.ReadNextByte(packetData); - Container inventory = new Container(windowID, inventoryType, ChatParser.ParseText(title)); - handler.OnInventoryOpen(windowID, inventory); + trackingposition = dataTypes.ReadNextBool(packetData); } - else + int iconcount = dataTypes.ReadNextVarInt(packetData); + handler.OnMapData(mapid, scale, trackingposition, locked, iconcount); + break; + case PacketTypesIn.TradeList: + if ((protocolversion >= MC114Version) && (handler.GetInventoryEnabled())) { // MC 1.14 or greater int windowID = dataTypes.ReadNextVarInt(packetData); - int windowType = dataTypes.ReadNextVarInt(packetData); - string title = dataTypes.ReadNextString(packetData); - Container inventory = new Container(windowID, windowType, ChatParser.ParseText(title)); - handler.OnInventoryOpen(windowID, inventory); + int size = dataTypes.ReadNextByte(packetData); + List trades = new List(); + for (int tradeId = 0; tradeId < size; tradeId++) + { + VillagerTrade trade = dataTypes.ReadNextTrade(packetData, itemPalette); + trades.Add(trade); + } + VillagerInfo villagerInfo = new VillagerInfo() + { + Level = dataTypes.ReadNextVarInt(packetData), + Experience = dataTypes.ReadNextVarInt(packetData), + IsRegularVillager = dataTypes.ReadNextBool(packetData), + CanRestock = dataTypes.ReadNextBool(packetData) + }; + handler.OnTradeList(windowID, trades, villagerInfo); } - } - break; - case PacketTypesIn.CloseWindow: - if (handler.GetInventoryEnabled()) - { - byte windowID = dataTypes.ReadNextByte(packetData); - lock (window_actions) { window_actions[windowID] = 0; } - handler.OnInventoryClose(windowID); - } - break; - case PacketTypesIn.WindowItems: - if (handler.GetInventoryEnabled()) - { - byte windowId = dataTypes.ReadNextByte(packetData); - - int stateId = -1; - - if(protocolversion >= MC1181Version) - stateId = dataTypes.ReadNextVarInt(packetData); - - int elements = dataTypes.ReadNextVarInt(packetData); - Dictionary inventorySlots = new Dictionary(); - for (short slotId = 0; slotId < elements; slotId++) - { - Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); - if (item != null) - inventorySlots[slotId] = item; - } - handler.OnWindowItems(windowId, inventorySlots); - } - break; - case PacketTypesIn.SetSlot: - if (handler.GetInventoryEnabled()) - { - byte windowID = dataTypes.ReadNextByte(packetData); - - int stateId = -1; - - if(protocolversion >= MC1181Version) - stateId = dataTypes.ReadNextVarInt(packetData); - - short slotID = dataTypes.ReadNextShort(packetData); - Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); - handler.OnSetSlot(windowID, slotID, item); - } - break; - case PacketTypesIn.WindowConfirmation: - if (handler.GetInventoryEnabled()) - { - byte windowID = dataTypes.ReadNextByte(packetData); - short actionID = dataTypes.ReadNextShort(packetData); - bool accepted = dataTypes.ReadNextBool(packetData); - if (!accepted) - { - SendWindowConfirmation(windowID, actionID, accepted); - } - } - break; - case PacketTypesIn.ResourcePackSend: - string url = dataTypes.ReadNextString(packetData); - string hash = dataTypes.ReadNextString(packetData); - bool forced = true; // Assume forced for MC 1.16 and below - if (protocolversion >= MC117Version) - { - forced = dataTypes.ReadNextBool(packetData); - String forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(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 - byte[] responseHeader = new byte[0]; - if (protocolversion < MC110Version) //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()) - { - Entity entity = dataTypes.ReadNextEntity(packetData, entityPalette, false); - handler.OnSpawnEntity(entity); - } - break; - case PacketTypesIn.EntityEquipment: - if (handler.GetEntityHandlingEnabled()) - { - int entityid = dataTypes.ReadNextVarInt(packetData); - if (protocolversion >= MC116Version) + case PacketTypesIn.Title: + if (protocolversion >= MC18Version) { - bool hasNext; - do + int action2 = dataTypes.ReadNextVarInt(packetData); + string titletext = String.Empty; + string subtitletext = String.Empty; + string actionbartext = String.Empty; + string json = String.Empty; + int fadein = -1; + int stay = -1; + int fadeout = -1; + if (protocolversion >= MC110Version) { - byte bitsData = dataTypes.ReadNextByte(packetData); - // Top bit set if another entry follows, and otherwise unset if this is the last item in the array - hasNext = (bitsData >> 7) == 1 ? true : false; - int slot2 = bitsData >> 1; - Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); - handler.OnEntityEquipment(entityid, slot2, item); - } while (hasNext); - } - else - { - int slot2 = dataTypes.ReadNextVarInt(packetData); - Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); - handler.OnEntityEquipment(entityid, slot2, item); - } - } - break; - case PacketTypesIn.SpawnLivingEntity: - if (handler.GetEntityHandlingEnabled()) - { - Entity entity = dataTypes.ReadNextEntity(packetData, entityPalette, true); - // packet before 1.15 has metadata at the end - // this is not handled in dataTypes.ReadNextEntity() - // we are simply ignoring leftover data in packet - handler.OnSpawnEntity(entity); - } - break; - case PacketTypesIn.SpawnPlayer: - if (handler.GetEntityHandlingEnabled()) - { - int EntityID = dataTypes.ReadNextVarInt(packetData); - Guid UUID = dataTypes.ReadNextUUID(packetData); - double X = dataTypes.ReadNextDouble(packetData); - double Y = dataTypes.ReadNextDouble(packetData); - double Z = dataTypes.ReadNextDouble(packetData); - byte Yaw = dataTypes.ReadNextByte(packetData); - byte Pitch = dataTypes.ReadNextByte(packetData); - - Location EntityLocation = new Location(X, Y, Z); - - handler.OnSpawnPlayer(EntityID, UUID, EntityLocation, Yaw, Pitch); - } - break; - case PacketTypesIn.EntityEffect: - if (handler.GetEntityHandlingEnabled()) - { - int entityid = dataTypes.ReadNextVarInt(packetData); - Inventory.Effects effect = Effects.Speed; - if (Enum.TryParse(dataTypes.ReadNextByte(packetData).ToString(), out effect)) - { - int amplifier = dataTypes.ReadNextByte(packetData); - int duration = dataTypes.ReadNextVarInt(packetData); - byte flags = dataTypes.ReadNextByte(packetData); - handler.OnEntityEffect(entityid, effect, amplifier, duration, flags); - } - } - break; - case PacketTypesIn.DestroyEntities: - if (handler.GetEntityHandlingEnabled()) - { - int EntityCount = dataTypes.ReadNextVarInt(packetData); - int[] EntitiesList = new int[EntityCount]; - for (int i = 0; i < EntityCount; i++) - { - EntitiesList[i] = dataTypes.ReadNextVarInt(packetData); - } - handler.OnDestroyEntities(EntitiesList); - } - break; - case PacketTypesIn.DestroyEntity: - if (handler.GetEntityHandlingEnabled()) - { - handler.OnDestroyEntities(new [] { dataTypes.ReadNextVarInt(packetData) }); - } - break; - case PacketTypesIn.EntityPosition: - if (handler.GetEntityHandlingEnabled()) - { - int EntityID = dataTypes.ReadNextVarInt(packetData); - Double DeltaX = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); - Double DeltaY = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); - Double DeltaZ = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); - bool OnGround = dataTypes.ReadNextBool(packetData); - DeltaX = DeltaX / (128 * 32); - DeltaY = DeltaY / (128 * 32); - DeltaZ = DeltaZ / (128 * 32); - handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround); - } - break; - case PacketTypesIn.EntityPositionAndRotation: - if (handler.GetEntityHandlingEnabled()) - { - int EntityID = dataTypes.ReadNextVarInt(packetData); - Double DeltaX = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); - Double DeltaY = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); - Double DeltaZ = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); - byte _yaw = dataTypes.ReadNextByte(packetData); - byte _pitch = dataTypes.ReadNextByte(packetData); - bool OnGround = dataTypes.ReadNextBool(packetData); - DeltaX = DeltaX / (128 * 32); - DeltaY = DeltaY / (128 * 32); - DeltaZ = DeltaZ / (128 * 32); - handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround); - } - break; - case PacketTypesIn.EntityProperties: - if (handler.GetEntityHandlingEnabled()) - { - int EntityID = dataTypes.ReadNextVarInt(packetData); - int NumberOfProperties = protocolversion >= MC117Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextInt(packetData); - Dictionary keys = new Dictionary(); - for (int i = 0; i < NumberOfProperties; i++) - { - string _key = dataTypes.ReadNextString(packetData); - Double _value = dataTypes.ReadNextDouble(packetData); - - List op0 = new List(); - List op1 = new List(); - List op2 = new List(); - int NumberOfModifiers = dataTypes.ReadNextVarInt(packetData); - for (int j = 0; j < NumberOfModifiers; j++) - { - dataTypes.ReadNextUUID(packetData); - Double amount = dataTypes.ReadNextDouble(packetData); - byte operation = dataTypes.ReadNextByte(packetData); - switch (operation) + if (action2 == 0) { - case 0: op0.Add(amount); break; - case 1: op1.Add(amount); break; - case 2: op2.Add(amount + 1); break; + json = titletext; + titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); + } + else if (action2 == 1) + { + json = subtitletext; + subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); + } + else if (action2 == 2) + { + json = actionbartext; + actionbartext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); + } + else if (action2 == 3) + { + fadein = dataTypes.ReadNextInt(packetData); + stay = dataTypes.ReadNextInt(packetData); + fadeout = dataTypes.ReadNextInt(packetData); } } - if (op0.Count > 0) _value += op0.Sum(); - if (op1.Count > 0) _value *= 1 + op1.Sum(); - if (op2.Count > 0) _value *= op2.Aggregate((a, _x) => a * _x); - keys.Add(_key, _value); + else + { + if (action2 == 0) + { + json = titletext; + titletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); + } + else if (action2 == 1) + { + json = subtitletext; + subtitletext = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); + } + else if (action2 == 2) + { + fadein = dataTypes.ReadNextInt(packetData); + stay = dataTypes.ReadNextInt(packetData); + fadeout = dataTypes.ReadNextInt(packetData); + } + } + handler.OnTitle(action2, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json); } - handler.OnEntityProperties(EntityID, keys); - } - break; - case PacketTypesIn.EntityMetadata: - if (handler.GetEntityHandlingEnabled()) - { - int EntityID = dataTypes.ReadNextVarInt(packetData); - Dictionary metadata = dataTypes.ReadNextMetadata(packetData, itemPalette); - int healthField = protocolversion >= MC114Version ? 8 : 7; // Health is field no. 7 in 1.10+ and 8 in 1.14+ - if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float)) - handler.OnEntityHealth(EntityID, (float)metadata[healthField]); - handler.OnEntityMetadata(EntityID, metadata); - } - break; - case PacketTypesIn.EntityStatus: - if (handler.GetEntityHandlingEnabled()) - { - int entityId = dataTypes.ReadNextInt(packetData); - byte status = dataTypes.ReadNextByte(packetData); - handler.OnEntityStatus(entityId, status); - } - break; - case PacketTypesIn.TimeUpdate: - long WorldAge = dataTypes.ReadNextLong(packetData); - long TimeOfday = dataTypes.ReadNextLong(packetData); - handler.OnTimeUpdate(WorldAge, TimeOfday); - break; - case PacketTypesIn.EntityTeleport: - if (handler.GetEntityHandlingEnabled()) - { - int EntityID = dataTypes.ReadNextVarInt(packetData); - Double X = dataTypes.ReadNextDouble(packetData); - Double Y = dataTypes.ReadNextDouble(packetData); - Double Z = dataTypes.ReadNextDouble(packetData); - byte EntityYaw = dataTypes.ReadNextByte(packetData); - byte EntityPitch = dataTypes.ReadNextByte(packetData); - bool OnGround = dataTypes.ReadNextBool(packetData); - handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround); - } - break; - case PacketTypesIn.UpdateHealth: - float health = dataTypes.ReadNextFloat(packetData); - int food; - if (protocolversion >= MC18Version) - food = dataTypes.ReadNextVarInt(packetData); - else - food = dataTypes.ReadNextShort(packetData); - dataTypes.ReadNextFloat(packetData); // Food Saturation - handler.OnUpdateHealth(health, food); - break; - case PacketTypesIn.SetExperience: - float experiencebar = dataTypes.ReadNextFloat(packetData); - int level = dataTypes.ReadNextVarInt(packetData); - int totalexperience = dataTypes.ReadNextVarInt(packetData); - handler.OnSetExperience(experiencebar, level, totalexperience); - break; - case PacketTypesIn.Explosion: - Location explosionLocation = new Location(dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData)); - float explosionStrength = dataTypes.ReadNextFloat(packetData); - int explosionBlockCount = protocolversion >= MC117Version - ? dataTypes.ReadNextVarInt(packetData) - : dataTypes.ReadNextInt(packetData); - // Ignoring additional fields (records, pushback) - handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount); - break; - case PacketTypesIn.HeldItemChange: - byte slot = dataTypes.ReadNextByte(packetData); - handler.OnHeldItemChange(slot); - break; - case PacketTypesIn.ScoreboardObjective: - string objectivename = dataTypes.ReadNextString(packetData); - byte mode = dataTypes.ReadNextByte(packetData); - string objectivevalue = String.Empty; - int type2 = -1; - if (mode == 0 || mode == 2) - { - objectivevalue = dataTypes.ReadNextString(packetData); - type2 = dataTypes.ReadNextVarInt(packetData); - } - handler.OnScoreboardObjective(objectivename, mode, objectivevalue, type2); - break; - case PacketTypesIn.UpdateScore: - string entityname = dataTypes.ReadNextString(packetData); - byte action3 = dataTypes.ReadNextByte(packetData); - string objectivename2 = null; - int value = -1; - if (action3 != 1 || protocolversion >= MC18Version) - objectivename2 = dataTypes.ReadNextString(packetData); - if (action3 != 1) - value = dataTypes.ReadNextVarInt(packetData); - handler.OnUpdateScore(entityname, action3, objectivename2, value); - break; - case PacketTypesIn.BlockBreakAnimation: - if (handler.GetEntityHandlingEnabled() && handler.GetTerrainEnabled()) - { - int playerId = dataTypes.ReadNextVarInt(packetData); - Location blockLocation = dataTypes.ReadNextLocation(packetData); - byte stage = dataTypes.ReadNextByte(packetData); - handler.OnBlockBreakAnimation(playerId, blockLocation, stage); - } - break; - case PacketTypesIn.EntityAnimation: - if (handler.GetEntityHandlingEnabled()) - { - int playerId2 = dataTypes.ReadNextVarInt(packetData); - byte animation = dataTypes.ReadNextByte(packetData); - handler.OnEntityAnimation(playerId2, animation); - } - break; - default: - return false; //Ignored packet - } + break; + case PacketTypesIn.MultiBlockChange: + if (handler.GetTerrainEnabled()) + { + if (protocolversion >= MC1162Version) + { + long chunkSection = dataTypes.ReadNextLong(packetData); + int sectionX = (int)(chunkSection >> 42); + int sectionY = (int)((chunkSection << 44) >> 44); + int sectionZ = (int)((chunkSection << 22) >> 42); + dataTypes.ReadNextBool(packetData); // Useless boolean + int blocksSize = dataTypes.ReadNextVarInt(packetData); + for (int i = 0; i < blocksSize; i++) + { + ulong block = (ulong)dataTypes.ReadNextVarLong(packetData); + int blockId = (int)(block >> 12); + int localX = (int)((block >> 8) & 0x0F); + int localZ = (int)((block >> 4) & 0x0F); + int localY = (int)(block & 0x0F); + + Block b = new Block((ushort)blockId); + int blockX = (sectionX * 16) + localX; + int blockY = (sectionY * 16) + localY; + int blockZ = (sectionZ * 16) + localZ; + var l = new Location(blockX, blockY, blockZ); + handler.GetWorld().SetBlock(l, b); + } + } + else + { + int chunkX = dataTypes.ReadNextInt(packetData); + int chunkZ = dataTypes.ReadNextInt(packetData); + int recordCount = protocolversion < MC18Version + ? (int)dataTypes.ReadNextShort(packetData) + : dataTypes.ReadNextVarInt(packetData); + + for (int i = 0; i < recordCount; i++) + { + byte locationXZ; + ushort blockIdMeta; + int blockY; + + if (protocolversion < MC18Version) + { + blockIdMeta = dataTypes.ReadNextUShort(packetData); + blockY = (ushort)dataTypes.ReadNextByte(packetData); + locationXZ = dataTypes.ReadNextByte(packetData); + } + else + { + locationXZ = dataTypes.ReadNextByte(packetData); + blockY = (ushort)dataTypes.ReadNextByte(packetData); + blockIdMeta = (ushort)dataTypes.ReadNextVarInt(packetData); + } + + int blockX = locationXZ >> 4; + int blockZ = locationXZ & 0x0F; + Block block = new Block(blockIdMeta); + handler.GetWorld().SetBlock(new Location(chunkX, chunkZ, blockX, blockY, blockZ), block); + } + } + } + break; + case PacketTypesIn.BlockChange: + if (handler.GetTerrainEnabled()) + { + if (protocolversion < MC18Version) + { + int blockX = dataTypes.ReadNextInt(packetData); + int blockY = dataTypes.ReadNextByte(packetData); + int blockZ = dataTypes.ReadNextInt(packetData); + short blockId = (short)dataTypes.ReadNextVarInt(packetData); + byte blockMeta = dataTypes.ReadNextByte(packetData); + handler.GetWorld().SetBlock(new Location(blockX, blockY, blockZ), new Block(blockId, blockMeta)); + } + else + { + handler.GetWorld().SetBlock(dataTypes.ReadNextLocation(packetData), new Block((ushort)dataTypes.ReadNextVarInt(packetData))); + } + } + break; + case PacketTypesIn.MapChunkBulk: + if (protocolversion < MC19Version && handler.GetTerrainEnabled()) + { + int chunkCount; + bool hasSkyLight; + Queue chunkData = packetData; + + //Read global fields + if (protocolversion < MC18Version) + { + chunkCount = dataTypes.ReadNextShort(packetData); + int compressedDataSize = dataTypes.ReadNextInt(packetData); + hasSkyLight = dataTypes.ReadNextBool(packetData); + byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData); + byte[] decompressed = ZlibUtils.Decompress(compressed); + chunkData = new Queue(decompressed); + } + else + { + hasSkyLight = dataTypes.ReadNextBool(packetData); + chunkCount = dataTypes.ReadNextVarInt(packetData); + } + + //Read chunk records + int[] chunkXs = new int[chunkCount]; + int[] chunkZs = new int[chunkCount]; + ushort[] chunkMasks = new ushort[chunkCount]; + ushort[] addBitmaps = new ushort[chunkCount]; + for (int chunkColumnNo = 0; chunkColumnNo < chunkCount; chunkColumnNo++) + { + chunkXs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); + chunkZs[chunkColumnNo] = dataTypes.ReadNextInt(packetData); + chunkMasks[chunkColumnNo] = dataTypes.ReadNextUShort(packetData); + addBitmaps[chunkColumnNo] = protocolversion < MC18Version + ? dataTypes.ReadNextUShort(packetData) + : (ushort)0; + } + + //Process chunk records + for (int chunkColumnNo = 0; chunkColumnNo < chunkCount; chunkColumnNo++) + pTerrain.ProcessChunkColumnData(chunkXs[chunkColumnNo], chunkZs[chunkColumnNo], chunkMasks[chunkColumnNo], addBitmaps[chunkColumnNo], hasSkyLight, true, currentDimension, chunkData); + } + break; + case PacketTypesIn.UnloadChunk: + if (protocolversion >= MC19Version && handler.GetTerrainEnabled()) + { + int chunkX = dataTypes.ReadNextInt(packetData); + int chunkZ = dataTypes.ReadNextInt(packetData); + handler.GetWorld()[chunkX, chunkZ] = null; + } + break; + case PacketTypesIn.PlayerInfo: + if (protocolversion >= MC18Version) + { + int action = dataTypes.ReadNextVarInt(packetData); + int numActions = dataTypes.ReadNextVarInt(packetData); + for (int i = 0; i < numActions; i++) + { + Guid uuid = dataTypes.ReadNextUUID(packetData); + switch (action) + { + case 0x00: //Player Join + string name = dataTypes.ReadNextString(packetData); + int propNum = dataTypes.ReadNextVarInt(packetData); + for (int p = 0; p < propNum; p++) + { + string key = dataTypes.ReadNextString(packetData); + string val = dataTypes.ReadNextString(packetData); + if (dataTypes.ReadNextBool(packetData)) + dataTypes.ReadNextString(packetData); + } + handler.OnGamemodeUpdate(uuid, dataTypes.ReadNextVarInt(packetData)); + dataTypes.ReadNextVarInt(packetData); + if (dataTypes.ReadNextBool(packetData)) + dataTypes.ReadNextString(packetData); + handler.OnPlayerJoin(uuid, name); + break; + case 0x01: //Update gamemode + handler.OnGamemodeUpdate(uuid, dataTypes.ReadNextVarInt(packetData)); + break; + case 0x02: //Update latency + int latency = dataTypes.ReadNextVarInt(packetData); + handler.OnLatencyUpdate(uuid, latency); //Update latency; + break; + case 0x03: //Update display name + if (dataTypes.ReadNextBool(packetData)) + dataTypes.ReadNextString(packetData); + break; + case 0x04: //Player Leave + handler.OnPlayerLeave(uuid); + break; + default: + //Unknown player list item type + break; + } + } + } + else //MC 1.7.X does not provide UUID in tab-list updates + { + string name = dataTypes.ReadNextString(packetData); + bool online = dataTypes.ReadNextBool(packetData); + short ping = dataTypes.ReadNextShort(packetData); + Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray()); + if (online) + handler.OnPlayerJoin(FakeUUID, name); + else handler.OnPlayerLeave(FakeUUID); + } + break; + case PacketTypesIn.TabComplete: + if (protocolversion >= MC113Version) + { + autocomplete_transaction_id = dataTypes.ReadNextVarInt(packetData); + dataTypes.ReadNextVarInt(packetData); // Start of text to replace + dataTypes.ReadNextVarInt(packetData); // Length of text to replace + } + + int autocomplete_count = dataTypes.ReadNextVarInt(packetData); + autocomplete_result.Clear(); + + for (int i = 0; i < autocomplete_count; i++) + { + autocomplete_result.Add(dataTypes.ReadNextString(packetData)); + if (protocolversion >= MC113Version) + { + // Skip optional tooltip for each tab-complete result + if (dataTypes.ReadNextBool(packetData)) + dataTypes.ReadNextString(packetData); + } + } + + autocomplete_received = true; + break; + case PacketTypesIn.PluginMessage: + String channel = dataTypes.ReadNextString(packetData); + // Length is unneeded as the whole remaining packetData is the entire payload of the packet. + if (protocolversion < MC18Version) + pForge.ReadNextVarShort(packetData); + handler.OnPluginChannelMessage(channel, packetData.ToArray()); + return pForge.HandlePluginMessage(channel, packetData, ref currentDimension); + case PacketTypesIn.Disconnect: + handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, ChatParser.ParseText(dataTypes.ReadNextString(packetData))); + return false; + case PacketTypesIn.SetCompression: + if (protocolversion >= MC18Version && protocolversion < MC19Version) + compression_treshold = dataTypes.ReadNextVarInt(packetData); + break; + case PacketTypesIn.OpenWindow: + if (handler.GetInventoryEnabled()) + { + if (protocolversion < MC114Version) + { + // MC 1.13 or lower + byte windowID = dataTypes.ReadNextByte(packetData); + string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper(); + ContainerTypeOld inventoryType = (ContainerTypeOld)Enum.Parse(typeof(ContainerTypeOld), type); + string title = dataTypes.ReadNextString(packetData); + byte slots = dataTypes.ReadNextByte(packetData); + Container inventory = new Container(windowID, inventoryType, ChatParser.ParseText(title)); + handler.OnInventoryOpen(windowID, inventory); + } + else + { + // MC 1.14 or greater + int windowID = dataTypes.ReadNextVarInt(packetData); + int windowType = dataTypes.ReadNextVarInt(packetData); + string title = dataTypes.ReadNextString(packetData); + Container inventory = new Container(windowID, windowType, ChatParser.ParseText(title)); + handler.OnInventoryOpen(windowID, inventory); + } + } + break; + case PacketTypesIn.CloseWindow: + if (handler.GetInventoryEnabled()) + { + byte windowID = dataTypes.ReadNextByte(packetData); + lock (window_actions) { window_actions[windowID] = 0; } + handler.OnInventoryClose(windowID); + } + break; + case PacketTypesIn.WindowItems: + if (handler.GetInventoryEnabled()) + { + byte windowId = dataTypes.ReadNextByte(packetData); + + int stateId = -1; + + if (protocolversion >= MC1181Version) + stateId = dataTypes.ReadNextVarInt(packetData); + + int elements = dataTypes.ReadNextVarInt(packetData); + Dictionary inventorySlots = new Dictionary(); + for (short slotId = 0; slotId < elements; slotId++) + { + Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); + if (item != null) + inventorySlots[slotId] = item; + } + handler.OnWindowItems(windowId, inventorySlots); + } + break; + case PacketTypesIn.SetSlot: + if (handler.GetInventoryEnabled()) + { + byte windowID = dataTypes.ReadNextByte(packetData); + + int stateId = -1; + + if (protocolversion >= MC1181Version) + stateId = dataTypes.ReadNextVarInt(packetData); + + short slotID = dataTypes.ReadNextShort(packetData); + Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); + handler.OnSetSlot(windowID, slotID, item); + } + break; + case PacketTypesIn.WindowConfirmation: + if (handler.GetInventoryEnabled()) + { + byte windowID = dataTypes.ReadNextByte(packetData); + short actionID = dataTypes.ReadNextShort(packetData); + bool accepted = dataTypes.ReadNextBool(packetData); + if (!accepted) + { + SendWindowConfirmation(windowID, actionID, accepted); + } + } + break; + case PacketTypesIn.ResourcePackSend: + string url = dataTypes.ReadNextString(packetData); + string hash = dataTypes.ReadNextString(packetData); + bool forced = true; // Assume forced for MC 1.16 and below + if (protocolversion >= MC117Version) + { + forced = dataTypes.ReadNextBool(packetData); + String forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(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 + byte[] responseHeader = new byte[0]; + if (protocolversion < MC110Version) //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()) + { + Entity entity = dataTypes.ReadNextEntity(packetData, entityPalette, false); + handler.OnSpawnEntity(entity); + } + break; + case PacketTypesIn.EntityEquipment: + if (handler.GetEntityHandlingEnabled()) + { + int entityid = dataTypes.ReadNextVarInt(packetData); + if (protocolversion >= MC116Version) + { + bool hasNext; + do + { + byte bitsData = dataTypes.ReadNextByte(packetData); + // Top bit set if another entry follows, and otherwise unset if this is the last item in the array + hasNext = (bitsData >> 7) == 1 ? true : false; + int slot2 = bitsData >> 1; + Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); + handler.OnEntityEquipment(entityid, slot2, item); + } while (hasNext); + } + else + { + int slot2 = dataTypes.ReadNextVarInt(packetData); + Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); + handler.OnEntityEquipment(entityid, slot2, item); + } + } + break; + case PacketTypesIn.SpawnLivingEntity: + if (handler.GetEntityHandlingEnabled()) + { + Entity entity = dataTypes.ReadNextEntity(packetData, entityPalette, true); + // packet before 1.15 has metadata at the end + // this is not handled in dataTypes.ReadNextEntity() + // we are simply ignoring leftover data in packet + handler.OnSpawnEntity(entity); + } + break; + case PacketTypesIn.SpawnPlayer: + if (handler.GetEntityHandlingEnabled()) + { + int EntityID = dataTypes.ReadNextVarInt(packetData); + Guid UUID = dataTypes.ReadNextUUID(packetData); + double X = dataTypes.ReadNextDouble(packetData); + double Y = dataTypes.ReadNextDouble(packetData); + double Z = dataTypes.ReadNextDouble(packetData); + byte Yaw = dataTypes.ReadNextByte(packetData); + byte Pitch = dataTypes.ReadNextByte(packetData); + + Location EntityLocation = new Location(X, Y, Z); + + handler.OnSpawnPlayer(EntityID, UUID, EntityLocation, Yaw, Pitch); + } + break; + case PacketTypesIn.EntityEffect: + if (handler.GetEntityHandlingEnabled()) + { + int entityid = dataTypes.ReadNextVarInt(packetData); + Inventory.Effects effect = Effects.Speed; + if (Enum.TryParse(dataTypes.ReadNextByte(packetData).ToString(), out effect)) + { + int amplifier = dataTypes.ReadNextByte(packetData); + int duration = dataTypes.ReadNextVarInt(packetData); + byte flags = dataTypes.ReadNextByte(packetData); + handler.OnEntityEffect(entityid, effect, amplifier, duration, flags); + } + } + break; + case PacketTypesIn.DestroyEntities: + if (handler.GetEntityHandlingEnabled()) + { + int EntityCount = dataTypes.ReadNextVarInt(packetData); + int[] EntitiesList = new int[EntityCount]; + for (int i = 0; i < EntityCount; i++) + { + EntitiesList[i] = dataTypes.ReadNextVarInt(packetData); + } + handler.OnDestroyEntities(EntitiesList); + } + break; + case PacketTypesIn.DestroyEntity: + if (handler.GetEntityHandlingEnabled()) + { + handler.OnDestroyEntities(new[] { dataTypes.ReadNextVarInt(packetData) }); + } + break; + case PacketTypesIn.EntityPosition: + if (handler.GetEntityHandlingEnabled()) + { + int EntityID = dataTypes.ReadNextVarInt(packetData); + Double DeltaX = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); + Double DeltaY = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); + Double DeltaZ = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); + bool OnGround = dataTypes.ReadNextBool(packetData); + DeltaX = DeltaX / (128 * 32); + DeltaY = DeltaY / (128 * 32); + DeltaZ = DeltaZ / (128 * 32); + handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround); + } + break; + case PacketTypesIn.EntityPositionAndRotation: + if (handler.GetEntityHandlingEnabled()) + { + int EntityID = dataTypes.ReadNextVarInt(packetData); + Double DeltaX = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); + Double DeltaY = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); + Double DeltaZ = Convert.ToDouble(dataTypes.ReadNextShort(packetData)); + byte _yaw = dataTypes.ReadNextByte(packetData); + byte _pitch = dataTypes.ReadNextByte(packetData); + bool OnGround = dataTypes.ReadNextBool(packetData); + DeltaX = DeltaX / (128 * 32); + DeltaY = DeltaY / (128 * 32); + DeltaZ = DeltaZ / (128 * 32); + handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround); + } + break; + case PacketTypesIn.EntityProperties: + if (handler.GetEntityHandlingEnabled()) + { + int EntityID = dataTypes.ReadNextVarInt(packetData); + int NumberOfProperties = protocolversion >= MC117Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextInt(packetData); + Dictionary keys = new Dictionary(); + for (int i = 0; i < NumberOfProperties; i++) + { + string _key = dataTypes.ReadNextString(packetData); + Double _value = dataTypes.ReadNextDouble(packetData); + + List op0 = new List(); + List op1 = new List(); + List op2 = new List(); + int NumberOfModifiers = dataTypes.ReadNextVarInt(packetData); + for (int j = 0; j < NumberOfModifiers; j++) + { + dataTypes.ReadNextUUID(packetData); + Double amount = dataTypes.ReadNextDouble(packetData); + byte operation = dataTypes.ReadNextByte(packetData); + switch (operation) + { + case 0: op0.Add(amount); break; + case 1: op1.Add(amount); break; + case 2: op2.Add(amount + 1); break; + } + } + if (op0.Count > 0) _value += op0.Sum(); + if (op1.Count > 0) _value *= 1 + op1.Sum(); + if (op2.Count > 0) _value *= op2.Aggregate((a, _x) => a * _x); + keys.Add(_key, _value); + } + handler.OnEntityProperties(EntityID, keys); + } + break; + case PacketTypesIn.EntityMetadata: + if (handler.GetEntityHandlingEnabled()) + { + int EntityID = dataTypes.ReadNextVarInt(packetData); + Dictionary metadata = dataTypes.ReadNextMetadata(packetData, itemPalette); + int healthField = protocolversion >= MC114Version ? 8 : 7; // Health is field no. 7 in 1.10+ and 8 in 1.14+ + if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float)) + handler.OnEntityHealth(EntityID, (float)metadata[healthField]); + handler.OnEntityMetadata(EntityID, metadata); + } + break; + case PacketTypesIn.EntityStatus: + if (handler.GetEntityHandlingEnabled()) + { + int entityId = dataTypes.ReadNextInt(packetData); + byte status = dataTypes.ReadNextByte(packetData); + handler.OnEntityStatus(entityId, status); + } + break; + case PacketTypesIn.TimeUpdate: + long WorldAge = dataTypes.ReadNextLong(packetData); + long TimeOfday = dataTypes.ReadNextLong(packetData); + handler.OnTimeUpdate(WorldAge, TimeOfday); + break; + case PacketTypesIn.EntityTeleport: + if (handler.GetEntityHandlingEnabled()) + { + int EntityID = dataTypes.ReadNextVarInt(packetData); + Double X = dataTypes.ReadNextDouble(packetData); + Double Y = dataTypes.ReadNextDouble(packetData); + Double Z = dataTypes.ReadNextDouble(packetData); + byte EntityYaw = dataTypes.ReadNextByte(packetData); + byte EntityPitch = dataTypes.ReadNextByte(packetData); + bool OnGround = dataTypes.ReadNextBool(packetData); + handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround); + } + break; + case PacketTypesIn.UpdateHealth: + float health = dataTypes.ReadNextFloat(packetData); + int food; + if (protocolversion >= MC18Version) + food = dataTypes.ReadNextVarInt(packetData); + else + food = dataTypes.ReadNextShort(packetData); + dataTypes.ReadNextFloat(packetData); // Food Saturation + handler.OnUpdateHealth(health, food); + break; + case PacketTypesIn.SetExperience: + float experiencebar = dataTypes.ReadNextFloat(packetData); + int level = dataTypes.ReadNextVarInt(packetData); + int totalexperience = dataTypes.ReadNextVarInt(packetData); + handler.OnSetExperience(experiencebar, level, totalexperience); + break; + case PacketTypesIn.Explosion: + Location explosionLocation = new Location(dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData), dataTypes.ReadNextFloat(packetData)); + float explosionStrength = dataTypes.ReadNextFloat(packetData); + int explosionBlockCount = protocolversion >= MC117Version + ? dataTypes.ReadNextVarInt(packetData) + : dataTypes.ReadNextInt(packetData); + // Ignoring additional fields (records, pushback) + handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount); + break; + case PacketTypesIn.HeldItemChange: + byte slot = dataTypes.ReadNextByte(packetData); + handler.OnHeldItemChange(slot); + break; + case PacketTypesIn.ScoreboardObjective: + string objectivename = dataTypes.ReadNextString(packetData); + byte mode = dataTypes.ReadNextByte(packetData); + string objectivevalue = String.Empty; + int type2 = -1; + if (mode == 0 || mode == 2) + { + objectivevalue = dataTypes.ReadNextString(packetData); + type2 = dataTypes.ReadNextVarInt(packetData); + } + handler.OnScoreboardObjective(objectivename, mode, objectivevalue, type2); + break; + case PacketTypesIn.UpdateScore: + string entityname = dataTypes.ReadNextString(packetData); + byte action3 = dataTypes.ReadNextByte(packetData); + string objectivename2 = null; + int value = -1; + if (action3 != 1 || protocolversion >= MC18Version) + objectivename2 = dataTypes.ReadNextString(packetData); + if (action3 != 1) + value = dataTypes.ReadNextVarInt(packetData); + handler.OnUpdateScore(entityname, action3, objectivename2, value); + break; + case PacketTypesIn.BlockBreakAnimation: + if (handler.GetEntityHandlingEnabled() && handler.GetTerrainEnabled()) + { + int playerId = dataTypes.ReadNextVarInt(packetData); + Location blockLocation = dataTypes.ReadNextLocation(packetData); + byte stage = dataTypes.ReadNextByte(packetData); + handler.OnBlockBreakAnimation(playerId, blockLocation, stage); + } + break; + case PacketTypesIn.EntityAnimation: + if (handler.GetEntityHandlingEnabled()) + { + int playerId2 = dataTypes.ReadNextVarInt(packetData); + byte animation = dataTypes.ReadNextByte(packetData); + handler.OnEntityAnimation(playerId2, animation); + } + break; + default: + return false; //Ignored packet + } return true; //Packet processed } catch (Exception innerException) @@ -1235,7 +1237,7 @@ namespace MinecraftClient.Protocol.Handlers List clone = packetData.ToList(); handler.OnNetworkPacket(packetID, clone, login_phase, false); } - + //The inner packet byte[] the_packet = dataTypes.ConcatBytes(dataTypes.GetVarInt(packetID), packetData.ToArray()); @@ -1904,21 +1906,21 @@ namespace MinecraftClient.Protocol.Handlers switch (action) { - case WindowActionType.LeftClick: button = 0; break; - case WindowActionType.RightClick: button = 1; break; - case WindowActionType.MiddleClick: button = 2; mode = 3; break; - case WindowActionType.ShiftClick: button = 0; mode = 1; item = new Item(ItemType.Null, 0, null); break; - case WindowActionType.DropItem: button = 0; mode = 4; item = new Item(ItemType.Null, 0, null); break; - case WindowActionType.DropItemStack: button = 1; mode = 4; item = new Item(ItemType.Null, 0, null); break; - case WindowActionType.StartDragLeft: button = 0; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; - case WindowActionType.StartDragRight: button = 4; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; - case WindowActionType.StartDragMiddle: button = 8; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; - case WindowActionType.EndDragLeft: button = 2; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; - case WindowActionType.EndDragRight: button = 6; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; - case WindowActionType.EndDragMiddle: button = 10; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; - case WindowActionType.AddDragLeft: button = 1; mode = 5; item = new Item(ItemType.Null, 0, null); break; - case WindowActionType.AddDragRight: button = 5; mode = 5; item = new Item(ItemType.Null, 0, null); break; - case WindowActionType.AddDragMiddle: button = 9; mode = 5; item = new Item(ItemType.Null, 0, null); break; + case WindowActionType.LeftClick: button = 0; break; + case WindowActionType.RightClick: button = 1; break; + case WindowActionType.MiddleClick: button = 2; mode = 3; break; + case WindowActionType.ShiftClick: button = 0; mode = 1; item = new Item(ItemType.Null, 0, null); break; + case WindowActionType.DropItem: button = 0; mode = 4; item = new Item(ItemType.Null, 0, null); break; + case WindowActionType.DropItemStack: button = 1; mode = 4; item = new Item(ItemType.Null, 0, null); break; + case WindowActionType.StartDragLeft: button = 0; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; + case WindowActionType.StartDragRight: button = 4; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; + case WindowActionType.StartDragMiddle: button = 8; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; + case WindowActionType.EndDragLeft: button = 2; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; + case WindowActionType.EndDragRight: button = 6; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; + case WindowActionType.EndDragMiddle: button = 10; mode = 5; item = new Item(ItemType.Null, 0, null); slotId = -999; break; + case WindowActionType.AddDragLeft: button = 1; mode = 5; item = new Item(ItemType.Null, 0, null); break; + case WindowActionType.AddDragRight: button = 5; mode = 5; item = new Item(ItemType.Null, 0, null); break; + case WindowActionType.AddDragMiddle: button = 9; mode = 5; item = new Item(ItemType.Null, 0, null); break; } List packet = new List(); @@ -2031,7 +2033,7 @@ namespace MinecraftClient.Protocol.Handlers catch (System.IO.IOException) { return false; } catch (ObjectDisposedException) { return false; } } - + public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags) { if (protocolversion <= MC113Version) @@ -2050,7 +2052,7 @@ namespace MinecraftClient.Protocol.Handlers catch (System.IO.IOException) { return false; } catch (ObjectDisposedException) { return false; } } - else { return false; } + else { return false; } } public bool SendWindowConfirmation(byte windowID, short actionID, bool accepted) diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index 089fad6b..c6db23d3 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -41,7 +41,8 @@ mcc.with_forge=, with Forge mcc.handshake=§8Handshake successful. (Server ID: {0}) mcc.realms_available=You have access to the following Realms worlds mcc.realms_join=Use realms: as server IP to join a Realms world - +mcc.generator.generating=Generating {0} palette using the dataset: {1} +mcc.generator.done=Succesfully generated {0} palette using the dataset: {1} [debug] # Messages from MCC Debug Mode @@ -92,6 +93,11 @@ error.realms.access_denied=This Realms world does not exist or access was denied error.realms.server_unavailable=Realms server may require some time to start up. Please retry again later. error.realms.server_id=Invalid or unknown Realms server ID. error.realms.disabled=Trying to join a Realms world but Realms support is disabled in config +error.missing.argument=You are missing argument {0} +error.usage=Usage: +error.generator.invalid=Invalid usage of the generator command! +error.generator.path=Invalid data path provided! (The path either does not exists or you have made a typo) +error.generator.json=The provided path must be a path to a file that is in .json format! [internal command] # MCC internal help command From dc0021d99092e99f892aa1e6a51a8940c44a1cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Tue, 28 Jun 2022 17:09:08 +0200 Subject: [PATCH 04/26] Fixed entity health update event (This will also fix the Auto Attack bot) --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index e8ed9d4b..81aae204 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1059,7 +1059,14 @@ namespace MinecraftClient.Protocol.Handlers { int EntityID = dataTypes.ReadNextVarInt(packetData); Dictionary metadata = dataTypes.ReadNextMetadata(packetData, itemPalette); - int healthField = protocolversion >= MC114Version ? 8 : 7; // Health is field no. 7 in 1.10+ and 8 in 1.14+ + + int healthField = 7; // From 1.10 to 1.14 (excluding 1.14) + + if (protocolversion >= MC114Version && protocolversion <= MC1165Version) + healthField = 8; + else if (protocolversion >= MC117Version) + healthField = 9; + if (metadata.ContainsKey(healthField) && metadata[healthField] != null && metadata[healthField].GetType() == typeof(float)) handler.OnEntityHealth(EntityID, (float)metadata[healthField]); handler.OnEntityMetadata(EntityID, metadata); From b5c4cd75668a79b3e9bec232c99d591059721983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Tue, 28 Jun 2022 17:37:16 +0200 Subject: [PATCH 05/26] Fixed Auto Attack bot (forgot to add a method to a commit before) Tested on 1.18.2 --- MinecraftClient/ChatBots/AutoAttack.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/ChatBots/AutoAttack.cs b/MinecraftClient/ChatBots/AutoAttack.cs index fae80faa..2fabee56 100644 --- a/MinecraftClient/ChatBots/AutoAttack.cs +++ b/MinecraftClient/ChatBots/AutoAttack.cs @@ -100,7 +100,7 @@ namespace MinecraftClient.ChatBots } } } - + if (entitiesToAttack.ContainsKey(priorityEntity)) { // check entity distance and health again @@ -144,6 +144,22 @@ namespace MinecraftClient.ChatBots } } + public override void OnEntityHealth(Entity entity, float health) + { + if (!entity.Type.IsHostile()) + return; + + if (entitiesToAttack.ContainsKey(entity.ID)) + { + entitiesToAttack[entity.ID].Health = health; + + if (entitiesToAttack[entity.ID].Health <= 0) + { + entitiesToAttack.Remove(entity.ID); + } + } + } + public override void OnEntityMove(Entity entity) { shouldAttackEntity(entity); From 3d8c1121591118e00f7777ff345f5657a7b5143d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Fri, 1 Jul 2022 18:59:58 +0200 Subject: [PATCH 06/26] Implemented "Click Window" for 1.18 (now sending the new required fields), formated few files with Visual Studio formatting. PS: left debug for people to see, I'll remove it once everything is working --- MinecraftClient/Inventory/Container.cs | 5 ++ MinecraftClient/McClient.cs | 15 +++--- .../Protocol/Handlers/DataTypes.cs | 19 +++++++- .../Protocol/Handlers/Protocol16.cs | 24 ++++++---- .../Protocol/Handlers/Protocol18.cs | 47 +++++++++++++++++-- MinecraftClient/Protocol/IMinecraftCom.cs | 10 ++-- .../Protocol/IMinecraftComHandler.cs | 3 +- 7 files changed, 94 insertions(+), 29 deletions(-) diff --git a/MinecraftClient/Inventory/Container.cs b/MinecraftClient/Inventory/Container.cs index 85f3e9a8..b39892b6 100644 --- a/MinecraftClient/Inventory/Container.cs +++ b/MinecraftClient/Inventory/Container.cs @@ -25,6 +25,11 @@ namespace MinecraftClient.Inventory /// public string Title; + /// + /// state of container + /// + public int StateID; + /// /// Container Items /// diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 94eda171..9d0fbf7c 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1066,7 +1066,7 @@ namespace MinecraftClient /// How long to wait until the path is evaluated (default: 5 seconds) /// When location is unreachable, computation will reach timeout, then optionally fallback to a close location within maxOffset /// True if a path has been found - public bool MoveTo(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout=null) + public bool MoveTo(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null) { lock (locationLock) { @@ -1244,7 +1244,7 @@ namespace MinecraftClient item = inventories[windowId].Items[slotId]; // Inventory update must be after sending packet - bool result = handler.SendWindowAction(windowId, slotId, action, item); + bool result = handler.SendWindowAction(windowId, slotId, action, item, inventories[windowId].Items, inventories[windowId].StateID); // Update our inventory base on action type var inventory = GetInventory(windowId); @@ -1707,7 +1707,7 @@ namespace MinecraftClient /// Teleporting to other entityies is NOT implemented yet public bool Spectate(Entity entity) { - if(entity.Type == EntityType.Player) + if (entity.Type == EntityType.Player) { return SpectateByUUID(entity.UUID); } @@ -1723,9 +1723,9 @@ namespace MinecraftClient /// UUID of player/entity to teleport to public bool SpectateByUUID(Guid UUID) { - if(GetGamemode() == 3) + if (GetGamemode() == 3) { - if(InvokeRequired) + if (InvokeRequired) return InvokeOnMainThread(() => SpectateByUUID(UUID)); return handler.SendSpectate(UUID); } @@ -1855,7 +1855,7 @@ namespace MinecraftClient /// Check if the client is currently processing a Movement. /// /// true if a movement is currently handled - public bool ClientIsMoving() + public bool ClientIsMoving() { return terrainAndMovementsEnabled && locationReceived && ((steps != null && steps.Count > 0) || (path != null && path.Count > 0)); } @@ -2030,11 +2030,12 @@ namespace MinecraftClient /// /// Inventory ID /// Item list, key = slot ID, value = Item information - public void OnWindowItems(byte inventoryID, Dictionary itemList) + public void OnWindowItems(byte inventoryID, Dictionary itemList, int stateId) { if (inventories.ContainsKey(inventoryID)) { inventories[inventoryID].Items = itemList; + inventories[inventoryID].StateID = stateId; DispatchBotEvent(bot => bot.OnInventoryUpdate(inventoryID)); } } diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs index 93c6562e..3bcacf7b 100644 --- a/MinecraftClient/Protocol/Handlers/DataTypes.cs +++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs @@ -401,7 +401,7 @@ namespace MinecraftClient.Protocol.Handlers { entityType = entityPalette.FromId(ReadNextByte(cache), living); } - + Double entityX = ReadNextDouble(cache); Double entityY = ReadNextDouble(cache); Double entityZ = ReadNextDouble(cache); @@ -1028,6 +1028,23 @@ namespace MinecraftClient.Protocol.Handlers return slotData.ToArray(); } + public string ByteArrayToString(byte[] ba) + { + return BitConverter.ToString(ba).Replace("-", " "); + } + + public byte[] GetSlotsArray(Dictionary items, ItemPalette itemPalette) + { + byte[] slotsArray = new byte[items.Count]; + + foreach (KeyValuePair item in items) + { + slotsArray = ConcatBytes(slotsArray, GetShort((short)item.Key), GetItemSlot(item.Value, itemPalette)); + } + + return slotsArray; + } + /// /// Get protocol block face from Direction /// diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index c0b04c33..c7e0b9ef 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -94,7 +94,8 @@ namespace MinecraftClient.Protocol.Handlers int nbr = 0; switch (id) { - case 0x00: byte[] keepalive = new byte[5] { 0, 0, 0, 0, 0 }; + case 0x00: + byte[] keepalive = new byte[5] { 0, 0, 0, 0, 0 }; Receive(keepalive, 1, 4, SocketFlags.None); handler.OnServerKeepAlive(); Send(keepalive); break; @@ -183,11 +184,13 @@ namespace MinecraftClient.Protocol.Handlers case 0xCF: if (protocolversion > 51) { readNextString(); readData(1); readNextString(); } readData(4); break; case 0xD0: if (protocolversion > 51) { readData(1); readNextString(); } break; case 0xD1: if (protocolversion > 51) { readNextTeamData(); } break; - case 0xFA: string channel = readNextString(); + case 0xFA: + string channel = readNextString(); byte[] payload = readNextByteArray(); handler.OnPluginChannelMessage(channel, payload); break; - case 0xFF: string reason = readNextString(); + case 0xFF: + string reason = readNextString(); handler.OnConnectionLost(ChatBot.DisconnectReason.InGameKick, reason); break; default: return false; //unknown packet! } @@ -666,12 +669,12 @@ namespace MinecraftClient.Protocol.Handlers } catch (SocketException) { return false; } } - + public bool SendUpdateSign(Location location, string line1, string line2, string line3, string line4) { return false; //Currently not implemented } - + public bool SendBrandInfo(string brandInfo) { return false; //Only supported since MC 1.7 @@ -701,23 +704,23 @@ namespace MinecraftClient.Protocol.Handlers { return false; //Currently not implemented } - + public bool SendInteractEntity(int EntityID, int type, int hand) { return false; //Currently not implemented } - + public bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags) { return false; //Currently not implemented } - + public bool SendUseItem(int hand) { return false; //Currently not implemented } - public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item) + public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, Dictionary Items, int stateId) { return false; //Currently not implemented } @@ -759,7 +762,8 @@ namespace MinecraftClient.Protocol.Handlers /// packet Data public bool SendPluginChannelPacket(string channel, byte[] data) { - try { + try + { byte[] channelLength = BitConverter.GetBytes((short)channel.Length); Array.Reverse(channelLength); diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 81aae204..aa51647f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -850,7 +850,7 @@ namespace MinecraftClient.Protocol.Handlers if (item != null) inventorySlots[slotId] = item; } - handler.OnWindowItems(windowId, inventorySlots); + handler.OnWindowItems(windowId, inventorySlots, stateId); } break; case PacketTypesIn.SetSlot: @@ -1895,7 +1895,7 @@ namespace MinecraftClient.Protocol.Handlers catch (ObjectDisposedException) { return false; } } - public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item) + public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, Dictionary items, int stateId) { try { @@ -1931,14 +1931,51 @@ namespace MinecraftClient.Protocol.Handlers } List packet = new List(); + + log.Info("Window id: " + windowId + " - State id: " + stateId + " - Slot id: " + slotId + " - Mode: " + mode); + log.Info("Bytes > " + (byte)windowId + " - State id: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(stateId)) + " - Slot id: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(slotId)) + " - Mode: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(mode))); + packet.Add((byte)windowId); - packet.AddRange(dataTypes.GetShort((short)slotId)); + + // 1.18+ + if (protocolversion > MC1171Version) + { + packet.AddRange(dataTypes.GetVarInt(stateId)); + packet.AddRange(dataTypes.GetShort((short)slotId)); + } + // 1.17.1 + else if (protocolversion == MC1171Version) + { + packet.AddRange(dataTypes.GetShort((short)slotId)); + packet.AddRange(dataTypes.GetVarInt(stateId)); + } + // Older + else + { + packet.AddRange(dataTypes.GetShort((short)slotId)); + } + packet.Add(button); if (protocolversion < MC117Version) packet.AddRange(dataTypes.GetShort(actionNumber)); - if (protocolversion >= MC19Version) + if (protocolversion >= MC1165Version) packet.AddRange(dataTypes.GetVarInt(mode)); - else packet.Add(mode); + + // 1.17+ + if (protocolversion >= MC117Version) + { + byte[] arrayOfSlots = dataTypes.GetSlotsArray(items, itemPalette); + + log.Info("Length: " + sizeof(byte) * arrayOfSlots.Length); + log.Info("Array: " + dataTypes.ByteArrayToString(arrayOfSlots)); + + packet.AddRange(dataTypes.GetVarInt(sizeof(byte) * arrayOfSlots.Length)); + packet.AddRange(arrayOfSlots); + } + packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); + + log.Info("Packet data: " + dataTypes.ByteArrayToString(packet.ToArray())); + SendPacket(PacketTypesOut.ClickWindow, packet); return true; } diff --git a/MinecraftClient/Protocol/IMinecraftCom.cs b/MinecraftClient/Protocol/IMinecraftCom.cs index 54d19e77..97aaca35 100644 --- a/MinecraftClient/Protocol/IMinecraftCom.cs +++ b/MinecraftClient/Protocol/IMinecraftCom.cs @@ -94,7 +94,7 @@ namespace MinecraftClient.Protocol /// packet Data /// True if message was successfully sent bool SendPluginChannelPacket(string channel, byte[] data); - + /// /// Send Entity Action packet to the server. /// @@ -102,7 +102,7 @@ namespace MinecraftClient.Protocol /// Type of packet to send /// True if packet was successfully sent bool SendEntityAction(int EntityID, int type); - + /// /// Send a held item change packet to the server. /// @@ -140,7 +140,7 @@ namespace MinecraftClient.Protocol /// Z coordinate for "interact at" /// True if packet was successfully sent bool SendInteractEntity(int EntityID, int type, float X, float Y, float Z); - + /// /// Send an entity interaction packet to the server. /// @@ -165,7 +165,7 @@ namespace MinecraftClient.Protocol /// Action to perform /// Item in the clicked slot /// True if packet was successfully sent - bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item); + bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, Dictionary Items, int stateId); /// /// Request Creative Mode item creation into regular/survival Player Inventory @@ -220,7 +220,7 @@ namespace MinecraftClient.Protocol /// New line 4 /// True if packet was succcessfully sent bool SendUpdateSign(Location location, string line1, string line2, string line3, string line4); - + /// /// Update command block /// diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index 107875c0..2b63d5e7 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -263,7 +263,8 @@ namespace MinecraftClient.Protocol /// /// Inventory ID /// Item list - void OnWindowItems(byte inventoryID, Dictionary itemList); + /// State ID + void OnWindowItems(byte inventoryID, Dictionary itemList, int stateId); /// /// Called when a single slot has been updated inside an inventory From 7c364731f51342aeb01216e6d288d5a7a2d5363f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Fri, 1 Jul 2022 19:02:53 +0200 Subject: [PATCH 07/26] Reverted a mistake --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index aa51647f..0dee10df 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1957,8 +1957,9 @@ namespace MinecraftClient.Protocol.Handlers packet.Add(button); if (protocolversion < MC117Version) packet.AddRange(dataTypes.GetShort(actionNumber)); - if (protocolversion >= MC1165Version) + if (protocolversion >= MC19Version) packet.AddRange(dataTypes.GetVarInt(mode)); + else packet.Add(mode); // 1.17+ if (protocolversion >= MC117Version) From 00d78ee81cd54e5eede0a6a8c032a5290168019c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Tue, 5 Jul 2022 09:29:40 +0200 Subject: [PATCH 08/26] Fixed the array length issue --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 0dee10df..f4cb507f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1966,10 +1966,10 @@ namespace MinecraftClient.Protocol.Handlers { byte[] arrayOfSlots = dataTypes.GetSlotsArray(items, itemPalette); - log.Info("Length: " + sizeof(byte) * arrayOfSlots.Length); + log.Info("Length: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(arrayOfSlots.Length)) + " (" + arrayOfSlots.Length + ")"); log.Info("Array: " + dataTypes.ByteArrayToString(arrayOfSlots)); - packet.AddRange(dataTypes.GetVarInt(sizeof(byte) * arrayOfSlots.Length)); + packet.AddRange(dataTypes.GetVarInt(arrayOfSlots.Length)); packet.AddRange(arrayOfSlots); } From 2dae739b74128d98c884c2415d88b51e5b77b369 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Fri, 22 Jul 2022 20:09:53 +0800 Subject: [PATCH 09/26] Update to .NET 4.8 --- MinecraftClient/MinecraftClient.csproj | 10 +++++++--- MinecraftClient/app.config | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 MinecraftClient/app.config diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index d104601e..44aec940 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -1,5 +1,5 @@  - + Debug x86 @@ -10,8 +10,9 @@ Properties MinecraftClient MinecraftClient - v4.0 - Client + v4.8 + + 512 publish\ true @@ -38,6 +39,7 @@ DEBUG;TRACE prompt 4 + false x86 @@ -47,6 +49,7 @@ TRACE prompt 4 + false @@ -418,6 +421,7 @@ + diff --git a/MinecraftClient/app.config b/MinecraftClient/app.config new file mode 100644 index 00000000..3e0e37cf --- /dev/null +++ b/MinecraftClient/app.config @@ -0,0 +1,3 @@ + + + From f9bb74a8bd3b0a6760887717cc9529be878806c0 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sat, 23 Jul 2022 22:34:16 +0800 Subject: [PATCH 10/26] Implemented ChunkData packet process for 1.17/1.17.1 --- MinecraftClient/Mapping/ChunkColumn.cs | 13 +- .../Protocol/Handlers/Protocol18.cs | 121 ++++++++----- .../Protocol/Handlers/Protocol18Terrain.cs | 170 +++++++++++++++++- 3 files changed, 255 insertions(+), 49 deletions(-) diff --git a/MinecraftClient/Mapping/ChunkColumn.cs b/MinecraftClient/Mapping/ChunkColumn.cs index 22c9d2ae..a7e704ce 100644 --- a/MinecraftClient/Mapping/ChunkColumn.cs +++ b/MinecraftClient/Mapping/ChunkColumn.cs @@ -11,18 +11,27 @@ namespace MinecraftClient.Mapping /// public class ChunkColumn { - public const int ColumnSize = 16; + public int ColumnSize; /// /// Blocks contained into the chunk /// - private readonly Chunk[] chunks = new Chunk[ColumnSize]; + private readonly Chunk[] chunks; /// /// Lock for thread safety /// private readonly ReaderWriterLockSlim chunkLock = new ReaderWriterLockSlim(); + /// + /// Create a new ChunkColumn + /// + public ChunkColumn(int size = 16) + { + ColumnSize = size; + chunks = new Chunk[size]; + } + /// /// Get or set the specified chunk column /// diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index f4cb507f..a276ee7a 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -111,7 +111,7 @@ namespace MinecraftClient.Protocol.Handlers { if (protocolVersion > MC1182Version && handler.GetTerrainEnabled()) throw new NotImplementedException(Translations.Get("exception.palette.block")); - if (protocolVersion >= MC1181Version) + if (protocolVersion >= MC117Version) Block.Palette = new Palette117(); else if (protocolVersion >= MC116Version) Block.Palette = new Palette116(); @@ -425,56 +425,77 @@ namespace MinecraftClient.Protocol.Handlers SendPacket(PacketTypesOut.TeleportConfirm, dataTypes.GetVarInt(teleportID)); } - if (protocolversion >= MC117Version) dataTypes.ReadNextBool(packetData); + if (protocolversion >= MC117Version) + dataTypes.ReadNextBool(packetData); // Dismount Vehicle - 1.17 and above break; - case PacketTypesIn.ChunkData: //TODO implement for 1.17, bit mask is not limited to 0-15 anymore + case PacketTypesIn.ChunkData: if (handler.GetTerrainEnabled()) { int chunkX = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData); - bool chunksContinuous = dataTypes.ReadNextBool(packetData); - if (protocolversion >= MC116Version && protocolversion <= MC1161Version) - dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only - ushort chunkMask = protocolversion >= MC19Version - ? (ushort)dataTypes.ReadNextVarInt(packetData) - : dataTypes.ReadNextUShort(packetData); - if (protocolversion < MC18Version) + if (protocolversion >= MC117Version) { - ushort addBitmap = dataTypes.ReadNextUShort(packetData); - int compressedDataSize = dataTypes.ReadNextInt(packetData); - byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData); - byte[] decompressed = ZlibUtils.Decompress(compressed); + ulong[] verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Length and Primary Bit Mask + dataTypes.ReadNextNbt(packetData); // Heightmaps + + int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length + for (int i = 0; i < biomesLength; i++) + { + dataTypes.SkipNextVarInt(packetData); // Biomes + } + + int dataSize = dataTypes.ReadNextVarInt(packetData); // Size new Task(() => { - pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, addBitmap, currentDimension == 0, chunksContinuous, currentDimension, new Queue(decompressed)); + pTerrain.ProcessChunkColumnData(chunkX, chunkZ, verticalStripBitmask, currentDimension, packetData); }).Start(); } else { - if (protocolversion >= MC114Version) - dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above - int biomesLength = 0; - if (protocolversion >= MC1162Version) - if (chunksContinuous) - biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above - if (protocolversion >= MC115Version && chunksContinuous) + bool chunksContinuous = dataTypes.ReadNextBool(packetData); + if (protocolversion >= MC116Version && protocolversion <= MC1161Version) + dataTypes.ReadNextBool(packetData); // Ignore old data - 1.16 to 1.16.1 only + ushort chunkMask = protocolversion >= MC19Version + ? (ushort)dataTypes.ReadNextVarInt(packetData) + : dataTypes.ReadNextUShort(packetData); + if (protocolversion < MC18Version) { - if (protocolversion >= MC1162Version) + ushort addBitmap = dataTypes.ReadNextUShort(packetData); + int compressedDataSize = dataTypes.ReadNextInt(packetData); + byte[] compressed = dataTypes.ReadData(compressedDataSize, packetData); + byte[] decompressed = ZlibUtils.Decompress(compressed); + new Task(() => { - for (int i = 0; i < biomesLength; i++) - { - // Biomes - 1.16.2 and above - // Don't use ReadNextVarInt because it cost too much time - dataTypes.SkipNextVarInt(packetData); - } - } - else dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above + pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, addBitmap, currentDimension == 0, chunksContinuous, currentDimension, new Queue(decompressed)); + }).Start(); } - int dataSize = dataTypes.ReadNextVarInt(packetData); - new Task(() => + else { - pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, currentDimension, packetData); - }).Start(); + if (protocolversion >= MC114Version) + dataTypes.ReadNextNbt(packetData); // Heightmaps - 1.14 and above + int biomesLength = 0; + if (protocolversion >= MC1162Version) + if (chunksContinuous) + biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - 1.16.2 and above + if (protocolversion >= MC115Version && chunksContinuous) + { + if (protocolversion >= MC1162Version) + { + for (int i = 0; i < biomesLength; i++) + { + // Biomes - 1.16.2 and above + // Don't use ReadNextVarInt because it cost too much time + dataTypes.SkipNextVarInt(packetData); + } + } + else dataTypes.ReadData(1024 * 4, packetData); // Biomes - 1.15 and above + } + int dataSize = dataTypes.ReadNextVarInt(packetData); + new Task(() => + { + pTerrain.ProcessChunkColumnData(chunkX, chunkZ, chunkMask, 0, false, chunksContinuous, currentDimension, packetData); + }).Start(); + } } } break; @@ -839,7 +860,7 @@ namespace MinecraftClient.Protocol.Handlers int stateId = -1; - if (protocolversion >= MC1181Version) + if (protocolversion >= MC1171Version) // State ID - 1.17.1 and above stateId = dataTypes.ReadNextVarInt(packetData); int elements = dataTypes.ReadNextVarInt(packetData); @@ -851,6 +872,9 @@ namespace MinecraftClient.Protocol.Handlers inventorySlots[slotId] = item; } handler.OnWindowItems(windowId, inventorySlots, stateId); + + if (protocolversion >= MC1171Version) // Carried Item - 1.17.1 and above + dataTypes.ReadNextItemSlot(packetData, itemPalette); } break; case PacketTypesIn.SetSlot: @@ -860,7 +884,7 @@ namespace MinecraftClient.Protocol.Handlers int stateId = -1; - if (protocolversion >= MC1181Version) + if (protocolversion >= MC1171Version) // State ID - 1.17.1 and above stateId = dataTypes.ReadNextVarInt(packetData); short slotID = dataTypes.ReadNextShort(packetData); @@ -888,6 +912,8 @@ namespace MinecraftClient.Protocol.Handlers { forced = dataTypes.ReadNextBool(packetData); String forcedMessage = ChatParser.ParseText(dataTypes.ReadNextString(packetData)); + // skip: Has Prompt Message (Boolean) + // skip: Prompt Message (Optional Chat) } // 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 @@ -986,7 +1012,20 @@ namespace MinecraftClient.Protocol.Handlers case PacketTypesIn.DestroyEntity: if (handler.GetEntityHandlingEnabled()) { - handler.OnDestroyEntities(new[] { dataTypes.ReadNextVarInt(packetData) }); + int[] entityIDs; + if (protocolversion == MC117Version) // single Entity ID per packet - 1.17 only + { + entityIDs = new int[1]; + entityIDs[0] = dataTypes.ReadNextVarInt(packetData); + } + else + { + int count = dataTypes.ReadNextVarInt(packetData); + entityIDs = new int[count]; + for (int i = 0; i < count; ++i) + entityIDs[i] = dataTypes.ReadNextVarInt(packetData); + } + handler.OnDestroyEntities(entityIDs); } break; case PacketTypesIn.EntityPosition: @@ -1646,7 +1685,7 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion >= MC19Version) fields.AddRange(dataTypes.GetVarInt(mainHand)); if (protocolversion >= MC117Version) - fields.Add(0); // Enables text filtering. Always false + fields.Add(1); // 1.17 and above - Disable text filtering. (Always true) if (protocolversion >= MC1181Version) fields.Add(1); // 1.18 and above - Allow server listings SendPacket(PacketTypesOut.ClientSettings, fields); @@ -1938,7 +1977,7 @@ namespace MinecraftClient.Protocol.Handlers packet.Add((byte)windowId); // 1.18+ - if (protocolversion > MC1171Version) + if (protocolversion >= MC1181Version) { packet.AddRange(dataTypes.GetVarInt(stateId)); packet.AddRange(dataTypes.GetShort((short)slotId)); @@ -1973,7 +2012,7 @@ namespace MinecraftClient.Protocol.Handlers packet.AddRange(arrayOfSlots); } - packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); + packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); // Clicked item log.Info("Packet data: " + dataTypes.ByteArrayToString(packet.ToArray())); diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs index 14202599..5ce8644f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs @@ -28,7 +28,164 @@ namespace MinecraftClient.Protocol.Handlers } /// - /// Process chunk column data from the server and (un)load the chunk from the Minecraft world + /// Process chunk column data from the server and (un)load the chunk from the Minecraft world - 1.17 and above + /// + /// Chunk X location + /// Chunk Z location + /// Chunk mask for reading data, store in bitset + /// Current dimension type (0 = overworld) + /// Cache for reading chunk data + public void ProcessChunkColumnData(int chunkX, int chunkZ, ulong[] chunkMasks, int currentDimension, Queue cache) + { + byte[] mirror = new byte[cache.Count]; + cache.CopyTo(mirror, 0); + int chunkColumnSize = chunkMasks.Length * 64; + if (protocolversion >= Protocol18Handler.MC117Version) + { + // 1.17 and above chunk format + // Unloading chunks is handled by a separate packet + for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) + { + if ((chunkMasks[chunkY / 64] & (1UL << (chunkY % 64))) != 0) + { + // Non-air block count inside chunk section, for lighting purposes + int blockCnt = dataTypes.ReadNextShort(cache); + + // read Block states (Type: Paletted Container) + Chunk chunk = new Chunk(); + + byte bitsPerEntry = dataTypes.ReadNextByte(cache); + if (bitsPerEntry == 0 && protocolversion >= Protocol18Handler.MC1181Version) + { + // Palettes: Single valued - 1.xx and above + ushort value = (ushort)dataTypes.ReadNextVarInt(cache); + + dataTypes.SkipNextVarInt(cache); // Data Array Length will be zero + + for (int blockY = 0; blockY < Chunk.SizeY; blockY++) + { + for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++) + { + for (int blockX = 0; blockX < Chunk.SizeX; blockX++) + { + chunk[blockX, blockY, blockZ] = new Block(value); + } + } + } + } + else + { + // Palettes: Indirect or Direct + bool usePalette = (bitsPerEntry <= 8); + + // Indirect Mode: For block states with bits per entry <= 4, 4 bits are used to represent a block. + if (bitsPerEntry < 4) bitsPerEntry = 4; + + // Direct Mode: Bit mask covering bitsPerBlock bits + // EG, if bitsPerBlock = 5, valueMask = 00011111 in binary + uint valueMask = (uint)((1 << bitsPerEntry) - 1); + + int paletteLength = 0; // Assume zero when length is absent + if (usePalette) paletteLength = dataTypes.ReadNextVarInt(cache); + + int[] palette = new int[paletteLength]; + for (int i = 0; i < paletteLength; i++) + palette[i] = dataTypes.ReadNextVarInt(cache); + + // Block IDs are packed in the array of 64-bits integers + ulong[] dataArray = dataTypes.ReadNextULongArray(cache); + + int longIndex = 0; + int startOffset = 0 - bitsPerEntry; + for (int blockY = 0; blockY < Chunk.SizeY; blockY++) + { + for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++) + { + for (int blockX = 0; blockX < Chunk.SizeX; blockX++) + { + // NOTICE: In the future a single ushort may not store the entire block id; + // the Block class may need to change if block state IDs go beyond 65535 + ushort blockId; + + // Calculate location of next block ID inside the array of Longs + startOffset += bitsPerEntry; + + if ((startOffset + bitsPerEntry) > 64) + { + // In MC 1.16+, padding is applied to prevent overlapping between Longs: + // [ LONG INTEGER ][ LONG INTEGER ] + // [Block][Block][Block]XXXXX[Block][Block][Block]XXXXX + + // When overlapping, move forward to the beginning of the next Long + startOffset = 0; + longIndex++; + } + + // Extract Block ID + blockId = (ushort)((dataArray[longIndex] >> startOffset) & valueMask); + + // Map small IDs to actual larger block IDs + if (usePalette) + { + if (paletteLength <= blockId) + { + int blockNumber = (blockY * Chunk.SizeZ + blockZ) * Chunk.SizeX + blockX; + throw new IndexOutOfRangeException(String.Format("Block ID {0} is outside Palette range 0-{1}! (bitsPerBlock: {2}, blockNumber: {3})", + blockId, + paletteLength - 1, + bitsPerEntry, + blockNumber)); + } + + blockId = (ushort)palette[blockId]; + } + + // We have our block, save the block into the chunk + chunk[blockX, blockY, blockZ] = new Block(blockId); + } + } + } + } + + //We have our chunk, save the chunk into the world + handler.InvokeOnMainThread(() => + { + if (handler.GetWorld()[chunkX, chunkZ] == null) + handler.GetWorld()[chunkX, chunkZ] = new ChunkColumn(chunkColumnSize); + handler.GetWorld()[chunkX, chunkZ][chunkY] = chunk; + }); + + if (protocolversion >= Protocol18Handler.MC1181Version) + { + // skip read Biomes (Type: Paletted Container) + byte bitsPerEntryBiome = dataTypes.ReadNextByte(cache); // Bits Per Entry + if (bitsPerEntryBiome == 0 && protocolversion >= Protocol18Handler.MC1181Version) + { + dataTypes.SkipNextVarInt(cache); // Value + dataTypes.SkipNextVarInt(cache); // Data Array Length + // Data Array must be empty + } + else + { + if (bitsPerEntryBiome <= 3) + { + int paletteLength = dataTypes.ReadNextVarInt(cache); // Palette Length + for (int i = 0; i < paletteLength; i++) + dataTypes.SkipNextVarInt(cache); // Palette + } + int dataArrayLength = dataTypes.ReadNextVarInt(cache); // Data Array Length + dataTypes.ReadData(dataArrayLength * 8, cache); // Data Array + } + } + } + } + // Don't worry about skipping remaining data since there is no useful data afterwards in 1.9 + // (plus, it would require parsing the tile entity lists' NBT) + } + } + + /// + /// Process chunk column data from the server and (un)load the chunk from the Minecraft world - 1.17 below /// /// Chunk X location /// Chunk Z location @@ -40,11 +197,12 @@ namespace MinecraftClient.Protocol.Handlers /// Cache for reading chunk data public void ProcessChunkColumnData(int chunkX, int chunkZ, ushort chunkMask, ushort chunkMask2, bool hasSkyLight, bool chunksContinuous, int currentDimension, Queue cache) { + const int chunkColumnSize = 16; if (protocolversion >= Protocol18Handler.MC19Version) { // 1.9 and above chunk format // Unloading chunks is handled by a separate packet - for (int chunkY = 0; chunkY < ChunkColumn.ColumnSize; chunkY++) + for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) { if ((chunkMask & (1 << chunkY)) != 0) { @@ -200,7 +358,7 @@ namespace MinecraftClient.Protocol.Handlers else { //Load chunk data from the server - for (int chunkY = 0; chunkY < ChunkColumn.ColumnSize; chunkY++) + for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) { if ((chunkMask & (1 << chunkY)) != 0) { @@ -224,7 +382,7 @@ namespace MinecraftClient.Protocol.Handlers } //Skip light information - for (int chunkY = 0; chunkY < ChunkColumn.ColumnSize; chunkY++) + for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) { if ((chunkMask & (1 << chunkY)) != 0) { @@ -258,7 +416,7 @@ namespace MinecraftClient.Protocol.Handlers //Count chunk sections int sectionCount = 0; int addDataSectionCount = 0; - for (int chunkY = 0; chunkY < ChunkColumn.ColumnSize; chunkY++) + for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) { if ((chunkMask & (1 << chunkY)) != 0) sectionCount++; @@ -286,7 +444,7 @@ namespace MinecraftClient.Protocol.Handlers dataTypes.ReadData(Chunk.SizeX * Chunk.SizeZ, cache); //Biomes //Load chunk data - for (int chunkY = 0; chunkY < ChunkColumn.ColumnSize; chunkY++) + for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) { if ((chunkMask & (1 << chunkY)) != 0) { From af574b654eb078e05856bd415057f3474af839cf Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sat, 23 Jul 2022 23:10:06 +0800 Subject: [PATCH 11/26] avoid pathfind to an unloaded chunk | remove debug logs --- MinecraftClient/Commands/Move.cs | 4 +++- MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs | 2 -- MinecraftClient/Resources/lang/en.ini | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 0af06344..56fde8e3 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -76,7 +76,9 @@ namespace MinecraftClient.Commands int z = int.Parse(args[2]); Location goal = new Location(x, y, z); - if (handler.MoveTo(goal, allowUnsafe: takeRisk)) + if (handler.GetWorld().GetChunkColumn(goal) == null) + return Translations.Get("cmd.move.chunk_not_loaded"); + else if (handler.MoveTo(goal, allowUnsafe: takeRisk)) return Translations.Get("cmd.move.walk", goal); else return takeRisk ? Translations.Get("cmd.move.fail", goal) : Translations.Get("cmd.move.suggestforce", goal); } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs index 5ce8644f..0a932bca 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs @@ -37,8 +37,6 @@ namespace MinecraftClient.Protocol.Handlers /// Cache for reading chunk data public void ProcessChunkColumnData(int chunkX, int chunkZ, ulong[] chunkMasks, int currentDimension, Queue cache) { - byte[] mirror = new byte[cache.Count]; - cache.CopyTo(mirror, 0); int chunkColumnSize = chunkMasks.Length * 64; if (protocolversion >= Protocol18Handler.MC117Version) { diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index c6db23d3..e1a72f12 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -319,6 +319,7 @@ cmd.move.fail=Failed to compute path to {0} cmd.move.suggestforce=Failed to compute a safe path to {0}. Try -f parameter to allow unsafe movements. cmd.move.gravity.enabled=Gravity is enabled. cmd.move.gravity.disabled=Gravity is disabled. +cmd.move.chunk_not_loaded=The chunk where the target location resides has not yet been loaded. # Reco cmd.reco.desc=restart and reconnect to the server. From 516effa81d25bc2dfad990369c4287bca251b7c1 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sun, 24 Jul 2022 21:41:56 +0800 Subject: [PATCH 12/26] terrain handling for 1.18(1.18.1) and 1.18.2 --- MinecraftClient/Mapping/Dimension.cs | 169 +++++++++++++ MinecraftClient/Mapping/Location.cs | 10 +- MinecraftClient/Mapping/World.cs | 30 +++ MinecraftClient/MinecraftClient.csproj | 1 + .../Protocol/Handlers/Protocol18.cs | 65 +++-- .../Protocol/Handlers/Protocol18Terrain.cs | 229 ++++++++++-------- 6 files changed, 384 insertions(+), 120 deletions(-) create mode 100644 MinecraftClient/Mapping/Dimension.cs diff --git a/MinecraftClient/Mapping/Dimension.cs b/MinecraftClient/Mapping/Dimension.cs new file mode 100644 index 00000000..0ca08e6e --- /dev/null +++ b/MinecraftClient/Mapping/Dimension.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MinecraftClient.Mapping +{ + + /// + /// The dimension type, available after 1.16.2 + /// + public class Dimension + { + /// + /// The name of the dimension type (for example, "minecraft:overworld"). + /// + public readonly string Name; + + /// + /// Whether piglins shake and transform to zombified piglins. + /// + public readonly bool piglin_safe; + + /// + /// When false, compasses spin randomly. When true, nether portals can spawn zombified piglins. + /// + public readonly bool natural; + + /// + /// How much light the dimension has. + /// + public readonly float ambient_light; + + + /// + /// If set, the time of the day is the specified value. + /// Value: -1: not set + /// Value: [0, 24000]: time of the day + /// + public readonly long fixed_time = -1; + + /// + /// A resource location defining what block tag to use for infiniburn. + /// Value: "" or minecraft resource "minecraft:...". + /// + public readonly string infiniburn; + + /// + /// Whether players can charge and use respawn anchors. + /// + public readonly bool respawn_anchor_works; + + /// + /// Whether the dimension has skylight access or not. + /// + public readonly bool has_skylight; + + /// + /// Whether players can use a bed to sleep. + /// + public readonly bool bed_works; + + /// + /// unknown + /// Values: "minecraft:overworld", "minecraft:the_nether", "minecraft:the_end" or something else. + /// + public readonly string effects; + + /// + /// Whether players with the Bad Omen effect can cause a raid. + /// + public readonly bool has_raids; + + /// + /// The minimum Y level. + /// + public readonly int min_y = 0; + + /// + /// The minimum Y level. + /// + public readonly int max_y = 256; + + /// + /// The maximum height. + /// + public readonly int height = 256; + + /// + /// The maximum height to which chorus fruits and nether portals can bring players within this dimension. + /// + public readonly int logical_height; + + /// + /// The multiplier applied to coordinates when traveling to the dimension. + /// + public readonly double coordinate_scale; + + /// + /// Whether the dimensions behaves like the nether (water evaporates and sponges dry) or not. Also causes lava to spread thinner. + /// + public readonly bool ultrawarm; + + /// + /// Whether the dimension has a bedrock ceiling or not. When true, causes lava to spread faster. + /// + public readonly bool has_ceiling; + + + /// + /// Create from the "Dimension Codec" NBT Tag Compound + /// + /// ChunkColumn X + /// ChunkColumn Y + /// chunk at the given location + public Dimension(string name, Dictionary nbt) + { + if (name == null) + throw new ArgumentNullException("name"); + if (nbt == null) + throw new ArgumentNullException("nbt Data"); + + this.Name = name; + + if (nbt.ContainsKey("piglin_safe")) + this.piglin_safe = 1 == (byte)nbt["piglin_safe"]; + if (nbt.ContainsKey("natural")) + this.natural = 1 == (byte)nbt["natural"]; + if (nbt.ContainsKey("ambient_light")) + this.ambient_light = (float)nbt["ambient_light"]; + if (nbt.ContainsKey("fixed_time")) + this.fixed_time = (long)nbt["fixed_time"]; + if (nbt.ContainsKey("infiniburn")) + this.infiniburn = (string)nbt["infiniburn"]; + if (nbt.ContainsKey("respawn_anchor_works")) + this.respawn_anchor_works = 1 == (byte)nbt["respawn_anchor_works"]; + if (nbt.ContainsKey("has_skylight")) + this.has_skylight = 1 == (byte)nbt["has_skylight"]; + if (nbt.ContainsKey("bed_works")) + this.bed_works = 1 == (byte)nbt["bed_works"]; + if (nbt.ContainsKey("effects")) + this.effects = (string)nbt["effects"]; + if (nbt.ContainsKey("has_raids")) + this.has_raids = 1 == (byte)nbt["has_raids"]; + if (nbt.ContainsKey("min_y")) + this.min_y = (int)nbt["min_y"]; + if (nbt.ContainsKey("height")) + this.height = (int)nbt["height"]; + if (nbt.ContainsKey("min_y") && nbt.ContainsKey("height")) + this.max_y = this.min_y + this.height; + if (nbt.ContainsKey("logical_height")) + this.logical_height = (int)nbt["logical_height"]; + if (nbt.ContainsKey("coordinate_scale")) + { + var coordinate_scale_obj = nbt["coordinate_scale"]; + if (coordinate_scale_obj.GetType() == typeof(float)) + this.coordinate_scale = (float)coordinate_scale_obj; + else + this.coordinate_scale = (double)coordinate_scale_obj; + } + if (nbt.ContainsKey("ultrawarm")) + this.ultrawarm = 1 == (byte)nbt["ultrawarm"]; + if (nbt.ContainsKey("has_ceiling")) + this.has_ceiling = 1 == (byte)nbt["has_ceiling"]; + } + + } +} diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs index 00f18071..ad02d75a 100644 --- a/MinecraftClient/Mapping/Location.cs +++ b/MinecraftClient/Mapping/Location.cs @@ -25,6 +25,11 @@ namespace MinecraftClient.Mapping /// public double Z; + /// + /// Current world: to get the lowest Y coordinate + /// + public static World world; + /// /// Get location with zeroed coordinates /// @@ -79,7 +84,10 @@ namespace MinecraftClient.Mapping { get { - return (int)Math.Floor(Y / Chunk.SizeY); + if (world.GetDimension() == null) + return (int)Math.Floor(Y / Chunk.SizeY); // old version, always start at zero + else + return (int)Math.Floor((Y - world.GetDimension().min_y) / Chunk.SizeY); } } diff --git a/MinecraftClient/Mapping/World.cs b/MinecraftClient/Mapping/World.cs index 9a57baae..b324007a 100644 --- a/MinecraftClient/Mapping/World.cs +++ b/MinecraftClient/Mapping/World.cs @@ -16,6 +16,11 @@ namespace MinecraftClient.Mapping /// private Dictionary> chunks = new Dictionary>(); + /// + /// The dimension info of the world + /// + private Dimension dimension; + /// /// Lock for thread safety /// @@ -78,6 +83,30 @@ namespace MinecraftClient.Mapping } } + public World() + { + Location.world = this; + } + + /// + /// Set dimension type + /// + /// The name of the dimension type + /// The dimension type (NBT Tag Compound) + public void SetDimension(string name, Dictionary nbt) + { + this.dimension = new Dimension(name, nbt); + } + + /// + /// Get dimension type + /// + /// The chunk column + public Dimension GetDimension() + { + return this.dimension; + } + /// /// Get chunk column at the specified location /// @@ -176,6 +205,7 @@ namespace MinecraftClient.Mapping try { chunks = new Dictionary>(); + dimension = null; } finally { diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 44aec940..86351c15 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -79,6 +79,7 @@ + diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index a276ee7a..a55a214c 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -302,17 +302,23 @@ namespace MinecraftClient.Protocol.Handlers for (int i = 0; i < worldCount; i++) dataTypes.ReadNextString(packetData); // World Names - 1.16 and above dataTypes.ReadNextNbt(packetData); // Dimension Codec - 1.16 and above + } - //Current dimension - String identifier in 1.16, varInt below 1.16, byte below 1.9.1 + string currentDimensionName = null; + Dictionary currentDimensionType = null; + + // Current dimension + // NBT Tag Compound: 1.16.2 and above + // String identifier: 1.16 and 1.16.1 + // varInt: [1.9.1 to 1.15.2] + // byte: below 1.9.1 if (protocolversion >= MC116Version) { if (protocolversion >= MC1162Version) - dataTypes.ReadNextNbt(packetData); + currentDimensionType = dataTypes.ReadNextNbt(packetData); else dataTypes.ReadNextString(packetData); - // TODO handle dimensions for 1.16+, needed for terrain handling - // TODO this data give min and max y which will be needed for chunk collumn handling this.currentDimension = 0; } else if (protocolversion >= MC191Version) @@ -322,8 +328,16 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion < MC114Version) dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below + if (protocolversion >= MC116Version) - dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above + + if (protocolversion >= MC1162Version) + new Task(() => + { + handler.GetWorld().SetDimension(currentDimensionName, currentDimensionType); + }).Start(); + if (protocolversion >= MC115Version) dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above @@ -362,13 +376,14 @@ namespace MinecraftClient.Protocol.Handlers handler.OnTextReceived(message, true); break; case PacketTypesIn.Respawn: + string dimensionNameInRespawn = null; + Dictionary dimensionTypeInRespawn = null; if (protocolversion >= MC116Version) { - // TODO handle dimensions for 1.16+, needed for terrain handling if (protocolversion >= MC1162Version) - dataTypes.ReadNextNbt(packetData); + dimensionTypeInRespawn = dataTypes.ReadNextNbt(packetData); else - dataTypes.ReadNextString(packetData); + dataTypes.ReadNextString(packetData); this.currentDimension = 0; } else @@ -377,7 +392,14 @@ namespace MinecraftClient.Protocol.Handlers this.currentDimension = dataTypes.ReadNextInt(packetData); } if (protocolversion >= MC116Version) - dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + + if (protocolversion >= MC1162Version) + new Task(() => + { + handler.GetWorld().SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn); + }).Start(); + if (protocolversion < MC114Version) dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below if (protocolversion >= MC115Version) @@ -435,19 +457,26 @@ namespace MinecraftClient.Protocol.Handlers int chunkZ = dataTypes.ReadNextInt(packetData); if (protocolversion >= MC117Version) { - ulong[] verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Length and Primary Bit Mask + ulong[] verticalStripBitmask = null; + + if (protocolversion == MC117Version || protocolversion == MC1171Version) + verticalStripBitmask = dataTypes.ReadNextULongArray(packetData); // Bit Mask Length and Primary Bit Mask + dataTypes.ReadNextNbt(packetData); // Heightmaps - int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length - for (int i = 0; i < biomesLength; i++) + if (protocolversion == MC117Version || protocolversion == MC1171Version) { - dataTypes.SkipNextVarInt(packetData); // Biomes + int biomesLength = dataTypes.ReadNextVarInt(packetData); // Biomes length + for (int i = 0; i < biomesLength; i++) + { + dataTypes.SkipNextVarInt(packetData); // Biomes + } } int dataSize = dataTypes.ReadNextVarInt(packetData); // Size new Task(() => { - pTerrain.ProcessChunkColumnData(chunkX, chunkZ, verticalStripBitmask, currentDimension, packetData); + pTerrain.ProcessChunkColumnData(chunkX, chunkZ, verticalStripBitmask, packetData); }).Start(); } else @@ -600,10 +629,10 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion >= MC1162Version) { long chunkSection = dataTypes.ReadNextLong(packetData); - int sectionX = (int)(chunkSection >> 42); - int sectionY = (int)((chunkSection << 44) >> 44); - int sectionZ = (int)((chunkSection << 22) >> 42); - dataTypes.ReadNextBool(packetData); // Useless boolean + int sectionX = (int)((chunkSection >> 42) & 0x3FFFFF); + int sectionZ = (int)((chunkSection >> 20) & 0x3FFFFF); + int sectionY = (int)((chunkSection) & 0xFFFFF); + dataTypes.ReadNextBool(packetData); // Useless boolean (Related to light update) int blocksSize = dataTypes.ReadNextVarInt(packetData); for (int i = 0; i < blocksSize; i++) { diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs index 0a932bca..f2a22b9f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs @@ -27,123 +27,150 @@ namespace MinecraftClient.Protocol.Handlers this.handler = handler; } + /// + /// Reading the "Block states" field: consists of 4096 entries, representing all the blocks in the chunk section. + /// + /// Blocks will store in this chunk + /// Cache for reading data + private Chunk ReadBlockStatesField(ref Chunk chunk, Queue cache) + { + // read Block states (Type: Paletted Container) + byte bitsPerEntry = dataTypes.ReadNextByte(cache); + + // 1.18(1.18.1) add a pattle named "Single valued" to replace the vertical strip bitmask in the old + if (bitsPerEntry == 0 && protocolversion >= Protocol18Handler.MC1181Version) + { + // Palettes: Single valued - 1.18(1.18.1) and above + ushort value = (ushort)dataTypes.ReadNextVarInt(cache); + + dataTypes.SkipNextVarInt(cache); // Data Array Length will be zero + + // Empty chunks will not be stored + if (new Block(value).Type == Material.Air) + return null; + + for (int blockY = 0; blockY < Chunk.SizeY; blockY++) + { + for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++) + { + for (int blockX = 0; blockX < Chunk.SizeX; blockX++) + { + chunk[blockX, blockY, blockZ] = new Block(value); + } + } + } + } + else + { + // Palettes: Indirect or Direct + bool usePalette = (bitsPerEntry <= 8); + + // Indirect Mode: For block states with bits per entry <= 4, 4 bits are used to represent a block. + if (bitsPerEntry < 4) bitsPerEntry = 4; + + // Direct Mode: Bit mask covering bitsPerEntry bits + // EG, if bitsPerEntry = 5, valueMask = 00011111 in binary + uint valueMask = (uint)((1 << bitsPerEntry) - 1); + + int paletteLength = 0; // Assume zero when length is absent + if (usePalette) paletteLength = dataTypes.ReadNextVarInt(cache); + + int[] palette = new int[paletteLength]; + for (int i = 0; i < paletteLength; i++) + palette[i] = dataTypes.ReadNextVarInt(cache); + + // Block IDs are packed in the array of 64-bits integers + ulong[] dataArray = dataTypes.ReadNextULongArray(cache); + + int longIndex = 0; + int startOffset = 0 - bitsPerEntry; + for (int blockY = 0; blockY < Chunk.SizeY; blockY++) + { + for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++) + { + for (int blockX = 0; blockX < Chunk.SizeX; blockX++) + { + // NOTICE: In the future a single ushort may not store the entire block id; + // the Block class may need to change if block state IDs go beyond 65535 + ushort blockId; + + // Calculate location of next block ID inside the array of Longs + startOffset += bitsPerEntry; + + if ((startOffset + bitsPerEntry) > 64) + { + // In MC 1.16+, padding is applied to prevent overlapping between Longs: + // [ LONG INTEGER ][ LONG INTEGER ] + // [Block][Block][Block]XXXXX[Block][Block][Block]XXXXX + + // When overlapping, move forward to the beginning of the next Long + startOffset = 0; + longIndex++; + } + + // Extract Block ID + blockId = (ushort)((dataArray[longIndex] >> startOffset) & valueMask); + + // Map small IDs to actual larger block IDs + if (usePalette) + { + if (paletteLength <= blockId) + { + int blockNumber = (blockY * Chunk.SizeZ + blockZ) * Chunk.SizeX + blockX; + throw new IndexOutOfRangeException(String.Format("Block ID {0} is outside Palette range 0-{1}! (bitsPerBlock: {2}, blockNumber: {3})", + blockId, + paletteLength - 1, + bitsPerEntry, + blockNumber)); + } + + blockId = (ushort)palette[blockId]; + } + + // We have our block, save the block into the chunk + chunk[blockX, blockY, blockZ] = new Block(blockId); + } + } + } + } + + return chunk; + } + /// /// Process chunk column data from the server and (un)load the chunk from the Minecraft world - 1.17 and above /// /// Chunk X location /// Chunk Z location - /// Chunk mask for reading data, store in bitset - /// Current dimension type (0 = overworld) + /// Chunk mask for reading data, store in bitset, used in 1.17 and 1.17.1 /// Cache for reading chunk data - public void ProcessChunkColumnData(int chunkX, int chunkZ, ulong[] chunkMasks, int currentDimension, Queue cache) + public void ProcessChunkColumnData(int chunkX, int chunkZ, ulong[] verticalStripBitmask, Queue cache) { - int chunkColumnSize = chunkMasks.Length * 64; + var world = handler.GetWorld(); + while (world.GetDimension() == null) + ; // Dimension parsing unfinished + + int chunkColumnSize = (world.GetDimension().height + 15) / 16; + if (protocolversion >= Protocol18Handler.MC117Version) { // 1.17 and above chunk format // Unloading chunks is handled by a separate packet for (int chunkY = 0; chunkY < chunkColumnSize; chunkY++) { - if ((chunkMasks[chunkY / 64] & (1UL << (chunkY % 64))) != 0) + // 1.18 and above always contains all chunk section in data + // 1.17 and 1.17.1 need vertical strip bitmask to know if the chunk section is included + if ((protocolversion >= Protocol18Handler.MC1181Version) || + (((protocolversion == Protocol18Handler.MC117Version) || + (protocolversion == Protocol18Handler.MC1171Version)) && + ((verticalStripBitmask[chunkY / 64] & (1UL << (chunkY % 64))) != 0))) { // Non-air block count inside chunk section, for lighting purposes int blockCnt = dataTypes.ReadNextShort(cache); - // read Block states (Type: Paletted Container) + // Read Block states (Type: Paletted Container) Chunk chunk = new Chunk(); - - byte bitsPerEntry = dataTypes.ReadNextByte(cache); - if (bitsPerEntry == 0 && protocolversion >= Protocol18Handler.MC1181Version) - { - // Palettes: Single valued - 1.xx and above - ushort value = (ushort)dataTypes.ReadNextVarInt(cache); - - dataTypes.SkipNextVarInt(cache); // Data Array Length will be zero - - for (int blockY = 0; blockY < Chunk.SizeY; blockY++) - { - for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++) - { - for (int blockX = 0; blockX < Chunk.SizeX; blockX++) - { - chunk[blockX, blockY, blockZ] = new Block(value); - } - } - } - } - else - { - // Palettes: Indirect or Direct - bool usePalette = (bitsPerEntry <= 8); - - // Indirect Mode: For block states with bits per entry <= 4, 4 bits are used to represent a block. - if (bitsPerEntry < 4) bitsPerEntry = 4; - - // Direct Mode: Bit mask covering bitsPerBlock bits - // EG, if bitsPerBlock = 5, valueMask = 00011111 in binary - uint valueMask = (uint)((1 << bitsPerEntry) - 1); - - int paletteLength = 0; // Assume zero when length is absent - if (usePalette) paletteLength = dataTypes.ReadNextVarInt(cache); - - int[] palette = new int[paletteLength]; - for (int i = 0; i < paletteLength; i++) - palette[i] = dataTypes.ReadNextVarInt(cache); - - // Block IDs are packed in the array of 64-bits integers - ulong[] dataArray = dataTypes.ReadNextULongArray(cache); - - int longIndex = 0; - int startOffset = 0 - bitsPerEntry; - for (int blockY = 0; blockY < Chunk.SizeY; blockY++) - { - for (int blockZ = 0; blockZ < Chunk.SizeZ; blockZ++) - { - for (int blockX = 0; blockX < Chunk.SizeX; blockX++) - { - // NOTICE: In the future a single ushort may not store the entire block id; - // the Block class may need to change if block state IDs go beyond 65535 - ushort blockId; - - // Calculate location of next block ID inside the array of Longs - startOffset += bitsPerEntry; - - if ((startOffset + bitsPerEntry) > 64) - { - // In MC 1.16+, padding is applied to prevent overlapping between Longs: - // [ LONG INTEGER ][ LONG INTEGER ] - // [Block][Block][Block]XXXXX[Block][Block][Block]XXXXX - - // When overlapping, move forward to the beginning of the next Long - startOffset = 0; - longIndex++; - } - - // Extract Block ID - blockId = (ushort)((dataArray[longIndex] >> startOffset) & valueMask); - - // Map small IDs to actual larger block IDs - if (usePalette) - { - if (paletteLength <= blockId) - { - int blockNumber = (blockY * Chunk.SizeZ + blockZ) * Chunk.SizeX + blockX; - throw new IndexOutOfRangeException(String.Format("Block ID {0} is outside Palette range 0-{1}! (bitsPerBlock: {2}, blockNumber: {3})", - blockId, - paletteLength - 1, - bitsPerEntry, - blockNumber)); - } - - blockId = (ushort)palette[blockId]; - } - - // We have our block, save the block into the chunk - chunk[blockX, blockY, blockZ] = new Block(blockId); - } - } - } - } + ReadBlockStatesField(ref chunk, cache); //We have our chunk, save the chunk into the world handler.InvokeOnMainThread(() => @@ -153,11 +180,11 @@ namespace MinecraftClient.Protocol.Handlers handler.GetWorld()[chunkX, chunkZ][chunkY] = chunk; }); + // Skip Read Biomes (Type: Paletted Container) - 1.18(1.18.1) and above if (protocolversion >= Protocol18Handler.MC1181Version) { - // skip read Biomes (Type: Paletted Container) byte bitsPerEntryBiome = dataTypes.ReadNextByte(cache); // Bits Per Entry - if (bitsPerEntryBiome == 0 && protocolversion >= Protocol18Handler.MC1181Version) + if (bitsPerEntryBiome == 0) { dataTypes.SkipNextVarInt(cache); // Value dataTypes.SkipNextVarInt(cache); // Data Array Length From 735d1824688dd101d20efd3b3fc50da311730772 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sun, 24 Jul 2022 21:48:09 +0800 Subject: [PATCH 13/26] Rename variables --- MinecraftClient/Mapping/Dimension.cs | 50 +++++++++---------- MinecraftClient/Mapping/Location.cs | 2 +- .../Protocol/Handlers/Protocol18.cs | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/MinecraftClient/Mapping/Dimension.cs b/MinecraftClient/Mapping/Dimension.cs index 0ca08e6e..ea512640 100644 --- a/MinecraftClient/Mapping/Dimension.cs +++ b/MinecraftClient/Mapping/Dimension.cs @@ -20,7 +20,7 @@ namespace MinecraftClient.Mapping /// /// Whether piglins shake and transform to zombified piglins. /// - public readonly bool piglin_safe; + public readonly bool piglinSafe; /// /// When false, compasses spin randomly. When true, nether portals can spawn zombified piglins. @@ -30,7 +30,7 @@ namespace MinecraftClient.Mapping /// /// How much light the dimension has. /// - public readonly float ambient_light; + public readonly float ambientLight; /// @@ -38,7 +38,7 @@ namespace MinecraftClient.Mapping /// Value: -1: not set /// Value: [0, 24000]: time of the day /// - public readonly long fixed_time = -1; + public readonly long fixedTime = -1; /// /// A resource location defining what block tag to use for infiniburn. @@ -49,17 +49,17 @@ namespace MinecraftClient.Mapping /// /// Whether players can charge and use respawn anchors. /// - public readonly bool respawn_anchor_works; + public readonly bool respawnAnchorWorks; /// /// Whether the dimension has skylight access or not. /// - public readonly bool has_skylight; + public readonly bool hasSkylight; /// /// Whether players can use a bed to sleep. /// - public readonly bool bed_works; + public readonly bool bedWorks; /// /// unknown @@ -70,17 +70,17 @@ namespace MinecraftClient.Mapping /// /// Whether players with the Bad Omen effect can cause a raid. /// - public readonly bool has_raids; + public readonly bool hasRaids; /// /// The minimum Y level. /// - public readonly int min_y = 0; + public readonly int minY = 0; /// /// The minimum Y level. /// - public readonly int max_y = 256; + public readonly int maxY = 256; /// /// The maximum height. @@ -90,12 +90,12 @@ namespace MinecraftClient.Mapping /// /// The maximum height to which chorus fruits and nether portals can bring players within this dimension. /// - public readonly int logical_height; + public readonly int logicalHeight; /// /// The multiplier applied to coordinates when traveling to the dimension. /// - public readonly double coordinate_scale; + public readonly double coordinateScale; /// /// Whether the dimensions behaves like the nether (water evaporates and sponges dry) or not. Also causes lava to spread thinner. @@ -105,7 +105,7 @@ namespace MinecraftClient.Mapping /// /// Whether the dimension has a bedrock ceiling or not. When true, causes lava to spread faster. /// - public readonly bool has_ceiling; + public readonly bool hasCeiling; /// @@ -124,45 +124,45 @@ namespace MinecraftClient.Mapping this.Name = name; if (nbt.ContainsKey("piglin_safe")) - this.piglin_safe = 1 == (byte)nbt["piglin_safe"]; + this.piglinSafe = 1 == (byte)nbt["piglin_safe"]; if (nbt.ContainsKey("natural")) this.natural = 1 == (byte)nbt["natural"]; if (nbt.ContainsKey("ambient_light")) - this.ambient_light = (float)nbt["ambient_light"]; + this.ambientLight = (float)nbt["ambient_light"]; if (nbt.ContainsKey("fixed_time")) - this.fixed_time = (long)nbt["fixed_time"]; + this.fixedTime = (long)nbt["fixed_time"]; if (nbt.ContainsKey("infiniburn")) this.infiniburn = (string)nbt["infiniburn"]; if (nbt.ContainsKey("respawn_anchor_works")) - this.respawn_anchor_works = 1 == (byte)nbt["respawn_anchor_works"]; + this.respawnAnchorWorks = 1 == (byte)nbt["respawn_anchor_works"]; if (nbt.ContainsKey("has_skylight")) - this.has_skylight = 1 == (byte)nbt["has_skylight"]; + this.hasSkylight = 1 == (byte)nbt["has_skylight"]; if (nbt.ContainsKey("bed_works")) - this.bed_works = 1 == (byte)nbt["bed_works"]; + this.bedWorks = 1 == (byte)nbt["bed_works"]; if (nbt.ContainsKey("effects")) this.effects = (string)nbt["effects"]; if (nbt.ContainsKey("has_raids")) - this.has_raids = 1 == (byte)nbt["has_raids"]; + this.hasRaids = 1 == (byte)nbt["has_raids"]; if (nbt.ContainsKey("min_y")) - this.min_y = (int)nbt["min_y"]; + this.minY = (int)nbt["min_y"]; if (nbt.ContainsKey("height")) this.height = (int)nbt["height"]; if (nbt.ContainsKey("min_y") && nbt.ContainsKey("height")) - this.max_y = this.min_y + this.height; + this.maxY = this.minY + this.height; if (nbt.ContainsKey("logical_height")) - this.logical_height = (int)nbt["logical_height"]; + this.logicalHeight = (int)nbt["logical_height"]; if (nbt.ContainsKey("coordinate_scale")) { var coordinate_scale_obj = nbt["coordinate_scale"]; if (coordinate_scale_obj.GetType() == typeof(float)) - this.coordinate_scale = (float)coordinate_scale_obj; + this.coordinateScale = (float)coordinate_scale_obj; else - this.coordinate_scale = (double)coordinate_scale_obj; + this.coordinateScale = (double)coordinate_scale_obj; } if (nbt.ContainsKey("ultrawarm")) this.ultrawarm = 1 == (byte)nbt["ultrawarm"]; if (nbt.ContainsKey("has_ceiling")) - this.has_ceiling = 1 == (byte)nbt["has_ceiling"]; + this.hasCeiling = 1 == (byte)nbt["has_ceiling"]; } } diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs index ad02d75a..3143fd99 100644 --- a/MinecraftClient/Mapping/Location.cs +++ b/MinecraftClient/Mapping/Location.cs @@ -87,7 +87,7 @@ namespace MinecraftClient.Mapping if (world.GetDimension() == null) return (int)Math.Floor(Y / Chunk.SizeY); // old version, always start at zero else - return (int)Math.Floor((Y - world.GetDimension().min_y) / Chunk.SizeY); + return (int)Math.Floor((Y - world.GetDimension().minY) / Chunk.SizeY); } } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index a55a214c..28ee0d77 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -392,7 +392,7 @@ namespace MinecraftClient.Protocol.Handlers this.currentDimension = dataTypes.ReadNextInt(packetData); } if (protocolversion >= MC116Version) - dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // World Name - 1.16 and above + dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above if (protocolversion >= MC1162Version) new Task(() => From 34299895276b532da87309fc860de276b0d9b9a1 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sun, 24 Jul 2022 22:03:02 +0800 Subject: [PATCH 14/26] change .NET version to 4.0 --- MinecraftClient/Mapping/Dimension.cs | 8 ++++---- MinecraftClient/Mapping/Location.cs | 2 +- MinecraftClient/MinecraftClient.csproj | 10 +++------- MinecraftClient/Protocol/Handlers/Protocol18.cs | 3 +-- MinecraftClient/app.config | 3 --- 5 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 MinecraftClient/app.config diff --git a/MinecraftClient/Mapping/Dimension.cs b/MinecraftClient/Mapping/Dimension.cs index ea512640..987209ff 100644 --- a/MinecraftClient/Mapping/Dimension.cs +++ b/MinecraftClient/Mapping/Dimension.cs @@ -153,11 +153,11 @@ namespace MinecraftClient.Mapping this.logicalHeight = (int)nbt["logical_height"]; if (nbt.ContainsKey("coordinate_scale")) { - var coordinate_scale_obj = nbt["coordinate_scale"]; - if (coordinate_scale_obj.GetType() == typeof(float)) - this.coordinateScale = (float)coordinate_scale_obj; + var coordinateScaleObj = nbt["coordinate_scale"]; + if (coordinateScaleObj.GetType() == typeof(float)) + this.coordinateScale = (float)coordinateScaleObj; else - this.coordinateScale = (double)coordinate_scale_obj; + this.coordinateScale = (double)coordinateScaleObj; } if (nbt.ContainsKey("ultrawarm")) this.ultrawarm = 1 == (byte)nbt["ultrawarm"]; diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs index 3143fd99..e8f2178d 100644 --- a/MinecraftClient/Mapping/Location.cs +++ b/MinecraftClient/Mapping/Location.cs @@ -85,7 +85,7 @@ namespace MinecraftClient.Mapping get { if (world.GetDimension() == null) - return (int)Math.Floor(Y / Chunk.SizeY); // old version, always start at zero + return (int)Math.Floor(Y / Chunk.SizeY); // below 1.16.2, Y coordinate always start from zero else return (int)Math.Floor((Y - world.GetDimension().minY) / Chunk.SizeY); } diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj index 86351c15..46521de9 100644 --- a/MinecraftClient/MinecraftClient.csproj +++ b/MinecraftClient/MinecraftClient.csproj @@ -1,5 +1,5 @@  - + Debug x86 @@ -10,9 +10,8 @@ Properties MinecraftClient MinecraftClient - v4.8 - - + v4.0 + Client 512 publish\ true @@ -39,7 +38,6 @@ DEBUG;TRACE prompt 4 - false x86 @@ -49,7 +47,6 @@ TRACE prompt 4 - false @@ -422,7 +419,6 @@ - diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 28ee0d77..a0b9766b 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -302,7 +302,6 @@ namespace MinecraftClient.Protocol.Handlers for (int i = 0; i < worldCount; i++) dataTypes.ReadNextString(packetData); // World Names - 1.16 and above dataTypes.ReadNextNbt(packetData); // Dimension Codec - 1.16 and above - } string currentDimensionName = null; @@ -383,7 +382,7 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion >= MC1162Version) dimensionTypeInRespawn = dataTypes.ReadNextNbt(packetData); else - dataTypes.ReadNextString(packetData); + dataTypes.ReadNextString(packetData); this.currentDimension = 0; } else diff --git a/MinecraftClient/app.config b/MinecraftClient/app.config deleted file mode 100644 index 3e0e37cf..00000000 --- a/MinecraftClient/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - From 59ed18bb407c182a0cec04b5e562f858511126c3 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Sun, 24 Jul 2022 22:21:15 +0800 Subject: [PATCH 15/26] Fixed incorrect handling in 1.18(1.18.1) and 1.18.2 --- MinecraftClient/ChatBot.cs | 2 +- MinecraftClient/McClient.cs | 2 +- MinecraftClient/Protocol/Handlers/DataTypes.cs | 5 ++++- MinecraftClient/Protocol/Handlers/Protocol18.cs | 11 ++++++++--- MinecraftClient/Protocol/IMinecraftComHandler.cs | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index 3b37d98b..5e354399 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -327,7 +327,7 @@ namespace MinecraftClient /// 0 to create/update an item. 1 to remove an item. /// The name of the objective the score belongs to /// The score to be displayed next to the entry. Only sent when Action does not equal 1. - public virtual void OnUpdateScore(string entityname, byte action, string objectivename, int value) { } + public virtual void OnUpdateScore(string entityname, int action, string objectivename, int value) { } /// /// Called when an inventory/container was updated by server diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 9d0fbf7c..d608cc5d 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -2490,7 +2490,7 @@ namespace MinecraftClient /// 0 to create/update an item. 1 to remove an item. /// The name of the objective the score belongs to /// he score to be displayed next to the entry. Only sent when Action does not equal 1. - public void OnUpdateScore(string entityname, byte action, string objectivename, int value) + public void OnUpdateScore(string entityname, int action, string objectivename, int value) { DispatchBotEvent(bot => bot.OnUpdateScore(entityname, action, objectivename, value)); } diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs index 3bcacf7b..b8f894b6 100644 --- a/MinecraftClient/Protocol/Handlers/DataTypes.cs +++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs @@ -410,7 +410,10 @@ namespace MinecraftClient.Protocol.Handlers if (living) { - entityPitch = ReadNextByte(cache); + if (protocolversion >= Protocol18Handler.MC1182Version) + entityYaw = ReadNextByte(cache); + else + entityPitch = ReadNextByte(cache); } else { diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index a0b9766b..abc4f2bb 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1208,7 +1208,7 @@ namespace MinecraftClient.Protocol.Handlers break; case PacketTypesIn.UpdateScore: string entityname = dataTypes.ReadNextString(packetData); - byte action3 = dataTypes.ReadNextByte(packetData); + int action3 = protocolversion >= MC1182Version ? dataTypes.ReadNextVarInt(packetData) : dataTypes.ReadNextByte(packetData); string objectivename2 = null; int value = -1; if (action3 != 1 || protocolversion >= MC18Version) @@ -1713,7 +1713,12 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion >= MC19Version) fields.AddRange(dataTypes.GetVarInt(mainHand)); if (protocolversion >= MC117Version) - fields.Add(1); // 1.17 and above - Disable text filtering. (Always true) + { + if (protocolversion == MC117Version || protocolversion == MC1171Version) + fields.Add(1); // 1.17 and 1.17.1 - Disable text filtering. (Always true) + else + fields.Add(0); // 1.18 and above - Enable text filtering. (Always false) + } if (protocolversion >= MC1181Version) fields.Add(1); // 1.18 and above - Allow server listings SendPacket(PacketTypesOut.ClientSettings, fields); @@ -2040,7 +2045,7 @@ namespace MinecraftClient.Protocol.Handlers packet.AddRange(arrayOfSlots); } - packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); // Clicked item + packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); // Carried item (Clicked item) log.Info("Packet data: " + dataTypes.ByteArrayToString(packet.ToArray())); diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index 2b63d5e7..4ca8faf9 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -374,7 +374,7 @@ namespace MinecraftClient.Protocol /// 0 to create/update an item. 1 to remove an item. /// The name of the objective the score belongs to /// he score to be displayed next to the entry. Only sent when Action does not equal 1. - void OnUpdateScore(string entityname, byte action, string objectivename, int value); + void OnUpdateScore(string entityname, int action, string objectivename, int value); /// /// Called when tradeList is received from server From 86dfd60d07b6612fd30b2784f5acae1a80b7d91e Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 01:13:41 +0800 Subject: [PATCH 16/26] =?UTF-8?q?Bugs=20fix=20for=20=E2=80=9CClickWindow?= =?UTF-8?q?=E2=80=9C=20packet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MinecraftClient/McClient.cs | 44 +++++++++++++++++-- .../Protocol/Handlers/Protocol16.cs | 2 +- .../Protocol/Handlers/Protocol18.cs | 43 +++++++++--------- MinecraftClient/Protocol/IMinecraftCom.cs | 6 ++- .../Protocol/IMinecraftComHandler.cs | 3 +- 5 files changed, 67 insertions(+), 31 deletions(-) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index d608cc5d..2f517021 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1243,8 +1243,7 @@ namespace MinecraftClient if (inventories.ContainsKey(windowId) && inventories[windowId].Items.ContainsKey(slotId)) item = inventories[windowId].Items[slotId]; - // Inventory update must be after sending packet - bool result = handler.SendWindowAction(windowId, slotId, action, item, inventories[windowId].Items, inventories[windowId].StateID); + List> changedSlots = new List>(); // List // Update our inventory base on action type var inventory = GetInventory(windowId); @@ -1295,6 +1294,8 @@ namespace MinecraftClient inventory.Items[slotId] = playerInventory.Items[-1]; playerInventory.Items.Remove(-1); } + + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); } else { @@ -1307,6 +1308,8 @@ namespace MinecraftClient // Put target slot item to cursor playerInventory.Items[-1] = inventory.Items[slotId]; inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)slotId, null)); } } break; @@ -1385,6 +1388,7 @@ namespace MinecraftClient } } } + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); break; case WindowActionType.ShiftClick: if (slotId == 0) break; @@ -1412,6 +1416,7 @@ namespace MinecraftClient // If hotbar already have same item, will put on it first until every stack are full // If no more same item , will put on the first empty slot (smaller slot id) // If inventory full, item will not move + int itemCount = inventory.Items[slotId].Count; if (slotId <= upperEndSlot) { // Clicked slot is on upper side inventory, put it to hotbar @@ -1431,11 +1436,16 @@ namespace MinecraftClient // Can fit into the stack inventory.Items[_item.Key].Count += inventory.Items[slotId].Count; inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)_item.Key, inventory.Items[_item.Key])); + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); } else { inventory.Items[slotId].Count -= spaceLeft; inventory.Items[_item.Key].Count = inventory.Items[_item.Key].Type.StackCount(); + + changedSlots.Add(new Tuple((short)_item.Key, inventory.Items[_item.Key])); } } } @@ -1454,6 +1464,13 @@ namespace MinecraftClient var itemTmp = inventory.Items[slotId]; inventory.Items[emptySlot] = new Item(itemTmp.Type, itemTmp.Count, itemTmp.NBT); inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)emptySlot, inventory.Items[emptySlot])); + changedSlots.Add(new Tuple((short)slotId, null)); + } + else if (inventory.Items[slotId].Count != itemCount) + { + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); } } } @@ -1477,11 +1494,16 @@ namespace MinecraftClient // Can fit into the stack inventory.Items[_item.Key].Count += inventory.Items[slotId].Count; inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)_item.Key, inventory.Items[_item.Key])); + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); } else { inventory.Items[slotId].Count -= spaceLeft; inventory.Items[_item.Key].Count = inventory.Items[_item.Key].Type.StackCount(); + + changedSlots.Add(new Tuple((short)_item.Key, inventory.Items[_item.Key])); } } } @@ -1501,6 +1523,13 @@ namespace MinecraftClient var itemTmp = inventory.Items[slotId]; inventory.Items[emptySlot] = new Item(itemTmp.Type, itemTmp.Count, itemTmp.NBT); inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)emptySlot, inventory.Items[emptySlot])); + changedSlots.Add(new Tuple((short)slotId, null)); + } + else if (inventory.Items[slotId].Count != itemCount) + { + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); } } } @@ -1512,14 +1541,18 @@ namespace MinecraftClient if (inventory.Items[slotId].Count <= 0) inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); break; case WindowActionType.DropItemStack: inventory.Items.Remove(slotId); + + changedSlots.Add(new Tuple((short)slotId, null)); break; } } - return result; + return handler.SendWindowAction(windowId, slotId, action, item, changedSlots, inventories[windowId].StateID); } /// @@ -2046,8 +2079,11 @@ namespace MinecraftClient /// Window ID /// Slot ID /// Item (may be null for empty slot) - public void OnSetSlot(byte inventoryID, short slotID, Item item) + public void OnSetSlot(byte inventoryID, short slotID, Item item, int stateId) { + if (inventories.ContainsKey(inventoryID)) + inventories[inventoryID].StateID = stateId; + // Handle inventoryID -2 - Add item to player inventory without animation if (inventoryID == 254) inventoryID = 0; diff --git a/MinecraftClient/Protocol/Handlers/Protocol16.cs b/MinecraftClient/Protocol/Handlers/Protocol16.cs index c7e0b9ef..0f30bfce 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol16.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol16.cs @@ -720,7 +720,7 @@ namespace MinecraftClient.Protocol.Handlers return false; //Currently not implemented } - public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, Dictionary Items, int stateId) + public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, List> changedSlots, int stateId) { return false; //Currently not implemented } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index abc4f2bb..cd8f831e 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -917,7 +917,7 @@ namespace MinecraftClient.Protocol.Handlers short slotID = dataTypes.ReadNextShort(packetData); Item item = dataTypes.ReadNextItemSlot(packetData, itemPalette); - handler.OnSetSlot(windowID, slotID, item); + handler.OnSetSlot(windowID, slotID, item, stateId); } break; case PacketTypesIn.WindowConfirmation: @@ -1967,7 +1967,7 @@ namespace MinecraftClient.Protocol.Handlers catch (ObjectDisposedException) { return false; } } - public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, Dictionary items, int stateId) + public bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, List> changedSlots, int stateId) { try { @@ -2004,51 +2004,48 @@ namespace MinecraftClient.Protocol.Handlers List packet = new List(); - log.Info("Window id: " + windowId + " - State id: " + stateId + " - Slot id: " + slotId + " - Mode: " + mode); - log.Info("Bytes > " + (byte)windowId + " - State id: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(stateId)) + " - Slot id: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(slotId)) + " - Mode: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(mode))); - - packet.Add((byte)windowId); + packet.Add((byte)windowId); // Window ID // 1.18+ if (protocolversion >= MC1181Version) { - packet.AddRange(dataTypes.GetVarInt(stateId)); - packet.AddRange(dataTypes.GetShort((short)slotId)); + packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID + packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID } // 1.17.1 else if (protocolversion == MC1171Version) { - packet.AddRange(dataTypes.GetShort((short)slotId)); - packet.AddRange(dataTypes.GetVarInt(stateId)); + packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID + packet.AddRange(dataTypes.GetVarInt(stateId)); // State ID } // Older else { - packet.AddRange(dataTypes.GetShort((short)slotId)); + packet.AddRange(dataTypes.GetShort((short)slotId)); // Slot ID } - packet.Add(button); - if (protocolversion < MC117Version) packet.AddRange(dataTypes.GetShort(actionNumber)); + packet.Add(button); // Button + + if (protocolversion < MC117Version) + packet.AddRange(dataTypes.GetShort(actionNumber)); + if (protocolversion >= MC19Version) - packet.AddRange(dataTypes.GetVarInt(mode)); + packet.AddRange(dataTypes.GetVarInt(mode)); // Mode else packet.Add(mode); // 1.17+ if (protocolversion >= MC117Version) { - byte[] arrayOfSlots = dataTypes.GetSlotsArray(items, itemPalette); - - log.Info("Length: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(arrayOfSlots.Length)) + " (" + arrayOfSlots.Length + ")"); - log.Info("Array: " + dataTypes.ByteArrayToString(arrayOfSlots)); - - packet.AddRange(dataTypes.GetVarInt(arrayOfSlots.Length)); - packet.AddRange(arrayOfSlots); + packet.AddRange(dataTypes.GetVarInt(changedSlots.Count)); // Length of the array + foreach (var slot in changedSlots) + { + packet.AddRange(dataTypes.GetShort(slot.Item1)); // slot ID + packet.AddRange(dataTypes.GetItemSlot(slot.Item2, itemPalette)); // slot Data + } } packet.AddRange(dataTypes.GetItemSlot(item, itemPalette)); // Carried item (Clicked item) - log.Info("Packet data: " + dataTypes.ByteArrayToString(packet.ToArray())); - SendPacket(PacketTypesOut.ClickWindow, packet); return true; } diff --git a/MinecraftClient/Protocol/IMinecraftCom.cs b/MinecraftClient/Protocol/IMinecraftCom.cs index 97aaca35..487e8190 100644 --- a/MinecraftClient/Protocol/IMinecraftCom.cs +++ b/MinecraftClient/Protocol/IMinecraftCom.cs @@ -162,10 +162,12 @@ namespace MinecraftClient.Protocol /// /// Id of the window being clicked /// Id of the clicked slot - /// Action to perform + /// Action to perform /// Item in the clicked slot + /// Slots that have been changed in this event: List + /// Inventory's stateId /// True if packet was successfully sent - bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, Dictionary Items, int stateId); + bool SendWindowAction(int windowId, int slotId, WindowActionType action, Item item, List> changedSlots, int stateId); /// /// Request Creative Mode item creation into regular/survival Player Inventory diff --git a/MinecraftClient/Protocol/IMinecraftComHandler.cs b/MinecraftClient/Protocol/IMinecraftComHandler.cs index 4ca8faf9..3da38c94 100644 --- a/MinecraftClient/Protocol/IMinecraftComHandler.cs +++ b/MinecraftClient/Protocol/IMinecraftComHandler.cs @@ -272,7 +272,8 @@ namespace MinecraftClient.Protocol /// Window ID /// Slot ID /// Item (may be null for empty slot) - void OnSetSlot(byte inventoryID, short slotID, Item item); + /// State ID + void OnSetSlot(byte inventoryID, short slotID, Item item, int stateId); /// /// Called when player health or hunger changed. From 20e99e65aff506cabb5be9a43fc3f031091b9833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Sun, 24 Jul 2022 20:44:37 +0200 Subject: [PATCH 17/26] Added debug statements for NBT Data. --- .../Protocol/Handlers/DataTypes.cs | 263 +++++++++++++++++- .../Protocol/Handlers/Protocol18.cs | 31 +++ 2 files changed, 292 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs index 3bcacf7b..6b2a1531 100644 --- a/MinecraftClient/Protocol/Handlers/DataTypes.cs +++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs @@ -358,6 +358,40 @@ namespace MinecraftClient.Protocol.Handlers ItemType type = itemPalette.FromId(ReadNextVarInt(cache)); byte itemCount = ReadNextByte(cache); Dictionary nbt = ReadNextNbt(cache); + + Console.WriteLine("Got ITEM NBT DATA: "); + Console.WriteLine("-----------------------------"); + + foreach (string x2 in GetNbtAsString(nbt, true)) + { + ConsoleIO.WriteLine(x2); + } + + Console.WriteLine("-----------------------------"); + + Console.WriteLine("-----------------------------"); + foreach (KeyValuePair i in nbt) + { + if (i.Value is object[]) + { + ConsoleIO.WriteLine(i.Key.ToString() + " = {"); + + foreach (object o in (object[])i.Value) + { + ConsoleIO.WriteLine("\t{"); + foreach (KeyValuePair o2 in ((Dictionary)o)) + { + ConsoleIO.WriteLine("\t\t" + o2.Key.ToString() + " = " + o2.Value.ToString() + ","); + } + ConsoleIO.WriteLine("\t},\n"); + } + + ConsoleIO.WriteLine("},\n"); + } + else ConsoleIO.WriteLine(i.Key.ToString() + " = " + i.Value.ToString() + ","); + } + Console.WriteLine("-----------------------------"); + return new Item(type, itemCount, nbt); } else return null; @@ -444,6 +478,7 @@ namespace MinecraftClient.Protocol.Handlers // NBT root name string rootName = Encoding.ASCII.GetString(ReadData(ReadNextUShort(cache), cache)); + if (!String.IsNullOrEmpty(rootName)) nbtData[""] = rootName; } @@ -700,10 +735,13 @@ namespace MinecraftClient.Protocol.Handlers // NBT root name string rootName = null; + if (nbt.ContainsKey("")) rootName = nbt[""] as string; + if (rootName == null) rootName = ""; + bytes.AddRange(GetUShort((ushort)rootName.Length)); bytes.AddRange(Encoding.ASCII.GetBytes(rootName)); } @@ -728,6 +766,227 @@ namespace MinecraftClient.Protocol.Handlers return bytes.ToArray(); } + public List GetNbtAsString(Dictionary nbt, bool root, string depth = "") + { + List strings = new List(); + + if (nbt == null || nbt.Count == 0) + { + strings.Add("TAG_End - No count or null"); + return strings; + } + + if (root) + { + // NBT root name + string rootName = null; + + if (nbt.ContainsKey("")) + rootName = nbt[""] as string; + + if (rootName == null) + rootName = ""; + + strings.Add("TAG_Compound('" + rootName + "'):"); + } + + foreach (var item in nbt) + { + // Skip NBT root name + if (item.Key == "" && root) + continue; + + int fieldType; + string fieldContent = GetNbtFieldAsAString(item.Value, out fieldType, depth); + strings.Add(GetNbtFieldTypeString(fieldType) + "('" + item.Key + "'):"); + strings.Add(depth + (fieldType == 10 ? "\t" : "") + fieldContent); + } + + strings.Add("TAG_End"); // TAG_End + return strings; + } + + private string GetNbtFieldAsAString(object obj, out int fieldType, string depth) + { + if (obj is byte) + { + fieldType = 1; // TAG_Byte + return ByteArrayToString(new byte[] { (byte)obj }); + } + else if (obj is short) + { + fieldType = 2; // TAG_Short + return "" + (short)obj; + } + else if (obj is int) + { + fieldType = 3; // TAG_Int + return "" + (int)obj; + } + else if (obj is long) + { + fieldType = 4; // TAG_Long + return "" + (long)obj; + } + else if (obj is float) + { + fieldType = 5; // TAG_Float + return "" + (float)obj; + } + else if (obj is double) + { + fieldType = 6; // TAG_Double + return "" + (double)obj; + } + else if (obj is byte[]) + { + fieldType = 7; // TAG_Byte_Array + return ByteArrayToString((byte[])obj); + } + else if (obj is string) + { + fieldType = 8; // TAG_String + return "'" + (string)obj + "'"; + } + else if (obj is object[]) + { + fieldType = 9; // TAG_List + + List list = new List((object[])obj); + int arrayLengthTotal = list.Count; + + // Treat empty list as TAG_Byte, length 0 + if (arrayLengthTotal == 0) + return "Empty List"; + + // Encode first list item, retain its type + int firstItemType; + string firstItemTypeString = list[0].GetType().Name; + string firstItemData = GetNbtFieldAsAString(list[0], out firstItemType, depth); + list.RemoveAt(0); + Console.WriteLine("Parsing a TAG_List it has a size of: " + arrayLengthTotal + " and type of: " + GetNbtFieldTypeString(firstItemType)); + + // Encode further list items, check they have the same type + int subsequentItemType; + List subsequentItems = new List(); + foreach (object item in list) + { + string _item = GetNbtFieldAsAString(item, out subsequentItemType, depth); + Console.WriteLine("Adding item to a list: " + _item); + subsequentItems.Add(_item); + + if (subsequentItemType != firstItemType) + throw new System.IO.InvalidDataException( + "GetNbt: Cannot encode object[] list with mixed types: " + firstItemTypeString + ", " + item.GetType().Name + " into NBT string!"); + } + + string itemsString = "" + GetNbtFieldTypeString(firstItemType) + "('" + firstItemData.Replace("\n", "").Trim() + "'): "; + + foreach (string listStr in subsequentItems) + { + itemsString += listStr; + } + + return itemsString; + } + else if (obj is Dictionary) + { + fieldType = 10; // TAG_Compound + + depth += "\t"; + List stringList = GetNbtAsString((Dictionary)obj, false, depth); + + string itemsString = ""; + + foreach (string listStr in stringList) + { + itemsString = depth + listStr; + itemsString += "\n"; + } + + return itemsString; + } + else if (obj is int[]) + { + fieldType = 11; // TAG_Int_Array + + int[] srcIntList = (int[])obj; + + string intListString = ""; + + foreach (int item in srcIntList) + { + intListString += item + ","; + } + + return intListString; + } + else if (obj is long[]) + { + fieldType = 12; // TAG_Long_Array + + long[] srcLongList = (long[])obj; + + string longListString = ""; + + foreach (int item in srcLongList) + { + longListString += item + ","; + } + + return longListString; + } + else + { + throw new System.IO.InvalidDataException("GetNbt: Cannot encode data type " + obj.GetType().Name + " into NBT string!"); + } + } + + private string GetNbtFieldTypeString(int fieldType) + { + if (fieldType == 0) + return "TAG_End"; + + if (fieldType == 1) + return "TAG_Byte"; + + if (fieldType == 2) + return "TAG_Short"; + + if (fieldType == 3) + return "TAG_Int"; + + if (fieldType == 4) + return "TAG_Long"; + + if (fieldType == 5) + return "TAG_Float"; + + if (fieldType == 6) + return "TAG_Double"; + + if (fieldType == 7) + return "TAG_Byte_Array"; + + if (fieldType == 8) + return "TAG_String"; + + if (fieldType == 9) + return "TAG_List"; + + if (fieldType == 10) + return "TAG_Compound"; + + if (fieldType == 11) + return "TAG_Int_Array"; + + if (fieldType == 11) + return "TAG_Long_Array"; + + throw new System.IO.InvalidDataException("Invalid Field Type provided: " + fieldType); + } + + /// /// Convert a single object into its NBT representation (internal) /// @@ -1004,10 +1263,10 @@ namespace MinecraftClient.Protocol.Handlers { // MC 1.13 and greater if (item == null || item.IsEmpty) - slotData.Add(0); // No item + slotData.AddRange(GetBool(false)); // No item else { - slotData.Add(1); // Item is present + slotData.AddRange(GetBool(true)); // Item is present slotData.AddRange(GetVarInt(itemPalette.ToId(item.Type))); slotData.Add((byte)item.Count); slotData.AddRange(GetNbt(item.NBT)); diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index f4cb507f..685a2a0f 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -1934,6 +1934,7 @@ namespace MinecraftClient.Protocol.Handlers log.Info("Window id: " + windowId + " - State id: " + stateId + " - Slot id: " + slotId + " - Mode: " + mode); log.Info("Bytes > " + (byte)windowId + " - State id: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(stateId)) + " - Slot id: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(slotId)) + " - Mode: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(mode))); + log.Info("Held item: " + item.ToString()); packet.Add((byte)windowId); @@ -1964,11 +1965,41 @@ namespace MinecraftClient.Protocol.Handlers // 1.17+ if (protocolversion >= MC117Version) { + try + { + foreach (KeyValuePair x in items) + { + log.Info("---------------------------------------------------"); + log.Info("ID: " + x.Key); + log.Info("Item: " + x.Value.ToString()); + + log.Info("Item NBT: "); + + if (x.Value.NBT.Count > 0) + { + foreach (string x2 in dataTypes.GetNbtAsString(x.Value.NBT, true)) + { + ConsoleIO.WriteLine(x2); + } + } + else + { + log.Info("\t- No NBT Data!"); + } + } + } + catch (Exception e) + { + ConsoleIO.WriteLine(e.StackTrace); + } + byte[] arrayOfSlots = dataTypes.GetSlotsArray(items, itemPalette); log.Info("Length: " + dataTypes.ByteArrayToString(dataTypes.GetVarInt(arrayOfSlots.Length)) + " (" + arrayOfSlots.Length + ")"); log.Info("Array: " + dataTypes.ByteArrayToString(arrayOfSlots)); + //packet.AddRange(dataTypes.GetArray(arrayOfSlots)); + packet.AddRange(dataTypes.GetVarInt(arrayOfSlots.Length)); packet.AddRange(arrayOfSlots); } From 357820e1c2532ee0dc9ce9c94f874177a18caa2a Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 03:19:24 +0800 Subject: [PATCH 18/26] Fix bugs in gravity handle --- MinecraftClient/Commands/Move.cs | 2 +- MinecraftClient/Mapping/ChunkColumn.cs | 2 ++ MinecraftClient/Mapping/Movement.cs | 7 +++++- MinecraftClient/Mapping/World.cs | 7 ++++++ MinecraftClient/McClient.cs | 22 +++++++++++++++++++ .../Protocol/Handlers/Protocol18.cs | 16 +++++++++++--- .../Protocol/Handlers/Protocol18Terrain.cs | 5 +++-- 7 files changed, 54 insertions(+), 7 deletions(-) diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 56fde8e3..7ccd3ed5 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -76,7 +76,7 @@ namespace MinecraftClient.Commands int z = int.Parse(args[2]); Location goal = new Location(x, y, z); - if (handler.GetWorld().GetChunkColumn(goal) == null) + if (handler.GetWorld().GetChunkColumn(goal) == null || handler.GetWorld().GetChunkColumn(goal).FullyLoaded == false) return Translations.Get("cmd.move.chunk_not_loaded"); else if (handler.MoveTo(goal, allowUnsafe: takeRisk)) return Translations.Get("cmd.move.walk", goal); diff --git a/MinecraftClient/Mapping/ChunkColumn.cs b/MinecraftClient/Mapping/ChunkColumn.cs index a7e704ce..5cbeda73 100644 --- a/MinecraftClient/Mapping/ChunkColumn.cs +++ b/MinecraftClient/Mapping/ChunkColumn.cs @@ -13,6 +13,8 @@ namespace MinecraftClient.Mapping { public int ColumnSize; + public bool FullyLoaded = false; + /// /// Blocks contained into the chunk /// diff --git a/MinecraftClient/Mapping/Movement.cs b/MinecraftClient/Mapping/Movement.cs index fc66ca7a..ff2e4089 100644 --- a/MinecraftClient/Mapping/Movement.cs +++ b/MinecraftClient/Mapping/Movement.cs @@ -31,9 +31,11 @@ namespace MinecraftClient.Mapping belowFoots = location; belowFoots.Y = Math.Truncate(location.Y); } + //Console.WriteLine("IsOnGround = " + IsOnGround(world, location)); if (!IsOnGround(world, location) && !IsSwimming(world, location)) { - while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1) + while (!IsOnGround(world, belowFoots) && + belowFoots.Y >= 1 + (world.GetDimension() == null ? 0 : world.GetDimension().minY)) belowFoots = Move(belowFoots, Direction.Down); location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue(); } @@ -262,6 +264,9 @@ namespace MinecraftClient.Mapping /// True if the specified location is on the ground public static bool IsOnGround(World world, Location location) { + if (world.GetChunkColumn(location) == null || world.GetChunkColumn(location).FullyLoaded == false) + return true; // avoid moving downward in a not loaded chunk + return world.GetBlock(Move(location, Direction.Down)).Type.IsSolid() && (location.Y <= Math.Truncate(location.Y) + 0.0001); } diff --git a/MinecraftClient/Mapping/World.cs b/MinecraftClient/Mapping/World.cs index b324007a..c753708b 100644 --- a/MinecraftClient/Mapping/World.cs +++ b/MinecraftClient/Mapping/World.cs @@ -26,6 +26,13 @@ namespace MinecraftClient.Mapping /// private readonly ReaderWriterLockSlim chunksLock = new ReaderWriterLockSlim(); + /// + /// Chunk data parsing progress + /// + public uint chunkCnt = 0; + public uint chunkLoadNotCompleted = 0; + + /// /// Read, set or unload the specified chunk column /// diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 2f517021..e3a9cab0 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -59,6 +59,8 @@ namespace MinecraftClient private float playerYaw; private float playerPitch; private double motionY; + private int chunkLoadingStateTicks = 30; // Setting it to zero to disable chunk loading statu log + private double lastChunkLoadedRatio = 0; private string host; private int port; @@ -385,6 +387,26 @@ namespace MinecraftClient taskToRun(); } } + + if (terrainAndMovementsEnabled) + { + if (chunkLoadingStateTicks <= 0) + { + chunkLoadingStateTicks = 50; + if (world.chunkCnt != 0) + { + double chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt; + if (chunkLoadedRatio != lastChunkLoadedRatio) + { + Log.Info(string.Format("Chunk loading: {0:P} {1}/{2}", + chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt)); + lastChunkLoadedRatio = chunkLoadedRatio; + } + } + } + else + chunkLoadingStateTicks--; + } } #region Connection Lost and Disconnect from Server diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index cd8f831e..687cd9cd 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -475,7 +475,10 @@ namespace MinecraftClient.Protocol.Handlers int dataSize = dataTypes.ReadNextVarInt(packetData); // Size new Task(() => { + handler.GetWorld().chunkCnt++; + handler.GetWorld().chunkLoadNotCompleted++; pTerrain.ProcessChunkColumnData(chunkX, chunkZ, verticalStripBitmask, packetData); + handler.GetWorld().chunkLoadNotCompleted--; }).Start(); } else @@ -628,9 +631,12 @@ namespace MinecraftClient.Protocol.Handlers if (protocolversion >= MC1162Version) { long chunkSection = dataTypes.ReadNextLong(packetData); - int sectionX = (int)((chunkSection >> 42) & 0x3FFFFF); - int sectionZ = (int)((chunkSection >> 20) & 0x3FFFFF); - int sectionY = (int)((chunkSection) & 0xFFFFF); + int sectionX = (int)(chunkSection >> 42); + int sectionY = (int)((chunkSection << 44) >> 44); + int sectionZ = (int)((chunkSection << 22) >> 42); + //int sectionX = (int)((chunkSection >> 42) & 0x3FFFFF); + //int sectionZ = (int)((chunkSection >> 20) & 0x3FFFFF); + //int sectionY = (int)((chunkSection) & 0xFFFFF); dataTypes.ReadNextBool(packetData); // Useless boolean (Related to light update) int blocksSize = dataTypes.ReadNextVarInt(packetData); for (int i = 0; i < blocksSize; i++) @@ -750,6 +756,10 @@ namespace MinecraftClient.Protocol.Handlers { int chunkX = dataTypes.ReadNextInt(packetData); int chunkZ = dataTypes.ReadNextInt(packetData); + + if (handler.GetWorld()[chunkX, chunkZ] != null) + handler.GetWorld().chunkCnt--; + handler.GetWorld()[chunkX, chunkZ] = null; } break; diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs index f2a22b9f..6416c303 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs @@ -147,8 +147,8 @@ namespace MinecraftClient.Protocol.Handlers public void ProcessChunkColumnData(int chunkX, int chunkZ, ulong[] verticalStripBitmask, Queue cache) { var world = handler.GetWorld(); - while (world.GetDimension() == null) - ; // Dimension parsing unfinished + if (world.GetDimension() == null) + return; int chunkColumnSize = (world.GetDimension().height + 15) / 16; @@ -207,6 +207,7 @@ namespace MinecraftClient.Protocol.Handlers // Don't worry about skipping remaining data since there is no useful data afterwards in 1.9 // (plus, it would require parsing the tile entity lists' NBT) } + handler.GetWorld()[chunkX, chunkZ].FullyLoaded = true; } /// From ff014d29127d959be7a5d352ffd3c249055a4f80 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 03:50:31 +0800 Subject: [PATCH 19/26] Delete unnecessary comments --- MinecraftClient/Mapping/World.cs | 1 - MinecraftClient/Protocol/Handlers/Protocol18.cs | 3 --- 2 files changed, 4 deletions(-) diff --git a/MinecraftClient/Mapping/World.cs b/MinecraftClient/Mapping/World.cs index c753708b..39b5f0c4 100644 --- a/MinecraftClient/Mapping/World.cs +++ b/MinecraftClient/Mapping/World.cs @@ -32,7 +32,6 @@ namespace MinecraftClient.Mapping public uint chunkCnt = 0; public uint chunkLoadNotCompleted = 0; - /// /// Read, set or unload the specified chunk column /// diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 687cd9cd..dc9e4789 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -634,9 +634,6 @@ namespace MinecraftClient.Protocol.Handlers int sectionX = (int)(chunkSection >> 42); int sectionY = (int)((chunkSection << 44) >> 44); int sectionZ = (int)((chunkSection << 22) >> 42); - //int sectionX = (int)((chunkSection >> 42) & 0x3FFFFF); - //int sectionZ = (int)((chunkSection >> 20) & 0x3FFFFF); - //int sectionY = (int)((chunkSection) & 0xFFFFF); dataTypes.ReadNextBool(packetData); // Useless boolean (Related to light update) int blocksSize = dataTypes.ReadNextVarInt(packetData); for (int i = 0; i < blocksSize; i++) From b0b45a74a05b53f8ac2ee8f23f80c52ffa476c08 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 14:20:24 +0800 Subject: [PATCH 20/26] Make chunk loading status to be displayed using "/move" command --- MinecraftClient/Commands/Move.cs | 23 ++++++++++++++++++- MinecraftClient/Mapping/Movement.cs | 1 - MinecraftClient/McClient.cs | 22 ------------------ .../Protocol/Handlers/Protocol18.cs | 3 --- MinecraftClient/Resources/lang/en.ini | 1 + 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 7ccd3ed5..4ccd033a 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -17,7 +17,14 @@ namespace MinecraftClient.Commands bool takeRisk = false; if (args.Count < 1) - return GetCmdDescTranslated(); + { + string desc = GetCmdDescTranslated(); + + if (handler.GetTerrainEnabled()) + handler.Log.Info(getChunkLoadingStatus(handler.GetWorld())); + + return desc; + } if (args.Contains("-f")) { @@ -88,5 +95,19 @@ namespace MinecraftClient.Commands } else return Translations.Get("extra.terrainandmovement_required"); } + + private string getChunkLoadingStatus(World world) + { + double chunkLoadedRatio; + if (world.chunkCnt == 0) + chunkLoadedRatio = 0; + else + chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt; + + string status = Translations.Get("cmd.move.chunk_loading_status", + chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt); + + return status; + } } } diff --git a/MinecraftClient/Mapping/Movement.cs b/MinecraftClient/Mapping/Movement.cs index ff2e4089..960921b7 100644 --- a/MinecraftClient/Mapping/Movement.cs +++ b/MinecraftClient/Mapping/Movement.cs @@ -31,7 +31,6 @@ namespace MinecraftClient.Mapping belowFoots = location; belowFoots.Y = Math.Truncate(location.Y); } - //Console.WriteLine("IsOnGround = " + IsOnGround(world, location)); if (!IsOnGround(world, location) && !IsSwimming(world, location)) { while (!IsOnGround(world, belowFoots) && diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index e3a9cab0..2f517021 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -59,8 +59,6 @@ namespace MinecraftClient private float playerYaw; private float playerPitch; private double motionY; - private int chunkLoadingStateTicks = 30; // Setting it to zero to disable chunk loading statu log - private double lastChunkLoadedRatio = 0; private string host; private int port; @@ -387,26 +385,6 @@ namespace MinecraftClient taskToRun(); } } - - if (terrainAndMovementsEnabled) - { - if (chunkLoadingStateTicks <= 0) - { - chunkLoadingStateTicks = 50; - if (world.chunkCnt != 0) - { - double chunkLoadedRatio = (world.chunkCnt - world.chunkLoadNotCompleted) / (double)world.chunkCnt; - if (chunkLoadedRatio != lastChunkLoadedRatio) - { - Log.Info(string.Format("Chunk loading: {0:P} {1}/{2}", - chunkLoadedRatio, world.chunkCnt - world.chunkLoadNotCompleted, world.chunkCnt)); - lastChunkLoadedRatio = chunkLoadedRatio; - } - } - } - else - chunkLoadingStateTicks--; - } } #region Connection Lost and Disconnect from Server diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index dc9e4789..474bbfe0 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -332,10 +332,7 @@ namespace MinecraftClient.Protocol.Handlers currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above if (protocolversion >= MC1162Version) - new Task(() => - { handler.GetWorld().SetDimension(currentDimensionName, currentDimensionType); - }).Start(); if (protocolversion >= MC115Version) dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index e1a72f12..c3f5901e 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -319,6 +319,7 @@ cmd.move.fail=Failed to compute path to {0} cmd.move.suggestforce=Failed to compute a safe path to {0}. Try -f parameter to allow unsafe movements. cmd.move.gravity.enabled=Gravity is enabled. cmd.move.gravity.disabled=Gravity is disabled. +cmd.move.chunk_loading_status=Chunk loading status: {0:P} - {1} out of {2} load completed. cmd.move.chunk_not_loaded=The chunk where the target location resides has not yet been loaded. # Reco From f0af851df882ca0229ddc438fdded2f38f97bc8a Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 17:04:14 +0800 Subject: [PATCH 21/26] Fixed bug where "ChunkFullyLoaded" was not updated below 1.17 --- MinecraftClient/Protocol/Handlers/Protocol18.cs | 2 +- MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 474bbfe0..9b2dfade 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -2037,7 +2037,7 @@ namespace MinecraftClient.Protocol.Handlers packet.AddRange(dataTypes.GetVarInt(mode)); // Mode else packet.Add(mode); - // 1.17+ + // 1.17+ Array of changed slots if (protocolversion >= MC117Version) { packet.AddRange(dataTypes.GetVarInt(changedSlots.Count)); // Length of the array diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs index 6416c303..73593da6 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs @@ -491,6 +491,7 @@ namespace MinecraftClient.Protocol.Handlers } } } + handler.GetWorld()[chunkX, chunkZ].FullyLoaded = true; } } } From cbe348555b91fadd11db0f0d60fc1e75eef1dd35 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 17:08:59 +0800 Subject: [PATCH 22/26] Fix bug: drop single item cause exception --- MinecraftClient/McClient.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 2f517021..3b9e8005 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1537,12 +1537,17 @@ namespace MinecraftClient break; case WindowActionType.DropItem: if (inventory.Items.ContainsKey(slotId)) + { inventory.Items[slotId].Count--; + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + } if (inventory.Items[slotId].Count <= 0) + { inventory.Items.Remove(slotId); + changedSlots.Add(new Tuple((short)slotId, null)); + } - changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); break; case WindowActionType.DropItemStack: inventory.Items.Remove(slotId); From a18b526a417652dac42527e33db1df2c5da02b35 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 17:22:01 +0800 Subject: [PATCH 23/26] bug fix: Error handling for empty slots --- MinecraftClient/McClient.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index 3b9e8005..b59ee3c8 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -1295,7 +1295,10 @@ namespace MinecraftClient playerInventory.Items.Remove(-1); } - changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + if (inventory.Items.ContainsKey(slotId)) + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + else + changedSlots.Add(new Tuple((short)slotId, null)); } else { @@ -1388,7 +1391,10 @@ namespace MinecraftClient } } } - changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + if (inventory.Items.ContainsKey(slotId)) + changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + else + changedSlots.Add(new Tuple((short)slotId, null)); break; case WindowActionType.ShiftClick: if (slotId == 0) break; @@ -1438,7 +1444,7 @@ namespace MinecraftClient inventory.Items.Remove(slotId); changedSlots.Add(new Tuple((short)_item.Key, inventory.Items[_item.Key])); - changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + changedSlots.Add(new Tuple((short)slotId, null)); } else { @@ -1496,7 +1502,7 @@ namespace MinecraftClient inventory.Items.Remove(slotId); changedSlots.Add(new Tuple((short)_item.Key, inventory.Items[_item.Key])); - changedSlots.Add(new Tuple((short)slotId, inventory.Items[slotId])); + changedSlots.Add(new Tuple((short)slotId, null)); } else { @@ -1551,7 +1557,6 @@ namespace MinecraftClient break; case WindowActionType.DropItemStack: inventory.Items.Remove(slotId); - changedSlots.Add(new Tuple((short)slotId, null)); break; } From 94fd8b118de50caa9863b8e9f73b024e1d491ff8 Mon Sep 17 00:00:00 2001 From: BruceChen Date: Mon, 25 Jul 2022 18:11:10 +0800 Subject: [PATCH 24/26] "/move X Y Z" now moves the player to the center of the block first --- MinecraftClient/Commands/Move.cs | 18 +++++++++++++++--- MinecraftClient/Mapping/Location.cs | 2 +- MinecraftClient/Resources/lang/en.ini | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 4ccd033a..8b5fecab 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -8,7 +8,7 @@ namespace MinecraftClient.Commands public class Move : Command { public override string CmdName { get { return "move"; } } - public override string CmdUsage { get { return "move [-f]"; } } + public override string CmdUsage { get { return "move [-f]"; } } public override string CmdDesc { get { return "walk or start walking. \"-f\": force unsafe movements like falling or touching fire"; } } public override string Run(McClient handler, string command, Dictionary localVars) @@ -63,6 +63,13 @@ namespace MinecraftClient.Commands case "west": direction = Direction.West; break; case "north": direction = Direction.North; break; case "south": direction = Direction.South; break; + case "center": + { + Location current = handler.GetCurrentLocation(); + Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5); + handler.MoveTo(currentCenter, allowDirectTeleport: true); + return Translations.Get("cmd.move.walk", currentCenter, current); + } case "get": return handler.GetCurrentLocation().ToString(); default: return Translations.Get("cmd.look.unknown", args[0]); } @@ -85,8 +92,13 @@ namespace MinecraftClient.Commands if (handler.GetWorld().GetChunkColumn(goal) == null || handler.GetWorld().GetChunkColumn(goal).FullyLoaded == false) return Translations.Get("cmd.move.chunk_not_loaded"); - else if (handler.MoveTo(goal, allowUnsafe: takeRisk)) - return Translations.Get("cmd.move.walk", goal); + + Location current = handler.GetCurrentLocation(); + Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5); + handler.MoveTo(currentCenter, allowDirectTeleport: true); + + if (handler.MoveTo(goal, allowUnsafe: takeRisk)) + return Translations.Get("cmd.move.walk", goal, current); else return takeRisk ? Translations.Get("cmd.move.fail", goal) : Translations.Get("cmd.move.suggestforce", goal); } catch (FormatException) { return GetCmdDescTranslated(); } diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs index e8f2178d..9dab848a 100644 --- a/MinecraftClient/Mapping/Location.cs +++ b/MinecraftClient/Mapping/Location.cs @@ -307,7 +307,7 @@ namespace MinecraftClient.Mapping /// String representation of the location public override string ToString() { - return String.Format("X:{0} Y:{1} Z:{2}", X, Y, Z); + return String.Format("X:{0:0.00} Y:{1:0.00} Z:{2:0.00}", X, Y, Z); } } } diff --git a/MinecraftClient/Resources/lang/en.ini b/MinecraftClient/Resources/lang/en.ini index c3f5901e..c773e62c 100644 --- a/MinecraftClient/Resources/lang/en.ini +++ b/MinecraftClient/Resources/lang/en.ini @@ -314,7 +314,7 @@ cmd.move.enable=Enabling Terrain and Movements on next server login, respawn or cmd.move.disable=Disabling Terrain and Movements. cmd.move.moving=Moving {0} cmd.move.dir_fail=Cannot move in that direction. -cmd.move.walk=Walking to {0} +cmd.move.walk=Walking from {1} to {0} cmd.move.fail=Failed to compute path to {0} cmd.move.suggestforce=Failed to compute a safe path to {0}. Try -f parameter to allow unsafe movements. cmd.move.gravity.enabled=Gravity is enabled. From 9f197d415ef1cfc5d17ae0eb06f4ddef3c14a3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Milutinovi=C4=87?= Date: Mon, 25 Jul 2022 16:55:46 +0200 Subject: [PATCH 25/26] Removed debug comments. --- .../Protocol/Handlers/DataTypes.cs | 255 ------------------ .../Protocol/Handlers/Protocol18.cs | 2 +- 2 files changed, 1 insertion(+), 256 deletions(-) diff --git a/MinecraftClient/Protocol/Handlers/DataTypes.cs b/MinecraftClient/Protocol/Handlers/DataTypes.cs index 0b82a810..c489051e 100644 --- a/MinecraftClient/Protocol/Handlers/DataTypes.cs +++ b/MinecraftClient/Protocol/Handlers/DataTypes.cs @@ -358,40 +358,6 @@ namespace MinecraftClient.Protocol.Handlers ItemType type = itemPalette.FromId(ReadNextVarInt(cache)); byte itemCount = ReadNextByte(cache); Dictionary nbt = ReadNextNbt(cache); - - Console.WriteLine("Got ITEM NBT DATA: "); - Console.WriteLine("-----------------------------"); - - foreach (string x2 in GetNbtAsString(nbt, true)) - { - ConsoleIO.WriteLine(x2); - } - - Console.WriteLine("-----------------------------"); - - Console.WriteLine("-----------------------------"); - foreach (KeyValuePair i in nbt) - { - if (i.Value is object[]) - { - ConsoleIO.WriteLine(i.Key.ToString() + " = {"); - - foreach (object o in (object[])i.Value) - { - ConsoleIO.WriteLine("\t{"); - foreach (KeyValuePair o2 in ((Dictionary)o)) - { - ConsoleIO.WriteLine("\t\t" + o2.Key.ToString() + " = " + o2.Value.ToString() + ","); - } - ConsoleIO.WriteLine("\t},\n"); - } - - ConsoleIO.WriteLine("},\n"); - } - else ConsoleIO.WriteLine(i.Key.ToString() + " = " + i.Value.ToString() + ","); - } - Console.WriteLine("-----------------------------"); - return new Item(type, itemCount, nbt); } else return null; @@ -769,227 +735,6 @@ namespace MinecraftClient.Protocol.Handlers return bytes.ToArray(); } - public List GetNbtAsString(Dictionary nbt, bool root, string depth = "") - { - List strings = new List(); - - if (nbt == null || nbt.Count == 0) - { - strings.Add("TAG_End - No count or null"); - return strings; - } - - if (root) - { - // NBT root name - string rootName = null; - - if (nbt.ContainsKey("")) - rootName = nbt[""] as string; - - if (rootName == null) - rootName = ""; - - strings.Add("TAG_Compound('" + rootName + "'):"); - } - - foreach (var item in nbt) - { - // Skip NBT root name - if (item.Key == "" && root) - continue; - - int fieldType; - string fieldContent = GetNbtFieldAsAString(item.Value, out fieldType, depth); - strings.Add(GetNbtFieldTypeString(fieldType) + "('" + item.Key + "'):"); - strings.Add(depth + (fieldType == 10 ? "\t" : "") + fieldContent); - } - - strings.Add("TAG_End"); // TAG_End - return strings; - } - - private string GetNbtFieldAsAString(object obj, out int fieldType, string depth) - { - if (obj is byte) - { - fieldType = 1; // TAG_Byte - return ByteArrayToString(new byte[] { (byte)obj }); - } - else if (obj is short) - { - fieldType = 2; // TAG_Short - return "" + (short)obj; - } - else if (obj is int) - { - fieldType = 3; // TAG_Int - return "" + (int)obj; - } - else if (obj is long) - { - fieldType = 4; // TAG_Long - return "" + (long)obj; - } - else if (obj is float) - { - fieldType = 5; // TAG_Float - return "" + (float)obj; - } - else if (obj is double) - { - fieldType = 6; // TAG_Double - return "" + (double)obj; - } - else if (obj is byte[]) - { - fieldType = 7; // TAG_Byte_Array - return ByteArrayToString((byte[])obj); - } - else if (obj is string) - { - fieldType = 8; // TAG_String - return "'" + (string)obj + "'"; - } - else if (obj is object[]) - { - fieldType = 9; // TAG_List - - List list = new List((object[])obj); - int arrayLengthTotal = list.Count; - - // Treat empty list as TAG_Byte, length 0 - if (arrayLengthTotal == 0) - return "Empty List"; - - // Encode first list item, retain its type - int firstItemType; - string firstItemTypeString = list[0].GetType().Name; - string firstItemData = GetNbtFieldAsAString(list[0], out firstItemType, depth); - list.RemoveAt(0); - Console.WriteLine("Parsing a TAG_List it has a size of: " + arrayLengthTotal + " and type of: " + GetNbtFieldTypeString(firstItemType)); - - // Encode further list items, check they have the same type - int subsequentItemType; - List subsequentItems = new List(); - foreach (object item in list) - { - string _item = GetNbtFieldAsAString(item, out subsequentItemType, depth); - Console.WriteLine("Adding item to a list: " + _item); - subsequentItems.Add(_item); - - if (subsequentItemType != firstItemType) - throw new System.IO.InvalidDataException( - "GetNbt: Cannot encode object[] list with mixed types: " + firstItemTypeString + ", " + item.GetType().Name + " into NBT string!"); - } - - string itemsString = "" + GetNbtFieldTypeString(firstItemType) + "('" + firstItemData.Replace("\n", "").Trim() + "'): "; - - foreach (string listStr in subsequentItems) - { - itemsString += listStr; - } - - return itemsString; - } - else if (obj is Dictionary) - { - fieldType = 10; // TAG_Compound - - depth += "\t"; - List stringList = GetNbtAsString((Dictionary)obj, false, depth); - - string itemsString = ""; - - foreach (string listStr in stringList) - { - itemsString = depth + listStr; - itemsString += "\n"; - } - - return itemsString; - } - else if (obj is int[]) - { - fieldType = 11; // TAG_Int_Array - - int[] srcIntList = (int[])obj; - - string intListString = ""; - - foreach (int item in srcIntList) - { - intListString += item + ","; - } - - return intListString; - } - else if (obj is long[]) - { - fieldType = 12; // TAG_Long_Array - - long[] srcLongList = (long[])obj; - - string longListString = ""; - - foreach (int item in srcLongList) - { - longListString += item + ","; - } - - return longListString; - } - else - { - throw new System.IO.InvalidDataException("GetNbt: Cannot encode data type " + obj.GetType().Name + " into NBT string!"); - } - } - - private string GetNbtFieldTypeString(int fieldType) - { - if (fieldType == 0) - return "TAG_End"; - - if (fieldType == 1) - return "TAG_Byte"; - - if (fieldType == 2) - return "TAG_Short"; - - if (fieldType == 3) - return "TAG_Int"; - - if (fieldType == 4) - return "TAG_Long"; - - if (fieldType == 5) - return "TAG_Float"; - - if (fieldType == 6) - return "TAG_Double"; - - if (fieldType == 7) - return "TAG_Byte_Array"; - - if (fieldType == 8) - return "TAG_String"; - - if (fieldType == 9) - return "TAG_List"; - - if (fieldType == 10) - return "TAG_Compound"; - - if (fieldType == 11) - return "TAG_Int_Array"; - - if (fieldType == 11) - return "TAG_Long_Array"; - - throw new System.IO.InvalidDataException("Invalid Field Type provided: " + fieldType); - } - - /// /// Convert a single object into its NBT representation (internal) /// diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 9b2dfade..1ff2d13b 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -332,7 +332,7 @@ namespace MinecraftClient.Protocol.Handlers currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above if (protocolversion >= MC1162Version) - handler.GetWorld().SetDimension(currentDimensionName, currentDimensionType); + handler.GetWorld().SetDimension(currentDimensionName, currentDimensionType); if (protocolversion >= MC115Version) dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above From af6f655d5e8e9babf3d00175d611f8f9d6cead1b Mon Sep 17 00:00:00 2001 From: Milutinke Date: Thu, 18 Aug 2022 20:58:49 +0200 Subject: [PATCH 26/26] Fixed the requested changes for Terrain Movement. Tested and working. --- MinecraftClient/Commands/Move.cs | 12 +++-- MinecraftClient/Mapping/Dimension.cs | 45 +++++++++++-------- MinecraftClient/Mapping/Location.cs | 12 +---- MinecraftClient/Mapping/Movement.cs | 15 +++---- MinecraftClient/Mapping/World.cs | 25 +++++------ .../Protocol/Handlers/Protocol18.cs | 17 ++++--- .../Protocol/Handlers/Protocol18Terrain.cs | 6 +-- 7 files changed, 60 insertions(+), 72 deletions(-) diff --git a/MinecraftClient/Commands/Move.cs b/MinecraftClient/Commands/Move.cs index 8b5fecab..6e9e7e2b 100644 --- a/MinecraftClient/Commands/Move.cs +++ b/MinecraftClient/Commands/Move.cs @@ -18,7 +18,7 @@ namespace MinecraftClient.Commands if (args.Count < 1) { - string desc = GetCmdDescTranslated(); + string desc = GetCmdDescTranslated(); if (handler.GetTerrainEnabled()) handler.Log.Info(getChunkLoadingStatus(handler.GetWorld())); @@ -64,12 +64,10 @@ namespace MinecraftClient.Commands case "north": direction = Direction.North; break; case "south": direction = Direction.South; break; case "center": - { - Location current = handler.GetCurrentLocation(); - Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5); - handler.MoveTo(currentCenter, allowDirectTeleport: true); - return Translations.Get("cmd.move.walk", currentCenter, current); - } + Location current = handler.GetCurrentLocation(); + Location currentCenter = new Location(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5); + handler.MoveTo(currentCenter, allowDirectTeleport: true); + return Translations.Get("cmd.move.walk", currentCenter, current); case "get": return handler.GetCurrentLocation().ToString(); default: return Translations.Get("cmd.look.unknown", args[0]); } diff --git a/MinecraftClient/Mapping/Dimension.cs b/MinecraftClient/Mapping/Dimension.cs index 987209ff..75642d51 100644 --- a/MinecraftClient/Mapping/Dimension.cs +++ b/MinecraftClient/Mapping/Dimension.cs @@ -20,17 +20,17 @@ namespace MinecraftClient.Mapping /// /// Whether piglins shake and transform to zombified piglins. /// - public readonly bool piglinSafe; + public readonly bool piglinSafe = false; /// - /// When false, compasses spin randomly. When true, nether portals can spawn zombified piglins. + /// When false, compasses spin randomly. When true, nether portals can spawn zombified piglins. /// - public readonly bool natural; + public readonly bool natural = true; /// /// How much light the dimension has. /// - public readonly float ambientLight; + public readonly float ambientLight = 0.0f; /// @@ -42,35 +42,36 @@ namespace MinecraftClient.Mapping /// /// A resource location defining what block tag to use for infiniburn. - /// Value: "" or minecraft resource "minecraft:...". + /// Value above 1.18.2: "#" or minecraft resource "#minecraft:...". + /// Value below 1.18.1: "" or minecraft resource "minecraft:...". /// - public readonly string infiniburn; + public readonly string infiniburn = "#minecraft:infiniburn_overworld"; /// /// Whether players can charge and use respawn anchors. /// - public readonly bool respawnAnchorWorks; + public readonly bool respawnAnchorWorks = false; /// /// Whether the dimension has skylight access or not. /// - public readonly bool hasSkylight; + public readonly bool hasSkylight = true; /// /// Whether players can use a bed to sleep. /// - public readonly bool bedWorks; + public readonly bool bedWorks = true; /// /// unknown /// Values: "minecraft:overworld", "minecraft:the_nether", "minecraft:the_end" or something else. /// - public readonly string effects; + public readonly string effects = "minecraft:overworld"; /// /// Whether players with the Bad Omen effect can cause a raid. /// - public readonly bool hasRaids; + public readonly bool hasRaids = true; /// /// The minimum Y level. @@ -78,7 +79,7 @@ namespace MinecraftClient.Mapping public readonly int minY = 0; /// - /// The minimum Y level. + /// The maximum Y level. /// public readonly int maxY = 256; @@ -90,30 +91,36 @@ namespace MinecraftClient.Mapping /// /// The maximum height to which chorus fruits and nether portals can bring players within this dimension. /// - public readonly int logicalHeight; + public readonly int logicalHeight = 256; /// /// The multiplier applied to coordinates when traveling to the dimension. /// - public readonly double coordinateScale; + public readonly double coordinateScale = 1.0; /// /// Whether the dimensions behaves like the nether (water evaporates and sponges dry) or not. Also causes lava to spread thinner. /// - public readonly bool ultrawarm; + public readonly bool ultrawarm = false; /// /// Whether the dimension has a bedrock ceiling or not. When true, causes lava to spread faster. /// - public readonly bool hasCeiling; + public readonly bool hasCeiling = false; + /// + /// Default value used in version below 1.17 + /// + public Dimension() + { + this.Name = "minecraft:overworld"; + } /// /// Create from the "Dimension Codec" NBT Tag Compound /// - /// ChunkColumn X - /// ChunkColumn Y - /// chunk at the given location + /// Dimension name + /// The dimension type (NBT Tag Compound) public Dimension(string name, Dictionary nbt) { if (name == null) diff --git a/MinecraftClient/Mapping/Location.cs b/MinecraftClient/Mapping/Location.cs index 9dab848a..cf45c493 100644 --- a/MinecraftClient/Mapping/Location.cs +++ b/MinecraftClient/Mapping/Location.cs @@ -14,7 +14,7 @@ namespace MinecraftClient.Mapping /// The X Coordinate /// public double X; - + /// /// The Y Coordinate (vertical) /// @@ -25,11 +25,6 @@ namespace MinecraftClient.Mapping /// public double Z; - /// - /// Current world: to get the lowest Y coordinate - /// - public static World world; - /// /// Get location with zeroed coordinates /// @@ -84,10 +79,7 @@ namespace MinecraftClient.Mapping { get { - if (world.GetDimension() == null) - return (int)Math.Floor(Y / Chunk.SizeY); // below 1.16.2, Y coordinate always start from zero - else - return (int)Math.Floor((Y - world.GetDimension().minY) / Chunk.SizeY); + return (int)Math.Floor((Y - World.GetDimension().minY) / Chunk.SizeY); } } diff --git a/MinecraftClient/Mapping/Movement.cs b/MinecraftClient/Mapping/Movement.cs index 960921b7..41bed746 100644 --- a/MinecraftClient/Mapping/Movement.cs +++ b/MinecraftClient/Mapping/Movement.cs @@ -33,8 +33,7 @@ namespace MinecraftClient.Mapping } if (!IsOnGround(world, location) && !IsSwimming(world, location)) { - while (!IsOnGround(world, belowFoots) && - belowFoots.Y >= 1 + (world.GetDimension() == null ? 0 : world.GetDimension().minY)) + while (!IsOnGround(world, belowFoots) && belowFoots.Y >= 1 + World.GetDimension().minY) belowFoots = Move(belowFoots, Direction.Down); location = Move2Steps(location, belowFoots, ref motionY, true).Dequeue(); } @@ -62,7 +61,7 @@ namespace MinecraftClient.Mapping } else { - foreach (Direction dir in new []{ Direction.East, Direction.West, Direction.North, Direction.South }) + foreach (Direction dir in new[] { Direction.East, Direction.West, Direction.North, Direction.South }) if (CanMove(world, location, dir) && IsOnGround(world, Move(location, dir)) && (allowUnsafe || IsSafe(world, Move(location, dir)))) availableMoves.Add(Move(location, dir)); availableMoves.Add(Move(location, Direction.Down)); @@ -168,7 +167,7 @@ namespace MinecraftClient.Mapping if (minOffset > maxOffset) throw new ArgumentException("minOffset must be lower or equal to maxOffset", "minOffset"); - + // We always use distance squared so our limits must also be squared. minOffset *= minOffset; maxOffset *= maxOffset; @@ -193,8 +192,8 @@ namespace MinecraftClient.Mapping : new KeyValuePair(location, int.MaxValue)) .OrderBy(pair => pair.Value). // Sort for h-score (f-score - g-score) to get smallest distance to goal if f-scores are equal - ThenBy(pair => f_score[pair.Key]-g_score[pair.Key]).First().Key; - + ThenBy(pair => f_score[pair.Key] - g_score[pair.Key]).First().Key; + // Only assert a value if it is of actual use later if (maxOffset > 0 && ClosedSet.Count > 0) // Get the block that currently is closest to the goal @@ -229,7 +228,7 @@ namespace MinecraftClient.Mapping } // Goal could not be reached. Set the path to the closest location if close enough - if (maxOffset == int.MaxValue || goal.DistanceSquared(closestGoal) <= maxOffset) + if (maxOffset == int.MaxValue || goal.DistanceSquared(closestGoal) <= maxOffset) return ReconstructPath(Came_From, closestGoal); else return null; @@ -290,7 +289,7 @@ namespace MinecraftClient.Mapping public static bool IsSafe(World world, Location location) { return - //No block that can harm the player + //No block that can harm the player !world.GetBlock(location).Type.CanHarmPlayers() && !world.GetBlock(Move(location, Direction.Up)).Type.CanHarmPlayers() && !world.GetBlock(Move(location, Direction.Down)).Type.CanHarmPlayers() diff --git a/MinecraftClient/Mapping/World.cs b/MinecraftClient/Mapping/World.cs index 39b5f0c4..aee80a25 100644 --- a/MinecraftClient/Mapping/World.cs +++ b/MinecraftClient/Mapping/World.cs @@ -19,7 +19,7 @@ namespace MinecraftClient.Mapping /// /// The dimension info of the world /// - private Dimension dimension; + private static Dimension dimension = new Dimension(); /// /// Lock for thread safety @@ -29,8 +29,8 @@ namespace MinecraftClient.Mapping /// /// Chunk data parsing progress /// - public uint chunkCnt = 0; - public uint chunkLoadNotCompleted = 0; + public int chunkCnt = 0; + public int chunkLoadNotCompleted = 0; /// /// Read, set or unload the specified chunk column @@ -89,28 +89,24 @@ namespace MinecraftClient.Mapping } } - public World() - { - Location.world = this; - } - /// /// Set dimension type /// /// The name of the dimension type /// The dimension type (NBT Tag Compound) - public void SetDimension(string name, Dictionary nbt) + public static void SetDimension(string name, Dictionary nbt) { - this.dimension = new Dimension(name, nbt); + // will change in 1.19 and above + dimension = new Dimension(name, nbt); } /// - /// Get dimension type + /// Get current dimension /// - /// The chunk column - public Dimension GetDimension() + /// Current dimension + public static Dimension GetDimension() { - return this.dimension; + return dimension; } /// @@ -211,7 +207,6 @@ namespace MinecraftClient.Mapping try { chunks = new Dictionary>(); - dimension = null; } finally { diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs index 1ff2d13b..a5f35dbb 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs @@ -332,7 +332,7 @@ namespace MinecraftClient.Protocol.Handlers currentDimensionName = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above if (protocolversion >= MC1162Version) - handler.GetWorld().SetDimension(currentDimensionName, currentDimensionType); + World.SetDimension(currentDimensionName, currentDimensionType); if (protocolversion >= MC115Version) dataTypes.ReadNextLong(packetData); // Hashed world seed - 1.15 and above @@ -391,10 +391,7 @@ namespace MinecraftClient.Protocol.Handlers dimensionNameInRespawn = dataTypes.ReadNextString(packetData); // Dimension Name (World Name) - 1.16 and above if (protocolversion >= MC1162Version) - new Task(() => - { - handler.GetWorld().SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn); - }).Start(); + World.SetDimension(dimensionNameInRespawn, dimensionTypeInRespawn); if (protocolversion < MC114Version) dataTypes.ReadNextByte(packetData); // Difficulty - 1.13 and below @@ -470,12 +467,13 @@ namespace MinecraftClient.Protocol.Handlers } int dataSize = dataTypes.ReadNextVarInt(packetData); // Size + + Interlocked.Increment(ref handler.GetWorld().chunkCnt); + Interlocked.Increment(ref handler.GetWorld().chunkLoadNotCompleted); new Task(() => { - handler.GetWorld().chunkCnt++; - handler.GetWorld().chunkLoadNotCompleted++; pTerrain.ProcessChunkColumnData(chunkX, chunkZ, verticalStripBitmask, packetData); - handler.GetWorld().chunkLoadNotCompleted--; + Interlocked.Decrement(ref handler.GetWorld().chunkLoadNotCompleted); }).Start(); } else @@ -752,7 +750,8 @@ namespace MinecraftClient.Protocol.Handlers int chunkZ = dataTypes.ReadNextInt(packetData); if (handler.GetWorld()[chunkX, chunkZ] != null) - handler.GetWorld().chunkCnt--; + Interlocked.Decrement(ref handler.GetWorld().chunkCnt); + // Warning: It is legal to include unloaded chunks in the UnloadChunk packet. Since chunks that have not been loaded are not recorded, this may result in loading chunks that should be unloaded and inaccurate statistics. handler.GetWorld()[chunkX, chunkZ] = null; } diff --git a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs index 73593da6..a66655a4 100644 --- a/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs +++ b/MinecraftClient/Protocol/Handlers/Protocol18Terrain.cs @@ -147,10 +147,8 @@ namespace MinecraftClient.Protocol.Handlers public void ProcessChunkColumnData(int chunkX, int chunkZ, ulong[] verticalStripBitmask, Queue cache) { var world = handler.GetWorld(); - if (world.GetDimension() == null) - return; - int chunkColumnSize = (world.GetDimension().height + 15) / 16; + int chunkColumnSize = (World.GetDimension().height + 15) / 16; // Round up if (protocolversion >= Protocol18Handler.MC117Version) { @@ -223,7 +221,7 @@ namespace MinecraftClient.Protocol.Handlers /// Cache for reading chunk data public void ProcessChunkColumnData(int chunkX, int chunkZ, ushort chunkMask, ushort chunkMask2, bool hasSkyLight, bool chunksContinuous, int currentDimension, Queue cache) { - const int chunkColumnSize = 16; + const int chunkColumnSize = 16; if (protocolversion >= Protocol18Handler.MC19Version) { // 1.9 and above chunk format