diff --git a/README.md b/README.md index bb0ac0491..753f4598b 100755 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools. -_Currently supported Minecraft version: `24w35a`._ +_Currently supported Minecraft version: `24w39a`._ > [!WARNING] > Azalea is still very unfinished, though most crates are in a somewhat useable state diff --git a/azalea-inventory/src/components.rs b/azalea-inventory/src/components.rs index e456662e4..d7adf2c90 100644 --- a/azalea-inventory/src/components.rs +++ b/azalea-inventory/src/components.rs @@ -5,8 +5,8 @@ use azalea_buf::{BufReadError, McBuf, McBufReadable, McBufWritable}; use azalea_chat::FormattedText; use azalea_core::{position::GlobalPos, resource_location::ResourceLocation}; use azalea_registry::{ - Attribute, Block, ConsumeEffectKind, DataComponentKind, Enchantment, HolderSet, Item, - MobEffect, Potion, SoundEvent, TrimMaterial, TrimPattern, + Attribute, Block, ConsumeEffectKind, DataComponentKind, Enchantment, EntityKind, HolderSet, + Item, MobEffect, Potion, SoundEvent, TrimMaterial, TrimPattern, }; use simdnbt::owned::{Nbt, NbtCompound}; use uuid::Uuid; @@ -51,6 +51,8 @@ pub fn from_kind( ) -> Result, BufReadError> { // if this is causing a compile-time error, look at DataComponents.java in the // decompiled vanilla code to see how to implement new components + + // note that this match statement is updated by genitemcomponents.py Ok(match kind { DataComponentKind::CustomData => Box::new(CustomData::read_from(buf)?), DataComponentKind::MaxStackSize => Box::new(MaxStackSize::read_from(buf)?), @@ -77,7 +79,6 @@ pub fn from_kind( } DataComponentKind::IntangibleProjectile => Box::new(IntangibleProjectile::read_from(buf)?), DataComponentKind::Food => Box::new(Food::read_from(buf)?), - DataComponentKind::FireResistant => Box::new(FireResistant::read_from(buf)?), DataComponentKind::Tool => Box::new(Tool::read_from(buf)?), DataComponentKind::StoredEnchantments => Box::new(StoredEnchantments::read_from(buf)?), DataComponentKind::DyedColor => Box::new(DyedColor::read_from(buf)?), @@ -122,6 +123,12 @@ pub fn from_kind( DataComponentKind::UseCooldown => Box::new(UseCooldown::read_from(buf)?), DataComponentKind::Enchantable => Box::new(Enchantable::read_from(buf)?), DataComponentKind::Repairable => Box::new(Repairable::read_from(buf)?), + DataComponentKind::ItemModel => Box::new(ItemModel::read_from(buf)?), + DataComponentKind::DamageResistant => Box::new(DamageResistant::read_from(buf)?), + DataComponentKind::Equippable => Box::new(Equippable::read_from(buf)?), + DataComponentKind::Glider => Box::new(Glider::read_from(buf)?), + DataComponentKind::TooltipStyle => Box::new(TooltipStyle::read_from(buf)?), + DataComponentKind::DeathProtection => Box::new(DeathProtection::read_from(buf)?), }) } @@ -361,10 +368,6 @@ pub struct Food { } impl DataComponent for Food {} -#[derive(Clone, PartialEq, McBuf)] -pub struct FireResistant; -impl DataComponent for FireResistant {} - #[derive(Clone, PartialEq, McBuf)] pub struct ToolRule { pub blocks: HolderSet, @@ -719,3 +722,61 @@ pub struct Repairable { pub items: HolderSet, } impl DataComponent for Repairable {} + +#[derive(Clone, PartialEq, McBuf)] +pub struct ItemModel { + pub resource_location: ResourceLocation, +} +impl DataComponent for ItemModel {} + +#[derive(Clone, PartialEq, McBuf)] +pub struct DamageResistant { + // in the vanilla code this is + // ``` + // StreamCodec.composite( + // TagKey.streamCodec(Registries.DAMAGE_TYPE), DamageResistant::types, DamageResistant::new + // ); + // ``` + // i'm not entirely sure if this is meant to be a vec or something, i just made it a + // resourcelocation for now + pub types: ResourceLocation, +} +impl DataComponent for DamageResistant {} + +#[derive(Clone, PartialEq, McBuf)] +pub struct Equippable { + pub slot: EquipmentSlot, + pub equip_sound: SoundEvent, + pub model: Option, + pub allowed_entities: HolderSet, +} +impl DataComponent for Equippable {} + +#[derive(Clone, Copy, Debug, PartialEq, McBuf)] +pub enum EquipmentSlot { + Mainhand, + Offhand, + Hand, + Feet, + Legs, + Chest, + Head, + Armor, + Body, +} + +#[derive(Clone, PartialEq, McBuf)] +pub struct Glider; +impl DataComponent for Glider {} + +#[derive(Clone, PartialEq, McBuf)] +pub struct TooltipStyle { + pub resource_location: ResourceLocation, +} +impl DataComponent for TooltipStyle {} + +#[derive(Clone, PartialEq, McBuf)] +pub struct DeathProtection { + pub death_effects: Vec, +} +impl DataComponent for DeathProtection {} diff --git a/azalea-language/src/en_us.json b/azalea-language/src/en_us.json index cc26594c2..5aeba786f 100755 --- a/azalea-language/src/en_us.json +++ b/azalea-language/src/en_us.json @@ -2895,8 +2895,8 @@ "connect.transferring": "Transferring to new server...", "container.barrel": "Barrel", "container.beacon": "Beacon", - "container.beehive.bees": "Bees: %s/%s", - "container.beehive.honey": "Honey: %s/%s", + "container.beehive.bees": "Bees: %s / %s", + "container.beehive.honey": "Honey: %s / %s", "container.blast_furnace": "Blast Furnace", "container.brewing": "Brewing Stand", "container.cartography_table": "Cartography Table", @@ -3272,30 +3272,38 @@ "enchantment.minecraft.unbreaking": "Unbreaking", "enchantment.minecraft.vanishing_curse": "Curse of Vanishing", "enchantment.minecraft.wind_burst": "Wind Burst", + "entity.minecraft.acacia_boat": "Acacia Boat", + "entity.minecraft.acacia_chest_boat": "Acacia Boat With Chest", "entity.minecraft.allay": "Allay", "entity.minecraft.area_effect_cloud": "Area Effect Cloud", "entity.minecraft.armadillo": "Armadillo", "entity.minecraft.armor_stand": "Armor Stand", "entity.minecraft.arrow": "Arrow", "entity.minecraft.axolotl": "Axolotl", + "entity.minecraft.bamboo_chest_raft": "Bamboo Raft With Chest", + "entity.minecraft.bamboo_raft": "Bamboo Raft", "entity.minecraft.bat": "Bat", "entity.minecraft.bee": "Bee", + "entity.minecraft.birch_boat": "Birch Boat", + "entity.minecraft.birch_chest_boat": "Birch Boat With Chest", "entity.minecraft.blaze": "Blaze", "entity.minecraft.block_display": "Block Display", - "entity.minecraft.boat": "Boat", "entity.minecraft.bogged": "Bogged", "entity.minecraft.breeze": "Breeze", "entity.minecraft.breeze_wind_charge": "Wind Charge", "entity.minecraft.camel": "Camel", "entity.minecraft.cat": "Cat", "entity.minecraft.cave_spider": "Cave Spider", - "entity.minecraft.chest_boat": "Boat with Chest", + "entity.minecraft.cherry_boat": "Cherry Boat", + "entity.minecraft.cherry_chest_boat": "Cherry Boat With Chest", "entity.minecraft.chest_minecart": "Minecart with Chest", "entity.minecraft.chicken": "Chicken", "entity.minecraft.cod": "Cod", "entity.minecraft.command_block_minecart": "Minecart with Command Block", "entity.minecraft.cow": "Cow", "entity.minecraft.creeper": "Creeper", + "entity.minecraft.dark_oak_boat": "Dark Oak Boat", + "entity.minecraft.dark_oak_chest_boat": "Dark Oak Boat With Chest", "entity.minecraft.dolphin": "Dolphin", "entity.minecraft.donkey": "Donkey", "entity.minecraft.dragon_fireball": "Dragon Fireball", @@ -3336,16 +3344,22 @@ "entity.minecraft.item": "Item", "entity.minecraft.item_display": "Item Display", "entity.minecraft.item_frame": "Item Frame", + "entity.minecraft.jungle_boat": "Jungle Boat", + "entity.minecraft.jungle_chest_boat": "Jungle Boat With Chest", "entity.minecraft.killer_bunny": "The Killer Bunny", "entity.minecraft.leash_knot": "Leash Knot", "entity.minecraft.lightning_bolt": "Lightning Bolt", "entity.minecraft.llama": "Llama", "entity.minecraft.llama_spit": "Llama Spit", "entity.minecraft.magma_cube": "Magma Cube", + "entity.minecraft.mangrove_boat": "Mangrove Boat", + "entity.minecraft.mangrove_chest_boat": "Mangrove Boat With Chest", "entity.minecraft.marker": "Marker", "entity.minecraft.minecart": "Minecart", "entity.minecraft.mooshroom": "Mooshroom", "entity.minecraft.mule": "Mule", + "entity.minecraft.oak_boat": "Oak Boat", + "entity.minecraft.oak_chest_boat": "Oak Boat With Chest", "entity.minecraft.ocelot": "Ocelot", "entity.minecraft.ominous_item_spawner": "Ominous Item Spawner", "entity.minecraft.painting": "Painting", @@ -3377,6 +3391,8 @@ "entity.minecraft.spawner_minecart": "Minecart with Monster Spawner", "entity.minecraft.spectral_arrow": "Spectral Arrow", "entity.minecraft.spider": "Spider", + "entity.minecraft.spruce_boat": "Spruce Boat", + "entity.minecraft.spruce_chest_boat": "Spruce Boat With Chest", "entity.minecraft.squid": "Squid", "entity.minecraft.stray": "Stray", "entity.minecraft.strider": "Strider", @@ -3549,7 +3565,7 @@ "gamerule.maxCommandForkCount.description": "Maximum number of contexts that can be used by commands like 'execute as'.", "gamerule.maxEntityCramming": "Entity cramming threshold", "gamerule.minecartMaxSpeed": "Minecart max speed", - "gamerule.minecartMaxSpeed.description": "Maximum default speed of a moving Minecart on land", + "gamerule.minecartMaxSpeed.description": "Maximum default speed of a moving Minecart on land.", "gamerule.mobExplosionDropDecay": "In mob explosions, some blocks won't drop their loot", "gamerule.mobExplosionDropDecay.description": "Some of the drops from blocks destroyed by explosions caused by mobs are lost in the explosion.", "gamerule.mobGriefing": "Allow destructive mob actions", @@ -3839,12 +3855,14 @@ "item.minecraft.beetroot_soup": "Beetroot Soup", "item.minecraft.birch_boat": "Birch Boat", "item.minecraft.birch_chest_boat": "Birch Boat with Chest", + "item.minecraft.black_bundle": "Black Bundle", "item.minecraft.black_dye": "Black Dye", "item.minecraft.blade_pottery_shard": "Blade Pottery Shard", "item.minecraft.blade_pottery_sherd": "Blade Pottery Sherd", "item.minecraft.blaze_powder": "Blaze Powder", "item.minecraft.blaze_rod": "Blaze Rod", "item.minecraft.blaze_spawn_egg": "Blaze Spawn Egg", + "item.minecraft.blue_bundle": "Blue Bundle", "item.minecraft.blue_dye": "Blue Dye", "item.minecraft.bogged_spawn_egg": "Bogged Spawn Egg", "item.minecraft.bolt_armor_trim_smithing_template": "Smithing Template", @@ -3862,6 +3880,7 @@ "item.minecraft.brewer_pottery_sherd": "Brewer Pottery Sherd", "item.minecraft.brewing_stand": "Brewing Stand", "item.minecraft.brick": "Brick", + "item.minecraft.brown_bundle": "Brown Bundle", "item.minecraft.brown_dye": "Brown Dye", "item.minecraft.brush": "Brush", "item.minecraft.bucket": "Bucket", @@ -3916,6 +3935,7 @@ "item.minecraft.creeper_spawn_egg": "Creeper Spawn Egg", "item.minecraft.crossbow": "Crossbow", "item.minecraft.crossbow.projectile": "Projectile:", + "item.minecraft.cyan_bundle": "Cyan Bundle", "item.minecraft.cyan_dye": "Cyan Dye", "item.minecraft.danger_pottery_shard": "Danger Pottery Shard", "item.minecraft.danger_pottery_sherd": "Danger Pottery Sherd", @@ -4044,7 +4064,9 @@ "item.minecraft.golden_pickaxe": "Golden Pickaxe", "item.minecraft.golden_shovel": "Golden Shovel", "item.minecraft.golden_sword": "Golden Sword", + "item.minecraft.gray_bundle": "Gray Bundle", "item.minecraft.gray_dye": "Gray Dye", + "item.minecraft.green_bundle": "Green Bundle", "item.minecraft.green_dye": "Green Dye", "item.minecraft.guardian_spawn_egg": "Guardian Spawn Egg", "item.minecraft.gunpowder": "Gunpowder", @@ -4094,8 +4116,11 @@ "item.minecraft.leather_helmet": "Leather Cap", "item.minecraft.leather_horse_armor": "Leather Horse Armor", "item.minecraft.leather_leggings": "Leather Pants", + "item.minecraft.light_blue_bundle": "Light Blue Bundle", "item.minecraft.light_blue_dye": "Light Blue Dye", + "item.minecraft.light_gray_bundle": "Light Gray Bundle", "item.minecraft.light_gray_dye": "Light Gray Dye", + "item.minecraft.lime_bundle": "Lime Bundle", "item.minecraft.lime_dye": "Lime Dye", "item.minecraft.lingering_potion": "Lingering Potion", "item.minecraft.lingering_potion.effect.awkward": "Awkward Lingering Potion", @@ -4127,6 +4152,7 @@ "item.minecraft.llama_spawn_egg": "Llama Spawn Egg", "item.minecraft.lodestone_compass": "Lodestone Compass", "item.minecraft.mace": "Mace", + "item.minecraft.magenta_bundle": "Magenta Bundle", "item.minecraft.magenta_dye": "Magenta Dye", "item.minecraft.magma_cream": "Magma Cream", "item.minecraft.magma_cube_spawn_egg": "Magma Cube Spawn Egg", @@ -4209,6 +4235,7 @@ "item.minecraft.ocelot_spawn_egg": "Ocelot Spawn Egg", "item.minecraft.ominous_bottle": "Ominous Bottle", "item.minecraft.ominous_trial_key": "Ominous Trial Key", + "item.minecraft.orange_bundle": "Orange Bundle", "item.minecraft.orange_dye": "Orange Dye", "item.minecraft.painting": "Painting", "item.minecraft.panda_spawn_egg": "Panda Spawn Egg", @@ -4223,6 +4250,7 @@ "item.minecraft.piglin_brute_spawn_egg": "Piglin Brute Spawn Egg", "item.minecraft.piglin_spawn_egg": "Piglin Spawn Egg", "item.minecraft.pillager_spawn_egg": "Pillager Spawn Egg", + "item.minecraft.pink_bundle": "Pink Bundle", "item.minecraft.pink_dye": "Pink Dye", "item.minecraft.pitcher_plant": "Pitcher Plant", "item.minecraft.pitcher_pod": "Pitcher Pod", @@ -4274,6 +4302,7 @@ "item.minecraft.pufferfish_spawn_egg": "Pufferfish Spawn Egg", "item.minecraft.pumpkin_pie": "Pumpkin Pie", "item.minecraft.pumpkin_seeds": "Pumpkin Seeds", + "item.minecraft.purple_bundle": "Purple Bundle", "item.minecraft.purple_dye": "Purple Dye", "item.minecraft.quartz": "Nether Quartz", "item.minecraft.rabbit": "Raw Rabbit", @@ -4288,6 +4317,7 @@ "item.minecraft.raw_gold": "Raw Gold", "item.minecraft.raw_iron": "Raw Iron", "item.minecraft.recovery_compass": "Recovery Compass", + "item.minecraft.red_bundle": "Red Bundle", "item.minecraft.red_dye": "Red Dye", "item.minecraft.redstone": "Redstone Dust", "item.minecraft.rib_armor_trim_smithing_template": "Smithing Template", @@ -4466,6 +4496,7 @@ "item.minecraft.wayfinder_armor_trim_smithing_template.new": "Wayfinder Armor Trim", "item.minecraft.wheat": "Wheat", "item.minecraft.wheat_seeds": "Wheat Seeds", + "item.minecraft.white_bundle": "White Bundle", "item.minecraft.white_dye": "White Dye", "item.minecraft.wild_armor_trim_smithing_template": "Smithing Template", "item.minecraft.wild_armor_trim_smithing_template.new": "Wild Armor Trim", @@ -4482,6 +4513,7 @@ "item.minecraft.wooden_sword": "Wooden Sword", "item.minecraft.writable_book": "Book and Quill", "item.minecraft.written_book": "Written Book", + "item.minecraft.yellow_bundle": "Yellow Bundle", "item.minecraft.yellow_dye": "Yellow Dye", "item.minecraft.zoglin_spawn_egg": "Zoglin Spawn Egg", "item.minecraft.zombie_horse_spawn_egg": "Zombie Horse Spawn Egg", @@ -4860,6 +4892,7 @@ "mco.connect.success": "Done", "mco.create.world": "Create", "mco.create.world.error": "You must enter a name!", + "mco.create.world.failed": "Failed to create world!", "mco.create.world.reset.title": "Creating world...", "mco.create.world.skip": "Skip", "mco.create.world.subtitle": "Optionally, select what world to put on your new realm", @@ -4891,6 +4924,7 @@ "mco.errorMessage.6009": "Invalid Realm description", "mco.errorMessage.connectionFailure": "An error occurred, please try again later.", "mco.errorMessage.generic": "An error occurred: ", + "mco.errorMessage.initialize.failed": "Failed to initialize Realm", "mco.errorMessage.noDetails": "No error details provided", "mco.errorMessage.realmsService": "An error occurred (%s):", "mco.errorMessage.realmsService.connectivity": "Could not connect to Realms: %s", @@ -5019,6 +5053,8 @@ "mco.upload.entry.commands": "%1$s, %2$s", "mco.upload.entry.id": "%1$s (%2$s)", "mco.upload.failed": "Upload failed! (%s)", + "mco.upload.failed.too_big.description": "The selected world is too big. The maximum allowed size is %s.", + "mco.upload.failed.too_big.title": "World too big", "mco.upload.hardcore": "Hardcore worlds can't be uploaded!", "mco.upload.percent": "%s %%", "mco.upload.preparing": "Preparing your world", @@ -5418,7 +5454,7 @@ "options.renderDistance": "Render Distance", "options.resourcepack": "Resource Packs...", "options.rotateWithMinecart": "Rotate with Minecarts", - "options.rotateWithMinecart.tooltip": "If the player's view should rotate with a turning Minecart. Only available in worlds with the 'Minecart Improvements' experimental setting turned on.", + "options.rotateWithMinecart.tooltip": "Whether the player's view should rotate with a turning Minecart. Only available in worlds with the 'Minecart Improvements' experimental setting turned on.", "options.screenEffectScale": "Distortion Effects", "options.screenEffectScale.tooltip": "Strength of nausea and Nether portal screen distortion effects.\nAt lower values, the nausea effect is replaced with a green overlay.", "options.sensitivity": "Sensitivity", diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs index a574e02b4..75c18457c 100755 --- a/azalea-protocol/src/packets/mod.rs +++ b/azalea-protocol/src/packets/mod.rs @@ -12,7 +12,7 @@ use std::io::{Cursor, Write}; // TODO: rename the packet files to just like clientbound_add_entity instead of // clientbound_add_entity_packet -pub const PROTOCOL_VERSION: i32 = 1073742031; +pub const PROTOCOL_VERSION: i32 = 1073742035; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConnectionProtocol { diff --git a/azalea-registry/src/lib.rs b/azalea-registry/src/lib.rs index d4c04e5e4..f87ffd7ce 100755 --- a/azalea-registry/src/lib.rs +++ b/azalea-registry/src/lib.rs @@ -1609,47 +1609,56 @@ enum Enchantment { registry! { /// An enum that contains every type of entity. enum EntityKind { + AcaciaBoat => "minecraft:acacia_boat", + AcaciaChestBoat => "minecraft:acacia_chest_boat", Allay => "minecraft:allay", AreaEffectCloud => "minecraft:area_effect_cloud", Armadillo => "minecraft:armadillo", ArmorStand => "minecraft:armor_stand", Arrow => "minecraft:arrow", Axolotl => "minecraft:axolotl", + BambooChestRaft => "minecraft:bamboo_chest_raft", + BambooRaft => "minecraft:bamboo_raft", Bat => "minecraft:bat", Bee => "minecraft:bee", + BirchBoat => "minecraft:birch_boat", + BirchChestBoat => "minecraft:birch_chest_boat", Blaze => "minecraft:blaze", BlockDisplay => "minecraft:block_display", - Boat => "minecraft:boat", Bogged => "minecraft:bogged", Breeze => "minecraft:breeze", BreezeWindCharge => "minecraft:breeze_wind_charge", Camel => "minecraft:camel", Cat => "minecraft:cat", CaveSpider => "minecraft:cave_spider", - ChestBoat => "minecraft:chest_boat", + CherryBoat => "minecraft:cherry_boat", + CherryChestBoat => "minecraft:cherry_chest_boat", ChestMinecart => "minecraft:chest_minecart", Chicken => "minecraft:chicken", Cod => "minecraft:cod", CommandBlockMinecart => "minecraft:command_block_minecart", Cow => "minecraft:cow", Creeper => "minecraft:creeper", + DarkOakBoat => "minecraft:dark_oak_boat", + DarkOakChestBoat => "minecraft:dark_oak_chest_boat", Dolphin => "minecraft:dolphin", Donkey => "minecraft:donkey", DragonFireball => "minecraft:dragon_fireball", Drowned => "minecraft:drowned", Egg => "minecraft:egg", ElderGuardian => "minecraft:elder_guardian", - EndCrystal => "minecraft:end_crystal", - EnderDragon => "minecraft:ender_dragon", - EnderPearl => "minecraft:ender_pearl", Enderman => "minecraft:enderman", Endermite => "minecraft:endermite", + EnderDragon => "minecraft:ender_dragon", + EnderPearl => "minecraft:ender_pearl", + EndCrystal => "minecraft:end_crystal", Evoker => "minecraft:evoker", EvokerFangs => "minecraft:evoker_fangs", ExperienceBottle => "minecraft:experience_bottle", ExperienceOrb => "minecraft:experience_orb", EyeOfEnder => "minecraft:eye_of_ender", FallingBlock => "minecraft:falling_block", + Fireball => "minecraft:fireball", FireworkRocket => "minecraft:firework_rocket", Fox => "minecraft:fox", Frog => "minecraft:frog", @@ -1670,18 +1679,23 @@ enum EntityKind { Item => "minecraft:item", ItemDisplay => "minecraft:item_display", ItemFrame => "minecraft:item_frame", - OminousItemSpawner => "minecraft:ominous_item_spawner", - Fireball => "minecraft:fireball", + JungleBoat => "minecraft:jungle_boat", + JungleChestBoat => "minecraft:jungle_chest_boat", LeashKnot => "minecraft:leash_knot", LightningBolt => "minecraft:lightning_bolt", Llama => "minecraft:llama", LlamaSpit => "minecraft:llama_spit", MagmaCube => "minecraft:magma_cube", + MangroveBoat => "minecraft:mangrove_boat", + MangroveChestBoat => "minecraft:mangrove_chest_boat", Marker => "minecraft:marker", Minecart => "minecraft:minecart", Mooshroom => "minecraft:mooshroom", Mule => "minecraft:mule", + OakBoat => "minecraft:oak_boat", + OakChestBoat => "minecraft:oak_chest_boat", Ocelot => "minecraft:ocelot", + OminousItemSpawner => "minecraft:ominous_item_spawner", Painting => "minecraft:painting", Panda => "minecraft:panda", Parrot => "minecraft:parrot", @@ -1705,11 +1719,13 @@ enum EntityKind { Slime => "minecraft:slime", SmallFireball => "minecraft:small_fireball", Sniffer => "minecraft:sniffer", - SnowGolem => "minecraft:snow_golem", Snowball => "minecraft:snowball", + SnowGolem => "minecraft:snow_golem", SpawnerMinecart => "minecraft:spawner_minecart", SpectralArrow => "minecraft:spectral_arrow", Spider => "minecraft:spider", + SpruceBoat => "minecraft:spruce_boat", + SpruceChestBoat => "minecraft:spruce_chest_boat", Squid => "minecraft:squid", Stray => "minecraft:stray", Strider => "minecraft:strider", @@ -2803,6 +2819,22 @@ enum Item { Compass => "minecraft:compass", RecoveryCompass => "minecraft:recovery_compass", Bundle => "minecraft:bundle", + WhiteBundle => "minecraft:white_bundle", + OrangeBundle => "minecraft:orange_bundle", + MagentaBundle => "minecraft:magenta_bundle", + LightBlueBundle => "minecraft:light_blue_bundle", + YellowBundle => "minecraft:yellow_bundle", + LimeBundle => "minecraft:lime_bundle", + PinkBundle => "minecraft:pink_bundle", + GrayBundle => "minecraft:gray_bundle", + LightGrayBundle => "minecraft:light_gray_bundle", + CyanBundle => "minecraft:cyan_bundle", + PurpleBundle => "minecraft:purple_bundle", + BlueBundle => "minecraft:blue_bundle", + BrownBundle => "minecraft:brown_bundle", + GreenBundle => "minecraft:green_bundle", + RedBundle => "minecraft:red_bundle", + BlackBundle => "minecraft:black_bundle", FishingRod => "minecraft:fishing_rod", Clock => "minecraft:clock", Spyglass => "minecraft:spyglass", @@ -3754,7 +3786,7 @@ enum RecipeSerializer { CraftingSpecialTippedarrow => "minecraft:crafting_special_tippedarrow", CraftingSpecialBannerduplicate => "minecraft:crafting_special_bannerduplicate", CraftingSpecialShielddecoration => "minecraft:crafting_special_shielddecoration", - CraftingSpecialShulkerboxcoloring => "minecraft:crafting_special_shulkerboxcoloring", + CraftingTransmute => "minecraft:crafting_transmute", CraftingSpecialRepairitem => "minecraft:crafting_special_repairitem", Smelting => "minecraft:smelting", Blasting => "minecraft:blasting", @@ -4450,7 +4482,6 @@ enum SoundEvent { EntityGoatPrepareRam => "minecraft:entity.goat.prepare_ram", EntityGoatRamImpact => "minecraft:entity.goat.ram_impact", EntityGoatHornBreak => "minecraft:entity.goat.horn_break", - ItemGoatHornPlay => "minecraft:item.goat_horn.play", EntityGoatScreamingAmbient => "minecraft:entity.goat.screaming.ambient", EntityGoatScreamingDeath => "minecraft:entity.goat.screaming.death", EntityGoatScreamingEat => "minecraft:entity.goat.screaming.eat", @@ -4459,7 +4490,6 @@ enum SoundEvent { EntityGoatScreamingMilk => "minecraft:entity.goat.screaming.milk", EntityGoatScreamingPrepareRam => "minecraft:entity.goat.screaming.prepare_ram", EntityGoatScreamingRamImpact => "minecraft:entity.goat.screaming.ram_impact", - EntityGoatScreamingHornBreak => "minecraft:entity.goat.screaming.horn_break", EntityGoatStep => "minecraft:entity.goat.step", BlockGrassBreak => "minecraft:block.grass.break", BlockGrassFall => "minecraft:block.grass.fall", @@ -5980,7 +6010,6 @@ enum BlockKind { Carpet => "minecraft:carpet", Carrot => "minecraft:carrot", CartographyTable => "minecraft:cartography_table", - CarvedPumpkin => "minecraft:carved_pumpkin", Cauldron => "minecraft:cauldron", CaveVines => "minecraft:cave_vines", CaveVinesPlant => "minecraft:cave_vines_plant", @@ -6229,7 +6258,7 @@ enum TriggerKind { FishingRodHooked => "minecraft:fishing_rod_hooked", ChanneledLightning => "minecraft:channeled_lightning", ShotCrossbow => "minecraft:shot_crossbow", - KilledByCrossbow => "minecraft:killed_by_crossbow", + KilledByArrow => "minecraft:killed_by_arrow", HeroOfTheVillage => "minecraft:hero_of_the_village", VoluntaryExile => "minecraft:voluntary_exile", SlideDownBlock => "minecraft:slide_down_block", @@ -6286,6 +6315,7 @@ enum DataComponentKind { Unbreakable => "minecraft:unbreakable", CustomName => "minecraft:custom_name", ItemName => "minecraft:item_name", + ItemModel => "minecraft:item_model", Lore => "minecraft:lore", Rarity => "minecraft:rarity", Enchantments => "minecraft:enchantments", @@ -6303,10 +6333,14 @@ enum DataComponentKind { Consumable => "minecraft:consumable", UseRemainder => "minecraft:use_remainder", UseCooldown => "minecraft:use_cooldown", - FireResistant => "minecraft:fire_resistant", + DamageResistant => "minecraft:damage_resistant", Tool => "minecraft:tool", Enchantable => "minecraft:enchantable", + Equippable => "minecraft:equippable", Repairable => "minecraft:repairable", + Glider => "minecraft:glider", + TooltipStyle => "minecraft:tooltip_style", + DeathProtection => "minecraft:death_protection", StoredEnchantments => "minecraft:stored_enchantments", DyedColor => "minecraft:dyed_color", MapColor => "minecraft:map_color", @@ -6353,7 +6387,6 @@ enum EntitySubPredicateKind { Raider => "minecraft:raider", Sheep => "minecraft:sheep", Axolotl => "minecraft:axolotl", - Boat => "minecraft:boat", Fox => "minecraft:fox", Mooshroom => "minecraft:mooshroom", Rabbit => "minecraft:rabbit", @@ -6361,6 +6394,7 @@ enum EntitySubPredicateKind { Llama => "minecraft:llama", Villager => "minecraft:villager", Parrot => "minecraft:parrot", + Salmon => "minecraft:salmon", TropicalFish => "minecraft:tropical_fish", Painting => "minecraft:painting", Cat => "minecraft:cat", diff --git a/azalea-registry/src/tags/blocks.rs b/azalea-registry/src/tags/blocks.rs index 039ee0f83..b57ae8c9e 100644 --- a/azalea-registry/src/tags/blocks.rs +++ b/azalea-registry/src/tags/blocks.rs @@ -286,6 +286,16 @@ pub static BASE_STONE_OVERWORLD: Lazy> = Lazy::new(|| { Block::Deepslate, ]) }); +pub static BATS_SPAWNABLE_ON: Lazy> = Lazy::new(|| { + HashSet::from_iter(vec![ + Block::Stone, + Block::Granite, + Block::Diorite, + Block::Andesite, + Block::Tuff, + Block::Deepslate, + ]) +}); pub static BEACON_BASE_BLOCKS: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Block::NetheriteBlock, diff --git a/azalea-registry/src/tags/items.rs b/azalea-registry/src/tags/items.rs index 65975193e..0b3b233a5 100644 --- a/azalea-registry/src/tags/items.rs +++ b/azalea-registry/src/tags/items.rs @@ -188,6 +188,29 @@ pub static BREAKS_DECORATED_POTS: Lazy> = Lazy::new(|| { Item::IronHoe, ]) }); +pub static BREWING_FUEL: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::BlazePowder])); +pub static BUNDLES: Lazy> = Lazy::new(|| { + HashSet::from_iter(vec![ + Item::Bundle, + Item::BlackBundle, + Item::BlueBundle, + Item::BrownBundle, + Item::CyanBundle, + Item::GrayBundle, + Item::GreenBundle, + Item::LightBlueBundle, + Item::LightGrayBundle, + Item::LimeBundle, + Item::MagentaBundle, + Item::OrangeBundle, + Item::PinkBundle, + Item::PurpleBundle, + Item::RedBundle, + Item::YellowBundle, + Item::WhiteBundle, + ]) +}); pub static BUTTONS: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Item::OakButton, @@ -511,6 +534,8 @@ pub static DOORS: Lazy> = Lazy::new(|| { Item::CherryDoor, ]) }); +pub static DUPLICATES_ALLAYS: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::AmethystShard])); pub static DYEABLE: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Item::LeatherHelmet, @@ -1197,6 +1222,8 @@ pub static MANGROVE_LOGS: Lazy> = Lazy::new(|| { Item::StrippedMangroveWood, ]) }); +pub static MAP_INVISIBILITY_EQUIPMENT: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::CarvedPumpkin])); pub static MEAT: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Item::Beef, @@ -1269,6 +1296,8 @@ pub static OAK_LOGS: Lazy> = Lazy::new(|| { }); pub static OCELOT_FOOD: Lazy> = Lazy::new(|| HashSet::from_iter(vec![Item::Cod, Item::Salmon])); +pub static PANDA_EATS_FROM_GROUND: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::Cake, Item::Bamboo])); pub static PANDA_FOOD: Lazy> = Lazy::new(|| HashSet::from_iter(vec![Item::Bamboo])); pub static PARROT_FOOD: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ @@ -1327,6 +1356,14 @@ pub static PIGLIN_LOVED: Lazy> = Lazy::new(|| { }); pub static PIGLIN_REPELLENTS: Lazy> = Lazy::new(|| HashSet::from_iter(vec![Item::SoulTorch, Item::SoulLantern, Item::SoulCampfire])); +pub static PIGLIN_SAFE_ARMOR: Lazy> = Lazy::new(|| { + HashSet::from_iter(vec![ + Item::GoldenHelmet, + Item::GoldenChestplate, + Item::GoldenLeggings, + Item::GoldenBoots, + ]) +}); pub static PLANKS: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Item::OakPlanks, @@ -1354,6 +1391,22 @@ pub static RAILS: Lazy> = Lazy::new(|| { }); pub static REDSTONE_ORES: Lazy> = Lazy::new(|| HashSet::from_iter(vec![Item::RedstoneOre, Item::DeepslateRedstoneOre])); +pub static REPAIRS_CHAIN_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::IronIngot])); +pub static REPAIRS_DIAMOND_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::Diamond])); +pub static REPAIRS_GOLD_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::GoldIngot])); +pub static REPAIRS_IRON_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::IronIngot])); +pub static REPAIRS_LEATHER_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::Leather])); +pub static REPAIRS_NETHERITE_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::NetheriteIngot])); +pub static REPAIRS_TURTLE_HELMET: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::TurtleScute])); +pub static REPAIRS_WOLF_ARMOR: Lazy> = + Lazy::new(|| HashSet::from_iter(vec![Item::ArmadilloScute])); pub static SAND: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Item::Sand, @@ -1387,6 +1440,27 @@ pub static SHOVELS: Lazy> = Lazy::new(|| { Item::IronShovel, ]) }); +pub static SHULKER_BOXES: Lazy> = Lazy::new(|| { + HashSet::from_iter(vec![ + Item::ShulkerBox, + Item::BlackShulkerBox, + Item::BlueShulkerBox, + Item::BrownShulkerBox, + Item::CyanShulkerBox, + Item::GrayShulkerBox, + Item::GreenShulkerBox, + Item::LightBlueShulkerBox, + Item::LightGrayShulkerBox, + Item::LimeShulkerBox, + Item::MagentaShulkerBox, + Item::OrangeShulkerBox, + Item::PinkShulkerBox, + Item::PurpleShulkerBox, + Item::RedShulkerBox, + Item::WhiteShulkerBox, + Item::YellowShulkerBox, + ]) +}); pub static SIGNS: Lazy> = Lazy::new(|| { HashSet::from_iter(vec![ Item::OakSign, diff --git a/codegen/genitemcomponents.py b/codegen/genitemcomponents.py new file mode 100644 index 000000000..32923e7e7 --- /dev/null +++ b/codegen/genitemcomponents.py @@ -0,0 +1,165 @@ +import lib.code.inventory +import lib.code.registry +import lib.code.version +import lib.code.packet +import lib.code.utils +import lib.code.tags +import lib.download +import lib.extract +import lib.utils + +ITEM_COMPONENTS_DIR = 'azalea-inventory/src/components.rs' + +def generate(version_id: str): + expected_variants = get_expected_variants(version_id) + actual_variants = get_actual_variants() + + new_variants = [] + removed_variants = [] + + for variant in expected_variants: + if variant not in actual_variants: + new_variants.append(variant) + for variant in actual_variants: + if variant not in expected_variants: + removed_variants.append(variant) + + print('New variants:') + for variant in new_variants: + print('-', variant) + print() + print('Removed variants:') + for variant in removed_variants: + print('-', variant) + print() + + for variant in removed_variants: + print(f'Removing {variant}...') + remove_variant(variant) + for variant in new_variants: + print(f'Adding {variant}...') + add_variant(variant) + + lib.code.utils.fmt() + + print('Done!') + +def get_expected_variants(version_id: str): + expected_variants = [] + registries = lib.extract.get_registries_report(version_id) + + registry = registries['minecraft:data_component_type'] + registry_entries = sorted( + registry['entries'].items(), key=lambda x: x[1]['protocol_id']) + for variant_name, _variant in registry_entries: + variant_struct_name = lib.utils.to_camel_case(variant_name.split(':')[-1]) + expected_variants.append(variant_struct_name) + + return expected_variants + +def get_actual_variants(): + actual_variants = [] + with open(ITEM_COMPONENTS_DIR, 'r') as f: + code = f.read().split('\n') + + in_match = False + for line in code: + if in_match: + if line == ' })': + break + variant_line_prefix = ' DataComponentKind::' + if line.startswith(variant_line_prefix): + variant = line[len(variant_line_prefix):].split(' ', 1)[0] + actual_variants.append(variant) + elif line == ' Ok(match kind {': + in_match = True + + return actual_variants + +def remove_variant(variant: str): + with open(ITEM_COMPONENTS_DIR, 'r') as f: + code = f.read().split('\n') + + first_line_with_variant = None + line_after_variant = None + + in_match = False + for i, line in enumerate(list(code)): + if in_match: + if line == ' })': + line_after_variant = i + break + variant_line_prefix = ' DataComponentKind::' + if line.startswith(variant_line_prefix): + if first_line_with_variant is not None: + line_after_variant = i + break + variant_name = line[len(variant_line_prefix):].split(' ', 1)[0] + if variant_name == variant: + first_line_with_variant = i + elif line == ' Ok(match kind {': + in_match = True + + if first_line_with_variant is None: + raise ValueError(f'Variant {variant} not found') + if line_after_variant is None: + raise ValueError(f'Couldn\'t find end of variant {variant}') + + code = code[:first_line_with_variant] + code[line_after_variant:] + + # now remove the struct + line_before_struct = None # this is the #[derive] line + line_after_struct = None # impl DataComponent for ... {} + for i, line in enumerate(list(code)): + if line == f'pub struct {variant} {{' or line == f'pub struct {variant};': + line_before_struct = i - 1 + elif line == f'impl DataComponent for {variant} {{}}': + line_after_struct = i + 1 + break + if line_before_struct is None: + raise ValueError(f'Couldn\'t find struct {variant}') + if line_after_struct is None: + raise ValueError(f'Couldn\'t find impl DataComponent for {variant}') + + code = code[:line_before_struct] + code[line_after_struct:] + + with open(ITEM_COMPONENTS_DIR, 'w') as f: + f.write('\n'.join(code)) + +def add_variant(variant: str): + with open(ITEM_COMPONENTS_DIR, 'r') as f: + code = f.read().split('\n') + + in_match = False + last_line_in_match = None + for i, line in enumerate(list(code)): + if in_match: + if line == ' })': + last_line_in_match = i + break + elif line == ' Ok(match kind {': + in_match = True + + if last_line_in_match is None: + raise ValueError('Couldn\'t find end of match') + + code = code[:last_line_in_match] + [ + f' DataComponentKind::{variant} => Box::new({variant}::read_from(buf)?),', + ] + code[last_line_in_match:] + + # now insert the struct + code.append('') + code.append('#[derive(Clone, PartialEq, McBuf)]') + code.append(f'pub struct {variant} {{') + code.append(' pub todo: todo!(), // see DataComponents.java') + code.append('}') + code.append(f'impl DataComponent for {variant} {{}}') + + with open(ITEM_COMPONENTS_DIR, 'w') as f: + f.write('\n'.join(code)) + + lib.code.utils.fmt() + +if __name__ == '__main__': + version_id = lib.code.version.get_version_id() + generate(version_id) diff --git a/codegen/lib/code/registry.py b/codegen/lib/code/registry.py index e203c11a5..401f4b022 100755 --- a/codegen/lib/code/registry.py +++ b/codegen/lib/code/registry.py @@ -5,7 +5,6 @@ REGISTRIES_DIR = get_dir_location('../azalea-registry/src/lib.rs') - def generate_registries(registries: dict): with open(REGISTRIES_DIR, 'r') as f: code = f.read().split('\n') @@ -17,23 +16,14 @@ def generate_registries(registries: dict): # }); registry_name = registry_name.split(':')[1] - - if registry_name.endswith('_type'): - # change _type to _kind because that's Rustier (and because _type - # is a reserved keyword) - registry_name = registry_name[:-5] + '_kind' - elif registry_name in {'menu'}: - registry_name += '_kind' - - registry_struct_name = to_camel_case(registry_name) + registry_enum_name = registry_name_to_enum_name(registry_name) registry_code = [] - registry_code.append(f'enum {registry_struct_name} {{') + registry_code.append(f'enum {registry_enum_name} {{') registry_entries = sorted( registry['entries'].items(), key=lambda x: x[1]['protocol_id']) for variant_name, _variant in registry_entries: - variant_struct_name = to_camel_case( - variant_name.split(':')[1]) + variant_struct_name = to_camel_case(variant_name.split(':')[-1]) registry_code.append(f'\t{variant_struct_name} => "{variant_name}",') registry_code.append('}') @@ -59,3 +49,15 @@ def generate_registries(registries: dict): with open(REGISTRIES_DIR, 'w') as f: f.write('\n'.join(code)) + +def registry_name_to_enum_name(registry_name: str) -> str: + registry_name = registry_name.split(':')[-1] + + if registry_name.endswith('_type'): + # change _type to _kind because that's Rustier (and because _type + # is a reserved keyword) + registry_name = registry_name[:-5] + '_kind' + elif registry_name in {'menu'}: + registry_name += '_kind' + + return to_camel_case(registry_name)