Jump to content

Recommended Posts

Posted

Hello again,

I am very new to the whole advancement thing and i was wondering how i could

A) add my own and 

B) remove vanilla ones

 

I know that removing the vanilla ones may cause issues with other mods but it is necessary because i am complete changing the games progression.

Posted
  On 8/12/2017 at 1:05 AM, jabelar said:

If you're considering advancements that are triggered similarly to vanilla ones, and for replacing vanilla ones you might want to read up on the JSON capabilities: http://www.minecraftforum.net/forums/minecraft-discussion/redstone-discussion-and/commands-command-blocks-and/2809368-1-12-custom-advancements-aka-achievements

Expand  

I know that i could just delete the advancement files but i cant have my mod do that automatically and unless i misread something.  I also cant include them in my mod i would have to add them to my data folder.  Would i need to make my mod write the json files to the data folder every time a world is created or is there a different way of doing it.

Posted

Forge will load advancements from your mod's assets/<modid>/advancements directory.

 

I don't think there's any way to remove vanilla advancements without messing around with the internals of AdvancementManager.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Thank you for explaining how to add them.  I will take a look at Advancement manager to see if i can remove the vanilla ones.  Worse case scenario i will advise users to delete the vanilla ones from their world folder.  Assuming that minecraft wont just add them back in.

Edited by drok0920
Posted

I have look into AdvancementManager and an instance of it is located in World but it is not accessible.  Is there another way to remove the vanilla advancement other than deleting them from their folder.

Posted

WorldServer#getAdvancementManager returns the server world's AdvancementManager. The World#advancementManager field is never used by client worlds, I'm not entirely sure why it's in World rather than WorldServer.

 

Looking into this further, advancements are actually stored in the AdvancementList instance (AdvancementManager.ADVANCEMENT_LIST and ClientAdvancementManager#advancementList). You'll need to use reflection to access the server instance and the internal collections.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/15/2017 at 12:35 AM, drok0920 said:

Ok i think i have figured out how to access the field via reflection but when should i remove the advancements?  I would assume post init?

Expand  

 

No, advancements are loaded when the server starts (WorldServer#init, called from MinecraftServer#loadAllWorlds) and when it's asked to reload them (MinecraftServer#reload).

 

WorldEvent.Load will be fired for dimension 0 just after the initial load, but there's currently no event fired for the reload. This PR adds an event for the reload, but it's not likely to be merged until the author documents the event.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/15/2017 at 2:44 AM, Choonster said:

 

No, advancements are loaded when the server starts (WorldServer#init, called from MinecraftServer#loadAllWorlds) and when it's asked to reload them (MinecraftServer#reload).

 

WorldEvent.Load will be fired for dimension 0 just after the initial load, but there's currently no event fired for the reload. This PR adds an event for the reload, but it's not likely to be merged until the author documents the event.

Expand  

ok so ill remove them during the load event but when does reload even get triggered? i am aware that there is no event but what would cause it to reload anyway.

Posted
  On 8/15/2017 at 4:29 PM, drok0920 said:

ok so ill remove them during the load event but when does reload even get triggered? i am aware that there is no event but what would cause it to reload anyway.

Expand  

 

If you look at the usages of MinecraftServer#reload, you'll see that it's called from CommandReload#execute (i.e. the /reload command) and from Minecraft#refreshResources (i.e. the method used to reload resource packs).

 

It's only called from Minecraft#refreshResources when there's an integrated server running (i.e. single player or the LAN host).

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 8/15/2017 at 8:45 PM, drok0920 said:

One last question.  Where would i find the WorldServer instance.

Expand  

 

It depends where you need it.

 

For WorldEvent.Load, use WorldEvent#getWorld to get the World. Most other places will have a World argument/field available.

 

If World#isRemote is false, you're on the logical server and the World is a WorldServer.

 

If you really don't have a World/WorldServer available, use DimensionManager.getWorld to get the WorldServer for dimension 0.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Thank you so much for your help but i have one last question.  I have put my advancement in a sub folder of advancements and it isnt loading.  There is no error so i would assume it only loads from the advancements folder and not its sub folders.  If this is the case how can i put my advancements in separate or custom tabs?

 

Edit after some experimentation even advancements located in advancements and not a subfolder still dont load.  No error is logged.

 

Here is my advancement:

	{
    "display": {
        "icon": {
            "item": "poverhaul:rock"
        },
        "title": "Leave No Stone Unturned"
    },
    "parent": "",
    "criteria": {
        "rock": {
            "trigger": "minecraft:inventory_changed",
            "conditions": {
                "items": [
                    {
                        "item": "poverhaul:rock"
                    }
                ]
            }
        }
    }
}
	

Capture.PNG

Edited by drok0920
Posted

If your advancement should be the root of a new tab, don't specify the parent element in the JSON file at all. If you specify the parent element, use an advancement that exists.

 

If you specify the parent element and the specified advancement doesn't exist, AdvancementList#loadAdvancements will ignore your advancement.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Ok thank you i will change that now.  But how do I create a new tab?  Will it auto create it and if so how do i name it or set the icon.  Also is it possible to use sub folders for organization?

Edited by drok0920
Posted (edited)
  On 8/17/2017 at 7:49 PM, drok0920 said:

Ok thank you i will change that now.  But how do I create a new tab?

Expand  

 

Just create an advancement with no parent and it will become the root of a new tab.

 

  Quote

Will it auto create it and if so how do i name it or set the icon.

Expand  

 

The JSON format is documented on the wiki. The display element controls how the advancement (and the tab if it's a root) is displayed.

 

  Quote

 Also is it possible to use sub folders for organization?

Expand  

 

Yes, Forge will traverse every file in your mod's advancements directory and every subdirectory of it.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I copied your advancements into my mod, modified them to use vanilla items and my mod ID for the parent advancements and then ran the game. When I loaded a world, I got an error saying that both advancements were missing a description element in the display object.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Can you show me your error log because i have added a description and they are still not loading and i dont see any errors almost as if they are not being seen at all.

Posted

These are the errors I get when both advancements are missing the description element:

  Reveal hidden contents

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

This is really weird.  I put the error back in to see if i would get it and i dont.  I refreshed the project in eclipse and created a new world just in case.  Are you sure that it auto loads them from the assets?  This is my log maybe i am missing something:

 

  Reveal hidden contents

 

I have no idea why its not loading them at all.  Is my forge version bugged?  My build.gradle version is 1.12-14.21.1.2443

Posted

I'm not sure what's going on in your workspace.

 

Try setting some breakpoints and stepping through ForgeHooks.loadAdvancements and AdvancementList#loadAdvancements in the debugger to see what's happening with your mod's advancements.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Im going with i found the problem as there is no method called loadAdvancements in ForgeHooks.  Why is this and how can i fix it.  Do i just rebuild my work space?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.