# Custom Fluids

Supported by Forge on all versions, and Fabric on 1.18.2+

```JavaScript
// Startup script
onEvent('fluid.registry', event => {
  // These first examples are 1.16.5 and 1.18.2 syntax
  
  // Basic "thick" (looks like lava) fluid with red tint
  event.create('thick_fluid')
    .thickTexture(0xFF0000)
    .bucketColor(0xFF0000)
    .displayName('Thick Fluid')
               
  // Basic "thin" (looks like water) fluid with cyan tint, has no bucket and is not placeable
  event.create('thick_fluid')
    .thinTexture(0xFF0000)
    .bucketColor(0x00FFFF)
    .displayName('Thin Fluid')
  	.noBucket() // both these methods are 1.18.2+ only
  	.noBlock() 
  
  // Fluid with custom textures
  event.create('strawberry_cream')
  	.displayName('Strawberry Cream')
    .stillTexture('kubejs:block/strawberry_still')
    .flowingTexture('kubejs:block/strawberry_flow')
    .bucketColor(0xFF33FF)
  
  // For 1.18.1 the syntax is slightly different
  event.create('thick_fluid', fluid => {
       fluid.textureThick(0xFF0000) // the texture method names are different in 1.18.1 and below, textureXyz instead of xyzTexture
       fluid.bucketColor(0xFF0000)
       fluid.displayName('Thick Fluid')
  })
})
```

<p class="callout warning">In 1.18.1, 1.17 and 1.16 the texture method names are swapped, so textureStill and textureThin instead of stillTexture and thinTexture</p>

Methods that you can use after the event.create('name')

- <span class="pl-en"><span class="pl-token active" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":46427577,"ref":"1.18/main","language":"Java","backend":"ALEPH_FUZZY","code_nav_context":"BLOB_VIEW","retry_backend":"","cross_repo_results_included":"CROSS_REPO_ENABLED","in_repo_result_count":3,"cross_repo_result_count":0,"originating_url":"https://github.com/KubeJS-Mods/KubeJS/find-definition?q=displayName&blob_path=common%2Fsrc%2Fmain%2Fjava%2Fdev%2Flatvian%2Fmods%2Fkubejs%2Ffluid%2FFluidBuilder.java&ref=1.18%2Fmain&language=Java&row=49&col=34&code_nav_context=BLOB_VIEW","user_id":84252593}}" data-hydro-click-hmac="1bddf569fed1366a78a9d47ed82835beb198a008c23d33a880c975563d9ada22">displayName</span></span>(name)
- color(color)
- bucketColor(color)
- <span class="pl-en"><span class="pl-token" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":46427577,"ref":"1.18/main","language":"Java","backend":"ALEPH_FUZZY","code_nav_context":"BLOB_VIEW","retry_backend":"","cross_repo_results_included":"CROSS_REPO_ENABLED","in_repo_result_count":1,"cross_repo_result_count":0,"originating_url":"https://github.com/KubeJS-Mods/KubeJS/find-definition?q=builtinTextures&blob_path=common%2Fsrc%2Fmain%2Fjava%2Fdev%2Flatvian%2Fmods%2Fkubejs%2Ffluid%2FFluidBuilder.java&ref=1.18%2Fmain&language=Java&row=112&col=21&code_nav_context=BLOB_VIEW","user_id":84252593}}" data-hydro-click-hmac="acff39c9ef96a6f2b939381b53700421bf355983c2c35a3ef05f12e5cc845bc2">builtinTextures</span></span>() 
    - same as thinTexture(0xFFFFFF)
- stillTexture(path) 
    - path is the path to txture is for example maybe "minecraft:block/sand"
    - this texture is recomended to be 16x16, or if animated with a mcmeta file then 16x48 for 3 frames or 16x80 for 5 or 16x240 for 15
    - Frame counts of 3, 5, 15, 6, 10, or 30 will make your life easier, because the flowing animation need to be a multiple of 15 to look good
- flowingTexture(path) 
    - path is the path to texture is for example maybe "minecraft:block/sand"
    - this texture is recommended to be 32x480 and animated with a mcmeta file
    - each frame is recommended to be 32x32 (recommended to be the same 16x16 texture tiled)
    - then each of these frames are shifted one pixel vertically from the previous, so it looks like its moving
    - If you are going to be making your own flowing fluid texture it is *highly recommended* to <span style="text-decoration: underline;">*not*</span> make these by hand (It is hours of suffering), and instead write a some program, or setup something with blender nodes to make it.
- noBucket()
- noBlock()
- gaseous() 
    - It is now a gas
- <span class="pl-en"><span class="pl-token" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":46427577,"ref":"1.18/main","language":"Java","backend":"ALEPH_FUZZY","code_nav_context":"BLOB_VIEW","retry_backend":"","cross_repo_results_included":"CROSS_REPO_ENABLED","in_repo_result_count":3,"cross_repo_result_count":0,"originating_url":"https://github.com/KubeJS-Mods/KubeJS/find-definition?q=rarity&blob_path=common%2Fsrc%2Fmain%2Fjava%2Fdev%2Flatvian%2Fmods%2Fkubejs%2Ffluid%2FFluidBuilder.java&ref=1.18%2Fmain&language=Java&row=161&col=21&code_nav_context=BLOB_VIEW","user_id":84252593}}" data-hydro-click-hmac="83f54f5c2c28fdbb8404eae2ab3f4e61356fe9a2744a405ceb84ab8b9b839e09">rarity</span></span>(value) 
    - Can be: 
        - "common"
        - "uncommon"
        - "rare"
        - "epic"

The following can also be used but have no effect unless a mod adds a purpose:

- <span class="pl-en"><span class="pl-token" data-hydro-click="{"event_type":"code_navigation.click_on_symbol","payload":{"action":"click_on_symbol","repository_id":46427577,"ref":"1.18/main","language":"Java","backend":"ALEPH_FUZZY","code_nav_context":"BLOB_VIEW","retry_backend":"","cross_repo_results_included":"CROSS_REPO_ENABLED","in_repo_result_count":1,"cross_repo_result_count":0,"originating_url":"https://github.com/KubeJS-Mods/KubeJS/find-definition?q=luminosity&blob_path=common%2Fsrc%2Fmain%2Fjava%2Fdev%2Flatvian%2Fmods%2Fkubejs%2Ffluid%2FFluidBuilder.java&ref=1.18%2Fmain&language=Java&row=136&col=21&code_nav_context=BLOB_VIEW","user_id":84252593}}" data-hydro-click-hmac="34c00cd9f060bd1cac987757b8c0cf0b50a09689a1012b213d2c5c9bd35c9354">luminosity</span></span>(value) 
    - default 0
- density(value) 
    - default 1000
- temperature(value) 
    - default 300
- viscosity(value) 
    - default 1000

<p class="callout danger">There is a good chance the following does not work at all</p>

You can use `.bucketItem` to get the bucket item builder.

If you one want to use it then you can place it at the end of the other methods then use the its methods instead.

```javascript
// notice this script has not been tested
onEvent('fluid.registry', event => {
  event.create('taco_suace')
                .thickTexture(0xFF0000)
                .bucketColor(0xFF0000)
                .bucketItem
                .group("food")
})
```

<p class="callout warning">Some amount of the methods in these builders will not work or cause problems</p>

- .bucketItem 
    - Any method that you can use on an[ item builder](https://mods.latvian.dev/books/kubejs-legacy/page/custom-items) might work