Jump to content

[1.15.2] How do I use Registries, Events, and Fluids.


Recommended Posts

I've been following various tutorials on how to develop mods for 1.15.2, and I've been able to follow them fairly well after spending a week trying to familiarize myself with java; however I don't actually understand what is going on with a significant portion of my code. More specifically with Registries and Events. What the heck are they?


The end goal of what I wish to create is a mod that can simulate gases by having a fluid that flows upwards instead of down, and eventually dissipates after a flowing up a significant amount. I found a mod that seems to do what I want but the latest release of it was for 1.7.10, and very little within the code makes sense to me. Is there anywhere I should be looking for further guidance? I checked out the documentation for 1.15.2, but there wasn't anything pertaining to fluids, or even an explanation for most of the classes and tags I've found within the forge libraries that my IDE imported.


I attached some screenshots of what I found referencing fluids at all, and they make a bit more sense than anything I've managed to find on google. I'm assuming I'd register them in my RegistryEvents class like a block; however that just leads back to my previous question of what the heck are Registries and Events even doing and how am I supposed to infer on what properties fluids can have, and how would I add new features to it such as making it float upwards and dissipate.





Edited by KINØ
Link to comment
Share on other sites

7 minutes ago, loordgek said:

can you list the tutorials that you are following because there a some bad ones out there

I've been using several different ones and completely starting over with each tutorial. I'll list them in order of when I did them, the last one being the current tutorial I'm using and so far my favorite. If you know of any better tutorials I would be extremely grateful for a link.


Cadiboo's (Stopped using bc the tutorial was still WIP on key concepts)


Technovision's (Stopped using bc there were limited videos, it's a new tutorial)


Jorrit Tyberghein's (Stopped using bc I found it hard to follow due to the creators accent, seemed like a good tutorial though)


TurtyWurty's (Currently using, it's easier to follow than Jorrit's, and has significantly more concepts covered than Cadiboo's & Technovision's)



Edited by KINØ
Link to comment
Share on other sites

Word of advice, it will take more than a week of modding/learning java to understand most of this stuff. The fluid concept you want to achieve isn't a very simple implementation. The best way to learn is through reading the source code to see how vanilla achieves things. This almost always requires some digging through packages, or reading forums to get led in the right direction.


Regarding the packages you have drawn attention to, the vanilla code is made up of many interfaces and parent classes that act as blueprints, while the classes you are most likely interested in reading are WaterFluid and LavaFluid, as these seem to be the most specific. For example, in the WaterFluid class:

   public void animateTick(World worldIn, BlockPos pos, IFluidState state, Random random) {
      if (!state.isSource() && !state.get(FALLING)) {
         if (random.nextInt(64) == 0) {
            worldIn.playSound((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, SoundEvents.BLOCK_WATER_AMBIENT, SoundCategory.BLOCKS, random.nextFloat() * 0.25F + 0.75F, random.nextFloat() + 0.5F, false);
      } else if (random.nextInt(10) == 0) {
         worldIn.addParticle(ParticleTypes.UNDERWATER, (double)pos.getX() + (double)random.nextFloat(), (double)pos.getY() + (double)random.nextFloat(), (double)pos.getZ() + (double)random.nextFloat(), 0.0D, 0.0D, 0.0D);


You already get a sense that there are block states such as FALLING, that describes the movement/behavior of the water. Looking at how the class is set up:

public abstract class WaterFluid extends FlowingFluid {
   public Fluid getFlowingFluid() {
      return Fluids.FLOWING_WATER;

   public Fluid getStillFluid() {
      return Fluids.WATER;

   public Item getFilledBucket() {
      return Items.WATER_BUCKET;

Any fluid you'd like to make must have these features. So, you notice that there is a class Fluids that seems to store all the types of fluids. Hence, you should look for a Forge registry that allows you register your own fluid to show up in the game. Hopefully this provides some direction, I personally haven't messed with fluids myself, but this is how I've tried to figure things out.


Registries and Events

I suggest checking out the net.minecraftforge.event package and poke around. An event is exactly what it sounds like. Something happens in the game. When you annotate your method with a @SubscribeEvent annotation, you signal to Forge that your method should run when something in the game happens. Which event depends on the Event parameter you give it. These events can be found in the aforementioned package. The class that contains this method (called an event handler) must be registered to the MinecraftForge.EVENT_BUS.register(...). An example of using under some condition you didn't want zombies to spawn. In otherwords, you wanted to cancel the event of a zombie spawning. You may have something like:

public static void onEntityJoinWorld(EntityJoinWorldEvent event){
	if(event.getEntity() instanceof ZombieEntity && condition)

And behold, during the game, given that condition is true, zombie spawns will be canceled faster than Kevin Hart was for his Oscar speech.


Registries are Forge's way of "injecting" your content into the game. Think of it like a list of things to be included into the game. The way you add to this list is to register an item. In your console, you may see something of the following:

[19:09:01] [Server-Worker-6/DEBUG] [ne.mi.re.ForgeRegistry/REGISTRYDUMP]: Registry Name: minecraft:block
        Entry: 0, minecraft:air, Block{minecraft:air}
        Entry: 1, minecraft:stone, Block{minecraft:stone}
        Entry: 2, minecraft:granite, Block{minecraft:granite}
        Entry: 3, minecraft:polished_granite, Block{minecraft:polished_granite}
        Entry: 4, minecraft:diorite, Block{minecraft:diorite}
        Entry: 5, minecraft:polished_diorite, Block{minecraft:polished_diorite}

Here, Forge is registering the blocks. If you don't register your items, they won't be in the game.


Hope this provides some guidance.


I would suggest reading the Forge Documentation EVEN THOUGH MANY OF THE SPECIFICS ARE OUTDATED (keep in mind, the dudes are doing this for free). Many of the concepts are still relevant, like Registries and Events.

  • Thanks 1
Link to comment
Share on other sites

Thank you so much! I had just finished going through the Forge Documentation again before reading your response, and things are much clearer now. Your explanation of Registries and Events has made it much more concise to me about what it's doing.

Link to comment
Share on other sites

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.

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.


  • Create New...

Important Information

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