How would I perform a inventory check on an Entity that has maintained components?

Started by Mouldycarnaval6 on

Topic category: Help with modding (Java Edition)

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How would I perform a inventory check on an Entity that has maintained components?

Hello! I am currently making a extension to the New TARDIS mod that adds in new gimmicks and cosmetics. One of which, is K-9, the funny little robot dog everyone liked that isn't available for 1.16.5 for any mod about the little guy anymore. I've got everything made and rolling so far. My only issue is I want K-9 to run off of a set of components that take damage after specific events. I've researched into how to make entities do AI tasks with an item in their inventory, but as far as I know, I'm just as clueless as everyone else who has tried to do similar things. How do I get the NPC to recognize an item in their inventory and do a trivial task like wandering based upon if that item is present?

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
there is a section on the…
Fri, 10/15/2021 - 03:22

there is a section on the entity to add an inventory

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I know about the section to…
Fri, 10/15/2021 - 04:05

I know about the section to add an inventory and the inventory bit actually works fine. My issue boils down to scripting an inventory 'check'. I want to check for a specific item in the NPC's inventory and have it change the NPC's behavior. The idea is to make primary components and sub-components, so you may have the machine, but you don't have the parts to have an 'operational' machine. Sorry, I hope that makes sense; I tried to clarify that as best as I could originally.

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
use procedure blocks such as…
Fri, 10/15/2021 - 04:22

use procedure blocks such as: get item in slot of event target entity inventory

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well, I've already used that…
Fri, 10/15/2021 - 20:03

Well, I've already used that and my entity either doesn't do anything when I apply it as a condition or continues with the wander task, neither achieving a correct outcome for item detection.

Here's some screenshots of my code and entity tasks:
https://drive.google.com/drive/folders/1XivPkUhDZcPqW1Vy8-7Nu4GMveSC5Qw…

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also, another thing to make…
Fri, 10/15/2021 - 20:07

Also, another thing to make note of, I know in the block code screenshot, it shows that I'm using a while loop and I have tried an if with it also. It only achieves both the same outcomes as before.

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
okay you do notice that will…
Fri, 10/15/2021 - 20:16

okay you do notice that will print on the console, not the game right?

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah wait a minute. I'm sorry,…
Fri, 10/15/2021 - 20:27

Ah wait a minute. I'm sorry, I had the wrong command. I'm not sure what the other one is used for, but I see what you were talking about now. Thank you. The NPC is wandering about just fine now.

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
And, aye, I see that it…
Fri, 10/15/2021 - 20:28

And, aye, I see that it prints in the console. If you want it to print in chat, you have to tell it specifically for the player or the game instance.

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yes. you can try by getting…
Fri, 10/15/2021 - 20:29

yes. you can try by getting nearest entity Type Player

Last seen on 20:04, 31. Oct 2021
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ah, I see thank you. You sir…
Fri, 10/15/2021 - 20:44

Ah, I see thank you. You sir are my savior. I was playing with the wrong command for 2 days wondering why it wasn't working on the inventory stuff, lol. What is Has (Event/Target Entity) In Inventory used for anyway?

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
for example it can be used…
Fri, 10/15/2021 - 20:58

for example it can be used so when you right click an entity, if you/him have a diamond on inventory, it gives another diamond