Remove some ToPrimitive
This commit is contained in:
parent
93c6da993f
commit
17f1984699
@ -1,12 +1,13 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::FromPrimitive;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct ParseGameModeError;
|
pub struct ParseGameModeError;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, FromPrimitive, ToPrimitive)]
|
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, FromPrimitive)]
|
||||||
|
#[repr(i8)]
|
||||||
pub enum GameMode {
|
pub enum GameMode {
|
||||||
Undefined = -1,
|
Undefined = -1,
|
||||||
Survival,
|
Survival,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::container_click::MouseClick;
|
use crate::container_click::MouseClick;
|
||||||
use crate::player::PlayerInventory;
|
use crate::player::PlayerInventory;
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::FromPrimitive;
|
||||||
use pumpkin_macros::screen;
|
use pumpkin_macros::screen;
|
||||||
use pumpkin_world::item::ItemStack;
|
use pumpkin_world::item::ItemStack;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ pub use error::InventoryError;
|
|||||||
pub use open_container::OpenContainer;
|
pub use open_container::OpenContainer;
|
||||||
|
|
||||||
/// https://wiki.vg/Inventory
|
/// https://wiki.vg/Inventory
|
||||||
#[derive(Debug, ToPrimitive, FromPrimitive, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, FromPrimitive, Clone, Copy, Eq, PartialEq)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum WindowType {
|
pub enum WindowType {
|
||||||
// not used
|
// not used
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use num_traits::{FromPrimitive, ToPrimitive};
|
use num_traits::FromPrimitive;
|
||||||
use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG};
|
use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG};
|
||||||
use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
@ -81,13 +81,11 @@ impl Client {
|
|||||||
// Don't allow new logons when server is full.
|
// Don't allow new logons when server is full.
|
||||||
// If max players is set to zero, then there is no max player count enforced.
|
// If max players is set to zero, then there is no max player count enforced.
|
||||||
// TODO: If client is an operator or otherwise suitable elevated permissions, allow client to bypass this requirement.
|
// TODO: If client is an operator or otherwise suitable elevated permissions, allow client to bypass this requirement.
|
||||||
let max_players = BASIC_CONFIG
|
let max_players = BASIC_CONFIG.max_players;
|
||||||
.max_players
|
if max_players > 0 && server.get_player_count().await >= max_players as usize {
|
||||||
.to_usize()
|
|
||||||
.expect("Unable to convert to usize");
|
|
||||||
if max_players > 0 && server.get_player_count().await >= max_players {
|
|
||||||
self.kick("The server is currently full, please try again later")
|
self.kick("The server is currently full, please try again later")
|
||||||
.await;
|
.await;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !Self::is_valid_player_name(&login_start.name) {
|
if !Self::is_valid_player_name(&login_start.name) {
|
||||||
|
|||||||
@ -10,7 +10,6 @@ use std::{
|
|||||||
use crossbeam::atomic::AtomicCell;
|
use crossbeam::atomic::AtomicCell;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use num_traits::ToPrimitive;
|
|
||||||
use pumpkin_config::ADVANCED_CONFIG;
|
use pumpkin_config::ADVANCED_CONFIG;
|
||||||
use pumpkin_core::{
|
use pumpkin_core::{
|
||||||
math::{boundingbox::BoundingBox, position::WorldPosition, vector2::Vector2, vector3::Vector3},
|
math::{boundingbox::BoundingBox, position::WorldPosition, vector2::Vector2, vector3::Vector3},
|
||||||
@ -591,10 +590,11 @@ impl Player {
|
|||||||
}],
|
}],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
#[allow(clippy::cast_precision_loss)]
|
||||||
self.client
|
self.client
|
||||||
.send_packet(&CGameEvent::new(
|
.send_packet(&CGameEvent::new(
|
||||||
GameEvent::ChangeGameMode,
|
GameEvent::ChangeGameMode,
|
||||||
gamemode.to_f32().unwrap(),
|
gamemode as i32 as f32,
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@ use crate::entity::{
|
|||||||
player::{ChunkHandleWrapper, Player},
|
player::{ChunkHandleWrapper, Player},
|
||||||
Entity,
|
Entity,
|
||||||
};
|
};
|
||||||
use num_traits::ToPrimitive;
|
|
||||||
use pumpkin_config::BasicConfiguration;
|
use pumpkin_config::BasicConfiguration;
|
||||||
use pumpkin_core::math::vector2::Vector2;
|
use pumpkin_core::math::vector2::Vector2;
|
||||||
use pumpkin_core::math::{position::WorldPosition, vector3::Vector3};
|
use pumpkin_core::math::{position::WorldPosition, vector3::Vector3};
|
||||||
@ -162,8 +161,8 @@ impl World {
|
|||||||
0.into(),
|
0.into(),
|
||||||
"minecraft:overworld",
|
"minecraft:overworld",
|
||||||
0, // seed
|
0, // seed
|
||||||
gamemode.to_u8().unwrap(),
|
gamemode as u8,
|
||||||
base_config.default_gamemode.to_i8().unwrap(),
|
base_config.default_gamemode as i8,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user