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:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted (edited)

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

28 minutes ago, DavidM said:

 

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

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
2 hours ago, Skelyvelocirap said:

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

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:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted
6 hours ago, 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?

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.