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