Skip to content

Commit

Permalink
Add Hunger
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Feb 6, 2025
1 parent 5c31e1f commit 2e2fe83
Show file tree
Hide file tree
Showing 35 changed files with 212 additions and 103 deletions.
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ and customizable experience. It prioritizes performance and player enjoyment whi

![image](https://github.com/user-attachments/assets/7e2e865e-b150-4675-a2d5-b52f9900378e)

## What Pumpkin wants to achieve
## Goals

- **Performance**: Leveraging multi-threading for maximum speed and efficiency.
- **Compatibility**: Supports the latest Minecraft server version and adheres to vanilla game mechanics.
- **Security**: Prioritizes security by preventing known security exploits.
- **Flexibility**: Highly configurable, with the ability to disable unnecessary features.
- **Extensibility**: Provides a foundation for plugin development.

## What Pumpkin will not

- Be compatible with plugins or mods for other servers

> [!IMPORTANT]
> Pumpkin is currently under heavy development.
Expand All @@ -48,6 +44,7 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [x] World Loading
- [x] Lighting
- [x] Entity Spawning
- [x] Item drops
- [x] Bossbar
- [x] Chunk Loading (Vanilla, Linear)
- [x] Chunk Generation
Expand All @@ -59,13 +56,15 @@ and customizable experience. It prioritizes performance and player enjoyment whi
- [ ] Redstone
- [ ] Liquid Physics
- Player
- [x] Player Skins
- [x] Player Client brand
- [x] Player Teleport
- [x] Player Movement
- [x] Player Animation
- [x] Player Inventory
- [x] Player Combat
- [x] Skins
- [x] Client brand
- [x] Teleport
- [x] Movement
- [x] Animation
- [x] Inventory
- [x] Combat
- [x] Experience
- [x] Hunger
- Entities
- [x] Non-Living (Minecart, Eggs...)
- [x] Players
Expand Down
2 changes: 0 additions & 2 deletions pumpkin-config/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ impl Default for ChunkCompression {
}

#[derive(Deserialize, Serialize, Clone)]
#[repr(u8)]
pub enum Compression {
/// GZip Compression
GZip,
Expand All @@ -38,7 +37,6 @@ pub enum Compression {
}

#[derive(Deserialize, Serialize, Clone, Default)]
#[repr(u8)]
pub enum ChunkFormat {
#[default]
Anvil,
Expand Down
4 changes: 2 additions & 2 deletions pumpkin-config/src/networking/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
pub struct AuthenticationConfig {
/// Whether to use Mojang authentication.
pub enabled: bool,
pub auth_url: Option<String>,
pub url: Option<String>,
pub connect_timeout: u32,
pub read_timeout: u32,
pub prevent_proxy_connections: bool,
Expand All @@ -24,7 +24,7 @@ impl Default for AuthenticationConfig {
prevent_proxy_connections: false,
player_profile: Default::default(),
textures: Default::default(),
auth_url: None,
url: None,
prevent_proxy_connection_auth_url: None,
connect_timeout: 5000,
read_timeout: 5000,
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/biome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub(crate) fn build() -> TokenStream {

quote! {
#[derive(Clone, Copy)]
#[repr(u8)]
pub enum Biome {
#variants
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/damage_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ pub(crate) fn build() -> TokenStream {
#(#constants)*

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum DamageType {
#(#enum_variants,)*
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/entity_pose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub(crate) fn build() -> TokenStream {

quote! {
#[derive(Clone, Copy)]
#[repr(u8)]
pub enum EntityPose {
#variants
}
Expand Down
5 changes: 3 additions & 2 deletions pumpkin-data/build/entity_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use heck::ToPascalCase;
use proc_macro2::TokenStream;
use quote::quote;
use serde::Deserialize;
use syn::LitInt;

use crate::ident;

Expand All @@ -22,9 +23,10 @@ pub(crate) fn build() -> TokenStream {

for (item, id) in json.iter() {
let id = id.id as u8;
let id_lit = LitInt::new(&id.to_string(), proc_macro2::Span::call_site());
let name = ident(item.to_pascal_case());
variants.extend([quote! {
#name = #id,
#name = #id_lit,
}]);
}

Expand Down Expand Up @@ -54,7 +56,6 @@ pub(crate) fn build() -> TokenStream {

quote! {
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[repr(u8)]
pub enum EntityType {
#variants
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/game_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub(crate) fn build() -> TokenStream {
let variants = array_to_tokenstream(game_events);

quote! {
#[repr(u8)]
pub enum GameEvent {
#variants
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/particle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub(crate) fn build() -> TokenStream {

quote! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum Particle {
#variants
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/scoreboard_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub(crate) fn build() -> TokenStream {
let variants = array_to_tokenstream(sound_categories);

quote! {
#[repr(u8)]
pub enum ScoreboardDisplaySlot {
#variants
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub(crate) fn build() -> TokenStream {

quote! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum WindowType {
#variants
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-data/build/sound_category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub(crate) fn build() -> TokenStream {

quote! {
#[derive(Clone, Copy)]
#[repr(u8)]
pub enum SoundCategory {
#variants
}
Expand Down
7 changes: 0 additions & 7 deletions pumpkin-inventory/src/window_property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ impl<T: WindowPropertyTrait> WindowProperty<T> {
(self.window_property.to_id(), self.value)
}
}
#[repr(u8)]
pub enum Furnace {
FireIcon,
MaximumFuelBurnTime,
Expand All @@ -46,35 +45,29 @@ impl WindowPropertyTrait for EnchantmentTable {
}) as i16
}
}
#[repr(u8)]
pub enum Beacon {
PowerLevel,
FirstPotionEffect,
SecondPotionEffect,
}

#[repr(u8)]
pub enum Anvil {
RepairCost,
}

#[repr(u8)]
pub enum BrewingStand {
BrewTime,
FuelTime,
}

#[repr(u8)]
pub enum Stonecutter {
SelectedRecipe,
}

#[repr(u8)]
pub enum Loom {
SelectedPattern,
}

#[repr(u8)]
pub enum Lectern {
PageNumber,
}
1 change: 0 additions & 1 deletion pumpkin-protocol/src/client/play/entity_animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ impl CEntityAnimation {
}

#[derive(Debug)]
#[repr(u8)]
pub enum Animation {
SwingMainArm,
LeaveBed = 2,
Expand Down
1 change: 0 additions & 1 deletion pumpkin-protocol/src/client/play/entity_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl<T> Metadata<T> {
}
}

#[repr(u8)]
pub enum MetaDataType {
Byte,
Integer,
Expand Down
1 change: 0 additions & 1 deletion pumpkin-protocol/src/client/play/game_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ impl CGameEvent {
}
}

#[repr(u8)]
pub enum GameEvent {
NoRespawnBlockAvailable,
BeginRaining,
Expand Down
7 changes: 3 additions & 4 deletions pumpkin-protocol/src/client/play/player_chat_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ pub struct PreviousMessage<'a> {
}

#[derive(Serialize)]
#[repr(i32)]
pub enum FilterType {
/// Message is not filtered at all
PassThrough = 0,
PassThrough,
/// Message is fully filtered
FullyFiltered = 1,
FullyFiltered,
/// Only some characters in the message are filtered
PartiallyFiltered(BitSet) = 2,
PartiallyFiltered(BitSet),
}
2 changes: 0 additions & 2 deletions pumpkin-protocol/src/client/play/update_objectives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ impl ClientPacket for CUpdateObjectives<'_> {
}
}

#[repr(u8)]
pub enum Mode {
Add,
Remove,
Update,
}

#[repr(i32)]
pub enum RenderType {
Integer,
Hearts,
Expand Down
1 change: 0 additions & 1 deletion pumpkin-protocol/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{ffi::CString, io::Cursor};

use tokio::io::{AsyncReadExt, AsyncWriteExt};

#[repr(u8)]
pub enum PacketType {
// There could be other types but they are not documented
// Besides these types are enough to get server status
Expand Down
1 change: 0 additions & 1 deletion pumpkin-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub struct SyncedRegistry {
}

#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum DimensionType {
Overworld,
OverworldCaves,
Expand Down
19 changes: 9 additions & 10 deletions pumpkin-util/src/gamemode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@ use serde::{Deserialize, Serialize};
pub struct ParseGameModeError;

#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
#[repr(i8)]
pub enum GameMode {
Undefined = -1,
Survival,
Creative,
Adventure,
Spectator,
}

impl From<i8> for GameMode {
fn from(value: i8) -> Self {
impl TryFrom<i8> for GameMode {
type Error = ();

fn try_from(value: i8) -> Result<Self, Self::Error> {
match value {
-1 => Self::Undefined,
0 => Self::Survival,
1 => Self::Creative,
2 => Self::Adventure,
3 => Self::Spectator,
_ => Self::Undefined,
0 => Ok(Self::Survival),
1 => Ok(Self::Creative),
2 => Ok(Self::Adventure),
3 => Ok(Self::Spectator),
_ => Err(()),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion pumpkin-util/src/permission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
/// - `Three`: `admin`: Player or executor can use commands related to multiplayer management.
/// - `Four`: `owner`: Player or executor can use all of the commands, including commands related to server management.
#[derive(Clone, Copy, Default, PartialEq, Eq)]
#[repr(i8)]
pub enum PermissionLvl {
#[default]
Zero = 0,
Expand Down
1 change: 0 additions & 1 deletion pumpkin-world/src/chunk/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const WORLD_DATA_VERSION: i32 = 4189;
pub struct AnvilChunkFormat;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum Compression {
/// GZip Compression
GZip = 1,
Expand Down
12 changes: 4 additions & 8 deletions pumpkin/src/command/args/gamemode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ impl ArgumentConsumer for GamemodeArgumentConsumer {
let s = args.pop()?;

if let Ok(id) = s.parse::<i8>() {
match GameMode::from(id) {
GameMode::Undefined => {}
gamemode => return Some(Arg::GameMode(gamemode)),
};
if let Ok(gamemode) = GameMode::try_from(id) {
return Some(Arg::GameMode(gamemode));
}
};

match GameMode::from_str(s) {
Err(_) | Ok(GameMode::Undefined) => None,
Ok(gamemode) => Some(Arg::GameMode(gamemode)),
}
GameMode::from_str(s).map_or_else(|_| None, |gamemode| Some(Arg::GameMode(gamemode)))
}

async fn suggest<'a>(
Expand Down
Loading

0 comments on commit 2e2fe83

Please sign in to comment.