Skip to content

[Bug]: FTBQuestsEvents.completed() event of KubeJS depends on number of tags of the task/quest #1269

Description

@HaloSense

Mod

FTB Quests

Mod version

ftb-quests-forge:2001.4.7

Forge / Fabric version

1.20.1 Forge 47.2.32

Modpack & version

No response

What issue are you having?

I am attempting to write a KubeJS server script where quest/task completion is monitored by listening to FTBQuestsEvents.completed() event.

The effects I expect:

  1. When a quest is completed, the event is triggered and the game writes some texts in the chat column.
  2. Track the status of one or more specific tasks or quests. The task/quest I expect to use as a trigger has a specific tag.
  3. I use the method QuestObject.hasTag("def_boost_1") to determine whether the quest/task that triggered the event has the specific tag. If the trigger has the tag, said method should return true.
  4. When a task of a quest is completed, the event should be triggered once. When all the tasks of a quest are completed, the quest is completed and the event should be triggered once more. I don't expect the process to involve number of the tags of the task/quest.
  5. Hence, if a quest with x tasks is completed, the event should be triggered x+1 times (x for the tasks and once for the quest), no matter how many tags the task/quest have.

What is happening:

  1. When I complete a quest (no tag) with one task (no tag), the event is triggered twice, as expected.
  2. When I complete a quest (1 tag) with one task (no tag), the event is triggered three times. (Twice expected)
  3. When I complete a quest (no tag) with one task (1 tag), the event is triggered three times. (Twice expected)
    1. When I complete a quest (2 tags, one is the trigger tag and the other one isn't) with one task (no tag), the event is triggered three times, where the first output is false (for the task) and the last two are true (for the quest). (Twice expected, a false for the task and a true for the quest.)
      )
  4. When I complete a quest (1 tag, not the trigger tag) with one task (1 tag, the trigger tag), the event is triggered four times, where the first two outputs are true (for the task) and the last two are false (for the quest). (Twice expected, a true for the task and a false for the quest.)

Other mods involved: KubeJS

This is the code I use in a server script: (trigger tag is def_boost_1)

FTBQuestsEvents.completed(event => {

    const questObj = event.getObject();
    const player = event.player;

    player.tell(Text.of(`Has tag? ${questObj.hasTag("def_boost_1")}`))

})

This is an image of the output for case 5 of "What is happening":

image

Crashlogs

No response

Steps to reproduce

  1. Create a quest with one task.
  2. Create a KubeJS script listening for completion event, reference code provided above. Trigger tag name is def_boost_1.
  3. Add several tags to the quest and its task arbitrarily. Make sure no trigger tag is added.
  4. Complete the task (in normal way, instead of simply setting the status to "completed"). If the script is loaded normally, there should be outputs.
  5. You should see x+2 lines of output, where x indicates the total number of tags of the task and the quest.
  6. Add the target tag to the task. Reset the status and complete the quest again.
  7. You should see x+1 lines of true output and y+1 lines of false output, where x indicates the number of tags of the task and y indicated the number of tags of the quest.
  8. Adding more tasks with tags should be effective.

Anything else to note?

KubeJS version: kubejs-forge-2001.6.5-build.7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions