Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom advancements not work #61

Open
DeltaX86 opened this issue Oct 26, 2023 · 5 comments
Open

Custom advancements not work #61

DeltaX86 opened this issue Oct 26, 2023 · 5 comments
Assignees
Labels
cannot replicate this cannot be replicated right now done task has been completed

Comments

@DeltaX86
Copy link

Expected behavior

When the progress is accomplished the box should expand by the chosen number.

Observed/Actual behavior

The advancement is not detected, and border not change
The directory IslandAdvancements in database directory not created
But player Advancements exist in world directory

Steps/models to reproduce

datapacks.zip
advancements.zip

BentoBox version

Running Invalid (PUFFERFISH) 1.20.1.
BentoBox version: 2.0.0-SNAPSHOT-b2474
Database: JSON
Loaded Game Worlds:
boxed_world (Boxed): Overworld, Nether
Loaded Addons:
BentoBoxFAWEHandler 1.1.0 (ENABLED)
Border 4.1.1-SNAPSHOT-b185 (ENABLED)
Boxed 2.3.1-SNAPSHOT-b242 (ENABLED)
Challenges 1.3.0-SNAPSHOT-b531 (ENABLED)
Chat 1.1.4 (ENABLED)
ControlPanel 1.13.1-SNAPSHOT-b61 (ENABLED)
InvSwitcher 1.12.0-SNAPSHOT-b230 (ENABLED)
IslandFly 1.11.1-SNAPSHOT-b165 (ENABLED)
Level 2.11.0-SNAPSHOT-b541 (ENABLED)
Likes 2.4.0-SNAPSHOT-b97 (ENABLED)
Limits 1.19.1-SNAPSHOT-b318 (ENABLED)
RoseStackerHook 1.0.0 (ENABLED)
Visit 1.7.0-SNAPSHOT (ENABLED)

Plugin list

No response

Other

No response

@tastybento
Copy link
Member

It does work, but the advancements.yml format is as follows:

# Lists how many blocks the box will increase when advancement occurs
settings:
  default-root-increase: 0
  unknown-advancement-increase: 0
  unknown-recipe-increase: 0
  # Scores based on proprietary algorithm. If false, each advancement is scored manually
  automatic-scoring: false
advancements:
  'building/clay_have': 10
  'building/brick': 15

So, don't put "bentobox:" on the front.
Screenshot 2023-10-26 at 11 41 02 PM

Also, the zip file datapacks.zip is not a datapack file, so it won't work. But maybe you know that. If you use the BoxedDataPack.zip file, then it will.

@tastybento tastybento added done task has been completed and removed under investigation labels Oct 27, 2023
@BONNe
Copy link
Member

BONNe commented Oct 27, 2023

Hmm, tasty, don't you need a correct advancement location with providing datapack name?

Also, I used bentobox in front and it worked

@tastybento
Copy link
Member

Hmm, tasty, don't you need a correct advancement location with providing datapack name?

I'm not sure what that means. Could you explain more please?

Also, I used bentobox in front and it worked

Are you sure you have automatic and unknown-advancement-increase set to 0?

Here's the debug:

[23:40:36 INFO]: [BentoBox] DEBUG: bentobox:building/brick
[23:40:36 INFO]: [BentoBox] DEBUG: in world
[23:40:36 INFO]: [BentoBox] DEBUG: get score
[23:40:36 INFO]: [BentoBox] DEBUG: Checking yaml for advancements.building/brick
[23:40:36 INFO]: [BentoBox] DEBUG: It's there
[23:40:36 INFO]: [BentoBox] DEBUG: score is 15
[23:40:36 INFO]: [BentoBox] DEBUG: Changing size old = 11 new = 26
[23:40:36 INFO]: [BentoBox] DEBUG: Score for this advancement is 15

and the code from AdvancementsManager.java:

    /**
     * Get the score for this advancement
     * @param a - advancement
     * @return score of advancement, or 0 if it cannot be worked out
     */
    public int getScore(Advancement a) {
        BentoBox.getInstance().logDebug("get score");
        String adv = "advancements." + a.getKey().getKey();
        // Unknowns
        if (adv.endsWith("/root")) {
            return advConfig.getInt("settings.default-root-increase");
        }
        if (adv.contains("recipes")) {
            return this.unknownRecipeChange;
        }
        if (advConfig.getBoolean("settings.automatic-scoring")) {
            if (!a.getKey().getKey().contains("recipes") && a.getDisplay() != null) {
                float x = a.getDisplay().getX();
                float y = a.getDisplay().getY();
                return (int) Math.round(Math.sqrt(x * x + y * y));
            } else {
                return 0;
            }
        } else {
            BentoBox.getInstance().logDebug("Checking yaml for " + adv);
            if (advConfig.contains(adv)) {
                BentoBox.getInstance().logDebug("It's there");
                return advConfig.getInt(adv, this.unknownAdvChange);
            }

            return this.unknownAdvChange;
        }
    }

I don't think the YAML check would work with bentobox: on the front. We can change the code to require it, but String adv = "advancements." + a.getKey().getKey(); does not include it.

@tastybento tastybento added the cannot replicate this cannot be replicated right now label Oct 28, 2023
@BONNe
Copy link
Member

BONNe commented Oct 28, 2023

Hmm, then I do not know how are you getting correct advancement via:
Advancement a = Bukkit.getAdvancement(NamespacedKey.fromString(key));

The code NamespacedKey#fromString would return minecraft:building/brick advancement instead of bentobox:building/brick advancement.,

So, a method where you check advancements in https://github.com/BentoBoxWorld/Boxed/blob/develop/src/main/java/world/bentobox/boxed/AdvancementsManager.java#L232-L234
Will return that advancement is null, and the score is 0.

I tested in the debug, with 2 quests:
bentobox:building/clay_have: 1 and building/brick: 1 and as expected, that method returned 1 for the first one, and 0 for the second one. As second does not exist in Minecraft advancement folder

@BONNe
Copy link
Member

BONNe commented Oct 28, 2023

Also, if you use just the last part of NamespacedKey and it would work, then 2 quests with the same id but in different packages/trees would not be possible to define.
This is not like a huge issue, but a bit of an annoyance it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cannot replicate this cannot be replicated right now done task has been completed
Projects
None yet
Development

No branches or pull requests

3 participants