#Ensure execution at position of placed block?

1 messages · Page 1 of 1 (latest)

novel stratus
#

When using an advancement to listen to a block placement like so:

{
  "criteria": {
    "place_block": {
      "trigger": "minecraft:placed_block",
      "conditions": {
        "location": [
          {
            "condition": "minecraft:location_check",
            "predicate": {
              "block": {
                "blocks": "minecraft:diamond_block"
              }
            }
          }
        ]
      }
    }
  },
  "requirements": [
    [
      "place_block"
    ]
  ],
  "rewards": {
    "function": "foo:bar"
  }
}

The function bar gets executed as and at the player. Is there a built-in way to execute said function as/at the block?
If not, what's the best way to ensure execution at the block?

Is it just to perform a raycast function with ^ ^ ^ ?

finite hornet
#

I don't think there is a better option other than a raycast

#

though if you could give more context on what you're trying to do, maybe we can find a substitute solution

novel stratus
#

Trying to summon an entity to allow me to track a structure if the structure is built correctly.
I'm verifying the validity of the structure using a predicate inside the advancement to check it positioned as the block that's being placed.

When the advancement rewards the player I want to summon an entity in a specific location relative to the block that was placed.

#

I can't think of another way..

finite hornet
#

If I understood correctly the block/location that this block is gonna be put on is part of the structure right, and you wanna test things and run them based on it's location

#

If that's the case, I recommend you shove in a marker entity with a certain tag inside the block in the structure file (don't forget to enable saving entities) and you can run it at the location of that marker if the advancement passes

#

like:
if success, execute at @n[tag=sometag] positioned ~ ~1 ~

#

that should run it at the location of the placed block

#

eee if that made sense or my understanding is incorrect, try to make use of a marker if it helps and use the location relative to it

novel stratus
#

That makes sense but sadly I'm trying to track a structure built by the player, not one that generates, so it isn't stored as a structure file..

vale pond
#

so something along the lines of a conduit?

novel stratus
#

Kind of, yes.

fiery jetty
#

aah you're making a multiblock structure?

novel stratus
#

Not quite sure what that means 😅

fiery jetty
#

anyways the best option you have is to just do a raycast

finite hornet
#

you have some kind of ritual set up or something

vale pond
#

A raycast, it would be easy if there was a certain "unique" or "root" block for this structure. Then depending on your goal either run the raycast and check if that last block placed matches a location predicate that checks the other blocks.

Note that you would need 4 conditions, one for each wind-direction (unless you actually want it to face a certain direction).

If you don't have a unique block, run the function from a certain block in the structure OR you have to write a predicate for each block in the structure (not sure if we have tools for this or if this is actually such a good idea).

By unique I mean unique in position in the structure or unique in type

finite hornet
#

like that herobrine summoning shrine where you should place a gold block in the middle

finite hornet
novel stratus
novel stratus
vale pond
#

Or make the special block summon a marker when placed somehow and have a predicate run from the marker in a function that is in the tick tag.

novel stratus
#

That wouldn't work, but I appreciate the help!

If we're already talking raycasts, these is the correct measurements for a "perfect" raycast right?

execute positioned as @s rotated as @s anchored eyes positioned ^ ^ ^.1

#

They don't seem to be fully accurate when I test, am I missing something?

fiery jetty
#

yea no thats the downside of a raycast

#

you can try to lower the ^ ^ ^.1 to ^ ^ ^.01

#

but yea the lower that number gets, the more lag it creates when placing a lightning rod

#

so you need to find a balence

novel stratus
#

Eh screw it. These inaccuracies are so unlikely too happen.

I'll just fix it with an ugly check:

execute if block ~ ~ ~ minecraft:lightning_rod run return run say found lightning rod!
execute if block ~ ~ ~.1 minecraft:lightning_rod run return run say found lightning rod!
execute if block ~-.1 ~ ~ minecraft:lightning_rod run return run say found lightning rod!
execute if block ~.1 ~ ~.1 minecraft:lightning_rod run return run say found lightning rod!
execute if block ~-.1 ~ ~-.1 minecraft:lightning_rod run return run say found lightning rod!```
#

Thanks for the help Yall!

fiery jetty
#

np

blazing templeBOT
blazing templeBOT