Commit Graph

390 Commits

Author SHA1 Message Date
Alexander Medvedev
6e4a05d66d More Entity Physics work
Co-Authored-By: akashbeh <112662680+akashbeh@users.noreply.github.com>
2025-08-02 16:24:06 +02:00
spr-equinox
8ce65cc42d Refactor ItemStack to Support Vanilla-Like Data Components (#1059)
* improve tag v1

* improve tag v2

* fix typo and make BlockPredicate better

* improve get state from state id

* impl DataComponent

* make tag pub

* make component work

* apply clippy

* apply clippy

* remove unused crate

* apply to itemstack and no lifetime mark anymore

* Update tag.rs

* use Cow

* remove unnecessary lazy_static and Cow

* Update mod.rs

* Update mod.rs

* make DataComponent dyn

* remove unused crate

* fix error

* Update Cargo.toml

* Update Cargo.lock

* fix

* Update composter.rs

* update rust-version, remove unused crate, and merge

* Update furnace.rs
2025-07-28 12:24:40 +02:00
spr-equinox
15c9aa4ac8 Improve tags (#1057)
* improve tag v1

* improve tag v2

* fix typo and make BlockPredicate better

* improve get state from state id

* make tag pub

* Update tag.rs

* fix error

* Update hopper.rs

* Update hopper.rs
2025-07-27 21:34:18 +02:00
Alexander Medvedev
8ccc135d74 Update all crates 2025-07-26 17:51:15 +02:00
unschlagbar
2e2236bf3b Bedrock player joining (#1063)
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-26 17:31:00 +02:00
Alexander Medvedev
b0cea38596 remove some internal crates 2025-07-11 14:23:14 +02:00
Liyan Zhao
d34b3eb3f7 Macroize serde (#1029)
* macroize serde

* fix
2025-07-10 10:52:28 +02:00
4lve
60d83022be Optimize everything (#1032)
* Start fixing block entities

* Fix

* Begin performance fixing

* Fix stuff

* cleanup

* fix clippy

* Fast as fuck

* fix clippy

* Write chunks concurrently

* Disable random ticks for now

* Fix

* Merge

* fix merge errors

* Fix clippy

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-07-09 23:53:50 +02:00
Alexander Medvedev
2f6c484b2b Protocol refactor (#1006)
* fixes

* Fixed missing ACKs (#1002)

* sefesf

* efrgf

* efes

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>

* Refactor Protocol

* Add CStartGame

currently broken, i will try to fix it tomorrow

* fix start packet

* more bedrock (#1014)

* srgjtdrwa

* sgs

* reg

* rg

* rgth

* ef

* rfrgreg

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>

* rename locations to position

---------

Co-authored-by: unschlagbar <153451111+unschlagbar@users.noreply.github.com>
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-06 15:43:53 +02:00
Alexander Medvedev
2e643cdeb1 add more packets 2025-07-02 15:48:57 +02:00
unschlagbar
2f5bb83a28 Fixed id parsing & fragmenting work (#994)
* ug

* clippy fix

* i hate clippy

* IOjeliufrhgiufehiuf

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-02 14:28:03 +02:00
4lve
622e2a13d2 Improve chunk generation speed by 5x (#988)
* Fewer locks and limit chunk gen to 2x per core

* remove logs

* Fix server shutdown

* Always use static blockstate

* Remove clone from block

* Fix clippy

* Imporve perf

* Implement FyorDev & MartV0 lookup tables

* Add chunk benchmark (FyorDev)

* fix c

* Fix CI

* fix clippy

* Format

* fix CI fr

* format

* Update benchmark to 1000 chunks
2025-07-02 09:48:36 +02:00
unschlagbar
5dac015dd9 Fixed gamepacket parsing (#987)
* grg

* ef

* gg

* refwd

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-01 21:33:45 +02:00
Alexander Medvedev
e2dec9b5e2 try to implement game packet 2025-07-01 19:44:21 +02:00
unschlagbar
8d934e31c7 First valid Raknet Frame set Packet :) (#983)
* hhlzuui

* gg

* reufef

* fix

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-01 14:04:23 +02:00
Alexander Medvedev
5db9bba5b7 some more bedrock work 2025-07-01 10:13:07 +02:00
Alexander Medvedev
637aada913 More Bedrock work 2025-06-30 23:15:09 +02:00
Alexander Medvedev
e0c91b3edc Initial Bedrock support
You can't join the World, But the base is ready
2025-06-29 00:33:44 +02:00
Arrow
be21e1381c Implement Game Mode Swapping (#922)
* feat: f3+f4 gamemode swapping

* fix: satisfy clippy

* fix: check permissions

* fix: move ChangeGameMode packet handling into its own function

* fix: imports

* fix: cargo fmt

---------

Co-authored-by: arrow <arrow.tsx@gmail.com>
2025-06-26 20:16:40 +02:00
Omar Afet
f92f9f2ad7 Add /tick command (#932)
* Tick Command Implementation

* Send the current ticking state to the new player so they are in sync.

* extend `/tick query` command with performance tracking

* feat: enhance tick sprint reporting and message formatting

* Add suggestion hints for tick command arguments

* fix: update tick command permission level

* fix: resolve clippy pedantic warnings and refactor tick command

- Refactor oversized execute function in tick command into smaller helper methods:
  - handle_query() for query command logic
  - handle_non_sprinting_status() for status display
  - send_percentiles() for percentile calculations
  - handle_step_command() and handle_sprint_command() for respective operations
- Fix format string warnings by using inline format arguments ({tickrate:.1})
- Replace lossless casts (ticks as i64) with From::from() for type safety
- Use Self instead of explicit type name in tick_worlds method signature
- Add Default trait implementation for Ticker struct
- Ensure all match arms return proper Result types

Resolves all clippy::pedantic warnings including too_many_lines, uninlined_format_args, cast_lossless, and use_self violations.

* fix: replace hardcoded tick rate with configurable value from BASIC_CONFIG

* revert back the old comment
2025-06-24 11:30:26 +02:00
Alexander Medvedev
83555e0dee CI: Remove macOS
For some reason it seems that macOS often has their own implementations and causes the CI to fail
2025-06-22 23:28:59 +02:00
Alexander Medvedev
8ebc9ee494 Refactor block default state 2025-06-22 21:28:14 +02:00
Alexander Medvedev
82948f830e Update to 1.21.6 2025-06-17 19:53:33 +02:00
Epix
d55364d66f Move ResourceLocation to pumpkin-util (#910)
* Rename Identifier to ResourceLocation

* Run cargo fmt

* Move ResourceLocation to pumpkin-util

* Remove redundant as_string function

* Run cargo fmt
2025-06-17 15:13:47 +02:00
とぴ。(おーけ
785c840fcb Add Player interact event to the Plugin API (#893)
* Implement player interact event

* Player Interact Event implementation complete

* fmt
2025-06-17 14:36:51 +02:00
Alexander Medvedev
ca5bd549e3 Chunk Feature generation fixes
especially Nether
2025-06-15 15:23:34 +02:00
Alexander Medvedev
c253b0902c fix some CI issues
hopefully...
2025-06-12 20:15:46 +02:00
Laurent Stéphenne
39e78a43fe Sleep and respawn point support (#799)
* Added bed block entity

* Player can sleep

* Format

* Respawn point works

* Clippy

* Added dimension support

* Sleeping works!

* Bed explodes when not in overworld

* Omg there was a packet missing

* Clippy

* Sleeping checks fully working!

* Clippy

* Wrong tick time

* Bruh mb
2025-06-09 16:13:53 +02:00
ioterw
87bb594025 usize crashes my server all the time (#839)
* client id is u64

* item_count is u64

* 32 bit overflow fix in pallete.rs

* removed some scary usize multiplications

* fixed format

* clippy fix
2025-06-08 21:32:15 +02:00
Omar Afet
1e8687a642 Implement Missing (De)Serializations for pumpkin-protocol (#863)
* feat(protocol): Implement char serialization and deserialization

This commit introduces support for serializing and deserializing individual characters within the pumpkin-protocol. Characters are handled as big-endian u32 Unicode scalar values.

Key changes:
- Implemented `Serializer::serialize_char` to write a `char` as a `u32`.
- Implemented `Deserializer::deserialize_char` to read a `u32` and convert it to a `char`, including validation for invalid scalar values.
- Added a new test suite `test_char_reserialize` with cases for ASCII, multi-byte Unicode characters (e.g., 'Ω'), and characters requiring 4-byte UTF-8 representation (e.g., '🎃').
- Corrected warnings related to unused mutable variables in the new tests.

Additionally, to support the testing and building of related crates:
- fix(build): Enabled the `io-util` feature for the `tokio` workspace dependency in the root `Cargo.toml`. This resolved compilation errors in the `pumpkin-world` crate by providing necessary async I/O utilities like `AsyncReadExt` and `AsyncWriteExt`.

* feat(protocol): Implement i128/u128 serialization and deserialization

This commit adds support for serializing and deserializing 128-bit integer types (i128 and u128) in the pumpkin-protocol. These values are written and read as 16 bytes in big-endian order.

Key changes:
- Implemented `Serializer::serialize_i128` and `Serializer::serialize_u128` to write i128/u128 values.
- Added `NetworkReadExt::get_i128_be` and `NetworkReadExt::get_u128_be` for reading these types.
- Implemented `Deserializer::deserialize_i128` and `Deserializer::deserialize_u128`.
- Added new test cases `test_i128_reserialize` and `test_u128_reserialize` to ensure correctness for both positive and negative i128 values, and positive u128 values.

* feat(protocol): Implement unit type (de)serialization

This commit introduces serialization and deserialization logic for Rust's unit type `()` and unit structs.

- `Serializer::serialize_unit` now correctly writes no bytes for unit types, as they carry no value.
- `Deserializer::deserialize_unit` and `Deserializer::deserialize_unit_struct` are implemented to
  consume no input and correctly reconstruct unit types/structs.
- Added `test_unit_reserialize` to verify that serializing and deserializing unit structs, both standalone and as fields within other structs, behaves as expected (i.e., no bytes are written or read for the unit components).

* feat(protocol): Implement enum (de)serialization for all variant types

This commit introduces comprehensive support for serializing and
deserializing Rust enums, including unit, newtype, tuple, and
struct variants.

Key changes:
- `serializer.rs`:
    - Implemented `serialize_struct_variant` to correctly write the
      variant index (as a VarInt) and then delegate to the
      `SerializeStructVariant` trait for field serialization.
    - Implemented `SerializeStructVariant` to serialize individual
      fields of a struct variant.
- `deserializer.rs`:
    - Implemented `deserialize_enum` to use `visitor.visit_enum`.
    - Implemented `EnumAccess` to read the variant index (as a VarInt,
      converted to u32) and deserialize the correct variant.
    - Implemented `VariantAccess` to handle deserialization of
      unit, newtype, tuple, and struct variants.
- `ser/mod.rs`:
    - Added `test_enum_reserialize` to thoroughly test (de)serialization
      of enums with unit, newtype (e.g., `Enum::B(i32)`), and struct
      variants (e.g., `Enum::C { field: T }`).

This ensures that enums with various structures can be reliably
transmitted over the network protocol.

* cargo fmt

* feat(protocol): Implement (de)serialization for tuple structs

This commit adds support for serializing and deserializing tuple
structs within the network protocol.

Key changes:
- `serializer.rs`:
    - `serialize_tuple_struct` in the main serializer now delegates
      to the `SerializeTupleStruct` trait implementation.
    - Implemented `SerializeTupleStruct` to serialize fields of a
      tuple struct sequentially.
    - Updated `SerializeTupleVariant::serialize_field` to correctly
      serialize tuple variant fields.
- `deserializer.rs`:
    - Implemented `deserialize_tuple_struct` to reuse the existing
      `deserialize_tuple` logic, as their serialization format is
      identical.
- `ser/mod.rs`:
    - Added `test_tuple_struct_reserialize` to verify the correct
      (de)serialization of tuple structs.

These changes ensure that tuple structs are handled correctly by the
protocol.

* feat(protocol): Implement (de)serialization for maps

This commit introduces support for serializing and deserializing
maps (specifically `std::collections::HashMap`) within the network
protocol.

Key changes:
- `serializer.rs`:
    - `serialize_map` now requires a known length for the map and
      writes this length as a VarInt before serializing key-value
      pairs.
    - Implemented `ser::SerializeMap` to handle the sequential
      serialization of map keys and values.
- `deserializer.rs`:
    - `deserialize_map` reads the VarInt length prefix.
    - Implemented `de::MapAccess` to deserialize key-value pairs
      according to the read length.
- `ser/mod.rs`:
    - Added `test_map_reserialize` to verify the correct
      (de)serialization of `HashMap<String, i32>`, including
      empty maps and maps with multiple entries.

These changes enable generic map types to be transmitted via the
protocol, with their length explicitly prefixed.
2025-06-08 12:00:45 +02:00
Alexander Medvedev
abccd3f700 add Chunk features (#685)
* inital chunk features

* add more things

great title i know

* add some features

still no result, but we are getting there...

* make it parse

* add simple BlockPredicate

* add simple random selector

* new things

* change stuff

* base tree impl

* change things

* add more heightmaps

* fix master merge

* steps towards proper random

* fix upper level block placement logic

* Make it compile

* fix block dir serde name

* Added Tree Foliage

* more Tree work

* Implement would_survive check

I don't say its good, but it works :D

* Fixed biome placement modifier (#836)

* Implement all tree foliages

* Fix grass, flowers, seagrass, seapickles...

* Add Ores

* add Bamboo, Vine, Spring feature

Also more fixes

* Corals

* Add Tree decoration & more

Many many fixes

* fix vines

* fixed bamboo

* fix some clippy warns

* fix trees outside of chunk

* make it compile again

upsi

* fix clippy warns

* fix InsideWorldBoundsBlockPredicate

* set dirt under tress trunk

dirt, not grass

* more trees work

---------

Co-authored-by: kralverde <github@email.kralverde.dev>
Co-authored-by: Laurent Stéphenne <laurent@guibi.dev>
2025-06-05 17:03:52 +02:00
Alexander Medvedev
68c24366c3 Less unwraps more fun 2025-05-18 18:55:19 +02:00
Alexander Medvedev
705ecfe221 Allow to enter other dimensions
a bit broken though
2025-05-18 14:59:01 +02:00
Alexander Medvedev
06c82c75f0 Multi Dimension refactor 2025-05-15 22:59:00 +02:00
Alexander Medvedev
1edbfa7289 Implement Piston 1/2
Not fully done
2025-05-12 19:42:55 +02:00
Alexander Medvedev
cb51228adb Add Noteblock support 2025-05-11 20:08:32 +02:00
Alexander Medvedev
575f17948f Inline format arguments
Looks much nicer and more readable
2025-05-10 15:22:06 +02:00
4lve
9e36cdf683 Full inventory refactor + barrels (#691)
* replace slot with ItemStackSeralizer

* Dismantle current inv logic

* Disassemble even more, items need fixing markd with TODO: Inv

* Player inventory methods implmented

* make some fields private

* remove invalid comment

* Partial screen handler and slot

* Add armorslot

* prepare for crafting

* implement some more crafting traits

* Fix ItemStack

* Fix pickup and remove faulty crafting (getting reworked in inv revamp)

* fix

* fix error

* add readme

* move readme file

* asd

* remove readme

* add uppsercase readme

* Some more work

* merge

* Move from generics to dynamics

* fix

* move to same impl

* Some changes

* add player open logic

* Basic impl of sync and listeners

* Why did mojang complicate it so much

* bruh

* Simplify things with DefaultScreenHandlerBehaviour

* Implement partial slot clicks

* add

* itemhashes are broken

* Start implementing packets

* fix deadlock

* new vanilla update

* Use static item refs and use Arc Mutex on invs

* working normal click

* fix deadlock

* implement sync handler

* small patch

* Implement quick_move

* Implement Swap click type

* pickup, update bug

* start fixing updates

* fix pickup desync

* Make Inventories non mutexes

* Implement some finishing stuff

* close screen on player leave

* fix pick item

* Move to item hashes

* remove some logs

* begin implementing barrels

* Begin implementing barrel

* implement barrels

* fix clippy + typos

* Fix merge conflicts

* Fix lint error

* don't use unwrap when getting equipment slot

* Fix typo and single threaded

* Accidentally removed tokio completley

* Fix crash when opening barrel holding item

* Add support for marking block entities dirty

* Player Equipment changes

* Make ScreenHandlerFactory own inventory instead of passing in optional

* remove log

* replace todo's

* fix clippy

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-05-09 16:28:15 +02:00
Alexander Medvedev
bfc2f6794a Update typos 2025-05-03 15:56:01 +02:00
Liyan Zhao
3e2ee98a93 Fix chunk loading and light data for vanilla imported save (#754) 2025-05-02 18:53:22 -10:00
Liyan Zhao
a516a68a24 Fix NaN rotation in player move packets (#784) 2025-05-01 20:17:40 -10:00
Alexander Medvedev
c07882369c Update rustyline-async to 0.4.6
This also includes 2 other smaller crate updates, but i wanted just have rustyline-async not using a weird commit, i asked the maintainer of rustyline-async to release a new version, now its released
2025-04-27 10:51:05 +02:00
Liyan Zhao
360b834bcf Revert packet name change from #742 (#768)
* revert: Revert packet name change from 48e2cf6b42

* fix: add comments
2025-04-26 20:31:21 -10:00
unschlagbar
b997687e8b implement Door placement & pumpkin_data changes (#713)
* fix: view distance goes no above 16

* fix: cargo fmt

* removed the floating point conversation

* fixed spelling

* renamed the test for the capacity estimation

* edit: replaced division with bitshifting

* added more ()

* extendet test and fixed missing chunks when the view distance is very low

* added commentar

* fixed door placement & fence connection

* fix linting

* fmt

* fix clippy

* removed useless borrow

* fix all clippy warnings

* bro i changed so much

* added const to fn

* Update block_state.rs

* added bunch of things

* fix

* lol

* fmt

* fix: player is able to place where it stands

* fix: spelling

* upd2

* upd 4

* remove Option types from blockstate

* resolve conflicts

* Update player.rs

* fix

* fmt

* remove uninit

* fix

* resolved conflicts

* fmt

* remove dupe code

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-04-26 10:27:37 -10:00
ht06
0495211744 Finalise the /effect command (#759)
* feat: add amplifier + hide particles (but the infinite time is missing)

* fix effect duration

* /effect give fully work

* feat: add basic remove effect (should work?)

* fix the import of remove_entity_effect packet

* /effect clear fully work + translation ok

* feat: command /effect is now complete

* fix visual bug when the duration is infinite

* Finalization

* Everything work fine now
2025-04-25 09:47:05 -10:00
Alvsch
48e2cf6b42 Fix position desync between clients (#742)
* fix teleport desync

* fix: move to fast desync
2025-04-24 14:38:03 +02:00
Alvsch
7f2c8b73f5 serialize without length prefixes (#748) 2025-04-18 09:27:59 +02:00
4lve
0dd176e8e2 add Block Entities (#737)
* Start implemetnign block entities

* fix

* Move block entites

* bruh wtf

* fix

* Add seralizers for compund

* don't panic on unknown block enity types

* Move block entites to pumpkin-world

* begin implementation

* Chunk packet works

* fix signs

* fix clippy

* merge

* Fix signs

* merge

* fix

* merge

* fix

* remove println

* move folder

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-04-13 16:22:12 +02:00
Alexander Medvedev
929388fc9d added more heightmaps
thanks to kralverde

Co-Authored-By: kralverde <80051564+kralverde@users.noreply.github.com>
2025-04-12 16:52:16 +02:00
4lve
7180ea69ee Remove non-vanilla Slot and replace with ItemStackSeralizer (#726)
* replace slot with ItemStackSeralizer

* Fix ItemStack

* Fix pickup and remove faulty crafting (getting reworked in inv revamp)

* re-add component check

---------

Co-authored-by: kralverde <github@email.kralverde.dev>
2025-04-12 11:28:36 +02:00