[0.8] Modules only apply after closing and re-opening the glasses inventory
SirEndii opened this issue ยท 6 comments
Describe
Currently, when we put a module in the smart glasses, they only apply after closing and re-opening the glasses' menu.
After some debugging,
SmartGlassesItemHandler#setStackInSlot
, placing an item into the modules slot and then skipping the called breakpoint(s) the module was recognized correctly, and the effects get applied to the glasses and Weirdly enough, setStackInSlot
gets called 6 times. Probably a client/server thing but 6 times seem wrong.
I tried to call the
int tickCount = ServerLifecycleHooks.getCurrentServer().getTickCount();
if (isDirty() && tickCount > (dirtyTickCount + 2)) {
updatePeripheralsAndModules(itemHandler);
isDirty = false;
}
This issue mainly exists for my own forgetfulness and for contributors who want to help.
Steps to reproduce
- Open glasses
- Put night vision module into a modules slot
- No night vision effect,
getModules
also returns an empty table - Close inventory
- Open inventory
- Module is loaded and you have night vision
Multiplayer?
No
Version
Own compiled build.
Minecraft, Forge and maybe other related mods versions
Forge 43.3.8 1.19.2
Screenshots or Videos
No response
Crashlog/log
No response
It's better if you can give a link to the actual code instead of pasting part of them
A link will include branch & file & line such useful information to help to position
It's better if you can give a link to the actual code instead of pasting part of them
A link will include branch & file & line such useful information to help to position
I agree
The only thing was that I wrote this in a rush. I hadn't the time to do that
Gonna edit the issue and add gh links to the actual code
I tried to test this on a dedicated server. But it seems that the modules don't work at all on a server. When inserting a module into the glasses, it never gets recognized by the glasses
It seems to be a client/server thing but I am unable to find a reason/fix for it...
After some random change now the module can work when inserting, and will stop to work when re-inserting ๐
And I found forge was doing some myth:
for some reason it's continuelly creating ModulePeripheral
and SmartGlassesItemHandler
.