Posted December 24, 20159 yr I want to create a fluid (similar to water) in my mod. I checked in the source for Minecraft and I was not able to find a class for water. I also have checked online, and I found one person who released the code for it, but he used a lot of algorithms to determine the water's height and position, and I couldn't fully understand the code. Is there a class in Forge that does those calculations for you? I feel like there is, as it was mentioned a little online, but I don't know what the class is or how it works. If there is a class like that, can you give me a tutorial or some example code so I can see how it works? Thanks, CC
December 24, 20159 yr Forge does provide mechanisms for modded fluids, look at the net.minecraftforge.fluids package. I explained a lot of the fluid system (including example code) in this thread a while back. Post #5 explains the fluid initialisation and registration, post #19 explains the model registration. I overhauled my fluid registration code after that post to properly support existing fluids, you can see the updated code here (model registration for fluids and buckets is here). My code uses several Java 8 features, if you're not compiling against Java 8 you'll need to replace these with the corresponding Java 6 features (e.g. replace lambdas with anonymous classes). Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
December 24, 20159 yr I was not able to find a class for water. You mean BlockDynamicLiquid and BlockStaticLiquid ? Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 25, 20159 yr Author Thank you Choonster! Your mod code was very helpful. I have a few questions, though: 1. What is the difference between a Fluid and a BlockFluidClassic? Is the BlockFluidClassic a source block, or is it something completely different? 2. What does the RegisterTank function do? 3. I have never worked with models, so the ModModelManager is completely new to me. How do I register the fluid models? Thanks, CC
December 25, 20159 yr 1. What is the difference between a Fluid and a BlockFluidClassic? Is the BlockFluidClassic a source block, or is it something completely different? The Fluid defines the physical properties (e.g. luminosity, density) and textures of the fluid. The IFluidBlock represents a block of the fluid in the world and uses the properties of the Fluid to determine the block's light level, flow speed, etc. BlockFluidClassic acts like vanilla liquids, you can use other implementations of IFluidBlock for different fluid behaviour. 2. What does the RegisterTank function do? It tells my Fluid Tank block to include a version of itself filled with that Fluid in creative tabs/NEI. 3. I have never worked with models, so the ModModelManager is completely new to me. How do I register the fluid models? ModModelManager#registerFluidModel registers a model for the specified IFluidBlock . I explained what this method does in the thread I linked previously. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.