summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-02-03 18:10:32 +0100
committernea <nea@nea.moe>2023-02-03 18:10:32 +0100
commitb41a8c812d72fa2755adc4317e3d033e4e5cbef3 (patch)
treee77dd4c54b76a3f581c82c8a4727788e90d262d9 /src
parent3db6a5be375be599dde20c8fc9649090bac85b1e (diff)
downloadmgasi-b41a8c812d72fa2755adc4317e3d033e4e5cbef3.tar.gz
mgasi-b41a8c812d72fa2755adc4317e3d033e4e5cbef3.tar.bz2
mgasi-b41a8c812d72fa2755adc4317e3d033e4e5cbef3.zip
biome codex
Diffstat (limited to 'src')
-rw-r--r--src/main.rs156
1 files changed, 104 insertions, 52 deletions
diff --git a/src/main.rs b/src/main.rs
index b7f1203..80dea19 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -56,8 +56,10 @@ impl MinecraftClient {
macro_rules! await_packet {
($packet_type:ident, $conn:expr) => {
- assert_packet!($packet_type,
- $conn.wait_for_packet(Packet761Kind::$packet_type).await?)
+ assert_packet!(
+ $packet_type,
+ $conn.wait_for_packet(Packet761Kind::$packet_type).await?
+ )
};
}
@@ -70,10 +72,13 @@ macro_rules! assert_packet {
}
};
($packet_type:ident, $conn:expr, $errmgs:literal) => {
- assert_packet!($packet_type,
- $conn.read_next_packet()
- .await?
- .ok_or(anyhow::anyhow!("Missing packet"))?)
+ assert_packet!(
+ $packet_type,
+ $conn
+ .read_next_packet()
+ .await?
+ .ok_or(anyhow::anyhow!("Missing packet"))?
+ )
};
}
@@ -117,8 +122,20 @@ impl ShittyToNbt for Tag {
}
}
+impl ShittyToNbt for f32 {
+ fn to_nbt(self) -> Tag {
+ Tag::Float(self)
+ }
+}
+
+impl ShittyToNbt for f64 {
+ fn to_nbt(self) -> Tag {
+ Tag::Double(self)
+ }
+}
+
macro_rules! nbt {
- { {$($name:literal :: $value:tt),* $(,)? } } => {
+ ( {$($name:literal :: $value:tt),* $(,)? } ) => {
Tag::Compound(vec![
$(
nbt!($value).with_name($name)
@@ -164,52 +181,85 @@ async fn handle_conn(mut client: MinecraftClient) -> Result<()> {
let hs = assert_packet!(Handshake, client, "Missing packet");
if hs.next_state == HandshakeNextState::Login {
client.connection.set_state(State::Login);
- let loginstart = assert_packet!(LoginStart,
- client.read_next_packet()
- .await?
- .ok_or(anyhow::anyhow!("Missing packet"))?);
+ let loginstart = assert_packet!(
+ LoginStart,
+ client
+ .read_next_packet()
+ .await?
+ .ok_or(anyhow::anyhow!("Missing packet"))?
+ );
println!("Login: {:?}", loginstart);
let uuid = UUID4::random();
- client.send_packet(Packet761::LoginSuccess(LoginSuccessSpec { uuid,
- username:
- loginstart.name,
- properties:
- vec![].into() }))
- .await?;
- let registry_doex = nbt! {
- "minecraft:dimension_type" :: {
- "type" :: ("minecraft:dimension_type"),
- "value" :: [{
+ client
+ .send_packet(Packet761::LoginSuccess(LoginSuccessSpec {
+ uuid,
+ username: loginstart.name,
+ properties: vec![].into(),
+ }))
+ .await?;
+ let overworld_spec = nbt! {
+ "id" :: (0),
+ "name" :: ("minecraft:overworld"),
+ "element" :: {
+ "ambient_light" :: (false),
+ "bed_works" :: (true),
+ "coordinate_scale" :: (1),
+ "effects" :: ("minecraft:overworld"),
+ "has_ceiling" :: (false),
+ "has_skylight" :: (true),
+ "has_raids" :: (false),
+ "height" :: (384),
+ "infiniburn" :: ("#minecraft:infiniburn_overworld"),
+ "logical_height" :: (384),
+ "min_y" :: (-64),
+ "monster_spawn_block_light_limit" :: (0),
+ "monster_spawn_light_level" :: {
+ "type" :: ("minecraft:uniform"),
+ "value" :: {
+ "max_inclusive" :: (7),
+ "min_inclusive" :: (0),
+ },
+ },
+ "natural" :: (true),
+ "piglin_safe" :: (false),
+ "respawn_anchor_works" :: (false),
+ "ultrawarm" :: (false),
+ },
+ };
+ let biome_spec = nbt!(
+ [
+ {
"id" :: (0),
- "name" :: ("minecraft:overworld"),
+ "name" :: ("minecraft:plains"),
"element" :: {
- "ambient_light" :: (false),
- "bed_works" :: (true),
- "coordinate_scale" :: (1),
- "effects" :: ("minecraft:overworld"),
- "has_ceiling" :: (false),
- "has_skylight" :: (true),
- "has_raids" :: (false),
- "height" :: (384),
- "infiniburn" :: ("#minecraft:infiniburn_overworld"),
- "logical_height" :: (384),
- "min_y" :: (-64),
- "monster_spawn_block_light_limit" :: (0),
- "monster_spawn_light_level" :: {
- "type" :: ("minecraft:uniform"),
- "value" :: {
- "max_inclusive" :: (7),
- "min_inclusive" :: (0),
+ "downfall" :: (0.5),
+ "precipitation" :: ("none"),
+ "temperature" :: (0.5),
+ "effects" :: {
+ "fog_color" :: (12638463),
+ "sky_color" :: (12638463),
+ "water_color" :: (12638463),
+ "water_fog_color" :: (12638463),
+ "mood_sound" :: {
+ "block_search_extent" :: (8),
+ "offset" :: (2),
+ "sound" :: ("minecraft:ambient.cave"),
+ "tick_delay" :: (6000),
},
- },
- "natural" :: (true),
- "piglin_safe" :: (false),
- "respawn_anchor_works" :: (false),
- "ultrawarm" :: (false),
-
- },
- }]
+ }
+ }
+ }
+ ]
+ );
+ let registry_doex = nbt! {
+ "minecraft:dimension_type" :: {
+ "type" :: ("minecraft:dimension_type"),
+ "value" :: [(overworld_spec)]
},
+ "minecraft:worldgen/biome" :: {
+ "type" :: ("minecraft:worldgen/biome"),
+ "value" :: (biome_spec),
+ }
};
client.connection.set_state(State::Play);
client
@@ -248,9 +298,10 @@ async fn handle_conn(mut client: MinecraftClient) -> Result<()> {
async fn handle_status(mut client: MinecraftClient) -> Result<()> {
client.connection.set_state(State::Status);
loop {
- match client.read_next_packet()
- .await?
- .ok_or(anyhow::anyhow!("Missing packet"))?
+ match client
+ .read_next_packet()
+ .await?
+ .ok_or(anyhow::anyhow!("Missing packet"))?
{
Packet761::StatusRequest(_) => {
client
@@ -272,8 +323,9 @@ async fn handle_status(mut client: MinecraftClient) -> Result<()> {
.await?;
}
Packet761::PingRequest(PingRequestSpec { payload }) => {
- client.send_packet(Packet761::PingResponse(PingResponseSpec { payload }))
- .await?;
+ client
+ .send_packet(Packet761::PingResponse(PingResponseSpec { payload }))
+ .await?;
return Ok(());
}
_ => anyhow::bail!("Unexpected packet during status communication"),