Fix: all clippy warns
This commit is contained in:
parent
a6d9ed216d
commit
de7b3aa2ea
@ -1,5 +1,6 @@
|
||||
use pumpkin_world::item::Item;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct PlayerInventory {
|
||||
// Main Inventory + Hotbar
|
||||
items: [Option<Item>; 36],
|
||||
@ -26,7 +27,7 @@ impl PlayerInventory {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_slot(slot: u32, item: Item) {}
|
||||
pub fn set_slot(_slot: u32, _item: Item) {}
|
||||
|
||||
pub fn set_selected(&mut self, slot: i16) {
|
||||
assert!((0..9).contains(&slot));
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
use pumpkin_macros::packet;
|
||||
use serde::Serialize;
|
||||
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[packet(0x01)]
|
||||
pub struct CPluginMessage<'a> {
|
||||
|
||||
@ -32,7 +32,7 @@ impl<'a> ClientPacket for CChunkData<'a> {
|
||||
data_buf.put_i16(block_count);
|
||||
//// Block states
|
||||
|
||||
let palette = chunk.into_iter().dedup().collect_vec();
|
||||
let palette = chunk.iter().dedup().collect_vec();
|
||||
// TODO: make dynamic block_size work
|
||||
// TODO: make direct block_size work
|
||||
enum PaletteType {
|
||||
@ -63,7 +63,7 @@ impl<'a> ClientPacket for CChunkData<'a> {
|
||||
palette.iter().enumerate().for_each(|(i, id)| {
|
||||
palette_map.insert(*id, i);
|
||||
// Palette
|
||||
data_buf.put_var_int(&VarInt(**id as i32));
|
||||
data_buf.put_var_int(&VarInt(**id));
|
||||
});
|
||||
for block_clump in chunk.chunks(64 / block_size as usize) {
|
||||
let mut out_long: i64 = 0;
|
||||
@ -109,7 +109,7 @@ impl<'a> ClientPacket for CChunkData<'a> {
|
||||
// Size
|
||||
buf.put_var_int(&VarInt(data_buf.buf().len() as i32));
|
||||
// Data
|
||||
buf.put_slice(&data_buf.buf());
|
||||
buf.put_slice(data_buf.buf());
|
||||
|
||||
// TODO: block entities
|
||||
buf.put_var_int(&VarInt(0));
|
||||
|
||||
@ -21,6 +21,7 @@ pub struct CParticle<'a> {
|
||||
}
|
||||
|
||||
impl<'a> CParticle<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
long_distance: bool,
|
||||
x: f64,
|
||||
|
||||
@ -83,10 +83,10 @@ impl PacketEncoder {
|
||||
self.buf
|
||||
.copy_within(start_len..start_len + data_len, start_len + data_prefix_len);
|
||||
|
||||
let mut front = &mut self.buf[start_len..];
|
||||
let front = &mut self.buf[start_len..];
|
||||
|
||||
VarInt(packet_len as i32)
|
||||
.encode(&mut front)
|
||||
.encode(front.as_mut())
|
||||
.map_err(|_| PacketError::EncodeLength)?;
|
||||
// Zero for no compression on this packet.
|
||||
VarInt(0)
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
use pumpkin_macros::packet;
|
||||
@ -21,7 +20,7 @@ impl ServerPacket for SInteract {
|
||||
) -> Result<Self, crate::bytebuf::DeserializerError> {
|
||||
let entity_id = bytebuf.get_var_int();
|
||||
let typ = bytebuf.get_var_int();
|
||||
let action = ActionType::from_i32(typ.0 as i32).unwrap();
|
||||
let action = ActionType::from_i32(typ.0).unwrap();
|
||||
let target_position: Option<(f32, f32, f32)> = match action {
|
||||
ActionType::Interact => None,
|
||||
ActionType::Attack => None,
|
||||
|
||||
@ -3,6 +3,7 @@ use pumpkin_macros::packet;
|
||||
use crate::{position::WorldPosition, VarInt};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
#[packet(0x24)]
|
||||
pub struct SPlayerAction {
|
||||
status: VarInt,
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use num_derive::FromPrimitive;
|
||||
use num_traits::FromPrimitive;
|
||||
use pumpkin_macros::packet;
|
||||
|
||||
use crate::{bytebuf::DeserializerError, ServerPacket, VarInt};
|
||||
|
||||
@ -3,6 +3,7 @@ use pumpkin_macros::packet;
|
||||
use crate::slot::Slot;
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
#[allow(dead_code)]
|
||||
#[packet(0x32)]
|
||||
pub struct SSetCreativeSlot {
|
||||
slot: i16,
|
||||
|
||||
@ -6,6 +6,7 @@ use serde::{
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct Slot {
|
||||
item_count: VarInt,
|
||||
item_id: Option<VarInt>,
|
||||
|
||||
@ -1,30 +1,3 @@
|
||||
// use fastnbt::nbt;
|
||||
|
||||
// pub const BLOCKS_AND_BIOMES: [u8; 2000] = [0x80; 2000];
|
||||
// pub const SKY_LIGHT_ARRAYS: [FixedArray<u8, 2048>; 26] = [FixedArray([0xff; 2048]); 26];
|
||||
|
||||
// #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
// #[repr(transparent)]
|
||||
// pub struct FixedArray<T, const N: usize>(pub [T; N]);
|
||||
|
||||
// pub struct TestChunk {
|
||||
// pub heightmap: Vec<u8>,
|
||||
// }
|
||||
|
||||
// impl Default for TestChunk {
|
||||
// fn default() -> Self {
|
||||
// Self::new()
|
||||
// }
|
||||
// }
|
||||
|
||||
// impl TestChunk {
|
||||
// pub fn new() -> Self {
|
||||
// let bytes = fastnbt::to_bytes(&nbt!({"MOTION_BLOCKING": [L; 123, 256]})).unwrap();
|
||||
|
||||
// Self { heightmap: bytes }
|
||||
// }
|
||||
// }
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use fastnbt::LongArray;
|
||||
@ -58,6 +31,7 @@ pub struct ChunkHeightmaps {
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct ChunkSection {
|
||||
#[serde(rename = "Y")]
|
||||
y: i32,
|
||||
@ -65,6 +39,7 @@ struct ChunkSection {
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct ChunkNbt {
|
||||
#[serde(rename = "DataVersion")]
|
||||
data_version: usize,
|
||||
|
||||
@ -26,6 +26,7 @@ pub fn get_protocol_id(category: &str, entry: &str) -> u32 {
|
||||
.expect("No Entry found")
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_default<'a>(category: &str) -> Option<&'a str> {
|
||||
REGISTRY
|
||||
.get(category)
|
||||
|
||||
@ -32,10 +32,12 @@ lazy_static! {
|
||||
serde_json::from_str(ITEMS_JSON).expect("Could not parse items.json registry.");
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_item_element(item_id: &str) -> &ItemComponents {
|
||||
&ITEMS.get(item_id).expect("Item not found").components
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_item_protocol_id(item_id: &str) -> u32 {
|
||||
global_registry::get_protocol_id(ITEM_REGISTRY, item_id)
|
||||
}
|
||||
|
||||
@ -8,13 +8,11 @@ use flate2::{bufread::ZlibDecoder, read::GzDecoder};
|
||||
use itertools::Itertools;
|
||||
use rayon::prelude::*;
|
||||
use thiserror::Error;
|
||||
use tokio::{
|
||||
io::{AsyncReadExt, AsyncSeekExt},
|
||||
sync::mpsc,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::chunk::ChunkData;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct Level {
|
||||
root_folder: PathBuf,
|
||||
region_folder: PathBuf,
|
||||
|
||||
@ -37,14 +37,18 @@ impl Client {
|
||||
self.protocol_version = handshake.protocol_version.0;
|
||||
self.connection_state = handshake.next_state;
|
||||
if self.connection_state == ConnectionState::Login {
|
||||
if self.protocol_version < CURRENT_MC_PROTOCOL as i32 {
|
||||
let protocol = self.protocol_version;
|
||||
match protocol.cmp(&(CURRENT_MC_PROTOCOL as i32)) {
|
||||
std::cmp::Ordering::Less => {
|
||||
self.kick(&format!("Client outdated ({protocol}), Server uses Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL}"));
|
||||
} else if self.protocol_version > CURRENT_MC_PROTOCOL as i32 {
|
||||
}
|
||||
std::cmp::Ordering::Equal => {}
|
||||
std::cmp::Ordering::Greater => {
|
||||
self.kick(&format!("Server outdated, Server uses Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_status_request(&mut self, server: &mut Server, _status_request: SStatusRequest) {
|
||||
self.send_packet(&CStatusResponse::new(&server.status_response_json));
|
||||
|
||||
@ -5,8 +5,7 @@ use pumpkin_entity::EntityId;
|
||||
use pumpkin_protocol::{
|
||||
client::play::{
|
||||
Animation, CBlockUpdate, CEntityAnimation, CEntityVelocity, CHeadRot, CHurtAnimation,
|
||||
CPlayerChatMessage, CUpdateEntityPos, CUpdateEntityPosRot,
|
||||
CUpdateEntityRot, FilterType,
|
||||
CPlayerChatMessage, CUpdateEntityPos, CUpdateEntityPosRot, CUpdateEntityRot, FilterType,
|
||||
},
|
||||
position::WorldPosition,
|
||||
server::play::{
|
||||
@ -316,7 +315,7 @@ impl Client {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn handle_player_action(&mut self, _server: &mut Server, player_action: SPlayerAction) {}
|
||||
pub fn handle_player_action(&mut self, _server: &mut Server, _player_action: SPlayerAction) {}
|
||||
|
||||
pub fn handle_use_item_on(&mut self, server: &mut Server, use_item_on: SUseItemOn) {
|
||||
let location = use_item_on.location;
|
||||
|
||||
@ -6,7 +6,7 @@ impl<'a> Command<'a> for StopCommand {
|
||||
const NAME: &'static str = "stop";
|
||||
const DESCRIPTION: &'static str = "Stops the server";
|
||||
|
||||
fn on_execute(sender: &mut super::CommandSender<'a>, command: String) {
|
||||
fn on_execute(_sender: &mut super::CommandSender<'a>, _command: String) {
|
||||
std::process::exit(0);
|
||||
}
|
||||
fn player_required() -> bool {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
use num_traits::Float;
|
||||
use pumpkin_entity::{entity_type::EntityType, Entity, EntityId};
|
||||
use pumpkin_inventory::player::PlayerInventory;
|
||||
use pumpkin_protocol::VarInt;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
#![allow(clippy::await_holding_refcell_ref)]
|
||||
|
||||
use mio::net::TcpListener;
|
||||
use mio::{Events, Interest, Poll, Token};
|
||||
use std::io::{self};
|
||||
|
||||
@ -65,7 +65,7 @@ impl Packet {
|
||||
buf.put_slice(bytes);
|
||||
buf.put_u8(0);
|
||||
buf.put_u8(0);
|
||||
connection.write(&buf).unwrap();
|
||||
let _ = connection.write(&buf).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user