Creating achievement

Started by Taras Ogurtsov on

Topic category: Help with modding (Java Edition)

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Creating achievement

Can anyone tell me how to make an achievement like "Sniper Duel", so that the player gets it when hitting a block from a certain distance?

Last seen on 15:03, 16. May 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello!You could do this by…
Tue, 08/01/2023 - 20:06

Hello!
You could do this by running a procedure where the block is hit by the arrow.

You just need an if not statement and a "does entity exist at in square cube with size [] of type Player" block. [found in world data]

If you are using a custom ranged weapon, just set the procedure to run when the projectile hits a block.

Hope this helps!

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It works, thank you!
Thu, 08/03/2023 - 15:18

It works, thank you!

Last seen on 15:03, 16. May 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Glad to help ^^ Have a good…
Thu, 08/03/2023 - 16:11

Glad to help ^^ Have a good day!

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There is a problem, if there…
Thu, 08/03/2023 - 19:49

There is a problem, if there is someone else standing not far from the block you need to hit, the player who shot will not get the achievement, even if he shot from the right distance. So, is it possible to make the procedure take into account only the player who shoots?

Last seen on 15:03, 16. May 2024
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It should theoretically…
Thu, 08/03/2023 - 20:41

It should theoretically still work, since player and server player are different entities

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
There is another problem, it…
Fri, 08/04/2023 - 13:42

There is another problem, it turns out that the achievement is not even being given to the player. Before I used to use the chat message to know that everything was working properly, but now I replaced it with the procedure for giving the achievement to the player and realized that now it doesn't work at all. This procedure just doesn't understand exactly who to give the achievement to. I've tried changing the Event/target entity to other components, but mcreator says there is a problem in this and even other procedures related to the block you need to hit. Could you please explain to me how to fix this?

Last seen on 21:38, 22. Apr 2024
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you send a picture of…
Fri, 08/04/2023 - 15:10

Can you send a picture of your procedure?

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
of course
Fri, 08/04/2023 - 15:55

of course

Last seen on 21:38, 22. Apr 2024
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try replacing "event target…
Sun, 08/13/2023 - 08:41

Try replacing "event target entity" with "get nearest entity at x y z in square cube with size 20 of type player

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I get your idea, but it…
Wed, 08/23/2023 - 17:13

I get your idea, but it doesn't work. First of all, the main condition for the achievement is to be outside the specified distance, i.e. the player can be at the minimum distance of 10 blocks, or at a much greater distance. And the second problem is that with this method, the achievement can be obtained by a completely different player who didn't even shoot at the block. I still haven't found a way to make this achievement work, so if anyone has any ideas, please help!

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Instead of verifying a…
Wed, 08/23/2023 - 18:44

Instead of verifying a player's proximity to the block that was hit, just compute the distance between the two (there should be a procedure to get entity's X, Y and Z value). 

You can add a check to ensure that arrow was shot by a player before calculating distance and granting advancement. 

Distance formula: d = √((x2 - x1)² + (y2 - y1)² + (z2 - z1)²)

Here, x1, y1, z1 are the player's coordinates, while x2, y2, z2 pertain to the block's location (x, y, z from provided dependencies). The d represents the distance between them.

Afterwards, check if the calculated distance equals or exceeds a set threshold: √((x2 - x1)² + (y2 - y1)² + (z2 - z1)²) >= Threshold

For more efficient, omit the square root computation and compare the squared distance against your squared desired threshold: ((x2 - x1)² + (y2 - y1)² + (z2 - z1)²) >= Threshold²

Bypassing the square root is beneficial as it's a resource-intensive operation, and you can simply compare the squared distances since precise values aren't necessary.

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This method is really…
Wed, 08/23/2023 - 20:22

This method is really interesting, but how do I get the coordinates of the player who is shooting? As I wrote in one of the posts above, the problem is that the game just doesn't understand who to give the achievement to, and in our case whose coordinates it needs to take. Moreover, I tried to make it so that when an arrow hits a block, a block is spawned at x y z coordinates of event/target entity, and I noticed that the block is spawned either exactly at the place of the arrow or within a radius of 1-2 blocks from it. Could you please explain me how to solve this problem?

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
X, Y, and Z denote the…
Thu, 08/24/2023 - 09:09

X, Y, and Z denote the coordinates of the hit block. In the Entity Data section, on top, you will find three procedures that provide the entity's position, one for x, y and z. The event/target entity refers to the entity that fired this arrow (also known as the owner).

 

Something like this should work:

Distance calc

Just replace 5 with a distance you want or entire 5^2 with a squared distance you want and pick your advancement ofc.

 

PS. For the future: in this trigger, arrow is available as immediate source entity in Minecraft Componentssection

Last seen on 12:18, 18. May 2024
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes, I understand how the…
Thu, 08/24/2023 - 15:24

Yes, I understand how the procedure works, but again, in my case the game sees the arrow as an event/target entity, not the player.