Skip to content

Commit

Permalink
1.20.3-pre2
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Nov 27, 2023
1 parent b379897 commit 7ede805
Show file tree
Hide file tree
Showing 31 changed files with 1,097 additions and 902 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A collection of Rust crates for making Minecraft bots, clients, and tools.
</p>

<!-- The line below is automatically read and updated by the migrate script, so don't change it manually. -->
*Currently supported Minecraft version: `23w45a`.*
*Currently supported Minecraft version: `1.20.3-pre2`.*

> **Warning**
> Azalea is still very unfinished, though most crates are in a somewhat useable state
Expand Down
68 changes: 59 additions & 9 deletions azalea-block/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,26 @@ make_block_states! {
},
"locked" => bool,
"down" => bool,
"age" => PumpkinStemAge {
_0,
_1,
_2,
_3,
_4,
_5,
_6,
_7,
},
"age" => MelonStemAge {
_0,
_1,
_2,
_3,
_4,
_5,
_6,
_7,
},
"down" => bool,
"north" => bool,
"south" => bool,
Expand Down Expand Up @@ -2261,7 +2281,7 @@ make_block_states! {
facing: FacingCubic::North,
},
cobweb => BlockBehavior::new().requires_correct_tool_for_drops().strength(4.0, 4.0), {},
grass => BlockBehavior::new(), {},
short_grass => BlockBehavior::new(), {},
fern => BlockBehavior::new(), {},
dead_bush => BlockBehavior::new(), {},
seagrass => BlockBehavior::new(), {},
Expand Down Expand Up @@ -2816,6 +2836,20 @@ make_block_states! {
waterlogged: false,
west: false,
},
pumpkin => BlockBehavior::new().strength(1.0, 1.0), {},
melon => BlockBehavior::new().strength(1.0, 1.0), {},
attached_pumpkin_stem => BlockBehavior::new(), {
facing: FacingCardinal::North,
},
attached_melon_stem => BlockBehavior::new(), {
facing: FacingCardinal::North,
},
pumpkin_stem => BlockBehavior::new(), {
age: PumpkinStemAge::_0,
},
melon_stem => BlockBehavior::new(), {
age: MelonStemAge::_0,
},
vine => BlockBehavior::new().strength(0.2, 0.2), {
east: false,
north: false,
Expand Down Expand Up @@ -5133,14 +5167,30 @@ make_block_states! {
powered: false,
waterlogged: false,
},
copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
exposed_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
weathered_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
oxidized_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
waxed_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
waxed_exposed_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
waxed_weathered_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
waxed_oxidized_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {},
copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
exposed_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
weathered_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
oxidized_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
waxed_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
waxed_exposed_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
waxed_weathered_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
waxed_oxidized_copper_grate => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
waterlogged: false,
},
copper_bulb => BlockBehavior::new().requires_correct_tool_for_drops().strength(3.0, 6.0), {
lit: false,
powered: false,
Expand Down
3 changes: 3 additions & 0 deletions azalea-chat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ version = "0.8.0"

[features]
default = ["azalea-buf"]
azalea-buf = ["dep:azalea-buf"]
numbers = ["dep:azalea-registry"]

[dependencies]
azalea-buf = { path = "../azalea-buf", features = [
Expand All @@ -21,3 +23,4 @@ log = "0.4.20"
once_cell = "1.18.0"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0.108"
azalea-registry = { path = "../azalea-registry", version = "0.8.0", optional = true }
2 changes: 2 additions & 0 deletions azalea-chat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

pub mod base_component;
mod component;
#[cfg(feature = "numbers")]
pub mod numbers;
pub mod style;
pub mod text_component;
pub mod translatable_component;
Expand Down
52 changes: 52 additions & 0 deletions azalea-chat/src/numbers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//! Contains a few ways to style numbers. At the time of writing, Minecraft only
//! uses this for rendering scoreboard objectives.
use std::io::{Cursor, Write};

#[cfg(feature = "azalea-buf")]
use azalea_buf::{McBufReadable, McBufWritable};
use azalea_nbt::Nbt;
use azalea_registry::NumberFormatKind;

use crate::FormattedText;

#[derive(Clone, Debug)]
pub enum NumberFormat {
Blank,
Styled { style: Nbt },
Fixed { value: FormattedText },
}

#[cfg(feature = "azalea-buf")]
impl McBufReadable for NumberFormat {
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<Self, azalea_buf::BufReadError> {
let kind = NumberFormatKind::read_from(buf)?;
match kind {
NumberFormatKind::Blank => Ok(NumberFormat::Blank),
NumberFormatKind::Styled => Ok(NumberFormat::Styled {
style: Nbt::read_from(buf)?,
}),
NumberFormatKind::Fixed => Ok(NumberFormat::Fixed {
value: FormattedText::read_from(buf)?,
}),
}
}
}

#[cfg(feature = "azalea-buf")]
impl McBufWritable for NumberFormat {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
match self {
NumberFormat::Blank => NumberFormatKind::Blank.write_into(buf)?,
NumberFormat::Styled { style } => {
NumberFormatKind::Styled.write_into(buf)?;
style.write_into(buf)?;
}
NumberFormat::Fixed { value } => {
NumberFormatKind::Fixed.write_into(buf)?;
value.write_into(buf)?;
}
}
Ok(())
}
}
10 changes: 8 additions & 2 deletions azalea-client/src/packet_handling/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub fn process_packet_events(ecs: &mut World) {
.write_packet(ServerboundPongPacket { id: p.id }.get())
.unwrap();
}
ClientboundConfigurationPacket::ResourcePack(p) => {
ClientboundConfigurationPacket::ResourcePackPush(p) => {
debug!("Got resource pack packet {p:?}");

let mut system_state: SystemState<Query<&RawConnection>> = SystemState::new(ecs);
Expand All @@ -188,9 +188,15 @@ pub fn process_packet_events(ecs: &mut World) {

// always accept resource pack
raw_connection.write_packet(
ServerboundResourcePackPacket { action: azalea_protocol::packets::configuration::serverbound_resource_pack_packet::Action::Accepted }.get()
ServerboundResourcePackPacket {
id: p.id,
action: azalea_protocol::packets::configuration::serverbound_resource_pack_packet::Action::Accepted
}.get()
).unwrap();
}
ClientboundConfigurationPacket::ResourcePackPop(_) => {
// we can ignore this
}
ClientboundConfigurationPacket::UpdateEnabledFeatures(p) => {
debug!("Got update enabled features packet {p:?}");
}
Expand Down
10 changes: 9 additions & 1 deletion azalea-client/src/packet_handling/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use azalea_world::{Instance, InstanceContainer, InstanceName, MinecraftEntityId,
use bevy_ecs::{prelude::*, system::SystemState};
use log::{debug, error, trace, warn};
use parking_lot::RwLock;
use uuid::Uuid;

use crate::{
chat::{ChatPacket, ChatReceivedEvent},
Expand Down Expand Up @@ -124,6 +125,9 @@ pub struct KeepAliveEvent {
#[derive(Event, Debug, Clone)]
pub struct ResourcePackEvent {
pub entity: Entity,
/// The random ID for this request to download the resource pack. The packet
/// for replying to a resource pack push must contain the same ID.
pub id: Uuid,
pub url: String,
pub hash: String,
pub required: bool,
Expand Down Expand Up @@ -1269,7 +1273,7 @@ pub fn process_packet_events(ecs: &mut World) {
}
ClientboundGamePacket::PlayerLookAt(_) => {}
ClientboundGamePacket::RemoveMobEffect(_) => {}
ClientboundGamePacket::ResourcePack(p) => {
ClientboundGamePacket::ResourcePackPush(p) => {
debug!("Got resource pack packet {p:?}");

let mut system_state: SystemState<EventWriter<ResourcePackEvent>> =
Expand All @@ -1278,6 +1282,7 @@ pub fn process_packet_events(ecs: &mut World) {

resource_pack_events.send(ResourcePackEvent {
entity: player_entity,
id: p.id,
url: p.url,
hash: p.hash,
required: p.required,
Expand All @@ -1286,6 +1291,7 @@ pub fn process_packet_events(ecs: &mut World) {

system_state.apply(ecs);
}
ClientboundGamePacket::ResourcePackPop(_) => {}
ClientboundGamePacket::Respawn(p) => {
debug!("Got respawn packet {p:?}");

Expand Down Expand Up @@ -1404,6 +1410,8 @@ pub fn process_packet_events(ecs: &mut World) {
ClientboundGamePacket::StartConfiguration(_) => {}
ClientboundGamePacket::TickingState(_) => {}
ClientboundGamePacket::TickingStep(_) => {}

ClientboundGamePacket::ResetScore(_) => {}
}
}
}
1 change: 1 addition & 0 deletions azalea-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod difficulty;
pub mod direction;
pub mod game_type;
pub mod math;
pub mod objectives;
pub mod particle;
pub mod position;
pub mod resource_location;
Expand Down
33 changes: 33 additions & 0 deletions azalea-core/src/objectives.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::{
fmt::{self, Display, Formatter},
str::FromStr,
};

use azalea_buf::McBuf;

#[derive(Clone, Copy, Debug, McBuf)]
pub enum ObjectiveCriteria {
Integer,
Hearts,
}

impl Display for ObjectiveCriteria {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
ObjectiveCriteria::Integer => write!(f, "integer"),
ObjectiveCriteria::Hearts => write!(f, "hearts"),
}
}
}

impl FromStr for ObjectiveCriteria {
type Err = ();

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"integer" => Ok(ObjectiveCriteria::Integer),
"hearts" => Ok(ObjectiveCriteria::Hearts),
_ => Err(()),
}
}
}
21 changes: 20 additions & 1 deletion azalea-language/src/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
"argument.rotation.incomplete": "Incomplete (expected 2 coordinates)",
"argument.scoreboardDisplaySlot.invalid": "Unknown display slot '%s'",
"argument.scoreHolder.empty": "No relevant score holders could be found",
"argument.style.invalid": "Invalid style: %s",
"argument.time.invalid_tick_count": "Tick count must be non-negative",
"argument.time.invalid_unit": "Invalid unit",
"argument.time.tick_count_too_low": "Tick count must not be less than %s, found %s",
Expand Down Expand Up @@ -1948,6 +1949,7 @@
"block.minecraft.sea_pickle": "Sea Pickle",
"block.minecraft.seagrass": "Seagrass",
"block.minecraft.set_spawn": "Respawn point set",
"block.minecraft.short_grass": "Short Grass",
"block.minecraft.shroomlight": "Shroomlight",
"block.minecraft.shulker_box": "Shulker Box",
"block.minecraft.skeleton_skull": "Skeleton Skull",
Expand Down Expand Up @@ -2478,6 +2480,7 @@
"commands.jfr.started": "JFR profiling started",
"commands.jfr.stopped": "JFR profiling stopped and dumped to %s",
"commands.kick.owner.failed": "Cannot kick server owner in LAN game",
"commands.kick.singleplayer.failed": "Cannot kick in an offline singleplayer game",
"commands.kick.success": "Kicked %s: %s",
"commands.kill.success.multiple": "Killed %s entities",
"commands.kill.success.single": "Killed %s",
Expand Down Expand Up @@ -2568,11 +2571,23 @@
"commands.scoreboard.objectives.display.set": "Set display slot %s to show objective %s",
"commands.scoreboard.objectives.list.empty": "There are no objectives",
"commands.scoreboard.objectives.list.success": "There are %s objective(s): %s",
"commands.scoreboard.objectives.modify.displayAutoUpdate.disable": "Disabled display auto-update for objective %s",
"commands.scoreboard.objectives.modify.displayAutoUpdate.enable": "Enabled display auto-update for objective %s",
"commands.scoreboard.objectives.modify.displayname": "Changed the display name of %s to %s",
"commands.scoreboard.objectives.modify.objectiveFormat.clear": "Cleared default number format of objective %s",
"commands.scoreboard.objectives.modify.objectiveFormat.set": "Changed default number format of objective %s",
"commands.scoreboard.objectives.modify.rendertype": "Changed the render type of objective %s",
"commands.scoreboard.objectives.remove.success": "Removed objective %s",
"commands.scoreboard.players.add.success.multiple": "Added %s to %s for %s entities",
"commands.scoreboard.players.add.success.single": "Added %s to %s for %s (now %s)",
"commands.scoreboard.players.display.name.clear.success.multiple": "Cleared display name for %s entities in %s",
"commands.scoreboard.players.display.name.clear.success.single": "Cleared display name for %s in %s",
"commands.scoreboard.players.display.name.set.success.multiple": "Changed display name to %s for %s entities in %s",
"commands.scoreboard.players.display.name.set.success.single": "Changed display name to %s for %s in %s",
"commands.scoreboard.players.display.numberFormat.clear.success.multiple": "Cleared number format for %s entities in %s",
"commands.scoreboard.players.display.numberFormat.clear.success.single": "Cleared number format for %s in %s",
"commands.scoreboard.players.display.numberFormat.set.success.multiple": "Changed number format for %s entities in %s",
"commands.scoreboard.players.display.numberFormat.set.success.single": "Changed number format for %s in %s",
"commands.scoreboard.players.enable.failed": "Nothing changed. That trigger is already enabled",
"commands.scoreboard.players.enable.invalid": "Enable only works on trigger-objectives",
"commands.scoreboard.players.enable.success.multiple": "Enabled trigger %s for %s entities",
Expand Down Expand Up @@ -3082,6 +3097,9 @@
"disconnect.spam": "Kicked for spamming",
"disconnect.timeout": "Timed out",
"disconnect.unknownHost": "Unknown host",
"download.pack.progress.bytes": "Progress: %s (total size unknown)",
"download.pack.progress.percent": "Progress: %s%%",
"download.pack.title": "Downloading resource pack %s/%s",
"editGamerule.default": "Default: %s",
"editGamerule.title": "Edit Game Rules",
"effect.duration.infinite": "\u221e",
Expand Down Expand Up @@ -4974,6 +4992,7 @@
"options.accessibility.high_contrast.tooltip": "Enhances the contrast of UI elements",
"options.accessibility.link": "Accessibility Guide",
"options.accessibility.narrator_hotkey": "Narrator Hotkey",
"options.accessibility.narrator_hotkey.mac.tooltip": "Allows the Narrator to be toggled on and off with 'Cmd+B'",
"options.accessibility.narrator_hotkey.tooltip": "Allows the Narrator to be toggled on and off with 'Ctrl+B'",
"options.accessibility.panorama_speed": "Panorama Scroll Speed",
"options.accessibility.text_background": "Text Background",
Expand Down Expand Up @@ -5914,7 +5933,7 @@
"subtitles.entity.generic.small_fall": "Something trips",
"subtitles.entity.generic.splash": "Splashing",
"subtitles.entity.generic.swim": "Swimming",
"subtitles.entity.generic.wind_burst": "Wind charge bursts",
"subtitles.entity.generic.wind_burst": "Wind Charge bursts",
"subtitles.entity.ghast.ambient": "Ghast cries",
"subtitles.entity.ghast.death": "Ghast dies",
"subtitles.entity.ghast.hurt": "Ghast hurts",
Expand Down
Loading

0 comments on commit 7ede805

Please sign in to comment.