fix: player count overflowing
This commit is contained in:
parent
84b0a6b25a
commit
67fc80439d
@ -1,5 +1,7 @@
|
|||||||
use pumpkin_data::packet::serverbound::PLAY_PLAYER_LOADED;
|
use pumpkin_data::packet::serverbound::PLAY_PLAYER_LOADED;
|
||||||
use pumpkin_macros::java_packet;
|
use pumpkin_macros::java_packet;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
#[java_packet(PLAY_PLAYER_LOADED)]
|
#[java_packet(PLAY_PLAYER_LOADED)]
|
||||||
pub struct SPlayerLoaded;
|
pub struct SPlayerLoaded;
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
use pumpkin_data::packet::serverbound::PLAY_MOVE_PLAYER_POS;
|
use pumpkin_data::packet::serverbound::PLAY_MOVE_PLAYER_POS;
|
||||||
use pumpkin_macros::java_packet;
|
use pumpkin_macros::java_packet;
|
||||||
use pumpkin_util::math::vector3::Vector3;
|
use pumpkin_util::math::vector3::Vector3;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[java_packet(PLAY_MOVE_PLAYER_POS)]
|
#[java_packet(PLAY_MOVE_PLAYER_POS)]
|
||||||
pub struct SPlayerPosition {
|
pub struct SPlayerPosition {
|
||||||
pub position: Vector3<f64>,
|
pub position: Vector3<f64>,
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
use pumpkin_data::packet::serverbound::PLAY_MOVE_PLAYER_ROT;
|
use pumpkin_data::packet::serverbound::PLAY_MOVE_PLAYER_ROT;
|
||||||
use pumpkin_macros::java_packet;
|
use pumpkin_macros::java_packet;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[java_packet(PLAY_MOVE_PLAYER_ROT)]
|
#[java_packet(PLAY_MOVE_PLAYER_ROT)]
|
||||||
pub struct SPlayerRotation {
|
pub struct SPlayerRotation {
|
||||||
pub yaw: f32,
|
pub yaw: f32,
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use pumpkin_data::packet::serverbound::PLAY_SWING;
|
use pumpkin_data::packet::serverbound::PLAY_SWING;
|
||||||
use pumpkin_macros::java_packet;
|
use pumpkin_macros::java_packet;
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[java_packet(PLAY_SWING)]
|
#[java_packet(PLAY_SWING)]
|
||||||
pub struct SSwingArm {
|
pub struct SSwingArm {
|
||||||
pub hand: VarInt,
|
pub hand: VarInt,
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use pumpkin_data::packet::serverbound::PLAY_USE_ITEM;
|
use pumpkin_data::packet::serverbound::PLAY_USE_ITEM;
|
||||||
use pumpkin_macros::java_packet;
|
use pumpkin_macros::java_packet;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[java_packet(PLAY_USE_ITEM)]
|
#[java_packet(PLAY_USE_ITEM)]
|
||||||
pub struct SUseItem {
|
pub struct SUseItem {
|
||||||
// 0 for main hand, 1 for off hand
|
// 0 for main hand, 1 for off hand
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
use pumpkin_data::packet::serverbound::PLAY_USE_ITEM_ON;
|
use pumpkin_data::packet::serverbound::PLAY_USE_ITEM_ON;
|
||||||
use pumpkin_macros::java_packet;
|
use pumpkin_macros::java_packet;
|
||||||
use pumpkin_util::math::{position::BlockPos, vector3::Vector3};
|
use pumpkin_util::math::{position::BlockPos, vector3::Vector3};
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
#[java_packet(PLAY_USE_ITEM_ON)]
|
#[java_packet(PLAY_USE_ITEM_ON)]
|
||||||
pub struct SUseItemOn {
|
pub struct SUseItemOn {
|
||||||
pub hand: VarInt,
|
pub hand: VarInt,
|
||||||
|
|||||||
@ -88,7 +88,7 @@ impl CachedStatus {
|
|||||||
// .compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
|
// .compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
|
||||||
// .is_ok()
|
// .is_ok()
|
||||||
// {
|
// {
|
||||||
players.online += 1;
|
players.online = players.online.saturating_add(1);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ impl CachedStatus {
|
|||||||
// .compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed)
|
// .compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed)
|
||||||
// .is_ok()
|
// .is_ok()
|
||||||
// {
|
// {
|
||||||
players.online -= 1;
|
players.online = players.online.saturating_sub(1);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user