Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Custom Effect not Rendering on GUI [1.16.5]


Recommended Posts

Hi! I was trying to  reate a custom effect, and it works properly except for a little thing.

When im on the Inventory of the Player, it doesn't render at all, how can i do?
image.thumb.png.d476e6da8e7d9d10d294ae762b355fe4.png
I see that there is a method called "renderHUDEffect(...)", but i don't know how to use it.
Someone can help me?

This is my Effect Class:

public class ColorEffect extends Effect {

    private final String colorName;
    private final String descriptionId;

    public ColorEffect(String colorName, int color) {
        super(EffectType.HARMFUL, color);
        this.colorName = colorName;
        this.descriptionId = "color.effect." + colorName;
    }

    @Override
    public void applyEffectTick(LivingEntity entity, int amplifier) {
        if (entity instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) entity;
            if (amplifier <= 0) {
                player.removeEffect(this);
                return;
            }
            player.causeFoodExhaustion(0.5f);
            player.addEffect(new EffectInstance(this, 2000, amplifier));
        }
    }

    @Override
    public boolean isDurationEffectTick(int duration, int amplifier) {
        return true;
    }

    public String getColorName() {
        return colorName;
    }

    @Override
    public ITextComponent getDisplayName() {
        return new TranslationTextComponent("colorfood.effect." + this.colorName);
    }

    public String getOrCreateDescriptionId() {
        return this.descriptionId;
    }
}

Thanks!

Link to post
Share on other sites
8 minutes ago, Yurim64 said:

Oh, I need to register the Effect?
Not finding the EFFECT tag in ForgeRegistries I thought I shouldn't register them. How can I register an effect?

DeferredRegisty
ForgeRegistries#POTIONS for an effect, ForgeRegistries#POTION_TYPES -> for a potion

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.