Mod Liquid - HiKoNe/LiquidLib GitHub Wiki
Sample code for a new fluid (Oil):
using LiquidLib;
using Terraria.ID;
namespace TestLiquid.Liquids.Oil
{
public class Oil : ModLiquid
{
public override string BucketTexture => "TestLiquid/Liquids/Oil/oil_bucket";
public override string LiquidTexture => "TestLiquid/Liquids/Oil/oil_liquid";
public override string SlopeTexture => "TestLiquid/Liquids/Oil/oil_slope";
public override string WaterfallTexture => "TestLiquid/Liquids/Oil/oil_waterfall";
public override string FlowTexture => "TestLiquid/Liquids/Oil/oil_flow";
public override bool AddOnlyBucket => false;
public override void SetStaticDefaults()
{
Opacity = 1.0f;
WaterfallLength = 3;
WaveMaskStrength = 0;
ViscosityMask = 0;
DustCount = 20;
DustType = DustID.Asphalt;
Sound = new LegacySoundStyle(SoundID.Splash, 0);
Delay = 5;
Drown = true;
LiquidLoader.CollisionGet(Type, LiquidID.Water)
.SetTileType(TileID.Diamond)
.SetSound(SoundID.LiquidsWaterLava);
LiquidLoader.CollisionGet(Type, LiquidID.Lava)
.SetTileType(TileID.Stone)
.SetSound(SoundID.LiquidsWaterLava);
LiquidLoader.CollisionGet(Type, LiquidID.Honey)
.SetTileType(TileID.GrayBrick)
.SetSound(SoundID.LiquidsWaterLava);
}
}
}
Info for next description:
(...) - Value type
[...] - Value range
{...} - Default value
Class
using LiquidLib
- Add lib.class Oil
- The class name will be the default liquid name.ModLiquid
- Mod liquid extension.
Abstract properties (necessarily)
BucketTexture
- Texture of Bucket.
LiquidTexture
- Texture of Liquid.
SlopeTexture
- Texture of Slopes.
WaterfallTexture
- Texture of Waterfall.
FlowTexture
- Texture of Flow.
AddOnlyBucket
(bool) [any] - Add only a bucket.
Properties
All properties are set in the method SetStaticDefaults()
Opacity
(float) [0f-1f] {0f} - Opacity of liquid.WaterfallLength
(int) [0-10] {5} - Length of waterfall.DustCount
(int) [any] {-1} - Number of particles in a splash.DustType
(int) [any] {-1} - Type of particles in a splash.Sound
(LegacySoundStyle) [new] {null} - Sound of splash.Delay
(int) [any] {0} - Liquid delay, aka viscosity.Drown
(bool) [any] {true} - If true, player and town NPC can drown in this liquid.WaveMaskStrength
(byte) [any] {0} - Power of wave.ViscosityMask
(byte) [any] {0} - Wave viscosity.
Auto Properties
These properties are readable. You can use them for your own purposes.
Type
(int) - Type of this liquid.BucketType
(int) - Bucket type for this liquid.Mod
(Mod) - This mod. (lib)Name
(string) - Name of this liquid. (You can change this, override this)FullName
(string) - Full internal name of this liquid.
Methods
void SetStaticDefaults()
{void} - Used for set properties.void OnCollision(int i, int j, Entity entity)
{void} - Called whenever any entity is in this liquid.bool OnInLiquid(Entity entity)
{true} - Called once if any entity has entered this liquid.bool OnOutLiquid(Entity entity)
{true} - Called once if any entity has left this liquid.bool OnUpdate(Liquid liquid)
{true} - Called every time this fluid is refreshed.void OnRandomUpdate(int i, int j)
{void} - Called randomly.void OnCatchFish(Projectile projectile, ref FishingAttempt fisher)
{void} - Called once before fishing.bool OnBucket(Item bucket)
{true} - Called every time a bucket of this liquid is used.void OnTilePlaceByLiquid(int i, int j, int liquidType)
{void} - Called once after this liquid has caused a reaction with another liquid.void OnCatchFish(Projectile projectile, ref FishingAttempt fisher)
{void} - Called once before fishing.