Jump to content

How do I increase the (Placing & Mining) Block reach range of a player?


PlayStarMC

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
}

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
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.
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.



×
×
  • Create New...

Important Information

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