MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.65k stars 400 forks source link

Using the new inventory handling feature #752

Closed EchoesNetwork closed 4 years ago

EchoesNetwork commented 5 years ago

Hi,

I noticed one of the recently closed pull requests implemented inventory handling and I'm excited to write some scripts that make use of it! However, I'm not sure which API documentation is relevant to it. How would I make use of the new inventoryhandling=true feature?

Thanks.

ORelio commented 5 years ago

Currently, this is work in progress so there is no API nor commands for it. See #738 and #205.

xPenguinx commented 5 years ago

Right, the inventoryhandling is just something i've started however I reached a barrier with an issue with readNextNbtData not working properly for it thus I'm waiting on if someone can possibly fix it or I somehow find a way to do it.

ORelio commented 5 years ago

Do you have any sample of problematic NBT? I should be able to debug the parsing function since I wrote it and it is pretty well documented.

xPenguinx commented 5 years ago

Do you have any sample of problematic NBT? I should be able to debug the parsing function since I wrote it and it is pretty well documented.

If you enable the feature and just login to a server maybe do /ah or something or it should even work when you just login with items. I have used the fNBT library to fix it by making it read all the bytes in the cache and then check the size to remove the amount which worked fine but isn't the most efficient way.

ORelio commented 5 years ago

Okay. I'll have a look at this. Maybe putting a book or enchanted item in inventory will trigger the issue.

xPenguinx commented 5 years ago

Okay. I'll have a look at this. Maybe putting a book or enchanted item in inventory will trigger the issue.

You might not have to! Looks like it was something else causing the issue. Will be committing soon also was able to handle clientside closewindow

ORelio commented 5 years ago

Well, I was expecting the ReadNextNbt() utility to contain bugs as it pretty new, and been tested with 1.14 terrain heightmaps only so it may not work with some other NBT fields 😄

JovonXandering commented 5 years ago

Well, I was expecting the ReadNextNbt() utility to contain bugs as it pretty new, and been tested with 1.14 terrain heightmaps only so it may not work with some other NBT fields 😄

Hi I am new to this so I might be wrong, but was messing around with the inventory handler stuff, and I think I found the problem with reading NBTs In the original code, it checked if theres a nbt by doing if (packetData.ToArray().Count() > 0) { dataTypes.ReadNextNbt(packetData); } But packetData will contain other data for other slots, so it'll always be true, therefore checking all items for NBT. so I changed it to if (packetData.ToArray()[0] != 0) { dataTypes.ReadNextNbt(packetData); } else { dataTypes.ReadNextByte(packetData); //if it doesnt contain NBT, it'll read it to get rid of the byte } I am not good at programming, so please correct me if I am wrong

RedByte1337 commented 5 years ago

Any updates on this? Can we access the inventory through the client?

ORelio commented 5 years ago

Don't have time to work on new features myself, so it entierely depends on contributions. Currently, this has not reached a usable state. Only some data structures are present.

ORelio commented 4 years ago

@xPenguinx Hi, for your information a fix for issue #883 seems to match the issue you encountered here, with inventory handling. As per https://wiki.vg/Slot_Data the NBT tag may be replaced by 0x00 (null) when no NBT data is present in the slot. readNextNbtData() will now handle this as a valid (but empty) NBT tag, although it is better to also check for 0x00 when handling the packet.

ORelio commented 4 years ago

Inventories are now handled in the newest development build.