Mods / CAN Effects

Category: #Other
Author: KenigVovan
Side: Both
Created: Jun 18th 2022 at 12:59 PM
Last modified: Oct 23rd at 2:57 PM
Downloads: 5290
Follow Unfollow 46

Latest file for v1.18.15: 1-click install

Allow register effects(or use default ones) and show them on client in HUD.

Inspired and uses parts of goxmeor 's BuffStuff -

Available default effects:

  • regeneration
  • miningslow
  • miningspeed
  • walkslow
  • walkspeed
  • weakmelee
  • strengthmelee
  • bleeding
  • thorns (damage the attacker)
  • firedamageimmune
  • safefall
  • weight buff(for weight mod)
  • cantemporalcharge(lowers speed of temporal stability drop and speed up restoration)
  • invisibility (hides armor and cloths as well now, idk yet how to leave armor/cloths render there)
  • forgetting (instant effect which lets player to use .charsel 1 more time)
  • extendedmaxbreath


Set effect on player using command:

/ef effectName durationInMins tier nickname (just for debug, requres creative mode)


If you want to apply effect on the player in the code:

create new Effect:

MiningSlowEffect ef = new MiningSlowEffect();

set duration:


apply effect on entity:

effectshud.src.effectshud.ApplyEffectOnEntity(entity, efslow);

(or using AddEffect of EBEffectsAffected - player's EntityBehavior)

You can set it's tier or duration with (SetExpiryInTicks,SetExpiryInRealMinutes and others)


To check if Entity has effect or get instance of applied effect you can use method below:

entity.EntityHasEffect(effectId); - to check if entity has active effect with provided id

entity.TryGetEntityEffect(effectId, out Effect); - try to get Effect with effectId


HUD with effect is shown by default for on/off use "L" button
use "L" + SHIFT to open GUI for easier effects application on players


To register you own effect in StartServerSide you need to call and provide typeId of effect and class

RegisterEntityEffect("myEffectTypeId", typeof(myEffectClass));

in StartClientSide: (typeId again, true if effect is positive, true if it's icon should be rendered in HUD)

RegisterClientEffectData("myEffectTypeId", true, true); - effect is positive will have tierNp.png overlay added if tier is > 0, the second true set
that we want it to be drawn in HUD
RegisterClientEffectData("myEffectTypeId", true, false); - this one is positive, but won't be rendered



TICK_EVERY_SECONDS - will change how long is tick in real seconds, for now it's 1 real second and for now can not be changed by config.


Assets generated by Midjourney


Version For Game version Downloads Release date Changelog Download 1-click mod install*
v0.2.9 459 Oct 23rd at 2:57 PM Show Install now
v0.2.8 91 Oct 20th at 3:06 PM Show Install now
v0.2.7 49 Oct 18th at 4:46 PM Show Install now
v0.2.6 45 Oct 17th at 8:10 PM Show Install now
v0.2.5 729 Jun 19th at 4:30 PM Show Install now
v0.2.4 111 Jun 18th at 9:42 AM Show Install now
v0.2.3 382 May 14th at 3:04 PM Show Install now
v0.2.2 144 May 10th at 3:42 PM Show Install now
v0.2.1 692 Apr 8th at 9:36 AM Show Install now
v0.2.0 341 Mar 1st at 7:30 PM Show Install now
v1.0.10 95 Apr 8th at 9:14 AM Show Install now
v1.0.8 447 Jan 31st at 5:43 PM Show Install now
v1.0.7 390 Nov 13th 2022 at 2:21 PM Show Install now
v1.0.6 295 Jul 11th 2022 at 2:04 PM Show Install now
v1.0.4 210 Jul 1st 2022 at 7:43 PM Show Install now
v1.0.5 139 Jul 10th 2022 at 9:59 AM Show Install now
v1.0.3 157 Jun 25th 2022 at 1:37 PM Show Install now
v1.0.2 146 Jun 25th 2022 at 9:50 AM Show Install now
v1.0.1 178 Jun 19th 2022 at 10:53 AM Show Install now
v1.0.0 167 Jun 18th 2022 at 1:00 PM Show Install now

15 Comments (oldest first | newest first)

💬 Telemachus, Oct 23rd at 5:07 PM

Yup, that fixed it. Thanks!


💬 KenigVovanAuthor, Oct 23rd at 2:57 PM


try 0.2.9

💬 Telemachus, Oct 23rd at 1:50 PM

Receiving this crash after updating from v0.2.5 to v0.2.8


💬 KenigVovanAuthor, Oct 20th at 3:12 PM

I'll look at new effects later, 
bool removedAfterDeath is added to Effect,
with font color/outline I'll take a look as well

💬 Frepo, Oct 20th at 12:12 PM

Some suggestions for the mod.

New default effects
GlowEffect - Makes the player emit a light, could be this eerie blue/green light that you have for a short while after you died. Higher tier = stronger light effect. VERY handy since it allows you to equip e.g. a shield while still having light i dark caves.
SpelunkerEffect - Makes the player see outlines of ore blocks/chest/translocators through walls. Might be hard to accomplish, but would be very cool. Higher tier = longer "sight radius".
BlindnessEffect - Renders a black filter over the entire screen. Higher tier = more opacity.
JumpEffect - Allows the player to jump higher. Higher tier = increased jump height. (for quality of life this effect should also secure you from taking fall damage from jumping, something similar to safefall. safefallDistance = jumpHeight)
WarmthEffect - Keeps you warm during cold winter nights. Higher tier = incresed bonus to body temperature (or some sort of protection in degrees like clothing has)

New property
DeathPermeable - [type: boolean] if true makes the effect stay after death.

About the hud graphics - Maybe try and change the font color for the timer. It's very hard to see in dark areas when the color is black. I have to look up at the sky to read how much time left. And when the sky is dark at night that wont help either.
Perhaps use green color for positive effects, and red color for negative. Or if possible, keep black color but with white outline, or try inverted (white font with black outline), see whatever works best. 

💬 Frepo, Oct 17th at 8:23 PM

Excellent! Ty for quick fix

💬 KenigVovanAuthor, Oct 17th at 8:12 PM


fixed, tier change not in effect's constructor didn't update damagePerTick, so it had default value everytime here

💬 Frepo, Oct 17th at 1:27 PM

Looks like setting a tier for the bleeding effect doesn't work correctly. The effect seems to always be tier 1 regardless if I try to set it to something else. Perhaps this is the same for other effects as well, that I don't know. I have only tested bleeding so far.
I've tested tier 1, 3 and 20, and you still take 0,05 damage/tick (at least according to the damage log, and what I can se by hovering over my health bar while bleeding).

The code
BleedingEffect effectBleed = new BleedingEffect();
effectBleed.tier = 20;
effectshud.src.effectshud.ApplyEffectOnEntity(__instance, effectBleed);

// tier 20 should result in 1 hp damage/tick

💬 Frepo, Oct 15th at 1:39 PM

Man, this mod sounds great! I've been longing for some "potion effects" for this game.
I've never used someone else's framework before. How do I get access to it in my source code? (visual studio 2022 community)
Do I have to unpack your mod? If so, must I place the unpacked stuff any place special? I figured I must reference your dll-file in my project. Is that enough or do I need to add your whole project to my solution?
Thanks in advance!

💬 KenigVovanAuthor, Jul 3rd 2022 at 6:44 PM

No problems with addons

If you mean to add OnEntityRevive, OnFallToGround, OnInteract, OnEntityReceiveDamage and others from EntityBehavior - i have it in a plan. To make a base for effects like vampirism, protections against(fire, fall, arrows, melee atacks), damage reflection etc.

I'll place source files on git in few days, but it's a mess now


💬 jakecool19, Jul 3rd 2022 at 3:50 PM

Would you be ok with mods that add on to this framework? For example adding more hooks to the base Buff class?

💬 KenigVovanAuthor, Jul 1st 2022 at 7:48 AM

The main point (at least for now) was to prepare effects handling for potions items.

Mod uses EntityBehavior so it might be expand on other entities, but Effects implementations could require some changes.
(because default Effects here use "Stats" of the player and i'm not 100% sure it's the same with other Entities)

💬 jakecool19, Jun 30th 2022 at 7:21 PM

Amazing work! I have been hoping we would get a proper status effect system for this game for quite awhile. What is the ultimate finished goal for this one? Will it just be for players, or will it work with all entities?

💬 KenigVovanAuthor, Jun 19th 2022 at 8:33 AM

It is WIP.
Mod for HUD on which effects (picture of buff/debuff) can be drawn. 
it uses player's WatchedAttributes to track updates.

You can register effect to show by:
RegisterEffect(string watchedBranch, string effectWatchedName, bool showTime, string effectDurationWatchedName, string [] domainAndPath, Vintagestory.API.Common.Func needToShow)

example of use for "miningSpeedMul" in stats:
effectshud.src.effectshud.RegisterEffect("stats", "miningSpeedMul", false, "", new string[] { "canmods:effects/slowmining1", "canmods:effects/slowmining2", "canmods:effects/slowmining3" }, checkminigSpeedMul);

checkminigSpeedMul here is function which is called on branch update and return number of picture which shoud be drawn, if -1 is return that means that effect is not active

public int checkminigSpeedMul()
      var t2 = capi.World.Player.Entity.Stats["miningSpeedMul"];
      var t = t2.GetBlended();
      if (t < 0.35)
          return 2;
      else if (t < 0.5)
          return 1;
      else if (t < 0.85)
          return 0;
      return -1;

Display of the time is not functinal yet, so choose false for showTime, if you want to try it.

Pictures size used is 64x64.

For HUD to show press "L"

💬 DemonBigj781, Jun 19th 2022 at 2:07 AM

whats this?

(edit comment delete)