Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
user622628252416 committed Aug 20, 2024
2 parents d221f89 + 3b55bc4 commit 0a69051
Show file tree
Hide file tree
Showing 52 changed files with 254 additions and 255 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
We appreciate your interest in contributing to Pumpkin! This document outlines the guidelines for submitting bug reports, feature suggestions, and code changes.
Getting Started

The easisty way to get started is by asking for help in our [discord](https://discord.gg/wT8XjrjKkf)
The easiest way to get started is by asking for help in our [discord](https://discord.gg/wT8XjrjKkf)

### How to Contribute

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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 achive:
### What Pumpkin wants to achieve:
- **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 exploits.
Expand Down Expand Up @@ -83,13 +83,13 @@ Make sure to generate chunks close to (0,0) since that is where the player gets

Then run:
> [!NOTE]
> This can take a while. Because we enabled heavy optimations for release builds
> This can take a while. Because we enabled heavy optimizations for release builds
```
RUSTFLAGS="-C target-cpu=native" cargo run --release
```

## Contributions
Contributions are welcome!. See [CONTRIBUTING.md](CONTRIBUTING.md)
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md)

## Communication
Consider joining our [discord](https://discord.gg/wT8XjrjKkf) to stay up-to-date on events, updates, and connect with other members.
Expand Down
5 changes: 3 additions & 2 deletions pumpkin-inventory/src/player.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use pumpkin_world::item::Item;

#[allow(dead_code)]
pub struct PlayerInventory {
// Main Inventory + Hotbar
items: [Option<Item>; 36],
Expand All @@ -21,12 +22,12 @@ impl PlayerInventory {
items: [None; 36],
armor: [None; 4],
offhand: None,
// TODO: What when player spawns in with an diffrent index ?
// TODO: What when player spawns in with an different index ?
selected: 0,
}
}

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));
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/bytebuf/packet_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{BitSet, ClientPacket, ServerPacket, VarInt, VarIntType};

use super::{deserializer, serializer, ByteBuffer, DeserializerError};

impl Serialize for BitSet<'static> {
impl<'a> Serialize for BitSet<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
22 changes: 12 additions & 10 deletions pumpkin-protocol/src/client/config/c_add_resource_pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use serde::Serialize;

use crate::uuid::UUID;

#[derive(Serialize)]
#[packet(0x09)]
pub struct CConfigAddResourcePack {
uuid: uuid::Uuid,
url: String,
hash: String,
pub struct CConfigAddResourcePack<'a> {
uuid: UUID,
url: &'a str,
hash: &'a str, // max 40
forced: bool,
prompt_message: Option<TextComponent>,
prompt_message: Option<TextComponent<'a>>,
}

impl CConfigAddResourcePack {
impl<'a> CConfigAddResourcePack<'a> {
pub fn new(
uuid: uuid::Uuid,
url: String,
hash: String,
uuid: UUID,
url: &'a str,
hash: &'a str,
forced: bool,
prompt_message: Option<TextComponent>,
prompt_message: Option<TextComponent<'a>>,
) -> Self {
Self {
uuid,
Expand Down
2 changes: 0 additions & 2 deletions pumpkin-protocol/src/client/config/c_plugin_message.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use pumpkin_macros::packet;
use serde::Serialize;

use crate::{bytebuf::ByteBuffer, ClientPacket};

#[derive(Serialize)]
#[packet(0x01)]
pub struct CPluginMessage<'a> {
Expand Down
8 changes: 4 additions & 4 deletions pumpkin-protocol/src/client/play/c_actionbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use serde::Serialize;

#[derive(Serialize)]
#[packet(0x4C)]
pub struct CActionBar {
action_bar: TextComponent,
pub struct CActionBar<'a> {
action_bar: TextComponent<'a>,
}

impl CActionBar {
pub fn new(action_bar: TextComponent) -> Self {
impl<'a> CActionBar<'a> {
pub fn new(action_bar: TextComponent<'a>) -> Self {
Self { action_bar }
}
}
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_chunk_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
16 changes: 8 additions & 8 deletions pumpkin-protocol/src/client/play/c_disguised_chat_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use crate::VarInt;

#[derive(Serialize)]
#[packet(0x1E)]
pub struct CDisguisedChatMessage {
message: TextComponent,
pub struct CDisguisedChatMessage<'a> {
message: TextComponent<'a>,
chat_type: VarInt,
sender_name: TextComponent,
target_name: Option<TextComponent>,
sender_name: TextComponent<'a>,
target_name: Option<TextComponent<'a>>,
}

impl CDisguisedChatMessage {
impl<'a> CDisguisedChatMessage<'a> {
pub fn new(
message: TextComponent,
message: TextComponent<'a>,
chat_type: VarInt,
sender_name: TextComponent,
target_name: Option<TextComponent>,
sender_name: TextComponent<'a>,
target_name: Option<TextComponent<'a>>,
) -> Self {
Self {
message,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/client/play/c_login.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pumpkin_macros::packet;
use serde::Serialize;

use crate::VarInt;
use crate::{position::WorldPosition, VarInt};

#[derive(Serialize)]
#[packet(0x2B)]
Expand All @@ -23,7 +23,7 @@ pub struct CLogin<'a> {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
death_dimension_name: Option<(String, i64)>, // POSITION NOT STRING
death_dimension_name: Option<(WorldPosition, i64)>,
portal_cooldown: VarInt,
enforce_secure_chat: bool,
}
Expand All @@ -47,7 +47,7 @@ impl<'a> CLogin<'a> {
previous_gamemode: i8,
debug: bool,
is_flat: bool,
death_dimension_name: Option<(String, i64)>,
death_dimension_name: Option<(WorldPosition, i64)>,
portal_cooldown: VarInt,
enforce_secure_chat: bool,
) -> Self {
Expand Down
8 changes: 4 additions & 4 deletions pumpkin-protocol/src/client/play/c_open_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use crate::VarInt;

#[derive(Serialize)]
#[packet(0x33)]
pub struct COpenScreen {
pub struct COpenScreen<'a> {
window_id: VarInt,
window_type: VarInt,
window_title: TextComponent,
window_title: TextComponent<'a>,
}

impl COpenScreen {
pub fn new(window_id: VarInt, window_type: VarInt, window_title: TextComponent) -> Self {
impl<'a> COpenScreen<'a> {
pub fn new(window_id: VarInt, window_type: VarInt, window_title: TextComponent<'a>) -> Self {
Self {
window_id,
window_type,
Expand Down
1 change: 1 addition & 0 deletions pumpkin-protocol/src/client/play/c_particle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions pumpkin-protocol/src/client/play/c_play_disconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use serde::Serialize;

#[derive(Serialize)]
#[packet(0x1D)]
pub struct CPlayDisconnect {
reason: TextComponent,
pub struct CPlayDisconnect<'a> {
reason: TextComponent<'a>,
}

impl CPlayDisconnect {
pub fn new(reason: TextComponent) -> Self {
impl<'a> CPlayDisconnect<'a> {
pub fn new(reason: TextComponent<'a>) -> Self {
Self { reason }
}
}
22 changes: 11 additions & 11 deletions pumpkin-protocol/src/client/play/c_player_chat_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@ pub struct CPlayerChatMessage<'a> {
sender: UUID,
index: VarInt,
message_signature: Option<&'a [u8]>,
message: String,
message: &'a str,
timestamp: i64,
salt: i64,
previous_messages_count: VarInt,
previous_messages: &'a [PreviousMessage<'a>], // max 20
unsigned_content: Option<TextComponent>,
unsigned_content: Option<TextComponent<'a>>,
/// See `FilterType`
filter_type: VarInt,
// TODO: THIS IS A HACK, We currently don't support writing or reading bitsets
filter_type_bits: bool,
filter_type_bits: Option<BitSet<'a>>,
chat_type: VarInt,
sender_name: TextComponent,
target_name: Option<TextComponent>,
sender_name: TextComponent<'a>,
target_name: Option<TextComponent<'a>>,
}

impl<'a> CPlayerChatMessage<'a> {
Expand All @@ -32,15 +31,16 @@ impl<'a> CPlayerChatMessage<'a> {
sender: UUID,
index: VarInt,
message_signature: Option<&'a [u8]>,
message: String,
message: &'a str,
timestamp: i64,
salt: i64,
previous_messages: &'a [PreviousMessage<'a>],
unsigned_content: Option<TextComponent>,
unsigned_content: Option<TextComponent<'a>>,
filter_type: VarInt,
filter_type_bits: Option<BitSet<'a>>,
chat_type: VarInt,
sender_name: TextComponent,
target_name: Option<TextComponent>,
sender_name: TextComponent<'a>,
target_name: Option<TextComponent<'a>>,
) -> Self {
Self {
sender,
Expand All @@ -53,7 +53,7 @@ impl<'a> CPlayerChatMessage<'a> {
previous_messages,
unsigned_content,
filter_type,
filter_type_bits: false,
filter_type_bits,
chat_type,
sender_name,
target_name,
Expand Down
8 changes: 4 additions & 4 deletions pumpkin-protocol/src/client/play/c_set_title.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use serde::Serialize;

#[derive(Serialize)]
#[packet(0x65)]
pub struct CTitleText {
title: TextComponent,
pub struct CTitleText<'a> {
title: TextComponent<'a>,
}

impl CTitleText {
pub fn new(title: TextComponent) -> Self {
impl<'a> CTitleText<'a> {
pub fn new(title: TextComponent<'a>) -> Self {
Self { title }
}
}
8 changes: 4 additions & 4 deletions pumpkin-protocol/src/client/play/c_subtitle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use serde::Serialize;

#[derive(Serialize)]
#[packet(0x63)]
pub struct CSubtitle {
subtitle: TextComponent,
pub struct CSubtitle<'a> {
subtitle: TextComponent<'a>,
}

impl CSubtitle {
pub fn new(subtitle: TextComponent) -> Self {
impl<'a> CSubtitle<'a> {
pub fn new(subtitle: TextComponent<'a>) -> Self {
Self { subtitle }
}
}
8 changes: 4 additions & 4 deletions pumpkin-protocol/src/client/play/c_system_chat_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use serde::Serialize;

#[derive(Serialize)]
#[packet(0x6C)]
pub struct CSystemChatMessge {
content: TextComponent,
pub struct CSystemChatMessge<'a> {
content: TextComponent<'a>,
overlay: bool,
}

impl CSystemChatMessge {
pub fn new(content: TextComponent, overlay: bool) -> Self {
impl<'a> CSystemChatMessge<'a> {
pub fn new(content: TextComponent<'a>, overlay: bool) -> Self {
Self { content, overlay }
}
}
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bytebuf::{packet_id::Packet, ByteBuffer, DeserializerError};
use bytes::Buf;
use serde::{Deserialize, Serialize, Serializer};
use serde::{Deserialize, Serialize};
use std::io::{self, Write};
use thiserror::Error;

Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/server/play/s_chat_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pumpkin_macros::packet;

use crate::{
bytebuf::{ByteBuffer, DeserializerError},
ServerPacket,
ServerPacket, VarInt,
};

// derive(Deserialize)]
Expand All @@ -12,7 +12,7 @@ pub struct SChatMessage {
pub timestamp: i64,
pub salt: i64,
pub signature: Option<Vec<u8>>,
// pub messagee_count: VarInt,
pub messagee_count: VarInt,
// acknowledged: BitSet,
}

Expand All @@ -24,7 +24,7 @@ impl ServerPacket for SChatMessage {
timestamp: bytebuf.get_i64(),
salt: bytebuf.get_i64(),
signature: bytebuf.get_option(|v| v.get_slice().to_vec()),
//messagee_count: bytebuf.get_var_int(),
messagee_count: bytebuf.get_var_int(),
})
}
}
Loading

0 comments on commit 0a69051

Please sign in to comment.