Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?ย 

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.

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.

  • Author

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?

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?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.