AE2-UEL / Applied-Energistics-2

AE2UEL, a Fork of a Minecraft Mod about Matter, Energy and using them to conquer the world.
https://legacy.curseforge.com/minecraft/mc-mods/ae2-extended-life
Other
74 stars 71 forks source link

Stack sizes over 127 in most AE2 blocks do not display in Multiplayer #196

Open mycroftjr opened 1 year ago

mycroftjr commented 1 year ago

Stack sizes above 127 do not display in the ME Interface or the crafting grid of the Pattern Terminal in Mutliplayer - instead, the slot appears to be empty.

To Reproduce Click 64 of an item into an ME Interface auto-stock configuration slot, then let go of the items and CTRL + Shift + Mouse Wheel scroll up while hovering over the config slot

Expected behavior The configured amount of the item should double to 128

Environment On a localhost server world, Modpack is Divine Journey 2 v2.18.0

KorewaLidesu commented 1 year ago

Weird, can't reproduce it? Dev environment, using v0.54.15

P/s: I just realize that your AE2 version isn't obtainable on CurseForge...

https://user-images.githubusercontent.com/24401452/208057972-52a4ffee-322d-47fa-9cf1-02bac37e6ac2.mp4

mycroftjr commented 1 year ago

Weird, can't reproduce it? Dev environment, using v0.54.15

Did you test it on a server or in singleplayer? I'll attempt to collect logs tomorrow if that's helpful. Did anything relevant change between 0.54.9 and 0.54.15?

P/s: I just realize that your AE2 version isn't obtainable on CurseForge...

https://www.curseforge.com/minecraft/mc-mods/ae2-extended-life/files/4056418, it's hidden by default as an Alpha file

KorewaLidesu commented 1 year ago

Did you test it on a server or in singleplayer?

Testing on single, will test on server later. P/s: Interesting, server side logic isn't working correctly.

Did anything relevant change between 0.54.9 and 0.54.15?

Don't really know tho...

KorewaLidesu commented 1 year ago

Using AE2 dev branch (commit https://github.com/PrototypeTrousers/Applied-Energistics-2/commit/e1ea4ae22f9e37a1e7fe72f61884f6a4deb8419a) Seem like happen to all container that have AppEngInternalInventory implement. Just done debug, client didn't sync properly with server? Testing with pattern terminal image Testing with interface image P/s: Stack still exist in the slot on server side. P/s2: Restart server, interface config inv image

KorewaLidesu commented 1 year ago

Update: Seem like Interface won't fire onChangeInventory if ItemStack is invisible, but Pattern still fire it own. Update2: -128x of Items.AIR? Version should not matter in this case. This gui with 127x item config will show properly, but if it more than 127 then gui will stop render them. The first slot of interface is configured with 128x Interface. No log avail while doing this image A separate network with storage bus attached to iface to checking iface inventory image

mycroftjr commented 1 year ago

So the problem is simply stacks of 128 or higher not rendering in the Interface except in singleplayer? Weirdly, the 128 renders fine in the Interface Configuration Terminal (which I didn't know was a thing until today).

I cloned the repo and debugged the server and client a bit with IntelliJ but wasn't able to find the problem...

mycroftjr commented 1 year ago

Everything works fine if you pretend you can see the item stack, at least in the Pattern Terminal - i.e. you can Ctrl + Shift + Scroll all the way up to 1024 for an ingredient and save it to a pattern, and the pattern will have 1024 of the item in the tooltip and work correctly (in the Quantum Compressor making Singularities), but the stack stops displaying once it has more than 127 items.

So it really seems like a pure display issue, but I can't quite figure out where the disconnect between single vs. multiplayer is, nor why it happens at 128 instead of 65 or even 100...

ghzdude commented 1 year ago

I think the issue may occur when information about the item is sent from server to client. And the reason it would not be able to go past 127 is because vanilla item stacksizes are stored as a signed byte (-128-127). I think that the item display sent to the client is at some point being converted to a vanilla itemstack (thus being capped at 127) before becoming an AE item stack.

mycroftjr commented 1 year ago

I think the issue may occur when information about the item is sent from server to client. And the reason it would not be able to go past 127 is because vanilla item stacksizes are stored as a signed byte (-128-127). I think that the item display sent to the client is at some point being converted to a vanilla itemstack (thus being capped at 127) before becoming an AE item stack.

An (unsigned) byte would actually make a lot of sense for vanilla stack size, but no, it's an int:

public final class ItemStack implements ICapabilitySerializable<NBTTagCompound> {
    ...
    private int stackSize;

although I guess it's NBT serialized as a byte?

    public ItemStack(NBTTagCompound p_i47263_1_) {
        ...
        this.stackSize = p_i47263_1_.getByte("Count");
mycroftjr commented 1 year ago

I think the issue may occur when information about the item is sent from server to client. And the reason it would not be able to go past 127 is because vanilla item stacksizes are stored as a signed byte (-128-127). I think that the item display sent to the client is at some point being converted to a vanilla itemstack (thus being capped at 127) before becoming an AE item stack.

An (unsigned) byte would actually make a lot of sense for vanilla stack size, but no, it's an int:

public final class ItemStack implements ICapabilitySerializable<NBTTagCompound> {
    ...
    private int stackSize;

although I guess it's NBT serialized as a byte?

    public ItemStack(NBTTagCompound p_i47263_1_) {
        ...
        this.stackSize = p_i47263_1_.getByte("Count");

I really thought that this would be the source of the bug but I went through all calls of ItemStack to/from NBT and replaced anything remotely relevant to use my helpers with the "stackSize" workaround in https://github.com/PrototypeTrousers/Applied-Energistics-2/pull/202 and... no noticable change in testing.