Skip to content

Commit 2552af3

Browse files
authored
Merge branch 'master' into feat/commands
2 parents ebb5c52 + 1df4866 commit 2552af3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2113
-458
lines changed

.etc/example-config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ map_size = 1_000
3636
cache_ttl = 60
3737
# How big the cache can be in kb.
3838
cache_capacity = 20_000
39+
40+
whitelist = false

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ferrumc-core = { path = "src/lib/core" }
9393
ferrumc-default-commands = { path = "src/lib/default_commands" }
9494
ferrumc-commands = { path = "src/lib/commands" }
9595
ferrumc-ecs = { path = "src/lib/ecs" }
96-
ferrumc-events = { path = "src/lib/events" }
96+
ferrumc-events = { path = "src/lib/events"}
9797
ferrumc-general-purpose = { path = "src/lib/utils/general_purpose" }
9898
ferrumc-logging = { path = "src/lib/utils/logging" }
9999
ferrumc-macros = { path = "src/lib/derive_macros" }
@@ -120,6 +120,7 @@ async-trait = "0.1.82"
120120
# Logging
121121
tracing = "0.1.40"
122122
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
123+
tracing-appender = "0.2.3"
123124
log = "0.4.22"
124125
console-subscriber = "0.4.1"
125126

README.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ our [Discord server](https://discord.gg/qT5J8EMjwk) for help or to discuss the p
4242
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/server%20list.png?raw=true" alt="Server list">
4343
</li>
4444
<li>
45-
<h4>🚄 Extremely fast and adaptable update speeds</h4>
45+
<h4>🚄 Extremely fast </h4>
4646
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/mind%20boggling.gif?raw=true" alt="Mind boggling">
4747
</li>
4848
<li>
4949
<h4>🖥️ Highly efficient memory usage</h4>
5050
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/mem_use.png?raw=true" alt="Low memory usage">
5151
</li>
5252
<li>
53-
<h4>🗂️ Customizable configuration</h4>
53+
<h4>🗂️ Straightforward Configuration</h4>
5454
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/config.toml.png?raw=true" alt="Configuration">
5555
</li>
5656
<li>
5757
<h4>🔄 Can import existing worlds from vanilla minecraft</h4>
5858
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/chunk_importing.gif?raw=true" alt="Configuration">
5959
</li>
6060
<li>
61-
<h4>🌐 Compatible with vanilla Minecraft clients (Currently only 1.21.1)</h4>
61+
<h4>🌐 Compatible with vanilla Minecraft clients (Version 1.21.1)</h4>
6262
</li>
6363
<li>
6464
<h4>💪 Powerful Entity Component System to handle high entity loads</h4>
@@ -72,7 +72,7 @@ our [Discord server](https://discord.gg/qT5J8EMjwk) for help or to discuss the p
7272
<h4>📝 Custom made network, NBT and Anvil encoding systems to allow for minimal I/O lag</h4>
7373
</li>
7474
<li>
75-
<h4>💾 Multiple database options to finetune the server to your needs</h4>
75+
<h4>💾 Crazy fast K/V database </h4>
7676
<i>32 render distance*</i>
7777
<img src="https://github.com/ferrumc-rs/ferrumc/blob/master/assets/README/chunk_loading.gif?raw=true" alt="Chunk Loading DEMO">
7878
</li>
@@ -82,19 +82,19 @@ our [Discord server](https://discord.gg/qT5J8EMjwk) for help or to discuss the p
8282

8383
<ul>
8484
<li>
85-
<h4>Ability to view other players</h4>
85+
<h4>PvE mechanics, and entities.</h4>
8686
</li>
8787
<li>
8888
<h4>World modification (place / break blocks etc)</h4>
8989
</li>
9090
<li>
91-
<h4>Chat & Command system</h4>
91+
<h4>Web based server dashboard</h4>
9292
</li>
9393
<li>
9494
<h4>Optimizations</h4>
9595
</li>
9696
<li>
97-
<h4>Plugin support (JVM currently, other languages will be considered later)</h4>
97+
<h4>Plugin support (FFI currently, other languages will be considered later)</h4>
9898
</li>
9999
</ul>
100100

@@ -148,9 +148,23 @@ cargo build --release
148148

149149
## 🖥️ Usage
150150

151+
```plaintext
152+
Usage: ferrumc.exe [OPTIONS] [COMMAND]
153+
154+
Commands:
155+
setup Sets up the config
156+
import Import the world data
157+
run Start the server (default, if no command is given)
158+
help Print this message or the help of the given subcommand(s)
159+
160+
Options:
161+
--log <LOG> [default: debug] [possible values: trace, debug, info, warn, error]
162+
-h, --help Print help
163+
```
164+
151165
1. Move the FerrumC binary (`ferrumc.exe` or `ferrumc` depending on the OS) to your desired server directory
152166
2. Open a terminal in that directory
153-
3. (Optional) Generate a config file: `./ferrumc --setup`
167+
3. (Optional) Generate a config file: `./ferrumc setup`
154168
- Edit the generated `config.toml` file to customize your server settings
155169
4. Import an existing world: Either copy your world files to the server directory or specify the path to the world files
156170
in the `config.toml` file. This should be the root directory of your world files, containing the `region` directory
@@ -218,10 +232,9 @@ with the vanilla server, but we do plan on implementing some sort of terrain gen
218232
219233
### Will there be plugins? And how?
220234
221-
We do very much plan to have a plugin system and as of right now, our plan is to leverage the
222-
JVM to allow for plugins to be written in Kotlin, Java, or any other JVM language. We are also considering other
223-
languages
224-
such as Rust, JavaScript and possibly other native languages, but that is a fair way off for now.
235+
We do very much plan to have a plugin system and as of right now we are planning to use
236+
some kind of ffi (foreign function interface) to allow for plugins to be written in other languages.
237+
Not confirmed yet.
225238
226239
### What does 'FerrumC' mean?
227240
@@ -240,4 +253,11 @@ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE) f
240253
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ferrumc-rs/ferrumc&type=Date" />
241254
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ferrumc-rs/ferrumc&type=Date" />
242255
</picture>
243-
</a>
256+
</a>
257+
258+
## 📊 Stats
259+
260+
[![Timeline graph](https://images.repography.com/59032276/ferrumc-rs/ferrumc/recent-activity/J6CgGhzs6y3LXRuADz1QpSUriBC3ix9DXnPUbbljruA/O-qGFiSVQmksFEaX7mVQ4jY3lppUTK2xUw4CpqZ3oUk_timeline.svg)](https://github.com/ferrumc-rs/ferrumc/commits)
261+
[![Issue status graph](https://images.repography.com/59032276/ferrumc-rs/ferrumc/recent-activity/J6CgGhzs6y3LXRuADz1QpSUriBC3ix9DXnPUbbljruA/O-qGFiSVQmksFEaX7mVQ4jY3lppUTK2xUw4CpqZ3oUk_issues.svg)](https://github.com/ferrumc-rs/ferrumc/issues)
262+
[![Pull request status graph](https://images.repography.com/59032276/ferrumc-rs/ferrumc/recent-activity/J6CgGhzs6y3LXRuADz1QpSUriBC3ix9DXnPUbbljruA/O-qGFiSVQmksFEaX7mVQ4jY3lppUTK2xUw4CpqZ3oUk_prs.svg)](https://github.com/ferrumc-rs/ferrumc/pulls)
263+
[![Top contributors](https://images.repography.com/59032276/ferrumc-rs/ferrumc/recent-activity/J6CgGhzs6y3LXRuADz1QpSUriBC3ix9DXnPUbbljruA/O-qGFiSVQmksFEaX7mVQ4jY3lppUTK2xUw4CpqZ3oUk_users.svg)](https://github.com/ferrumc-rs/ferrumc/graphs/contributors)

scripts/new_packet.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import os.path
2+
3+
incoming_template = """
4+
use crate::packets::IncomingPacket;
5+
use crate::NetResult;
6+
use ferrumc_macros::{packet, NetDecode};
7+
use ferrumc_state::ServerState;
8+
use std::sync::Arc;
9+
10+
#[derive(NetDecode)]
11+
#[packet(packet_id = ++id++, state = "play")]
12+
pub struct ++name++ {
13+
}
14+
15+
impl IncomingPacket for ++name++ {
16+
async fn handle(self, conn_id: usize, state: Arc<ServerState>) -> NetResult<()> {
17+
todo!()
18+
}
19+
}
20+
"""
21+
22+
outgoing_template = """
23+
use ferrumc_macros::{packet, NetEncode};\
24+
use std::io::Write;
25+
26+
#[derive(NetEncode)]
27+
#[packet(packet_id = ++id++)]
28+
pub struct ++name++ {}
29+
"""
30+
31+
32+
def to_snake_case(string) -> str:
33+
return string.lower().replace(" ", "_")
34+
35+
36+
def to_camel_case(string) -> str:
37+
return string.title().replace(" ", "")
38+
39+
40+
packet_type_input = input("Incoming or outgoing packet? (i/o): ")
41+
packet_type = ""
42+
if packet_type_input == "i":
43+
packet_type = "incoming"
44+
elif packet_type_input == "o":
45+
packet_type = "outgoing"
46+
else:
47+
print("Invalid input")
48+
exit()
49+
50+
packet_name = input("Packet name: ")
51+
packets_dir = os.path.join(os.path.join(os.path.dirname(__file__), ".."), "src/lib/net/src/packets")
52+
53+
packet_id = input("Packet ID (formatted like 0x01): ")
54+
packet_id = packet_id[:-2] + packet_id[-2:].upper()
55+
56+
with open(f"{packets_dir}/{packet_type}/{to_snake_case(packet_name)}.rs", "x") as f:
57+
if packet_type == "incoming":
58+
f.write(incoming_template.replace("++name++", to_camel_case(packet_name)).replace("++id++", packet_id))
59+
with open(f"{packets_dir}/incoming/mod.rs", "a") as modfile:
60+
modfile.write(f"\npub mod {to_snake_case(packet_name)};")
61+
else:
62+
f.write(outgoing_template.replace("++name++", to_camel_case(packet_name)).replace("++id++", packet_id))
63+
with open(f"{packets_dir}/outgoing/mod.rs", "a") as modfile:
64+
modfile.write(f"\npub mod {to_snake_case(packet_name)};")

src/bin/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ ferrumc-commands = { workspace = true }
3030
ferrumc-default-commands = { workspace = true }
3131
ferrumc-text = { workspace = true }
3232

33-
ctor = { workspace = true }
3433
parking_lot = { workspace = true, features = ["deadlock_detection"] }
3534
tracing = { workspace = true }
3635
tokio = { workspace = true }
37-
rayon = { workspace = true }
3836
futures = { workspace = true }
39-
serde_json = { workspace = true }
4037
async-trait = { workspace = true }
4138
clap = { workspace = true, features = ["derive"] }
39+
flate2 = { workspace = true }
40+
ctor = { workspace = true }
4241

4342

4443
[[bin]]

src/bin/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ferrumc_world::World;
1616
use std::hash::{Hash, Hasher};
1717
use std::sync::Arc;
1818
use systems::definition;
19-
use tracing::{error, info};
19+
use tracing::{error, info, trace};
2020

2121
pub(crate) mod errors;
2222
use crate::cli::{CLIArgs, Command, ImportArgs};
@@ -37,11 +37,11 @@ async fn main() {
3737
let mut hasher = std::collections::hash_map::DefaultHasher::new();
3838
std::any::TypeId::of::<ChunkReceiver>().hash(&mut hasher);
3939
let digest = hasher.finish();
40-
println!("ChunkReceiver: {:X}", digest);
40+
trace!("ChunkReceiver: {:X}", digest);
4141
let mut hasher = std::collections::hash_map::DefaultHasher::new();
4242
std::any::TypeId::of::<StreamWriter>().hash(&mut hasher);
4343
let digest = hasher.finish();
44-
println!("StreamWriter: {:X}", digest);
44+
trace!("StreamWriter: {:X}", digest);
4545
}
4646

4747
match cli_args.command {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use ferrumc_macros::event_handler;
2+
use ferrumc_net::errors::NetError;
3+
use ferrumc_net::packets::outgoing::entity_animation::EntityAnimationEvent;
4+
use ferrumc_net::utils::broadcast::{broadcast, BroadcastOptions};
5+
use ferrumc_state::GlobalState;
6+
7+
#[event_handler]
8+
async fn entity_animation(
9+
event: EntityAnimationEvent,
10+
state: GlobalState,
11+
) -> Result<EntityAnimationEvent, NetError> {
12+
//TODO change this global broadcast to a broadcast that affects only players in the view distance
13+
// of the player doing it, but as long as we still cant see other players, this will be fine.
14+
broadcast(
15+
&event.packet,
16+
&state,
17+
BroadcastOptions::default().except([event.entity]),
18+
)
19+
.await?;
20+
Ok(event)
21+
}

0 commit comments

Comments
 (0)