Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Port to Fabric #144

Closed
wants to merge 32 commits into from
Closed

[WIP] Port to Fabric #144

wants to merge 32 commits into from

Conversation

hanbings
Copy link
Contributor

@hanbings hanbings commented Jun 30, 2023

#117

There is still a lot of work to be done. This PR is to keep in sync with the upstream code. Review work needs to be postponed a little longer. Sorry for taking so much time.

Basic Information:

Target game version: 1.20.1
Fabric Loader version: 0.14.21
Fabric API version: 0.83.0+1.20.1

Progress:

Basic

  • build system
  • configuration file.

Database

  • Mysql
  • Redis

Events

  • player joins the game
  • player quit the game
  • player death
  • server saved world
  • projectile
  • player drop
  • player pick
  • player interact
  • player place block
  • player break block
  • open the Inventory
  • hurt
  • command

Data

  • Serialization and Deserialization
  • Code for Platform Setup and Get Data Objects (FabricPlayer.class) partially done

API No plans yet

Migration tool No plans yet

Analytics

  • Plan Analytics

Currently encountered problems:

  1. The current Bukkit platform code uses Bukkit's Serializer tool, which has some special behaviors for Bukkit serializable classes, which are difficult to implement on the Fabric platform.
  2. There is a lot of code for Setter Getter behavior in a partial class file, considering using Lombok to simplify the code? (this is just my personal suggestion)
  3. Fabric Loom requires Gradle 8.0 or higher, currently upgraded to 8.1.1.

@hanbings hanbings changed the title [WIP] Port to Fabric [WIP] Port to Fabric https://github.com/WiIIiam278/HuskSync/issues/117 Jun 30, 2023
@hanbings hanbings changed the title [WIP] Port to Fabric https://github.com/WiIIiam278/HuskSync/issues/117 [WIP] Port to Fabric Jun 30, 2023
@WiIIiam278 WiIIiam278 added status: in progress This issue is in progress type: feature request This issue is about a new feature or request labels Jul 1, 2023
@WiIIiam278
Copy link
Owner

WiIIiam278 commented Jul 1, 2023

Breathtaking work thus far. 👍 Really excellent stuff.

As for (de)serialization -- I think it's exposed as raw NBT in Fabric, which we can serialize I believe (& there's methods to do so afaik). I'm not too worried about supporting cross-compat with Spigot servers, as that uses proprietary Spigot API to function (which we might change in the future tbh).

@hanbings
Copy link
Contributor Author

hanbings commented Jul 1, 2023

Thank you so much for your endorsement! Next I'll peruse the source code of Bukkit serialization for the correct way they work. There will be new commits here soon, once again sorry for the speed of work.

@WiIIiam278
Copy link
Owner

WiIIiam278 commented Jul 1, 2023

All good! Thanks for your work. Just a heads up -- I've changed the license to Apache-2.0 today to be more permissive -- I hope this is a bit better to work with! :)

I hope that's okay with you? You'll need to update it to Apache-2.0 in the fabric mod config, too (and re-run updateLicenses once you've pulled from master) :)

@hanbings
Copy link
Contributor Author

hanbings commented Jul 1, 2023

My pleasure, Thanks for contributing to open source!

@Hlebuw3k
Copy link

Hlebuw3k commented Sep 6, 2023

Hey this is awesome I need this

@Hlebuw3k
Copy link

Hlebuw3k commented Sep 6, 2023

I was looking at the code, and if the player is in adventure game mode, does it change to survival game mode?
fabric/src/main/java/net/william278/husksync/player/FabricPlayer.java
line 77

@hanbings
Copy link
Contributor Author

hanbings commented Sep 6, 2023

I was looking at the code, and if the player is in adventure game mode, does it change to survival game mode? fabric/src/main/java/net/william278/husksync/player/FabricPlayer.java line 77

It does seem that Adventure mode is not recognized. I’ve been very busy at work recently, so I haven’t updated it for a long time: (. If you are willing, you are welcome to PR!

@MasterSwish
Copy link

Hey this is awesome I need this

Me too! Thank you for your work on this!

@WiIIiam278
Copy link
Owner

WiIIiam278 commented Sep 10, 2023

Probably a good idea to rebase this on the new serialisation-refactor branch when that’s merged as that’ll help big time with a few of the todos on this PR. Also, new task system can borrow HuskHomes existing fabric code

@xPand4B
Copy link

xPand4B commented Sep 11, 2023

I'd love to use this mod on our fabric network!

@hanbings @WiIIiam278 So you need some coding support for this one?

@hanbings
Copy link
Contributor Author

Probably a good idea to rebase this on the new serialisation-refactor branch when that’s merged as that’ll help big time with a few of the todos on this PR. Also, new task system can borrow HuskHomes existing fabric code

Do you mean to merge this PR first and then fork it for the next step? Of course, it's up to you.

@hanbings
Copy link
Contributor Author

I'd love to use this mod on our fabric network!

@hanbings @WiIIiam278 So you need some coding support for this one?

Yes. There has been no progress for a long time due to my work. It's currently hard for me to find the time to work on Bukkit's item deserialization, which will result in us not being able to correctly parse the player's item information from the database.

@WiIIiam278
Copy link
Owner

@hanbings No problem at all!
I'm currently refactoring the plugin on the serialization-refactor branch to use NBTAPI instead of Bukkit serialisation, so this should make this PR much easier to finish up when done.

@hanbings
Copy link
Contributor Author

@hanbings No problem at all! I'm currently refactoring the plugin on the serialization-refactor branch to use NBTAPI instead of Bukkit serialisation, so this should make this PR much easier to finish up when done.

Thank you for your attention! I've synced the upstream code. Now that I'm ready to merge the code I've completed so far (this PR), I'll compile it in my local environment later to make sure the fabric version can pass the build.

@hanbings
Copy link
Contributor Author

@WiIIiam278 I modified some code to make it pass the build. Please approve the Actions workflow again. Thanks!

@WiIIiam278
Copy link
Owner

Workflow approved :)

@WiIIiam278
Copy link
Owner

@hanbings I'm going to commit to this branch if it's okay to help you out with this -- please let me know if there's anything you'd prefer to work on / feel free to self-review the PR. Thanks very much!

It seems that there is a big difference between 3.0 and previous versions. I am not sure what to do next. My current idea is to manually modify the previous code and then determine our new progress. What do you think?

And... thanks for your continued follow-up!

No problem! I have done a fair bit of work today. The next thing to do is implement Data and Serializable for each class type. Minecraft provides utils for getting NBT from Items, so we can do that. Persistent Data Containers isn't a feature in the Vanilla game, so this will utilize the custom data store I wrote for third party plugin/mod support.

And a bunch of mixins to handle events -- this is something I'm not very good at, though!

@WiIIiam278
Copy link
Owner

WiIIiam278 commented Sep 23, 2023

@hanbings To keep you in the loop, I've added Data and Serializer classes for Item data types to NBT. Needs testing, but just need to add equivalent ones for the other data types and the base sync system should work :)

The big remaining work is mixin logic for handling the various events that don't have workable API equivalents.

Feel free to have a look at what I've done, make suggestions/changes, and update the checklist in the PR detail.

@WiIIiam278
Copy link
Owner

I'm still slowly chipping away at this bit by bit and awhile ago added Fabric implementations of inventory data types.

If anyone more experienced with mixins is able to have a look at some of the needed ones for this PR, get in touch!

@Stampede2011
Copy link
Contributor

I have begun implementing more of the events needed for this, here. I am still working on ensuring each event is precise, but the basics are there.

  • projectile
  • player drop (needs more testing)
  • player pickup
  • player interact
  • player place block
  • player break block
  • open the Inventory
  • hurt
  • command

@WiIIiam278
Copy link
Owner

@Stampede2011 Hey, great work! Feel free to PR into this branch or even into master if you want to supersede this PR :)

@Stampede2011
Copy link
Contributor

@Stampede2011 Hey, great work! Feel free to PR into this branch or even into master if you want to supersede this PR :)

Just created a PR for this if your able to review: https://github.com/hanbings/HuskSync/pull/1

@WiIIiam278
Copy link
Owner

@Stampede2011 Hey, great work! Feel free to PR into this branch or even into master if you want to supersede this PR :)

Just created a PR for this if your able to review: hanbings#1

Had a quick cursory glance just now, and this looks to be excellent work.

What I'm going to do, in the interest of making this a bit easier for me to manage and review, is merge this PR into a feat/fabric branch on this repository. I'll open another tracking PR for merging that branch into master, at which point you can target your PR to merge into the feat/fabric branch :)

@WiIIiam278
Copy link
Owner

Superseded by #217

@WiIIiam278 WiIIiam278 closed this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in progress This issue is in progress type: feature request This issue is about a new feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants