Posted April 11, 20205 yr 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! Edited April 11, 20205 yr by Skelyvelocirap solved
April 11, 20205 yr 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.
April 11, 20205 yr Author 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 April 11, 20205 yr by Skelyvelocirap
April 11, 20205 yr 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.
April 11, 20205 yr Author How exactly would i do that? Creating the class would be simple but i mean how would i make them discern whether its filling or draining?
April 11, 20205 yr Author 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?
April 11, 20205 yr Author 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.javahttps://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.