Commit graph

311 commits

Author SHA1 Message Date
Carson McManus 9faac7a0fb
add open_inventory to clients (#119) 2022-10-16 14:12:36 -07:00
Ryan 0e58bfbb77 Remove dbg! macro 2022-10-16 04:13:10 -07:00
Ryan Johnson ad153159dd
Add replaceable boolean to block states (#116) 2022-10-16 03:50:57 -07:00
Carson McManus 59ca1ab573
Set up Inventory module (#75)
This is a very rough version of the inventory module and associated features. This will be a good base to start building something more robust.

- adds a player inventory to all clients
- makes clients keep track of what inventory they have open
- adds very naive state sync for inventories

related: #53 

# Test plans

### Building

1. run `building` example
2. pick any block from creative
3. place it
4. pick a different block from creative
5. place 2
6. break the last one
7. see that both remaining blocks don't become dirt

### Chest inventories

1. run `chest` example
2. sneak to give yourself a stone block
3. open the chest (it's invisible on top of the stone block)
4. place stone in chest
5. see the stone moving around in the chest

## Known Issues

To be fixed in later PRs

- It's very easy to duplicate items if you take the stone out of the chest on the same tick as the server trying to move the item.
- The chest is invisible when you spawn in. It appears if you break it.
- `get_slot` and `set_slot` can panic.
2022-10-15 19:47:02 -07:00
Ryan Johnson f58e6662dd
Add performance tests (#113)
Adds the performance_tests/ directory.

In the future we could use our own fake client software instead of
rust-mc-bot. This would make it easier to run the tests.
2022-10-14 21:18:03 -07:00
Ryan a53738355f Fix bug in ident and use AsRef instead of Borrow 2022-10-13 22:28:12 -07:00
Ryan Johnson 056b4ebd32
Correctly encode biomes (#112) 2022-10-13 18:19:35 -07:00
Sekky61 a29542b467
Dying and respawning (#51)
* `RespawnRequest` client event

* `CombatDeath` packet

* `kill` client method

* `death.rs` example

* clippy lint fix

* Clean up examples

* Fix formatting

* `win_game`, `set_respawn_screen` client methods

* respawn screen no longer deferred
This means that death example does not have respawn screen now.

Co-authored-by: Ryan <ryanj00a@gmail.com>
2022-10-12 11:11:33 -07:00
Ryan Johnson 7d0c254874
Rewrite ident module (again) (#111)
Ident is now a wrapper around any string type `S`.
2022-10-12 03:53:59 -07:00
Ryan afe390836c Remove dbg! calls and make some tweaks to Ident 2022-10-11 14:05:00 -07:00
Zh_Jk e30ed62240
Fix typo in c2s.rs (#109) 2022-10-11 11:12:06 -07:00
Carson McManus a02b657f3c
clamp ItemStack item count to range 1-127 (#110) 2022-10-11 11:10:04 -07:00
Ryan Johnson 23fdc41610
Clean up ident module and add lifetime (#108)
This lifetime will be useful for zero-copy decoding later.
2022-10-11 01:10:49 -07:00
Tert0 c758f70c33
Implement Weather (#106)
* implemented raining, rain level and thunder level

* fix linter and cargo fmt

* removed field from the client, removed weather getters, added docs, ensuring valid rain/thunder level values and sending weather changing directly

* Remove results from `set_rain_level` and `set_thunder_level`

* Remove unused import

Co-authored-by: Ryan <ryanj00a@gmail.com>
2022-10-09 15:18:15 -07:00
Carson McManus 0652fa13a4
change Slot enum into alias of Option<ItemStack> (#107) 2022-10-09 12:38:00 -07:00
Ryan 82323eaa12 Clarify top-down modules guideline and remove "separate data and functions" guideline. 2022-10-08 19:51:01 -07:00
Ryan c214ffc262 Tweak CONTRIBUTING.md 2022-10-08 18:42:02 -07:00
Ryan Johnson f26f4be1fe
Add link to CONTRIBUTING.md in README.md 2022-10-08 18:08:48 -07:00
Ryan Johnson b0646a5398
Create CONTRIBUTING.md 2022-10-08 18:06:05 -07:00
Daniel Huth e13d0ffe7a
Skip spawn of non visible player characters (#100)
* Skip spawn of non visible player characters
* Don't spawn player if player list is `None`

Co-authored-by: Ryan <ryanj00a@gmail.com>
2022-10-08 15:12:30 -07:00
Ryan Johnson 153cde1a04
Chunk Rewrite With Paletted Containers (#91)
The current approach to managing chunk data is misconceived. This new approach uses genuine paletted containers and does not suffer from complexities caused by caching. As a result, memory usage (according to htop) in the terrain example with render distance = 32 has gone from 785 megs to 137 megs. That's 17.4% of the memory it used to use. Terrain generation speed was not affected.
2022-10-07 15:52:55 -07:00
Ryan 5a686a0e8b Derive terrain seed from current day
It's easier to test things when the terrain isn't constantly changing.
2022-10-07 00:17:14 -07:00
Ryan 886d036b97 Use valence.rs domain in extractor package 2022-10-06 13:49:30 -07:00
Ryan 1fcc5bd527 Set player head yaw when spawning 2022-10-05 15:02:40 -07:00
EmperialDev 1f996f7549
Add Items (#92)
Adding all the items, just like the blocks are. This will adress 1. and 2. bullet from issue #53
This will also make it easier to convert between block <-> item.
2022-10-05 09:28:08 -07:00
Ryan e985bae469 Use StatusCode in auth server response check 2022-10-04 23:35:34 -07:00
Ryan b330f97642 Remove top level object from enchantments 2022-10-04 23:16:48 -07:00
Ryan Johnson 85cc3a28ea
Add --workspace flag to commands in CI (#101) 2022-10-04 02:12:32 -07:00
Terminator b83b9f76ed
Expose enchantments to Rust (#99)
* Expose extracted enchantments to Rust.

* Give enchantments a `level: i16` field.

* Update enchantment derive impls

* Restructure how enchants are exposed to Rust through C-like enums

* Update build/enchant.rs

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>

* Update build/enchant.rs

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>

* Move enchantment sources to their own struct.

* make id() function return it's discriminant instead of matching

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
2022-10-03 13:19:42 -07:00
Ryan cf5b9136df Bump valence_nbt version in valence 2022-10-01 15:47:59 -07:00
Ryan f94c50bfd3 Change valence_nbt repository link 2022-10-01 15:38:14 -07:00
Ryan Johnson 2cd8bd2195
Replace HashMap with BTreeMap in valence_nbt (#98)
* Replace HashMap with BTreeMap in valence_nbt

Turns out that `BTreeMap`s are a bit faster when the element count is low.

This change also makes debugging compounds a bit easier since the elements are displayed in sorted order.

* Simplify read_list function slightly
2022-10-01 15:36:04 -07:00
Ryan Johnson 9c62bc1b90
Move valence_nbt to main Valence repo. (#97)
This also adds another check in CI
2022-10-01 14:18:42 -07:00
Terminator ef64296159
Implement prevent-proxy-connections
This adds the `prevent-proxy-connections` server property and implements it into valence.

Note that if the server is in offline mode, this changes nothing.

By default, proxy connections are allowed.

Fixes #95
2022-10-01 10:42:43 -07:00
Terminator 838a75d2f9
Add basic enchantment extraction (#93)
* Add basic enchantment extraction

* Change source format to individual fields rather than a list

Co-authored-by: Terminator <terminator@nonexistent.com>
2022-09-29 12:34:44 -07:00
Ryan Johnson 94cfc41486 Fix formatting 2022-09-28 00:23:14 -07:00
Ryan Johnson 77df8b668d Fix nightly clippy lints in build/entity.rs 2022-09-28 00:17:43 -07:00
Carson McManus 46b62f29a8
add readme for extractor (#90) 2022-09-27 16:22:28 -07:00
Carson McManus dfce70ef5c
check gradlew for the extractor into git (#88)
This is how it's intended to be used. See https://stackoverflow.com/questions/20348451/why-should-the-gradle-wrapper-be-committed-to-vcs
2022-09-27 13:06:34 -07:00
Ryan Johnson a623c9b1f0 fix formatting 2022-09-26 22:32:04 -07:00
Ryan Johnson ca89140ebe rustdoc checks to github actions 2022-09-26 22:30:42 -07:00
Ryan Johnson 25e99a4133 Fix SetTitleAnimationTimes doc link 2022-09-26 21:08:37 -07:00
Ryan Johnson 82152c5e5d More docs on protocol module 2022-09-26 21:08:17 -07:00
Carson McManus 47538ea05c
Refactor Slot (#87)
* create ItemStack type

* move slot back into protocol

* change DropItemStack to use ItemStack, because it's imposible to drop nothing
2022-09-26 20:44:06 -07:00
emortal 2044add969
Create parkour.rs example (#28) 2022-09-24 19:40:10 -07:00
Ryan 1dc5d84ba9 Add biomes example (which is currently broken due to bugs in chunk module) 2022-09-23 19:10:11 -07:00
Ryan 28b26b2aae Reorganize registry codec stuff and fix some bugs 2022-09-23 04:51:26 -07:00
Ryan Johnson 36b63e777e
Replace serde_nbt with valence_nbt (#80)
valence_nbt has a much nicer API and avoids the complications brought by integrating with serde. valence_nbt also fixes some bugs and is 3x faster according to benchmarks.
2022-09-23 04:03:21 -07:00
Ryan cc9cd0be2d Use exact versions of dependencies in Cargo.toml 2022-09-22 17:00:02 -07:00
dani162 eed39364df
Set time of day #55 (#76)
* Set time of day #55

* fix typo

* Update src/client.rs

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>

* format file

Co-authored-by: Ryan Johnson <ryanj00a@gmail.com>
2022-09-21 15:12:31 -07:00