* fix(pumpkin): stop entities from duplicating on chunk reload
Entities lived in two places at once: the live World::entities list and the
serialized NBT in the entity chunk's data. On load the saved NBT was turned
into live entities but never cleared, and on unload each live entity was
appended back onto that still-populated list - so the persisted entity count
doubled every load/unload (reconnect) cycle. Freshly spawned entities hit the
same trap: add_entity_silent pushed their NBT into the chunk immediately, so
they were both live and serialized, doubling on the first unload too.
Make the live entity the single source of truth, matching vanilla:
- on load, take (clear) the chunk's serialized entities as they become live,
and restore their persisted UUID so they keep their identity;
- a second watcher of an already-loaded chunk is sent spawn packets built from
the live entities, not the stale NBT;
- entities are serialized fresh, from their current live state, only when their
chunk unloads (save_entity);
- add_entity_silent no longer serializes on spawn.
Because the live entity is serialized fresh on unload, any change made to it
while loaded (health, effects, ...) is persisted automatically, without having
to be written back to the chunk data by hand.
* Move UUID int-array NBT helpers into pumpkin-nbt
Review feedback: the UUID read helper doesn't belong in world/mod.rs.
NbtCompound now has put_uuid/get_uuid for the vanilla 4-int-array
layout, used by both Entity::write_nbt and the entity chunk loader.
Serialized bytes are unchanged.
Add the `broadcast_console_to_ops` configuration option matching
vanilla's `broadcast-console-to-ops` server property. When set to
`false`, suppresses console and RCON command output from being
broadcast to online operators.
- Add `broadcast_console_to_ops` field to `CommandsConfig` (defaults
to `true` for vanilla compatibility)
- Track the setting via an `AtomicBool` in the command module
- Replace hardcoded `true` in `should_broadcast_console_to_ops` for
Console and RCON senders with the configurable value
- Initialize the setting during server startup from advanced config
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
* removed codecs in favor of the `Encode` and `Decode` traits and their derivatives
* placed more exports in the `pumpkin-codecs` lib
* split primitives into their own folder and added some tests
* added `Either` support and added a simple test for it
* fixed linting for tests
* initial commit
# Conflicts:
# Cargo.toml
* implemented more `DataResult` methods
* finished data result struct
* fixed clippy errors
* implemented `map_like` and more `dynamic_ops` methods
* finished most other `DynamicOps` methods
* Fixed doc in get_bytes
* added encoder and decoder files
* fixed some stuff and added primitive codecs
* added some primitive codecs (has errors for now)
* changed the "stream" ops methods
* reworked types of the coders and codecs, added list codecs
* added JSON ops
* fixed list codecs, added some doc test examples in `JsonOps`
* added lazy codecs
* added map encoders, decoders and struct builders
* actually added mapdecoder
* added encoder and decoder transformations
* fixed encoder and decoder transformations and added transformation functions and range codecs
* added field encoders and decoders and separated range codecs
* added field encoders and decoders and separated range codecs
* added BaseMapCodec and SimpleMapCodec
* added struct codecs and moved tests
* added `NbtOps`, unsigned number codec types, range codec tests, a struct test, detailed `Codec` documentation
* added optional field map codecs, the validator function and reworked struct builder functions
* added unbounded map and struct codec tests and reworked validated codecs
* did some visibility refactoring
* fixed some stuff and renamed unsigned number codecs
* fixed formatting
* fixed docs to reflect changes on renaming unsigned number codecs
* fixed validated test
* fixed doctest
* moved base_map_codec and fixed docs about codecs
* fixed some mistakes in the code
* fixed some more mistakes in the code and converted some `DataResult::error` calls to `DataResult::partial_error`
* fixed formatting
* fixed some incorrect docs
* removed `OnceLock`s in `MapCodec`s so they can be used more easily
* fixed transformer codec descriptions, added more `NbtOps` tests and fixed some `NbtOps` list methods
* fixed doctest
* added a fourth specific `NbtOps` test for byte buffers (`ByteArray`s in NBT)
* fixed grammar mistake
* log messages for discarded keys in `create_map`
* use the `tracing` crate for logging
* added a method to allow creating a field using a `MapCodec` reference
* bifurcated `MapCodecCodec`s as well
* removed imports only for documentation and replaced them with intra-doc links
* added additional docs to `optional_field_with_default` and `lenient_optional_field_with_default` Codec methods for additional details on encoding
* renamed crate to `pumpkin-codecs` so that data fixing can be placed somewhere else not frequently used
* fixed some more errors and reworked `nbt_ops`'s `ListCollector` to be like 1.21.11, also allows &str in `DataResult`'s creation methods
* fixed invalid nbt tag for test
* reverted wrapping the tags for heterogeneous elements
* renamed function parameter in `DataResult::apply_2`
* removed unnecessary comment
* fixed a few more issues
* fixed formatting
* fixed another mistake for `DataResult::add_message`
* renamed `DataResult` factory methods to be more idiomatic and removed unnecessary `dyn` method
* removed unnecessary `clone()`
* updated Cargo.lock
* added wrapping, unwrapping tags during serializing/deserializing NBT to/from bytes and added a serialization test
* fixed wrapping check in `wrap_tag_if_needed`
* added wrapped compound to test and renamed `put_component`
* fixed formatting
* fixed comment in test
* fixed test comments
* fix: improve level.dat deserialization for imported worlds
worlds from different minecraft versions could fail to load due to
strict field requirements and missing nbt type support. this makes
level.dat fields default to vanilla values when missing, handles
both string and compound generator settings, and fixes nbttag
deserialization for lists containing compound elements.
* style: run cargo fmt on world_info module
* fix: use int array instead of list for chunk entities
* just get the int array and don't fall back for the list
* update deserialization to use proper NbtTag
* dix deserialization of nbt arrays
---------
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
Registry data is now loaded dynamically for automatic future-proofing, ending the need for manual struct updates. Access to specific values now requires explicit data lookups.
doing `let _ = io::copy(&mut self.reader.by_ref().take(count), &mut io::sink())` was just crazy slow when skipping bytes in NBT, we now instead use `seek`
The Palette was also changed and does not use a HashMap anymore
* feat(player-data): Support saving and loading player NBT Data
* fix(player_data): ensure player data is save before continuing
* fix(player_data): implement NBTStorage for hunger data
* feat(player-data): allow setting world name in config
* fix(player-data): use correct method to retrieve world_name
* feat(player-data): move PlayerDataStorage to pumpkin-world
* fix(player-data): ci not building
* fix(player-data): ci not building
* feat(player-data): support inventory saving + review fix
* fix(player-data): forgot the format
* some fixes
* fix clippy
---------
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
* Major grammar sweep
* Remove extra backtick
* Use more specific terminology for chunk data storage
* Forgor to cargofmt
* Fix typo "thier"
* Fix typo "clousures"
* Try new terminology
* Forgor to cargofmt
* Use "Subchunks" instead of "Heterogeneous" for ChunkBlocks variant
* Fix variable name
* Forgor to change comment