MarkusBordihn / BOs-Easy-NPC

Create easily NPC for your world or for your mod.
Other
19 stars 7 forks source link

[Bug] NPC 1 cannot open NPC 2's dialogues from his actions #300

Closed Yoshun closed 1 month ago

Yoshun commented 1 month ago

Minecraft and Mod version ๐Ÿž Minecraft 1.20.1 with Fabric 0.5.11 - EasyNPC 5.5.6

Describe the bug ๐Ÿž I want to display dialogues based on a score from the player's scoreboard. For this, I created two NPCs. A first which has all the dialogues and a second which has the actions which open the desired dialogue according to the score via the "execute" and "easy_npc dialog open" command like this : /execute if score @initiator testDialog matches 1 run easy_npc dialog open 09d270d0-b91c-4abc-ba1d-b88e79672556 @initiator npc_dialog_1

The "execute" command works if I type it by hand but it doesn't work from the NPC and I get this error in the console: The entity Humanoid['NPC 2'/321, l='ServerLevel[world]', x=-12.50, y=102.00, z=4.50] tried to access EasyNPC with UUID 09d270d0-b91c-4abc-ba1d-b88e79672556!

Note that a "give" type command works well, it's really the opening of the dialogue that poses a problem. And in case it's related, I'll take this opportunity to report a second problem that I encountered. On my production server (with EasyNPC 5.5.1, I haven't taken the time to update it yet), I have another error message with the same configuration when another player clicks on the NPC, the message in the console says "Player has no access!". And I told myself that I was going to use the command to change the owner but I got the same error as above at that moment.

To Reproduce โš™๏ธ Steps to reproduce the behavior:

  1. Create a dummy objectiv : /scoreboard objectives add testDialog dummy
  2. Set score : /scoreboard players set Yoshun testDialog 1
  3. Create the first NPC with two dialog in advanced tab
  4. Create the second NPC with two actions that should open the corresponding dialogue based on the score with : /execute if score @initiator testDialog matches 1 run easy_npc dialog open 09d270d0-b91c-4abc-ba1d-b88e79672556 @initiator npc_dialog_1

I exported the NPCs if necessary, it will certainly be necessary to change the UUID in the NPC 2 actions :

Expected behavior โœ”๏ธ I would therefore like the dialog to open with the "/easy_npc dialog open" command when it is carried out from an action of another NPC.

And congratulations again for the work done on the mod, itโ€™s incredible :)

MarkusBordihn commented 1 month ago

Thank you for the detailed report. Currently, a "safety" check is in place to prevent loops or other unintended behaviors involving NPCs and player actions. However, I'll investigate whether this check can be refined to allow interactions between NPCs that share the same ownership status (either both have no owner or both are owned by the same player).

Additionally, I'll review the other commands to ensure the access system functions correctly and to address any instances where the "Player has no access!" message might be erroneously displayed.

Yoshun commented 1 month ago

In fact, it is just not possible to make a single NPC with dialogues and actions associated with the dialogue. If I define dialogs, it automatically opens the last dialog in the list and I can't use an action to open the dialog I want. The simple solution would be to be able to define dialogues with a parameter to prevent them from being automatically displayed as soon as we interact with the NPC. This way, we can let the actions manage the display and there is no need for 2 NPCs for that.

MarkusBordihn commented 1 month ago

I'm currently working on a solution that will allow you to remove the default "open trading screen" and "open default dialog" options from an NPC. The main task left is finalizing the automatic migration of existing NPC data.

Once this is complete, it will be possible to create a single NPC with dialogues and actions that aren't automatically triggered. This means you'll be able to control when specific dialogues are displayed through actions, without the need for multiple NPCs. Thank you for your patience as I finalize these updates.

Yoshun commented 1 month ago

It will be perfect! Thank you so much!

MarkusBordihn commented 1 month ago

I'm updating the mod to version 5.5.7, which should work smoothly for what you need.

You can turn off or remove the "Open Default Dialog" and "Open Trading Screen" by going to "Actions" -> "On Interaction," like this:

image

Also, by turning on "debug" mode, you can now see why permissions are either granted or denied.

Feel free to reach out if you have any more problems.