Need help with out of sync issue on living entity inventory and world load

Started by zjkipping on

Topic category: Troubleshooting, bugs, and solutions

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Need help with out of sync issue on living entity inventory and world load
Tue, 06/20/2023 - 20:59 (edited)

I am currently experiencing a frustrating potential bug with a living entity's inventory system where the initial load of the world causes the entity's inventory slot data to be wiped until the player right-clicks on the entity (causing the inventory GUI to pop up).

After the world is loaded and the first right-click on the entity occurs, things work perfectly fine with the procedure logic. The procedure logic can be seen below, it triggers off the entity's tick update trigger. I simplified it compared to the additional item type checks I want to have:
if (not(Get a copy of item slot [0] of [Event/target entity] = Item in main-hand of [Event/target entity])) { do Set item in main-hand of [Event/target entity] to [1] Get a copy of item from slot [0] of [Event/target entity] if it has inventory }

The logic is simple. What I am trying to accomplish is having an entity with an "equipment" slot on it's inventory GUI so you can swap out which main_hand item it has. So, when the inventory slot changes the main hand should change to match. Though the problem is when the world first loads the "Render" thread thinks the inventory slot has air in it thus it tries to equip air. Once you right the entity once, it realizes it actually has an item in the slot and equips that instead.

Is this just because the entity doesn't have an inventory on it after world load? Whenever it spawns it correctly works with the below procedure (done on entity spawn trigger)...

Set [1] [stone pickaxe] in slot [0] of [Event/target entity] if it has inventory

Any help with this is greatly appreciated. Trying to learn this tool to help create a learning path for my 10 year old nephew who wants to learn how to mod minecraft a bit to get him started on "programming".

Edited by zjkipping on Tue, 06/20/2023 - 20:59
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The reason I am doing this…
Tue, 06/20/2023 - 20:54

The reason I am doing this logic in the entity tick update trigger is because for w/e reason it seems you can't get the living entity reference while in the inventory GUI that pops up when you right click it. The only "entity" reference you get is to the player and not the living entity mob that the GUI/inventory is bound to. Shouldn't you have access to both? The "entity" (living entity mob) and the "source entity" (player)?

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello friend, did you manage…
Wed, 01/17/2024 - 06:32

Hello friend, did you manage to solve it? I have the same problem