#Alternatives to scoreboards?

1 messages · Page 1 of 1 (latest)

silver pagoda
#

Hello fellow datapackers, I was wondering if there are any alternatives to selecting a specific player to run a function on and the only way I know right now is scoreboards. I have realised many issues because i want to select the player that pressed a button to activate the command block that activates the function but when i add the score to the player who presses the button i use @p but if there is someone closer to the command block it will select them and i do not want that. Another problem I have is writing execute as @a if score… because my entire function just wants to run on that player once and only that player who has the score but i find it very annoying to having to paste in the first half of the command every time i want to run a command on that player. I am looking for a potentially better/less laggy solution to this and I was wondering if i could use predicates or execute store but i have absolutely no experience in these 2 things and i need help please.

I apologise if my post is hard to read because i am not great at english and i am sleepy right now.

left ledgeBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1749816314:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

rose spire
#

For the button you can use interactions

gentle needle
#

or even better, advancements that check for default use

#

that way you also immediately get rid of the player selection problem

#

because advancements when they run a function as reward, always run it as and at the player who got the advancement.

rose spire
gentle needle
#

conditions

#

you could hide a specific block 10 blocks below the button and check for that.

#

there are multiple ways to do it though

lament raptor
#

How about scoreboard objectives add used_button minecraft.used:minecraft.stone_button

#

An advancement would be better, since this may cause some amount of lag by checking every tick

gentle needle
#

this is exactly like the advancement but with extra steps on top for no additional perks

gentle needle
half anvil
#

The easiest method is a sign if you don't want to change or add any code

#

The player who clicked the sign is @s in the command it runs. As fast as advancements

rose spire
rose spire
gentle needle
#

I preseted a solution for that a few messages above

lament raptor
gentle needle
#

...

gentle needle
lament raptor
#

I meant the scoreboard

gentle needle
#

We already told that this is a worse option

lament raptor
#

Yes, but I'm explaining how it could potentially work 🙂

gentle needle
#

no, no you're not

#

you just add unnecessary confusion and text

silver pagoda
#

oh wow i just slept

#

anyways i think the advancement way would be better and easier but how would i make the condition of that achievement activate when that specific button is pressed?

silver pagoda
#

can someone check if this is right?

{
"display": {
"icon": {
"id": "minecraft:acacia_button"
},
"title": "button",
"description": "button",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"root": {
"trigger": "minecraft:any_block_use",
"conditions": {
"player": [
{
"condition": "minecraft:location_check",
"predicate": {
"position": {
"x": {
"min": -245,
"max": -245
},
"y": {
"min": 23,
"max": 23
},
"z": {
"min": 94,
"max": 94
}
}
}
}
]
}
}
},
"requirements": []
}

rose spire
#

I think this would check the location of the player

silver pagoda
#

oh

#

wait let me try again

rose spire
#

I'm not completely sure, but I think this would work:

#
{
  "display": {
    "icon": {
      "id": "minecraft:acacia_button"
    },
    "title": "",
    "description": "",
    "hidden": true
  },
  "criteria": {
    "button_used": {
      "trigger": "minecraft:default_block_use",
      "conditions": {
        "location": [
          {
            "condition": "minecraft:block_state_property",
            "block": "minecraft:acacia_button"
          },
          {
            "condition": "minecraft:location_check",
            "predicate": {
              "position": {
                "x": 123,
                "y": 456,
                "z": 789
              }
            }
          }
        ]
      }
    }
  }
}
silver pagoda
#

does that only work for a acacia button or any button?

rose spire
#

Only acacia

#

Wait ill change it

#
{
  "criteria": {
    "block_used": {
      "trigger": "minecraft:default_block_use",
      "conditions": {
        "location": [
          {
            "condition": "minecraft:location_check",
            "predicate": {
              "position": {
                "x": 123,
                "y": 456,
                "z": 789
              }
            }
          }
        ]
      }
    }
  },
  "rewards": {
    "function": "your:function"
  }
}
#

Now it works for any block at that position

silver pagoda
#

ok i will test now

rose spire
#

Oh and you dont need the requirements
But it should work with them as well

silver pagoda
#

it didnt run the function when i pressed the button but it did run the function when i used commands to give the advancement

rose spire
#

Did you replace the position with the actual block position?

silver pagoda
#

i inputed the position of the myself because i was standing on the button

rose spire
#

Can you send the advancement u use rn?

silver pagoda
#

{
"criteria": {
"block_used": {
"trigger": "minecraft:default_block_use",
"conditions": {
"location": [
{
"condition": "minecraft:location_check",
"predicate": {
"position": {
"x": 0,
"y": -60,
"z": 0
}
}
}
]
}
}
},
"rewards": {
"function": "hfbd:test"
}
}

#

i made a root advancement for it

#

but i cant access the datapack right now because im on a different laptop but ill send you a screenshot of the advancement and the root when i do

left ledgeBOT
#
Closed for inactivity

This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.