Jump to content

Recommended Posts

Posted (edited)

Hello,

 

I have a block called the fluid tank. This block is... as the name suggests... a fluid tank. The issue though is that i want it to have two FluidTank inside. One of those tanks being like normal but the other tank can only be filled using a machine but can be drained like normal(but has priority). Is that possible? And if so, how can i do that? Thank you! :D

Edited by Skelyvelocirap
solved
Posted

Yes. Just create another fluid handler.

Then, in getCapability, determine which tank to return based on the given information and the current data in the tile entity.

Some tips:

  Reveal hidden contents

 

Posted (edited)

Why do i need to create a new Fluid handler? Can i not do this with the normal one?
 

  On 4/11/2020 at 3:53 AM, DavidM said:

 

Then, in getCapability, determine which tank to return based on the given information and the current data in the tile entity.

Expand  

And so i can simply choose what tank using getCapability? Ohhhh, thats what that means...

return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);

The tank is the tank that is actually being used. I thought that that line simply meant that the tank has the fluid handler capability. Ok, Thank you for your help! I will try this immediately!

Hmmm.. although, how do i check if the person is filling or draining?

Edited by Skelyvelocirap
Posted
  On 4/11/2020 at 4:10 AM, Skelyvelocirap said:

Hmmm.. although, how do i check if the person is filling or draining?

Expand  

I don’t think it is possible to tell so from the tile entity with the vanilla fluid handler.

However you could create your own fluid handler implementation that handles 2 different tanks and their insertion/extraction.

Some tips:

  Reveal hidden contents

 

Posted
  On 4/11/2020 at 10:34 AM, diesieben07 said:

I mean... IFluidHandler has a method for filling (helpfully called fill) and two for draining (helpfully called drain). What more do you need?

Expand  

I thought that those two were used to actually drain/fill or check it is possible to do so. How should i use those to solve my issue?

Posted

Success! It works! I am not sure if it is exactly(i think someone might have told me that actually) but what i did was use drain from the i fluid handler but simulated it and checked if it wasn't null. If it isn't null then i just return the second tank. I will post the code just so anyone who needs help can use it and so that if its not very efficiently done than you can tell me.

https://github.com/Skelyvelocirap/Thebalance/blob/master/java/skely/mod/objects/block/TBFluidTank.java

https://github.com/Skelyvelocirap/Thebalance/blob/master/java/skely/mod/objects/block/tileentity/TileEntityTank.java

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.