User Tools

Site Tools


tutorial:status_effects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tutorial:status_effects [2020/08/30 08:21] – Create a tutorial on how to add status effects siglongtutorial:status_effects [2023/01/12 07:06] (current) – [Registering Status Effect] fix code errors tao0lu
Line 1: Line 1:
 ===== Adding Status Effects ===== ===== Adding Status Effects =====
  
-To add enchantments to your mod, you'll need to:+To add status effects to your mod, you'll need to:
   * create a class that extends ''StatusEffect''   * create a class that extends ''StatusEffect''
-  * register your status effect 
   * add custom functionality   * add custom functionality
 +  * register your status effect
   * add translations and textures for your status effect   * add translations and textures for your status effect
  
 ==== Creating Status Effect Class ==== ==== Creating Status Effect Class ====
-We will add new status effect that gives you EXP every tick.+We will add new status effect that gives you EXP every tick.
  
 <code java> <code java>
Line 14: Line 14:
   public ExpStatusEffect() {   public ExpStatusEffect() {
     super(     super(
-      StatusEffectType.BENEFICIAL, // whether beneficial or harmful for entities+      StatusEffectCategory.BENEFICIAL, // whether beneficial or harmful for entities
       0x98D982); // color in RGB       0x98D982); // color in RGB
   }   }
  
-  // This method is called every tick to check weather it should apply the status effect or not+  // This method is called every tick to check whether it should apply the status effect or not
   @Override   @Override
   public boolean canApplyUpdateEffect(int duration, int amplifier) {   public boolean canApplyUpdateEffect(int duration, int amplifier) {
Line 44: Line 44:
   @Override   @Override
   public void onInitialize() {   public void onInitialize() {
-    Registry.register(Registry.STATUS_EFFECT, new Identifier("tutorial", "exp"), EXP);+    Registry.register(Registries.STATUS_EFFECT, new Identifier("tutorial", "exp"), EXP);
   }   }
 } }
tutorial/status_effects.1598775665.txt.gz · Last modified: 2020/08/30 08:21 by siglong