Update to 1.9.0

This commit is contained in:
Thinkofname 2016-03-25 20:56:45 +00:00
parent 69139b2933
commit ba29de40ae
6 changed files with 94 additions and 58 deletions

View File

@ -33,7 +33,7 @@ use flate2::read::{ZlibDecoder, ZlibEncoder};
use flate2; use flate2;
use time; use time;
pub const SUPPORTED_PROTOCOL: i32 = 74; pub const SUPPORTED_PROTOCOL: i32 = 107;
/// Helper macro for defining packets /// Helper macro for defining packets

View File

@ -48,10 +48,16 @@ state_packets!(
} }
play Play { play Play {
serverbound Serverbound { serverbound Serverbound {
// TeleportConfirm is sent by the client as a reply to a telport from
// the server.
TeleportConfirm {
teleport_id: VarInt =,
}
// TabComplete is sent by the client when the client presses tab in // TabComplete is sent by the client when the client presses tab in
// the chat box. // the chat box.
TabComplete { TabComplete {
text: String =, text: String =,
assume_command: bool =,
has_target: bool =, has_target: bool =,
target: Option<types::Position> = when(|p: &TabComplete| p.has_target == true), target: Option<types::Position> = when(|p: &TabComplete| p.has_target == true),
} }
@ -68,7 +74,7 @@ state_packets!(
ClientSettings { ClientSettings {
locale: String =, locale: String =,
view_distance: u8 =, view_distance: u8 =,
chat_mode: u8 =, chat_mode: VarInt =,
chat_colors: bool =, chat_colors: bool =,
displayed_skin_parts: u8 =, displayed_skin_parts: u8 =,
main_hand: VarInt =, main_hand: VarInt =,
@ -90,7 +96,7 @@ state_packets!(
slot: i16 =, slot: i16 =,
button: u8 =, button: u8 =,
action_number: u16 =, action_number: u16 =,
mode: u8 =, mode: VarInt =,
clicked_item: Option<item::Stack> =, clicked_item: Option<item::Stack> =,
} }
// CloseWindow is sent when the client closes a window. // CloseWindow is sent when the client closes a window.
@ -147,6 +153,19 @@ state_packets!(
Player { Player {
on_ground: bool =, on_ground: bool =,
} }
// Sent by the client when in a vehicle instead of the normal move packet.
VehicleMove {
x: f64 =,
y: f64 =,
z: f64 =,
yaw: f32 =,
pitch: f32 =,
}
// TODO: Document
SteerBoat {
unknown: bool =,
unknown2: bool =,
}
// ClientAbilities is used to modify the players current abilities. // ClientAbilities is used to modify the players current abilities.
// Currently flying is the only one // Currently flying is the only one
ClientAbilities { ClientAbilities {
@ -157,7 +176,7 @@ state_packets!(
// PlayerDigging is sent when the client starts/stops digging a block. // PlayerDigging is sent when the client starts/stops digging a block.
// It also can be sent for droppping items and eating/shooting. // It also can be sent for droppping items and eating/shooting.
PlayerDigging { PlayerDigging {
status: u8 =, status: VarInt =,
location: types::Position =, location: types::Position =,
face: u8 =, face: u8 =,
} }
@ -229,9 +248,9 @@ state_packets!(
entity_id: VarInt =, entity_id: VarInt =,
uuid: UUID =, uuid: UUID =,
ty: u8 =, ty: u8 =,
x: i32 =, x: f64 =,
y: i32 =, y: f64 =,
z: i32 =, z: f64 =,
pitch: i8 =, pitch: i8 =,
yaw: i8 =, yaw: i8 =,
data: i32 =, data: i32 =,
@ -244,9 +263,9 @@ state_packets!(
// gained when collected. // gained when collected.
SpawnExperienceOrb { SpawnExperienceOrb {
entity_id: VarInt =, entity_id: VarInt =,
x: i32 =, x: f64 =,
y: i32 =, y: f64 =,
z: i32 =, z: f64 =,
count: i16 =, count: i16 =,
} }
// SpawnGlobalEntity spawns an entity which is visible from anywhere in the // SpawnGlobalEntity spawns an entity which is visible from anywhere in the
@ -254,9 +273,9 @@ state_packets!(
SpawnGlobalEntity { SpawnGlobalEntity {
entity_id: VarInt =, entity_id: VarInt =,
ty: u8 =, ty: u8 =,
x: i32 =, x: f64 =,
y: i32 =, y: f64 =,
z: i32 =, z: f64 =,
} }
// SpawnMob is used to spawn a living entity into the world when it is in // SpawnMob is used to spawn a living entity into the world when it is in
// range of the client. // range of the client.
@ -264,9 +283,9 @@ state_packets!(
entity_id: VarInt =, entity_id: VarInt =,
uuid: UUID =, uuid: UUID =,
ty: u8 =, ty: u8 =,
x: i32 =, x: f64 =,
y: i32 =, y: f64 =,
z: i32 =, z: f64 =,
yaw: i8 =, yaw: i8 =,
pitch: i8 =, pitch: i8 =,
head_pitch: i8 =, head_pitch: i8 =,
@ -279,6 +298,7 @@ state_packets!(
// the client. The title effects the size and the texture of the painting. // the client. The title effects the size and the texture of the painting.
SpawnPainting { SpawnPainting {
entity_id: VarInt =, entity_id: VarInt =,
uuid: UUID =,
title: String =, title: String =,
location: types::Position =, location: types::Position =,
direction: u8 =, direction: u8 =,
@ -289,9 +309,9 @@ state_packets!(
SpawnPlayer { SpawnPlayer {
entity_id: VarInt =, entity_id: VarInt =,
uuid: UUID =, uuid: UUID =,
x: i32 =, x: f64 =,
y: i32 =, y: f64 =,
z: i32 =, z: f64 =,
yaw: i8 =, yaw: i8 =,
pitch: i8 =, pitch: i8 =,
metadata: types::Metadata =, metadata: types::Metadata =,
@ -420,6 +440,16 @@ state_packets!(
channel: String =, channel: String =,
data: Vec<u8> =, data: Vec<u8> =,
} }
// Plays a sound by name on the client
NamedSoundEffect {
name: String =,
category: VarInt =,
x: i32 =,
y: i32 =,
z: i32 =,
volume: f32 =,
pitch: u8 =,
}
// Disconnect causes the client to disconnect displaying the passed reason. // Disconnect causes the client to disconnect displaying the passed reason.
Disconnect { Disconnect {
reason: format::Component =, reason: format::Component =,
@ -448,10 +478,6 @@ state_packets!(
x: i32 =, x: i32 =,
z: i32 =, z: i32 =,
} }
// SetCompression updates the compression threshold.
SetCompression {
threshold: VarInt =,
}
// ChangeGameState is used to modify the game's state like gamemode or // ChangeGameState is used to modify the game's state like gamemode or
// weather. // weather.
ChangeGameState { ChangeGameState {
@ -499,15 +525,6 @@ state_packets!(
data1: VarInt = when(|p: &Particle| p.particle_id == 36 || p.particle_id == 37 || p.particle_id == 38), data1: VarInt = when(|p: &Particle| p.particle_id == 36 || p.particle_id == 37 || p.particle_id == 38),
data2: VarInt = when(|p: &Particle| p.particle_id == 36), data2: VarInt = when(|p: &Particle| p.particle_id == 36),
} }
// SoundEffect plays the named sound at the target location.
SoundEffect {
name: String =,
x: i32 =,
y: i32 =,
z: i32 =,
volume: f32 =,
pitch: u8 =,
}
// JoinGame is sent after completing the login process. This // JoinGame is sent after completing the login process. This
// sets the initial state for the client. // sets the initial state for the client.
JoinGame { JoinGame {
@ -542,17 +559,17 @@ state_packets!(
// EntityMove moves the entity with the id by the offsets provided. // EntityMove moves the entity with the id by the offsets provided.
EntityMove { EntityMove {
entity_id: VarInt =, entity_id: VarInt =,
delta_x: i8 =, delta_x: i16 =,
delta_y: i8 =, delta_y: i16 =,
delta_z: i8 =, delta_z: i16 =,
on_ground: bool =, on_ground: bool =,
} }
// EntityLookAndMove is a combination of EntityMove and EntityLook. // EntityLookAndMove is a combination of EntityMove and EntityLook.
EntityLookAndMove { EntityLookAndMove {
entity_id: VarInt =, entity_id: VarInt =,
delta_x: i8 =, delta_x: i16 =,
delta_y: i8 =, delta_y: i16 =,
delta_z: i8 =, delta_z: i16 =,
yaw: i8 =, yaw: i8 =,
pitch: i8 =, pitch: i8 =,
on_ground: bool =, on_ground: bool =,
@ -568,6 +585,14 @@ state_packets!(
Entity { Entity {
entity_id: VarInt =, entity_id: VarInt =,
} }
// Teleports the player's vehicle
VehicleTeleport {
x: f64 =,
y: f64 =,
z: f64 =,
yaw: f32 =,
pitch: f32 =,
}
// SignEditorOpen causes the client to open the editor for a sign so that // SignEditorOpen causes the client to open the editor for a sign so that
// it can write to it. Only sent in vanilla when the player places a sign. // it can write to it. Only sent in vanilla when the player places a sign.
SignEditorOpen { SignEditorOpen {
@ -604,6 +629,7 @@ state_packets!(
yaw: f32 =, yaw: f32 =,
pitch: f32 =, pitch: f32 =,
flags: u8 =, flags: u8 =,
teleport_id: VarInt =,
} }
// EntityUsedBed is sent by the server when a player goes to bed. // EntityUsedBed is sent by the server when a player goes to bed.
EntityUsedBed { EntityUsedBed {
@ -674,7 +700,6 @@ state_packets!(
EntityAttach { EntityAttach {
entity_id: i32 =, entity_id: i32 =,
vehicle: i32 =, vehicle: i32 =,
leash: bool =,
} }
// EntityVelocity sets the velocity of an entity in 1/8000 of a block // EntityVelocity sets the velocity of an entity in 1/8000 of a block
// per a tick. // per a tick.
@ -711,6 +736,11 @@ state_packets!(
value: String = when(|p: &ScoreboardObjective| p.mode == 0 || p.mode == 2), value: String = when(|p: &ScoreboardObjective| p.mode == 0 || p.mode == 2),
ty: String = when(|p: &ScoreboardObjective| p.mode == 0 || p.mode == 2), ty: String = when(|p: &ScoreboardObjective| p.mode == 0 || p.mode == 2),
} }
// SetPassengers mounts entities to an entity
SetPassengers {
entity_id: VarInt =,
passengers: LenPrefixed<VarInt, VarInt> =,
}
// Teams creates and updates teams // Teams creates and updates teams
Teams { Teams {
name: String =, name: String =,
@ -740,7 +770,7 @@ state_packets!(
// TimeUpdate is sent to sync the world's time to the client, the client // TimeUpdate is sent to sync the world's time to the client, the client
// will manually tick the time itself so this doesn't need to sent repeatedly // will manually tick the time itself so this doesn't need to sent repeatedly
// but if the server or client has issues keeping up this can fall out of sync // but if the server or client has issues keeping up this can fall out of sync
// so it is a good idea to sent this now and again // so it is a good idea to send this now and again
TimeUpdate { TimeUpdate {
world_age: i64 =, world_age: i64 =,
time_of_day: i64 =, time_of_day: i64 =,
@ -750,9 +780,9 @@ state_packets!(
action: VarInt =, action: VarInt =,
title: Option<format::Component> = when(|p: &Title| p.action.0 == 0), title: Option<format::Component> = when(|p: &Title| p.action.0 == 0),
sub_title: Option<format::Component> = when(|p: &Title| p.action.0 == 1), sub_title: Option<format::Component> = when(|p: &Title| p.action.0 == 1),
fade_in: Option<format::Component> = when(|p: &Title| p.action.0 == 2), fade_in: Option<i32> = when(|p: &Title| p.action.0 == 2),
fade_stay: Option<format::Component> = when(|p: &Title| p.action.0 == 2), fade_stay: Option<i32> = when(|p: &Title| p.action.0 == 2),
fade_out: Option<format::Component> = when(|p: &Title| p.action.0 == 2), fade_out: Option<i32> = when(|p: &Title| p.action.0 == 2),
} }
// UpdateSign sets or changes the text on a sign. // UpdateSign sets or changes the text on a sign.
UpdateSign { UpdateSign {
@ -762,6 +792,16 @@ state_packets!(
line3: format::Component =, line3: format::Component =,
line4: format::Component =, line4: format::Component =,
} }
// SoundEffect plays the named sound at the target location.
SoundEffect {
name: VarInt =,
category: VarInt =,
x: i32 =,
y: i32 =,
z: i32 =,
volume: f32 =,
pitch: u8 =,
}
// PlayerListHeaderFooter updates the header/footer of the player list. // PlayerListHeaderFooter updates the header/footer of the player list.
PlayerListHeaderFooter { PlayerListHeaderFooter {
header: format::Component =, header: format::Component =,
@ -777,9 +817,9 @@ state_packets!(
// sent if the entity moves further than EntityMove allows. // sent if the entity moves further than EntityMove allows.
EntityTeleport { EntityTeleport {
entity_id: VarInt =, entity_id: VarInt =,
x: i32 =, x: f64 =,
y: i32 =, y: f64 =,
z: i32 =, z: f64 =,
yaw: i8 =, yaw: i8 =,
pitch: i8 =, pitch: i8 =,
on_ground: bool =, on_ground: bool =,

View File

@ -23,7 +23,7 @@ use std::io;
use std::fs; use std::fs;
use std::sync::mpsc; use std::sync::mpsc;
const RESOURCES_VERSION: &'static str = "15w39c"; const RESOURCES_VERSION: &'static str = "1.9";
pub trait Pack: Sync + Send { pub trait Pack: Sync + Send {
fn open(&self, name: &str) -> Option<Box<io::Read>>; fn open(&self, name: &str) -> Option<Box<io::Read>>;

View File

@ -392,13 +392,8 @@ impl Server {
self.yaw = teleport.yaw as f64; self.yaw = teleport.yaw as f64;
self.pitch = teleport.pitch as f64; self.pitch = teleport.pitch as f64;
self.write_packet(packet::play::serverbound::PlayerPositionLook { self.write_packet(packet::play::serverbound::TeleportConfirm {
x: teleport.x, teleport_id: teleport.teleport_id,
y: teleport.y,
z: teleport.z,
yaw: teleport.yaw,
pitch: teleport.pitch,
on_ground: false,
}); });
} }

View File

@ -29,8 +29,7 @@ pub struct MetadataKey<T: MetaValue> {
impl <T: MetaValue> MetadataKey<T> { impl <T: MetaValue> MetadataKey<T> {
#[allow(dead_code)] #[allow(dead_code)]
// TODO: Make const later when possible const fn new(index: i32) -> MetadataKey<T> {
/*const*/ fn new(index: i32) -> MetadataKey<T> {
MetadataKey { MetadataKey {
index: index, index: index,
ty: PhantomData, ty: PhantomData,

View File

@ -309,14 +309,16 @@ impl World {
let section = chunk.sections[i as usize].as_mut().unwrap(); let section = chunk.sections[i as usize].as_mut().unwrap();
section.dirty = true; section.dirty = true;
let bit_size = try!(data.read_u8()); let mut bit_size = try!(data.read_u8());
let mut block_map = HashMap::with_hasher(BuildHasherDefault::<FNVHash>::default()); let mut block_map = HashMap::with_hasher(BuildHasherDefault::<FNVHash>::default());
if bit_size <= 8 { if bit_size != 0 {
let count = try!(VarInt::read_from(&mut data)).0; let count = try!(VarInt::read_from(&mut data)).0;
for i in 0 .. count { for i in 0 .. count {
let id = try!(VarInt::read_from(&mut data)).0; let id = try!(VarInt::read_from(&mut data)).0;
block_map.insert(i as usize, id); block_map.insert(i as usize, id);
} }
} else {
bit_size = 13;
} }
let bits = try!(LenPrefixed::<VarInt, u64>::read_from(&mut data)).data; let bits = try!(LenPrefixed::<VarInt, u64>::read_from(&mut data)).data;