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