Applied Energistics 2 Wireless Terminals

Applied Energistics 2 Wireless Terminals

29M Downloads

1.20.1 Items disappearing with in trinket slot

Gamerbolts opened this issue ยท 9 comments

commented

Hello!

I am using my own modpack here https://www.curseforge.com/minecraft/modpacks/pxc-fabric-adventure

Noticed that when the wireless terminal is equipped into the head slot for trinkets that when opening it and putting items into the crafting grid then closing the terminal if you reopen it then the items are gone, no longer in the ME system just vanished. If you put the wireless terminal into the hotbar and right click then put items into the grid you can close and reopen and it works. Then you put the grid back into your head slot and open and try a crafting recipe, close, reopen and the items are there again from when it was on the hotbar. So it is essentially deleting the items and I am not sure what to do. I have no idea if this is due to this mod, AE2 or Trinkets. Hopefully it can be resolved. Thanks!

commented

I think I know why this happens, but I am not sure if I can fix this

somehow the open terminal looses the reference to the terminal itemstack, thus being unable to save the inventory to it

commented

Interesting, well I hope you can fix it if you can, if not is there way to prevent the wireless terminal from going into the trinket slot? I am created a modpack for others to play and would not like them to lose items.

commented

is there way to prevent the wireless terminal from going into the trinket slot?

you can remove the items from the trinkets tags using a datapack or kubejs

commented

Thank you, i'll do this

commented

since the fix for this bug would be rather complicated, and only applies to 1.20.1, I won't be fixing this

commented

i presume this is the code that loses the reference to the ItemStack when in a trinket slot?

@Deprecated
public static ItemStack getSavedSlot(ItemStack hostItem, String slot) {
if (!(hostItem.getItem() instanceof IUniversalWirelessTerminalItem))
return ItemStack.EMPTY;
return ItemStack.of(hostItem.getOrCreateTag().getCompound(slot));
}

no, that is just responsible to load data from an already present ItemStack

the issue is that the ItemStack instance in the slot changes, but WTMenuHost doesn't know about this, so WTMenuHost#getItemStack still returns the old instance, where all changes are then saved to (but lost, since that stack isn't stored anywhere else)

AE2 has a workaround for that, but it only works for the player inventory, but not trinkets. (see WirelessTerminalMenuHost#ensureItemStillInSlot) (in later minecraft versions this is fixed by just always directly getting the ItemStack from the slot, but in 1.20.1, we don't even know the slot if it is a trinkets slot)

I wonder if we can assign each terminal a unique id in the nbt and scan all the non-inventory slots for it when attempting to save the data. Are we able to see the data if we check slots sequentially?

Also, if this is a trinkets specific issue, maybe posting an issue on the trinkets repo may help get a fix implemented?

commented

i presume this is the code that loses the reference to the ItemStack when in a trinket slot?

@Deprecated
public static ItemStack getSavedSlot(ItemStack hostItem, String slot) {
if (!(hostItem.getItem() instanceof IUniversalWirelessTerminalItem))
return ItemStack.EMPTY;
return ItemStack.of(hostItem.getOrCreateTag().getCompound(slot));
}

commented

i presume this is the code that loses the reference to the ItemStack when in a trinket slot?

@Deprecated
public static ItemStack getSavedSlot(ItemStack hostItem, String slot) {
if (!(hostItem.getItem() instanceof IUniversalWirelessTerminalItem))
return ItemStack.EMPTY;
return ItemStack.of(hostItem.getOrCreateTag().getCompound(slot));
}

no, that is just responsible to load data from an already present ItemStack

the issue is that the ItemStack instance in the slot changes, but WTMenuHost doesn't know about this, so WTMenuHost#getItemStack still returns the old instance, where all changes are then saved to (but lost, since that stack isn't stored anywhere else)

AE2 has a workaround for that, but it only works for the player inventory, but not trinkets. (see WirelessTerminalMenuHost#ensureItemStillInSlot)
(in later minecraft versions this is fixed by just always directly getting the ItemStack from the slot, but in 1.20.1, we don't even know the slot if it is a trinkets slot)

commented

i know this is an older issue and one that isn't getting a fix in 1.20.1 but i found a workaround. setting the terminal to "clear inventory after close" prevents items in the crafting slots getting deleted and applying any upgrades outside the trinket slot then returning it to the trinket slot does circumvent the issue. mentioning this in case anyone else comes across this when looking up the issue and needs a solution/workaround.