Skip to content

Commit

Permalink
start updating to 24w39a + itemcomponent codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Sep 30, 2024
1 parent 9d495c1 commit 2d5dec9
Show file tree
Hide file tree
Showing 9 changed files with 425 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools.

<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->

_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
Expand Down
75 changes: 68 additions & 7 deletions azalea-inventory/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,6 +51,8 @@ pub fn from_kind(
) -> Result<Box<dyn EncodableDataComponent>, 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)?),
Expand All @@ -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)?),
Expand Down Expand Up @@ -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)?),
})
}

Expand Down Expand Up @@ -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<Block, ResourceLocation>,
Expand Down Expand Up @@ -719,3 +722,61 @@ pub struct Repairable {
pub items: HolderSet<Item, ResourceLocation>,
}
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<ResourceLocation>,
pub allowed_entities: HolderSet<EntityKind, ResourceLocation>,
}
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<ConsumeEffectKind>,
}
impl DataComponent for DeathProtection {}
48 changes: 42 additions & 6 deletions azalea-language/src/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion azalea-protocol/src/packets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit 2d5dec9

Please sign in to comment.