Jump to content

Recommended Posts

Posted

I'm trying to make a custom enchant reduce damage from a custom mob I created. From looking at the vanilla protection enchants, it seems that they all work based on damage types. Does this mean I would have to create a new damage type for my mob? Or is there a way to specify in the getDamageProtection that the damage from the mob type specified should apply the reduction? 

Posted

It's not clear from your question what you are trying to do?

But maybe you want to check for the damage source being EntityDamageSource or IndirectEntityDamageSource?

Both contain a reference to the Entity causing the damage.

  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

I'm sorry, but I just cannot figure out how to have it search for such a thing. Should I use an if statement? Is there a way to call the EntityDamageSource/IndirectEntityDamageSource? 

To clarify, I want my enchantment to only reduce damage that is taken from a specific entity. 

What should I put in here to achieve this goal?

-----------------------------------------------------------------------------------------------------------------------------

@Override public int getDamageProtection(int p_44680_, DamageSource p_44681_) {

return super.getDamageProtection(p_44680_, p_44681_); }

-----------------------------------------------------------------------------------------------------------------------------

Side question, is it possible to configure what % of damage gets reduced? or is that it's own tree of classes and separate functions?

Posted

We don't write your mod for you. Nor do we teach java or basic logic.

You also need to learn how to use your IDE by the sounds of it?

 

Here is some untested pseudo code that checks for indirect (e.g. projectile/arrow) damage from skeletons

@Override 
public int getDamageProtection(int level, DamageSource source) {
    if (source.isBypassInvul()) return 0;

    if (source instanceof IndirectEntityDamageSource indirect
        && indirect.getEntity() instanceof Skeleton) {
        return calculateProtection();
    }
    return 0;
}

 

Damage protection is a flat addition calculation.

I would say look at the vanilla code for the logic, but you don't seem to know how to do that?

  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.