Hi,
I'm trying to register a custom MobEffect, but when the mod load it seams to not have the MobEffect to be registered. The forge version is the 40.2.1
"Main" class
@Mod(MODID)
public class BetterArmor
{
//region Constructor
public BetterArmor()
{
// Register the setup method for modloading
IEventBus eventBus=FMLJavaModLoadingContext.get().getModEventBus();
CustomEffectsRegistry.register(eventBus);
BetterArmorRegistryItems.register(eventBus);
eventBus.addListener(this::setup);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
...
}
Class that hold references and register the effect
public class CustomEffectsRegistry
{
public static void register(IEventBus eventBus)
{
MOB_EFFECTS.register(eventBus);
}
public static final DeferredRegister<MobEffect> MOB_EFFECTS= DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, BetterArmor.MODID);
public static RegistryObject<MobEffect> FLY=MOB_EFFECTS.register("fly", ()->new FlyingEffect(MobEffectCategory.BENEFICIAL, 3124687));
}
Effetcs class
public class FlyingEffect extends MobEffect
{
public FlyingEffect(MobEffectCategory mobEffectCategory, int color)
{
super(mobEffectCategory, color);
}
@Override
public void applyEffectTick(LivingEntity livingEntity, int amplifier)
{
...
}
@Override
public boolean isDurationEffectTick(int p_19455_, int p_19456_)
{
//return super.isDurationEffectTick(p_19455_, p_19456_);
return true;
}
}
There's a method where I use the effect and where it gives me an excpetion(seems that Items are registerd before MobEffects)
private static ArrayList<MobEffectInstance> buildEffectsArray()
{
ArrayList<MobEffectInstance> effects=new ArrayList<>();
effects.add(new MobEffectInstance(MobEffects.NIGHT_VISION, BaseMultipliers.BASETIMER, 50));
effects.add(new MobEffectInstance(CustomEffectsRegistry.FLY.get(), 200, 5));
return effects;
}
There's the exception