Coding Help!

Started by -Seba-San- on Sat, 08/10/2019 - 14:47

Topic category: Help with MCreator modding

Last seen on 12:23, 12. Nov 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Coding Help!
Sun, 08/11/2019 - 02:51 (edited)

Hello! I'm having some trouble coding my mod for more achievements.

I have a rudimentary understanding of coding but I don't know how to make an achievement that when the player picks up a block/item, the achievement is given to the player.

I have an image of what i have so far, but I'm quite stuck and need help. If anyone knows the proper code for such an achievement, I would be very grateful!

Thank you!

My work so far.

 

Edited by -Seba-San- on Sun, 08/11/2019 - 02:51
Last seen on 15:25, 7. Nov 2019
Joined Dec 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
I can't see your screenshot…
Sat, 08/10/2019 - 16:37

I can't see your screenshot. Are we talking about the player just picking up a random block/item or a specific one?

 

Last seen on 12:23, 12. Nov 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Terribly sorry! The image…
Sat, 08/10/2019 - 17:44

Terribly sorry! The image was a print screen. Here's a imgur link: https://imgur.com/a/agFQKuS

I'm trying to give the player the "Tree Puncher" achievement when the player picks up any vannila log.

Last seen on 15:25, 7. Nov 2019
Joined Dec 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
The player won't get the…
Sat, 08/10/2019 - 18:18

The player won't get the achievement when there's no external or additional trigger for this procedure to trigger. Use either the "OnPlayerTick" or "WhenPlayerPicksUpItem" trigger but the way I recommend is to edit the .json file of your advancement because that's how minecraft does it. Search for this:

 

"criteria": {
    "<AchievementName>": {
      "trigger": "<AchievementName>"
    }
  },

 

select the "trigger" line part and replace it with this:

 

"trigger": "minecraft:inventory_changed",
            "conditions": {
                "items": [
                    {
                        "item": "minecraft:log"
                    }
                ]
            }

 

And then you should get your advancement once the Player has a Log in his/her inventory. If it doesn't work then the advancement won't be shown in the advancement GUI/Tab thingy.

 

Last seen on 12:23, 12. Nov 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Thank you so much! This…
Sat, 08/10/2019 - 19:32

Thank you so much! This helps a lot!

Last seen on 12:23, 12. Nov 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Despite my appreciation, I'm…
Sat, 08/10/2019 - 20:12

Despite my appreciation, I'm quite confused on where to put this code. I unlocked the code on the asset it's self and cant find the specific line you are talking about: 

"criteria": {
    "<AchievementName>": {
      "trigger": "<AchievementName>"
    }
  }

I also went to the file it's self in the file explorer, no dice; the file wasn't there. All were .class files. 

Am i looking in the wrong place?

Last seen on 15:25, 7. Nov 2019
Joined Dec 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
The word <AchievementName>…
Sat, 08/10/2019 - 21:13

The word <AchievementName> is not literally there. I was jsut trying to show that that's where your achievements registry name would be. If you still don't find it just select the entire line that has the word "trigger" in it and replace it with the piece of code I showed you before.

Last seen on 12:23, 12. Nov 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
It seems I didn't clarify my…
Sat, 08/10/2019 - 22:57

It seems I didn't clarify my point, I physically cannot find the trigger line; it's non-existent. I will provide screenshots for more info.

 

https://imgur.com/a/pgKJdEw

 

Again, am i looking in the wrong place or am i doing something wrong?

 

Last seen on 15:25, 7. Nov 2019
Joined Dec 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
You have to open the .Json…
Mon, 08/12/2019 - 17:02

You have to open the .Json file NOT the .Java file

Last seen on 12:23, 12. Nov 2019
Joined Aug 2019
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Okay I found and succesfully…
Wed, 08/14/2019 - 02:19

Okay I found and succesfully edited the .json file and added the line of code you added, however it still wont work.

I edited the code from the unlocked source code and didnt lock it back, as it would "reset" the code and undo my changes.

Once more; am I doing something wrong?

Images: https://imgur.com/a/ZVKVuva

Last seen on 15:25, 7. Nov 2019
Joined Dec 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Add one more bracket above …
Wed, 08/14/2019 - 19:42

Add one more bracket above "parent"