feather-rs / feather

A Minecraft server implementation in Rust
Apache License 2.0
2.63k stars 143 forks source link

Refactor such that libcraft contains all generated files (almost). #461

Closed Miro-Andrin closed 3 years ago

Miro-Andrin commented 3 years ago

Moved generated code into libcraft.

Status

Description

I have moved the code from feather/generated into libcraft/generated and made everything depend on that version instead. I have not moved feather/blocks into libcraft, but might do that in a different pull request.

Related issues

459

What's missing in this pull request:

ItemStack in libcraft was different in libcraft then in the original generated module. I have no idea why. The original version allowed for ItemStacks containing zero items, but the new version does not. This broke a lot of small things, but especially feather/common/window.rs. I tried to quickly adapt it to the new ItemStack methods in libcraft, but i have not gotten it to work. It compiles, but the test don't pass .

Checklist

Miro-Andrin commented 3 years ago

My bad hygiene when doing commits has bitten me in the ass. So it's a very messy commit history, but currently the code is in a finished state.

Things that we did:

Moved /generated into /libcraft by moving most of the generated files into feather/core
and the generators into /libcraft/generators. All the generators have been updated
such that they pull data from the right folder and output to were I moved the generated
files. 

All files in /feather that had 'use generated:{...' now point to an equivalent file 
in /libcraft. This went mostly without any issues. 

ItemKind and ItemStack had a version in /generated and /libcraft. The ItemKind was identical, but the ItemStack in libcraft had a difference. The libcraft version does not allow for the creation of a stack containing zero items. Therefore every case where feather used the old ItemStack was a bit tricky. 

My guess is that someone was in the middle of moving the code to the libcraft version, but just stopped for some reason. The function bodies in /feather/common/src/window.rs had to be completely rewritten, and the InventorySlot struct had to fleshed out as well in libcraft.