Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

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.

  • 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

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.