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

Move from LDLib's FluidStack implementation to Forge's FluidStack #1975

Merged
merged 23 commits into from
Oct 19, 2024

Conversation

krossgg
Copy link
Contributor

@krossgg krossgg commented Sep 18, 2024

What

This PR moves the codebase off of LDLib's FluidStack implementation and onto Forge's native FluidStack implementation.
This includes switching from LDLib's IFluidTransfer to Forge's IFluidHandler. The behavior between the two is extremely similar, and this change will allow for better maintainability and better understanding of the depended-upon implementation, as Forge is very well documented.

Implementation Details

I have added a couple new methods to GTUtils which I use sporadically, please see them here so you don't have to go flopping around trying to find what a certain utility method will do.
I also make very good use of Forge's FluidUtil class, which has many helper methods similar to LDLib's. See the docs for those here or check the implementation in your own IDE at net.minecraftforge.fluids.FluidUtil.java

Potential Compatibility Issues

Forge's FluidStacks are limited to integer amounts, rather than the long-based FluidStacks from LDLib. This could potentially cause issues in certain cases, specifically during interactions with AE2.
Further testing is required for this, however. From what I can tell, it would only affect people who attempt to use more than 2.147 million buckets in an ME hatch or an ME Pattern Buffer.
If this is a cause for concern, please let me know.

If I have missed ANYTHING or if there are ANY questions please let me know.

The first commit 4ef64c9 are fairly simple switches and don't necessarily need the most attention. Please look over the other four commits well. Thanks.

@krossgg krossgg added the Do Not Merge DO NOT MERGE THIS PR YET! label Sep 18, 2024
@krossgg krossgg self-assigned this Sep 18, 2024
@krossgg krossgg requested a review from a team as a code owner September 18, 2024 05:11
@krossgg krossgg removed their assignment Sep 18, 2024
Copy link
Member

@screret screret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna do the rest in intellij github's UI isn't happy rn

@krossgg krossgg requested a review from screret September 19, 2024 00:28
@krossgg krossgg requested a review from screret September 20, 2024 01:54
@screret
Copy link
Member

screret commented Sep 20, 2024

conflicts

@krossgg
Copy link
Contributor Author

krossgg commented Sep 22, 2024

Last commit is the only new content. Rebased and resolved conflicts because things were getting a little out of hand.

Adds classes in /api/misc/lib/ which are Forge FluidStack compatible stand-ins for LDLib's versions
Creates a Payload for Forge FluidStacks and registers them with LDLib
Adds a mixin for LDLib to allow for FluidStack syncing
Rewrites these classes to use Forge's native IFLuidHandler rather than LDLib's IFluidTransfer
Switches from hardcoded logic to using Forge's FluidUtil to add cleanliness
Now passes the interaction for drums and tanks if the held item isn't a fluidhandler
Also cleaned up the CreativeTankMachine to more properly make use of being a subclass
Implemented CreativeTankMachine right-click behavior
Removed any unnecessary BUCKET_VOLUME uses
Moved new classes to appropriate packages
Renamed Fluid classes to use Handler rather than Transfer
Also clean up some lingering references
@screret screret removed the Do Not Merge DO NOT MERGE THIS PR YET! label Sep 24, 2024
@Fuyukai
Copy link
Contributor

Fuyukai commented Sep 24, 2024

This causes issues with loading certain machines:

[16:54:12] [Server thread/ERROR] [minecraft/BlockEntity]: Failed to load data for block entity gtceu:mv_super_tank
java.lang.ClassCastException: class net.minecraft.nbt.LongTag cannot be cast to class net.minecraft.nbt.IntTag (net.minecraft.nbt.LongTag and net.minecraft.nbt.IntTag are in module [email protected] of loader 'TRANSFORMER' @84a9f65)

I don't know how much this actually affects (as none of my tanks emptied) but a few of my fluid pipes spontaneously disconnected.

@krossgg krossgg added the Do Not Merge DO NOT MERGE THIS PR YET! label Sep 26, 2024
@screret screret added the type: refactor Suggestion to refactor a section of code label Sep 29, 2024
@krossgg
Copy link
Contributor Author

krossgg commented Oct 1, 2024

Ready for merge after one last review. Will almost certainly break addons.

@screret
Copy link
Member

screret commented Oct 1, 2024

merge #1945 first

@screret screret removed the Do Not Merge DO NOT MERGE THIS PR YET! label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Suggestion to refactor a section of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants