Commit Graph

458 Commits

Author SHA1 Message Date
Noah
2c192b5689 add requested targets 2024-08-31 11:53:45 -04:00
Snowiiii
e4fd015265 Fix .gitignore 2024-08-31 11:48:34 +02:00
Snowiiii
ee4e18282e Support multiple worlds
- We moved all players to seperate worlds. This will save performance when many different players are on different worlds. The only thing broken now are commands because of async stuff
2024-08-31 11:39:59 +02:00
Alexander Medvedev
6a45746703 Merge pull request #66 from kralverde/xoroshiro
implement xoroshiro128 RNG
2024-08-30 17:53:14 +01:00
Snowiiii
f45ebb2d4f Cache: Chunks 2024-08-30 18:42:54 +02:00
lukas0008
ab73f3a3a4 Cargo fmt 2024-08-30 18:00:23 +02:00
lukas0008
8bb00e26be Make ChunkData use Vector2 instead of ChunkCoordinates 2024-08-30 17:40:55 +02:00
lukas0008
5f05a1886b Change coordinates, and add .get_block to ChunkBlocks
- Renamed ChunkRelativeScalar to ChunkRelativeOffset
- Added more traits to Height and ChunkRelativeOffset
- Added .get_block to ChunkBlocks
2024-08-30 15:07:54 +02:00
lukas0008
0c79d38de9 Update .gitignore 2024-08-30 14:46:49 +02:00
kralverde
fea3cf7ad1 refactor and verify 2024-08-29 18:25:02 -04:00
Snowiiii
3cc0c9a52a Broadcast Sneaking/Sprinting
For some reason Sneaking "partially" works. Only the player names becomes darker when sneaking but the actual pose does not change. Weird
2024-08-29 22:43:43 +02:00
Snowiiii
7ed46e25a0 Add EntityPose 2024-08-29 17:35:49 +02:00
kralverde
df92b5fbcf verify originals were not mutated 2024-08-28 23:44:21 -04:00
kralverde
21c7c2c04c tweaks 2024-08-28 23:26:56 -04:00
kralverde
0a351171c6 implement xoroshiro128 RNG 2024-08-28 19:16:22 -04:00
StripedMonkey
3159e61c05 create rust-toolchain.toml 2024-08-28 18:56:35 -04:00
Snowiiii
443febefdb Update README.md 2024-08-28 19:04:31 +02:00
Alexander Medvedev
94f1e21dec Create FUNDING.yml 2024-08-28 18:59:56 +02:00
Snowiiii
c36b6d3464 Less unwraps 2024-08-28 18:52:30 +02:00
Alexander Medvedev
0ba9b37048 Merge pull request #63 from DaniD3v/master
Superflat Worldgeneration
2024-08-28 16:44:28 +01:00
DaniD3v
ff06d05487 Made ChunkNBT struct slightly more readable 2024-08-28 17:35:01 +02:00
DaniD3v
e2d2b53f41 Fixed bug where whole chunk can break in one mined block 2024-08-28 17:34:56 +02:00
DaniD3v
112a899559 Added logic to generate chunks if they can't be read from the world file.
Moved warning about ./world folder to only appear when necessary +
Updated warning contents to reflect changes

Made the save_file in the `Level` struct optional
in case someone wants an entirely generated World.

Removed now redundant asserts.
2024-08-28 17:34:47 +02:00
DaniD3v
43c724dec7 Added Superflat implementation. 2024-08-28 17:34:37 +02:00
DaniD3v
9149e82508 Added WorldGenerator traits and a GenericWorldGenerator. 2024-08-28 17:28:48 +02:00
DaniD3v
4031c4dc13 Added Seed Type. 2024-08-28 12:52:26 +02:00
DaniD3v
eb4d47aa74 Added an Enum for Biomes 2024-08-28 12:52:26 +02:00
DaniD3v
b5b27885c7 Added ChunkStatus to check if a chunk is fully generated yet.
When loading a partially generated world there's some
incomplete chunks that might not have a heightmap yet.

If that is the case we return a ChunkNotGeneratedError
to indicate that it's ok to (re-)generate it.
2024-08-28 12:52:26 +02:00
DaniD3v
17b285081a Refractored read_chunk
Added new error types to indicate a chunk should be generated.
Renamed to `fetch_chunks` to indicate that it no longer just reads chunks (might write to the worldfile in the future)
Take a reference to a slice instead of an owned vector because the data is Copy anyways.

Remove the ChunkCoordinates that are sent over the mpsc Sender.
- The coordinates are stored in ChunkData anyways.
- If there is an Error the coordinates should not matter because the error can't be recovered from.

Moved the reading from file logic to `read_chunk`.
- So that we don't always have to repeat `channel.blocking_send(...); return;`
- To make it clearly distinct from the main program logic.

Replaced some verbose match statements with `Result.map_err()`.
2024-08-28 12:52:26 +02:00
DaniD3v
cdb0e6b761 Refractored coordinates.rs 2024-08-28 12:52:26 +02:00
DaniD3v
cf283323fc BlockId refactor.
Moved `BlockId` to it's own file.
Prefixed all of the `block_registry` types with Registry to avoid confusion.
Made stuff that should not be public private.
2024-08-28 12:52:19 +02:00
DaniD3v
bef3ddef50 Replaced redundant .map with .for_each 2024-08-28 12:52:19 +02:00
DaniD3v
a8d9c89da2 Implemented Default for ChunkHeightmaps and ChunkBlocks 2024-08-28 12:52:19 +02:00
DaniD3v
52c34caaa6 Added ChunkBlocks abstraction for ChunkData
ChunkBlocks makes it easy & safer to access blocks of a chunk.
It also makes it possible to consistently handle the heightmap updates in 1 place.
2024-08-28 12:52:07 +02:00
DaniD3v
1d1dd2ed6c Added consts CHUNK_AREA, SUBCHUNK_VOLUME and CHUNK_VOLUME, 2024-08-28 12:52:07 +02:00
DaniD3v
4565133ef5 Refractored ChunkData::from_bytes
Simply count blocks instead of doing some complex operation with k/j/i
Marked comment with TODO
Replaced if/else condition with std::cmp::max
Removed some redundant `.enumerate()`s
2024-08-28 12:52:07 +02:00
DaniD3v
fe56d32463 Renamed block_size to block_bit_size for readability 2024-08-28 12:52:07 +02:00
DaniD3v
33ec123148 Added BlockIdentifierNotFound Error to differentiate from BlockStateIdNotFound 2024-08-28 12:52:07 +02:00
DaniD3v
43164ee4f1 Added abstraction for BlockId
`i32` is really ambiguous and it is not immediately obvious what it is supposed to represent.
`BlockId` is much more readable.

Changed internal type to u16 because we currently have ~30k/64k block states.
(and i32 doesn't make a lot of sense for an Id, except when replicating mojang behavior)
2024-08-28 12:52:07 +02:00
DaniD3v
5a21a687d8 Block structs refractor + added comments
renamed a few fields for clarity.
added examples for fields that might not immediately be obvious.
removed some `Option`s that are not necessary.

renamed `BlockElement` to `BlockType` because you could mistake
`BlockElement` for the main way to represent a Block (e.g. in Chunks).
2024-08-28 12:52:07 +02:00
DaniD3v
03fcdc2e32 Imported serde::Deserialize to avoid spelling it out frequently. 2024-08-28 12:52:07 +02:00
DaniD3v
a0260acd8b WORLD_Y_START_AT refactor
Renamed `WORLD_Y_START_AT` to `WORLD_LOWEST_Y`.
Added `WORLD_Y_END_AT`.
Changed the type to i16 for ergonomics.
Moved the constants under the use statements for readability.
2024-08-28 12:51:43 +02:00
DaniD3v
be98a730b0 Added abstraction for coordinates.
These ensure that there aren't any out of bound values
and make the code significantly more readable
2024-08-28 12:38:22 +02:00
Snowiiii
3b438872a8 Add pumpkin-plugin
mhh, Whats that?
2024-08-27 22:47:21 +02:00
Alexander Medvedev
8e9ea66787 README: Change run command
I still like to use target-cpu=native. The problem is that there is no cross platform way to the the env var RUSTFLAGS. I also don't want to have a script for that
2024-08-27 16:17:59 +01:00
Snowiiii
65d8093694 Add PlayerAbilities 2024-08-26 22:21:02 +02:00
Snowiiii
80ffaff777 Update deps 2024-08-26 17:06:15 +02:00
Alexander Medvedev
52ffec0dd3 Merge pull request #61 from neeleshpoli/master
Implement Use Item (packet id 0x39) packet
2024-08-25 21:48:23 +01:00
Snowiiii
9d6c8dc524 Check block distance 2024-08-25 19:16:38 +02:00
we sell insurance
983ede2ef6 Create function for packet handling 2024-08-25 10:52:20 -05:00