Skip to content

Creating a fluid

Olafcio1 edited this page Jul 24, 2026 · 6 revisions

This guide assumes you've already created and setup an Avoid project.
This guide uses meta-programming. Another way may either not be implemented or you may need to figure it out on your own.


§ Making a fluid with the Avoid Framework


  1. Create a java class;
    You can pick any location within your project source code directory.

  2. Paste the following code:

    package com.example.avoidtmpl.fluid;
    
    import pl.olafcio.avoid.mods.annotation_processor.AutoFluid;
    import pl.olafcio.avoid.mods.annotation_processor.AutoID;
    import pl.olafcio.avoid.net.block.Blocks;
    import pl.olafcio.avoid.net.fluid.Fluid;
    import pl.olafcio.avoid.net.fluid.FluidState;
    import pl.olafcio.avoid.net.fluid.properties._layer;
    import pl.olafcio.avoid.net.fluid.properties.layer.ChunkLayer;
    import pl.olafcio.avoid.net.id.Identification;
    import pl.olafcio.avoid.net.item.Item;
    import pl.olafcio.avoid.net.world.block_data.BlockData;
    
    @AutoFluid
    @AutoID
    
    @_layer(ChunkLayer.SOLID)
    @_gravity
    @_swimmable
    @_unbreatheable
    
    public class OilFluid extends Fluid {
        @Override
        public Item getBucket() {
            return Item.of("lava_bucket"); // replace this with a new bucket item for your fluid!
        }
    
        @Override
        public Identification getBlockType() {
            return Identification.of("testmod:oil"); // replace this with [your mod ID]:[your fluid ID]
        }
    
        @Override
        public BlockData createBlock(FluidState state) {
            return Blocks.create(Identification.of("testmod:oil")); // replace this with [your mod ID]:[your fluid ID]
        }
    }

    Of course you need to replace the class name and package.

  3. Set the layer;
    You can change the fluid's layer (which is kinda like a rendering type) by changing the @_layer line.
    Here are all the layers you can pick from:

    Constant Explanation
    SOLID Makes the fluid opaque.
    CUTOUT Draws a stroke around the fluid. (TODO Is this true?)
    TRANSLUCENT Makes the fluid translucent/see-through.
    TRIPWIRE That's where I have no clue.

    (If you're using the SOLID layer, you don't have to specify the @_layer declaration.)

  4. Customize it as you wish;
    You can change the fluid's tick methods and more in the class contents itself [by overriding inherited Fluid methods].
    Other than the @_layer property, you can also tinker with all of those:

    • @_gravity: enables gravity for the fluid.
    • @_swimmable: enables swimming for entities inside the fluid.
    • @_unbreatheable: enables air mechanics for the fluid.
    • @_model(
         flowing = @ID(namespace = "minecraft", path = "lava_flow"),
         still = @ID(namespace = "minecraft", path = "lava_still")
      )
      : changes the model of the fluid.
  5. Create a block.
    Then, mark it as @_liquid(fluid = YourFluid.class).
    You probably also want to mark it as @_noCollision and @_replaceable (don't you?).

  6. Create a fog.
    A fog is the blur around you, that appears when:

    • going into caves,
    • going into a fluid (e.g. water), and
    • when you have the blindness effect.

    There may be more cases when a fog appears, of course.
    You cannot assign the water's fog just with an annotation, because the fog itself decides about when to appear - it's not invoked by someone else.


Avoid Framework


    🏚️ 1. Home
    📽️ 2. Creating your mod
    🌄 3. Adding assets to your mod
    🧊 4. Creating a block
    💧 5. Creating a fluid
    ✏️ 6. Creating an item
    🎯 7. Creating an entity selector
    🤖 8. Creating a command
    ⌨️ 9. Creating a keybind
    🐺 10. Creating an entity
    🌫️ 11. Creating a fog

Clone this wiki locally