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

https://github.com/MinecraftForge/MinecraftForge/blob/817e20821d04225e2b39e2ce64be9b70c8ddfa27/src/main/java/net/minecraftforge/common/ForgeMod.java#L153

Change that attribute of the player, either directly or having the modifier apply to some equipment (e.g. armor or a tool they are using).

More details on this many times asked question can be found using search in this forum.

Edited by warjort

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

Yea, I already looked through older posts but most of them were linked to methods i did not get to work.
Its my first name making a mod, how do I temporarily change an attribute?

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.

Sorry, this is the attribute modifier thread, not the mob effect thread 🙂

You want this search: https://github.com/search?q=addtransientmodifier&type=code

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 just used
 

Quote
double reach = 3.5;
...
if(...){
  player.getAttribute(ForgeMod.BLOCK_REACH.get()).setBaseValue(block_reach+2.5);
} else {
  player.getAttribute(ForgeMod.BLOCK_REACH.get()).setBaseValue(block_reach);
}

 

 

Why are you setting the base value?

That will just lead to incompatiblities with other mods that (incorrectly) do the same thing.

Or you will write over any change a modpack developer (or server owner) wants to make globally for all players.

 

You should add a +2.5 modifier, then you will always get the correct effect regardless of what other mods do.

Edited by warjort

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.

I gave you a link to other mods doing it above.

And as I said before, there are many other discussions about it in this forum.

 

Also, you spent less than 20 minutes from my previous answer trying to understand what you need to do.

This is a support forum, it does not exist for you to proxy the work of writing your mod to us.

 

Feel free to come back and ask questions after you have tried to write some code and get stuck.

But you need to post more than a 5 line code snippet out of context (like you did above) if you want help.

You need to put a reproducable example of your problem on github.

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 looked at some other mods and this is what I have now (extra health instead of block reach)
 

            AttributeModifier HEART_CRYSTAL_MODIFIER = new AttributeModifier(UUID.fromString("68a6dc55-32e4-46a2-8707-57fd16f6afdd"), "AuroraAttributeModifier_HeartCrystal", 4, AttributeModifier.Operation.ADDITION);
            if (pEvent.phase == TickEvent.Phase.START) {
                ItemStack item = new ItemStack(ModItems.HEART_CRYSTAL.get(), 1);
                if (player.getInventory().contains(item)) {
                    if (!Objects.requireNonNull(player.getAttribute(Attributes.MAX_HEALTH)).hasModifier(HEART_CRYSTAL_MODIFIER)) {
                        Objects.requireNonNull(player.getAttribute(Attributes.MAX_HEALTH)).addTransientModifier(HEART_CRYSTAL_MODIFIER);
                    }
                } else {
                        Objects.requireNonNull(player.getAttribute(Attributes.MAX_HEALTH)).removeModifier(HEART_CRYSTAL_MODIFIER.getId());
                }
            }

There are no errors but it doesn't work

4 hours ago, warjort said:

But you need to post more than a 5 line code snippet out of context (like you did above) if you want help.

You need to put a reproducable example of your problem on github.

 

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.