mirror of
https://github.com/italicsjenga/valence.git
synced 2025-01-11 07:11:30 +11:00
Use Rust 1.62.0 features
This commit is contained in:
parent
560163fd2e
commit
6ef634ca2c
|
@ -18,7 +18,6 @@ base64 = "0.13"
|
||||||
bitfield-struct = "0.1"
|
bitfield-struct = "0.1"
|
||||||
bitvec = "1"
|
bitvec = "1"
|
||||||
byteorder = "1"
|
byteorder = "1"
|
||||||
bytes = "1"
|
|
||||||
cfb8 = "0.7"
|
cfb8 = "0.7"
|
||||||
flate2 = "1"
|
flate2 = "1"
|
||||||
flume = "0.10"
|
flume = "0.10"
|
||||||
|
@ -26,8 +25,6 @@ futures = "0.3"
|
||||||
hematite-nbt = "0.5"
|
hematite-nbt = "0.5"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
num = "0.4"
|
num = "0.4"
|
||||||
ordered-float = "3.0.0"
|
|
||||||
parking_lot = "0.12"
|
|
||||||
paste = "1"
|
paste = "1"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
rayon = "1"
|
rayon = "1"
|
||||||
|
|
|
@ -61,19 +61,14 @@ impl Default for Biome {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Default, Debug)]
|
||||||
pub enum BiomePrecipitation {
|
pub enum BiomePrecipitation {
|
||||||
|
#[default]
|
||||||
Rain,
|
Rain,
|
||||||
Snow,
|
Snow,
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BiomePrecipitation {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Rain
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Minecraft handles grass colors for swamps and dark oak forests in a special
|
/// Minecraft handles grass colors for swamps and dark oak forests in a special
|
||||||
/// way.
|
/// way.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||||
|
|
|
@ -79,10 +79,11 @@ impl Encode for VillagerData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
pub enum VillagerType {
|
pub enum VillagerType {
|
||||||
Desert,
|
Desert,
|
||||||
Jungle,
|
Jungle,
|
||||||
|
#[default]
|
||||||
Plains,
|
Plains,
|
||||||
Savanna,
|
Savanna,
|
||||||
Snow,
|
Snow,
|
||||||
|
@ -90,14 +91,9 @@ pub enum VillagerType {
|
||||||
Taiga,
|
Taiga,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VillagerType {
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
fn default() -> Self {
|
|
||||||
Self::Plains
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub enum VillagerProfession {
|
pub enum VillagerProfession {
|
||||||
|
#[default]
|
||||||
None,
|
None,
|
||||||
Armorer,
|
Armorer,
|
||||||
Butcher,
|
Butcher,
|
||||||
|
@ -115,14 +111,9 @@ pub enum VillagerProfession {
|
||||||
Weaponsmith,
|
Weaponsmith,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for VillagerProfession {
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
fn default() -> Self {
|
|
||||||
Self::None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
|
||||||
pub enum Pose {
|
pub enum Pose {
|
||||||
|
#[default]
|
||||||
Standing,
|
Standing,
|
||||||
FallFlying,
|
FallFlying,
|
||||||
Sleeping,
|
Sleeping,
|
||||||
|
@ -139,12 +130,6 @@ pub enum Pose {
|
||||||
Digging,
|
Digging,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Pose {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Standing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Encode for Pose {
|
impl Encode for Pose {
|
||||||
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
||||||
VarInt(*self as i32).encode(w)
|
VarInt(*self as i32).encode(w)
|
||||||
|
@ -152,26 +137,22 @@ impl Encode for Pose {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The main hand of a player.
|
/// The main hand of a player.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
pub enum MainHand {
|
pub enum MainHand {
|
||||||
Left,
|
Left,
|
||||||
|
#[default]
|
||||||
Right,
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MainHand {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Right
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Encode for MainHand {
|
impl Encode for MainHand {
|
||||||
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
||||||
(*self as u8).encode(w)
|
(*self as u8).encode(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
pub enum BoatVariant {
|
pub enum BoatVariant {
|
||||||
|
#[default]
|
||||||
Oak,
|
Oak,
|
||||||
Spruce,
|
Spruce,
|
||||||
Birch,
|
Birch,
|
||||||
|
@ -180,21 +161,16 @@ pub enum BoatVariant {
|
||||||
DarkOak,
|
DarkOak,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BoatVariant {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::Oak
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Encode for BoatVariant {
|
impl Encode for BoatVariant {
|
||||||
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
||||||
VarInt(*self as i32).encode(w)
|
VarInt(*self as i32).encode(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
pub enum CatVariant {
|
pub enum CatVariant {
|
||||||
Tabby,
|
Tabby,
|
||||||
|
#[default]
|
||||||
Black,
|
Black,
|
||||||
Red,
|
Red,
|
||||||
Siamese,
|
Siamese,
|
||||||
|
@ -207,48 +183,32 @@ pub enum CatVariant {
|
||||||
AllBlack,
|
AllBlack,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for CatVariant {
|
|
||||||
fn default() -> Self {
|
|
||||||
CatVariant::Black
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Encode for CatVariant {
|
impl Encode for CatVariant {
|
||||||
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
||||||
VarInt(*self as i32).encode(w)
|
VarInt(*self as i32).encode(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
pub enum FrogVariant {
|
pub enum FrogVariant {
|
||||||
|
#[default]
|
||||||
Temperate,
|
Temperate,
|
||||||
Warm,
|
Warm,
|
||||||
Cold,
|
Cold,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FrogVariant {
|
|
||||||
fn default() -> Self {
|
|
||||||
FrogVariant::Temperate
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Encode for FrogVariant {
|
impl Encode for FrogVariant {
|
||||||
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
||||||
VarInt(*self as i32).encode(w)
|
VarInt(*self as i32).encode(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug)]
|
||||||
pub enum PaintingVariant {
|
pub enum PaintingVariant {
|
||||||
|
#[default]
|
||||||
Default, // TODO
|
Default, // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PaintingVariant {
|
|
||||||
fn default() -> Self {
|
|
||||||
PaintingVariant::Default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Encode for PaintingVariant {
|
impl Encode for PaintingVariant {
|
||||||
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
fn encode(&self, w: &mut impl Write) -> anyhow::Result<()> {
|
||||||
VarInt(*self as i32).encode(w)
|
VarInt(*self as i32).encode(w)
|
||||||
|
|
|
@ -944,8 +944,9 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
|
||||||
GameMode: u8 {
|
GameMode: u8 {
|
||||||
|
#[default]
|
||||||
Survival = 0,
|
Survival = 0,
|
||||||
Creative = 1,
|
Creative = 1,
|
||||||
Adventure = 2,
|
Adventure = 2,
|
||||||
|
@ -953,12 +954,6 @@ pub mod play {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GameMode {
|
|
||||||
fn default() -> Self {
|
|
||||||
GameMode::Survival
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_struct! {
|
def_struct! {
|
||||||
EntityPosition 0x26 {
|
EntityPosition 0x26 {
|
||||||
entity_id: VarInt,
|
entity_id: VarInt,
|
||||||
|
@ -996,8 +991,9 @@ pub mod play {
|
||||||
}
|
}
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
#[derive(Copy, PartialEq, Eq)]
|
#[derive(Copy, PartialEq, Eq, Default)]
|
||||||
ChatMessageType: VarInt {
|
ChatMessageType: VarInt {
|
||||||
|
#[default]
|
||||||
Chat = 0,
|
Chat = 0,
|
||||||
SystemMessage = 1,
|
SystemMessage = 1,
|
||||||
GameInfo = 2,
|
GameInfo = 2,
|
||||||
|
@ -1009,12 +1005,6 @@ pub mod play {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ChatMessageType {
|
|
||||||
fn default() -> Self {
|
|
||||||
ChatMessageType::Chat
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def_enum! {
|
def_enum! {
|
||||||
PlayerInfo 0x34: VarInt {
|
PlayerInfo 0x34: VarInt {
|
||||||
AddPlayer: Vec<PlayerInfoAddPlayer> = 0,
|
AddPlayer: Vec<PlayerInfoAddPlayer> = 0,
|
||||||
|
|
|
@ -3,14 +3,13 @@ use std::error::Error;
|
||||||
use std::iter::FusedIterator;
|
use std::iter::FusedIterator;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::atomic::{AtomicI64, Ordering};
|
use std::sync::atomic::{AtomicI64, Ordering};
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use anyhow::{bail, ensure, Context};
|
use anyhow::{bail, ensure, Context};
|
||||||
use flume::{Receiver, Sender};
|
use flume::{Receiver, Sender};
|
||||||
use num::BigInt;
|
use num::BigInt;
|
||||||
use parking_lot::Mutex;
|
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use rayon::iter::ParallelIterator;
|
use rayon::iter::ParallelIterator;
|
||||||
use reqwest::Client as HttpClient;
|
use reqwest::Client as HttpClient;
|
||||||
|
@ -199,7 +198,7 @@ impl Server {
|
||||||
E: Into<Box<dyn Error + Send + Sync + 'static>>,
|
E: Into<Box<dyn Error + Send + Sync + 'static>>,
|
||||||
{
|
{
|
||||||
self.0.connection_sema.close();
|
self.0.connection_sema.close();
|
||||||
*self.0.shutdown_result.lock() = Some(res.into().map_err(|e| e.into()));
|
*self.0.shutdown_result.lock().unwrap() = Some(res.into().map_err(|e| e.into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +350,7 @@ fn do_update_loop(server: Server, worlds: &mut Worlds) -> ShutdownResult {
|
||||||
let mut tick_start = Instant::now();
|
let mut tick_start = Instant::now();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(res) = server.0.shutdown_result.lock().take() {
|
if let Some(res) = server.0.shutdown_result.lock().unwrap().take() {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue