xana43 Posted April 15, 2022 Posted April 15, 2022 (edited) I'm working on a pretty advanced mod that has to muck about with dimensions and changing the entire player inventory between these dimensions. I currently have this Capability https://github.com/xana43/CodeLyoko-Legacy/blob/MC-1.18/src/main/java/com/Ultra_Nerd/CodeLyokoLegacy/player/Dimension/DimensionCapabilities.java and it's registered here https://github.com/xana43/CodeLyoko-Legacy/blob/MC-1.18/src/main/java/com/Ultra_Nerd//CodeLyokoLegacy/player/Capabilities/CapabilityRegistration.java and like most of the mod functions i'm doing I'm defining the server message here https://github.com/xana43/CodeLyoko-Legacy/blob/MC-1.18/src/main/java/com/Ultra_Nerd//CodeLyokoLegacy/Network/Util/CapabilityPlayerInventorySync.java and adding the capability packet handler here https://github.com/xana43/CodeLyoko-Legacy/blob/MC-1.18/src/main/java/com/Ultra_Nerd//CodeLyokoLegacy/Network/Util/PacketHandler.java this issue i've been having is that for some reason whenever the inventory save is triggered (currently it's triggered whenever the player changes a dimension and the dimension they're changing to isn't a vanilla dimension) the log keeps saying this https://pastebin.com/VPDMYry3 I've dealt with handling simple values in the Byte buffer (such as normal NBT as defined by the player Class capability) but i'm confused on how reading a collection works. any help would be appreciated (also sorry if the formatting it's the prettiest i'm a bit rusty on my java because i've mainly been working on other projects that are in C# or javascript) Edited April 15, 2022 by xana43 link change Quote
Luis_ST Posted April 15, 2022 Posted April 15, 2022 (edited) On 4/15/2022 at 12:48 AM, xana43 said: I'm working on a pretty advanced mod that has to muck about with dimensions and changing the entire player inventory between these dimensions. Expand why did you not use Forge's IItemHandler and ItemStackHandler? create a Level Capability and create there a Map with the IItemHandler (Inventory) and the Player (you should use the GameProfile or the UUID) then subscribe to PlayerChangedDimensionEvent and load the Inventory from the Level Capability the save and sync of IItemHandler is done automatically, if you create the Capability Correct Edited April 15, 2022 by Luis_ST Quote
xana43 Posted April 15, 2022 Author Posted April 15, 2022 On 4/15/2022 at 11:37 AM, Luis_ST said: the save and sync of IItemHandler is done automatically, if you create the Capability Correct Expand huh, that's good to know that it handles all that now, because back when I first started modding (1.12) IItem handler didn't use to sync with the server properly Quote
xana43 Posted April 15, 2022 Author Posted April 15, 2022 well now i'm confused, because the player can't provide an Item handler, only the raw inventory class that it contains, i'm not sure if that's the same thing, but i'll try it and see what happens Quote
Luis_ST Posted April 15, 2022 Posted April 15, 2022 extends the Forge IItemHandler and add it to the Player Quote
xana43 Posted April 15, 2022 Author Posted April 15, 2022 (edited) how would I go about doing that? I've been trying for the past hour and i'm really confused, is it that I need to extend the item handler in the capability class or add an item handler to the player and reference that? Edited April 15, 2022 by xana43 Quote
Luis_ST Posted April 15, 2022 Posted April 15, 2022 (edited) On 4/15/2022 at 1:23 PM, xana43 said: how would I go about doing that? I've been trying for the past hour and i'm really confused, is it that I need to extend the item handler in the capability class or add an item handler to the player and reference that? Expand if you don't know how to extends an Interface and a class, you should learn basic java before modding minecraft Edited April 15, 2022 by Luis_ST Quote
xana43 Posted April 15, 2022 Author Posted April 15, 2022 On 4/15/2022 at 2:07 PM, Luis_ST said: if you don't know how to extends an Interface and a class Expand oh that's what you mean, well I tried to implement I Item handler, but it seemed to be not the thing I was looking for (a lot more data needed to be sent to it than was available) so I decided to try a more simpler route. I extended INBTSerializeable<ListTag> then made a hashmap that held a UUID and a ListTag, and used the methods that are part of the inventory class (I.E. player.getInventory().save()) and loaded the map with that, then serialized it using a forloop on it's keyset and returned each element etc etc. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.