1

I am creating a character for a friend (JA) where everyone around him in a 7 block radius receives debuffs. The problem is I am trying to give JA an increasing buff where the more people that are within a 7 block radius of him, the stronger the strength buff he has. For example, if there were 3 people within a 7 block radius to JA he would receive strength 3. I can't seem to find a solution as I've tried using Redstone comparators so that when a player is nearby it sets a Redstone signal, but the signal does not strengthen when there is a larger quantity of players. Is there any way I could do this as I've done quite a bit of research on this whole ordeal but can't get this last piece down.

1
  • Please provide the commands you are currently using so that we can tailor our answers to your problem.
    – One 2 Many
    May 29, 2020 at 23:23

1 Answer 1

1

You will need to use a scoreboard objective to track the number of players around JA. Unfortunately there is no way that you can use a scoreboard value as a command argument, so you will need to use one command for each level.


Setup

Run the following command one time:

/scoreboard objectives add playersAround dummy

Create a scoreboard objective named playersAround.
This is where we will store the value that says the number of players around.

Then run the following command one time to setup JA's score.

/scoreboard players set JA playersAround 0

Set JA's score of playersAround to 0.

Usage

In a repeating command block set to Always Active, insert the following command:

/execute at JA store result score JA playersAround if entity @e[distance=0..7]

Detect how many players are around JA's location, and store it in JA's score of playersAround.

Then, put in commands like these to apply the effects. Place each in a chain command block heading outwards. Ensure that the command blocks face in the correct direction. See this answer for examples and a guide on how to place them. Each block should contain a command looking a little like this:

/execute if score JA playersAround matches 1 at JA run effect @a[distance=0..7] minecraft:strength 1 0
/execute if score JA playersAround matches 2 at JA run effect @a[distance=0..7] minecraft:strength 1 1
/execute if score JA playersAround matches 3 at JA run effect @a[distance=0..7] minecraft:strength 1 2

And so on. Note that the first level (1 player) uses effect level 0, not 1. That's because the effects are on a 0-based index, meaning 0 is the first, 1 is the 2nd, etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .