Commit Graph

1163 Commits

Author SHA1 Message Date
Alexander Medvedev
94572d1878 Fix https://github.com/Pumpkin-MC/Pumpkin/issues/628 2025-03-13 19:22:58 +01:00
kralverde
300ccde108 ChunkIO api and world saving optimizations (#624) 2025-03-12 08:40:53 -10:00
Florian Lang
2bc19bacb5 Fix order of explosion block handling that droping and explotion of blocks work (#620)
* fix: explosion set block_state to 0 after drop and explode

* fix: load block before setting block_state to handle drop and explode of block after
2025-03-12 08:15:04 +01:00
vyPal
f0bdfc943e Add more events to the Plugin API (#552)
* Add PlayerChangeWorld event

* Fix docs

* Add PlayerGamemodeChange event

* Add PlayerLogin event

* Fix clippy

* Fix docs

* Add PlayerChat event

* Fix some event impls

* Post-merge issues

* Add PlayerCommandSend event

* Fix PlayerCommandSend event

* Fix PlayerLogin event docs

* Add PlayerMove event

* Implement PlayerCommandSend event

* Implement player position sync when move event cancelled

* Add PlayerMove event to handle_position_rotation

* Fix docs

* Implement PlayerTeleport event

* Add ServerBroadcast event

* Fix some event impls

* Add ServerPluginEnable event

* Add ServerPluginDisable event

* Implement plugin enable/disable events

* Add ServerComand event

* Fix clippy

* Add teleport method to player

* Fix player teleport event impl

* Fix imports

* remove not needed clones

* Fix clippy

* Fix formatting

* Respect server.defaultgamemode

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-03-12 08:14:40 +01:00
Alexander Medvedev
b8810e8102 Merge pull request #623 from vyPal/api-macros-unsafe-mangle
Fix other no_mangle
2025-03-11 12:21:00 +01:00
vyPal
243258f1c4 Fix other no_mangle 2025-03-11 11:44:22 +01:00
Alexander Medvedev
900e81301e Merge pull request #622 from vyPal/api-macros-unsafe-mangle
Add the unsafe attribute to no_mangle in plugin method generation
2025-03-11 11:18:43 +01:00
vyPal
54b1bf1759 Add the unsafe attribute to no_mangle in plugin method generation 2025-03-11 11:01:32 +01:00
4lve
eb27cfa16a Generate Blocks and Properties Revamp (#613)
* Add block builder

* Implement loot tables

* chaos snapshot

* LFG

* add oak fence

* lever facing

* Add trait for CardinalDirection

* fix clippy

* fix clippy

* reimplement partial state of loottable

* Implement neighbor block updates

* add oak door

* Fix crash on invalid state

* Fixes

* Add fences

* Add doors

* Refactor how we handle block properties when implemented in many places

* Remove old loot_table, moved to block generation

* Better Block Properties

* Add fence gates

* Update block_grouper and add logs

* Build tags instead and make it easier to define variants of blocks

* Save block states

* Allow nether fences to connect with fence gates

* Move away from hardcoded property names

* Clean up property remaps

* start refactor of blocks

* refactor block compile build

* refactor name map for property groups

* Make it so fences can't connect to the air part of a fence gate

* Use extractor instead of hard coded property names

* to_value and from_value should be stripped of "L" prefix

* Prefix isn't used anymore

* use hashes to verify uniqueness

* Don't declare IntProvider twice and fix typo

* remove some comments that don't apply anymore

* Move loot table so it's shared

* Futureproof Loot Tables

* Implement BlockStateProperty condition for LootTables

* Move experience to pumpkin_utils

* Add is_liquid

---------

Co-authored-by: kralverde <github@email.kralverde.dev>
2025-03-10 18:06:44 +01:00
Pastel de N4ta
26f822ba92 Change velocity to include y and z for respective vector fields (#615) 2025-03-09 11:45:34 +01:00
Mili
8a29f1e95f Implement Bulk Loading/Writing for Chunks (#535)
* feat: add linear chunk format with zstd lib dependency

* fixing a typo

* refactor: rename file handling methods for clarity and more lint fixes

* refactor: improve clarity on validation methods

* fix: invert version check in LinearFile header validation

* fix: remove leading dot from file path formatting in LinearChunkFormat

* refactor: improve error handling and method naming in LinearFile operations

* fix: ensure file is flushed after writing in LinearFile operations

* fix: lints and warnings

* fix: more lints

* refactor: streamline LinearFile structure and improve header management

* refactor: change chunks_headers to use Box for improved memory management and use exception to know if file exist

* refactor: update path parameter types to PathBuf for consistency and improved usability

* refactor: update path parameter types to Path avoiding uknown changes and adjust file truncation logic

* fix: avoid using the same path for different tests

* fix: fix some bytes sizes for the header based on the spec

* refactor: enable file truncation when opening for writing and simplify save method

* fix: removing IoSlices for windows issues.

* fix: clippy lints

* refactor: improve incompatible files cheking, some documentation and variable nameing

* feat: add file_format to ChunkConfig and implement format handling in Level

* feat: add error logging for invalid file headers and data size checks in LinearFile and tmp filenames on write

* feat: implement file locking mechanism for concurrent chunk read/write operations

* fix: bug at desserializing the chunks headers.

* feat: (Bulk API) refactor chunk reading and writing to handle multiple chunks at once

* refactor: streamline chunk reading and writing methods, improve chunk management logic

* feat: enhance chunk reading and writing to support bulk and improve concurrency

* feat: add file locking during chunk writing to ensure safe concurrent access

* fix: resolve some issues with the merge

* fix: update chunk header size calculation in linear chunk parsing

* refactor: optimize chunk processing and improve concurrency handling

* feat: implement chunk I/O management with file locking for safe concurrent access

* refactor: simplify public load method and fix clippy issues

* feature: add file cache for files with ongoing IO ops

* refactor: update LoadedData enum variants for consistency and clarity and include docs.

* refactor: restore compression enum and replace ChunkSerializingError with ChunkWritingError for improved error handling

* refactor: enhance chunk cache cleaning logic and improve logging during chunk fetching

* refactor: optimize chunk data handling with parallel processing and improve chunk fetching logic

* fix: lints and logging

* fix: correct typo and import format

* refactor: anvil code organization and llinear chunk reading code.

* fix logging issue and refactor some locks bindings

* refactor: reduce chunk cloning, ensure drop bindings/guards

* refactor: reduce some threading overhead when not needed

* fix: clippy lints

* refactor: simplify chunk data processing in Anvil and Linear serializers

* fix: clippy lints rust 1.84.1 to 1.85.0

* add file drop guard and rework some logic

* refactor: improve AnvilChunkFile and AnvilChunkData serialization logic and docs

* fix: typos

* feature: initial async implementation of  Bulk API

* fix: chunk writing with async read

* refactor: improve async handling and use asyn IO for reading files

* fix: sorry i delet a mod xd

* refactor: enhance chunk management with async locks and OneCells

* use async methods where avaliable and stream chunks instead of collecting them

* refactor: streamline chunk management by removing unnecessary mutex and optimizing cache cleanup

* Split data

* Move format related stuff from chunk

* refactor: decoupling Serializer from ChunkIO and reduce CPU usage by 25%-50% when flying as spectator at max speed

* refactor: imrpove CPU usage marking Heavy CPU tasks with tokio block_in_place and improve Docs/Comments

* refactor: improve linear format performance and imrpove some localize tokio::block_in_place for compression and uncompression in both formats, also for serialization and deserialization

* Remove parking_lot dependency from Cargo.toml

* feat: add futures crate for improved async handling and performance optimizations

* refactor: change some comments about blocking (not needed with futures::future::join_all) and zstd compression concerns

* refactor: remove unnecessary blocking in AnvilChunkFile methods for improved performance

* refactor: change receive_chunks parameter from slice to vector for improved flexibility

* fix: add timestamp tracking for chunk updates

* refactor: remove async_trait usage from chunk serializers

* fix: handle potential errors in chunk decompression and parsing

* fix: prevent parsing of empty chunks by updating condition for sector offset and count

* fix: improve dashmap reference management

* dont log if chunk does not exist and tweak help functions

* refactor: reduce CPU and Memory usage while improving Chunk Generation performance and reducing code complexity.

* fix: improve logging for file operations and ensure proper lock management during closure

* fix extra log

* fix: chunk generation threading issue (not using rayon spawn) and a emory leak in the level cache cleanup

* fix: handle expected chunk reading errors without logging as failures

* feat: add intial benchmark for chunk I/O performance and update criterion dependencies

* remove panic for bad chunk return

* refactor: comment out benchmark code for test without BulkAPI PR

* Refactor benchmarking code and remove unused chunk_io benchmark

* fix: remove dummy benchmark file and using paths/files instead of temp dirs

* refactor: update benchmark to re-instanciate the level on each iteration avoiding caching

* fix: clippy lints and add comments

* fix: correct chunk count logging in benchmarking tests

* refactor: replace hardcoded channel size with a constant, print seed used, add one more size to bench.

* use bytes for anvil and stream deserialization

* re-add streaming w/ capacities

* tweak rayon threads

* fix deadlock, max concurrency, box chunks early

* add parallel benchmarking for chunk read/write operations

* work on chunk batching

* add chunk batching

* fix chunk batching

* add comment to lru cache

* fix test

* fix spelling

---------

Co-authored-by: Mili <santiagoogle@hotmail.com>
Co-authored-by: kralverde <github@email.kralverde.dev>
Co-authored-by: suprohub <suprohub@gmail.com>
2025-03-06 08:26:52 -10:00
Alexander Medvedev
aa9de86d4e Update README.md (#614) 2025-03-06 16:35:54 +01:00
Alexander Medvedev
081bdbbbaa Added Stop Command 2025-03-05 23:06:33 +01:00
kralverde
7a4b46f51b pumpkin-world: panic on chunk invokation not creation (#611) 2025-03-05 20:43:19 +01:00
Alexander Medvedev
5dd79329c6 Fix CI after rustup 1.28 (#608) 2025-03-04 22:19:30 +01:00
Alexander Medvedev
b41d8bed94 add put_string and put_list in pumpkin-nbt 2025-03-04 20:28:22 +01:00
Alexander Medvedev
e055dd740c Check if player can destroy block using an tool
Prevents players to destroy blocks when holding a sword or trident in creative
2025-03-04 19:45:39 +01:00
Alexander Medvedev
cccdf53e7c Add Multi noise (#597)
* Copy @urisinger work

* Fix compile time errors

* fix clippy
2025-03-04 10:07:06 +01:00
dependabot[bot]
a9bfd1316b Bump crate-ci/typos from 1.29.9 to 1.30.0 (#606)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.29.9 to 1.30.0.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.29.9...v1.30.0)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-03 10:53:38 +01:00
Alexander Medvedev
3e0c8da7db fix typos 1.30 warns 2025-03-03 09:49:25 +01:00
kralverde
7b27da995f Chunk io benchmarking (#601) 2025-03-02 07:41:23 -10:00
Alexander Medvedev
be44ccc8df Don't require server when spawning a entity
Makes it much simpler
2025-03-02 16:05:31 +01:00
ht06
52e48ec0bd Add /defaultgamemode command (#588)
* Add Defaultgamemode command

* add force_gamemode in configuration.toml
Check if the force_gamemode is enabled while doing the command

* Delete useless import + adapt to the new TextComponent::translate.

* add a space...

* Save the default gamemode in the server

* refactor + delete a .clone

* Add #[must_use]
2025-03-02 15:02:11 +01:00
Alvsch
85d457fa88 rename rayon worker threads (#603) 2025-03-02 14:52:53 +01:00
Alexander Medvedev
440008fe0a Use Loot tables for blocks (#605)
* more loot table work

* make Loot Tables work
2025-03-02 14:49:53 +01:00
kralverde
d518732a76 Fix dupe, double click, and shift click (re-PR) (#591)
* Fix dupe, doubble click and shift click

* Fix inventory desync

* Fix clippy

* refactor magic numbers

* fix clippy

* refactor item logic

* fix inventory

* prefer main inventory over offhand

* Set slot stack to None if empty

* fix container deadlock

* fix linter

* fix lint pt 2

---------

Co-authored-by: 4lve <72332750+4lve@users.noreply.github.com>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-03-01 08:09:14 -10:00
Alexander Medvedev
a60a3ba243 Add Experience Orb and drop it when breaking Blocks 2025-03-01 16:58:02 +01:00
Alexander Medvedev
27f239a612 Living Entity: Proper death
Now we wait until despawning the entity so the death animation is played
2025-02-27 22:51:49 +01:00
Toyo
d827f68826 README: Specify features state (#598)
* Order completed to be up

Make completed features on top and unfinished below

* Group similar features

* Add features and mark if completed

Basically we have:
(W.I.P): The feature is there but is not behaving as intended.
Checkmark: The feature works as intended, it could be improved but it works.
No checkmark: The feature does not exist and will not work nor do anything.

* config is not wip
2025-02-27 16:42:05 +01:00
Alexander Medvedev
fe400e4970 Make non living entities not attackable
Adds a cool abstraction to progress damage, Now implementing End Crystals should be very easy
2025-02-26 22:48:19 +01:00
Alexander Medvedev
01e5719464 Make SChatMessage sendable 2025-02-26 19:41:46 +01:00
Alexander Medvedev
b336a50955 Batch CSetEntityMetadata data
Allows us to send multiple meta in only one Packet
2025-02-25 23:21:59 +01:00
kralverde
0f6c7aed73 fix resource leak (#593) 2025-02-25 11:34:33 -10:00
Alexander Medvedev
9a1add029f Fix Explosion block sounds 2025-02-25 22:27:02 +01:00
Alexander Medvedev
8aef30ee13 Make TNT Work (#590)
* make tnt work

* Spawn TNT at right position

* Fix tnt
2025-02-25 16:38:12 +01:00
kralverde
7c3487e9c1 revert resource pack names (#587) 2025-02-24 06:17:45 -10:00
dependabot[bot]
0bbb7f7823 Bump crate-ci/typos from 1.29.7 to 1.29.9 (#586)
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.29.7 to 1.29.9.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.29.7...v1.29.9)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-02-24 07:51:30 +01:00
Luís Tavares
110ba3ad94 fix docker logger (#580) 2025-02-23 14:40:58 -10:00
Luis
160d98d5c7 fix: encode Uuid correctly (fixes #454) (#583)
* fix: encode Uuid correctly (fixes #454)

* chore: use default implementation for #is_human_readable

* chore: override #is_human_readable to always return false

* fix resource packs

* fix spelling

---------

Co-authored-by: kralverde <github@email.kralverde.dev>
2025-02-23 13:09:41 -10:00
kralverde
cc9d0a8a63 Merge pull request #563 from kralverde/clean_logger
Clean our logger interface slightly
2025-02-23 07:42:38 -10:00
Alexander Medvedev
7c1d5eff4c Implement ServerPacket for CPlayerPosition 2025-02-23 14:35:02 +01:00
Alexander Medvedev
f45991a717 pumpkin-protocol: make more fields public 2025-02-23 14:23:06 +01:00
Alexander Medvedev
26b69eae33 Minior packet changes 2025-02-23 13:35:22 +01:00
kralverde
2323c60a54 merge master 2025-02-22 22:03:15 -10:00
suprohub
f71ec64e22 removes unused dependency uuid in pumpkin-utils (#578) 2025-02-22 16:48:25 +01:00
Alexander Medvedev
995edfb3c2 Add Effects 2025-02-22 14:17:06 +01:00
Jayryn
0fb1b76ea7 Fix tool rules: Ensure get_speed and is_correct_for_drops check for tags (#566)
* fix(tool-rules): ensure `get_speed` and `is_correct_for_drops` check for tags

Both functions were ignoring tags (`#tag`), causing incorrect default values.
- Now correctly checks tags before returning speed or drop validity.
- Ensures tool rules work as expected for both direct and tagged block matches.

* Make Clippy happy and use strip_prefix

replace manual stripping with strip_prefix

* Make clippy happy and use strip_prefix

Make clippy happy and use strip_prefix instead of manual stripping. Also removing unnecessary reference

* cargo: fmt

---------

Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
2025-02-22 14:04:49 +01:00
Toyo
2af2fbbf73 README: Add more to the To-Do (#569)
* Add more to the To-Do

Added biomes, vegetation, player data saving, off hand, advancements, villagers and mobs inventory as objectives in the to-do

* Remove stack limits from the to-do
2025-02-21 09:42:40 +01:00
Alexander Medvedev
1f414f347c Support dropping items out of Inventory 2025-02-20 21:50:59 +01:00
Alexander Medvedev
1fb2be46d4 Update to Rust edition 2024 2025-02-20 18:42:20 +01:00