Jump to content

Recommended Posts

Posted (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 by xana43
link change
Posted (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 by Luis_ST
Posted
  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

 

Posted

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

Posted (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 by xana43
Posted (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 by Luis_ST
Posted
  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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been attempting to trouble shoot performance issues with this version of forge - I've been getting 10 - 14 FPS on a fresh install while the same settings on vanilla will net me ~ 250 FPS  I've tried setting ram to 2, 4, 6, 8, 16 GB, making sure that the GPU is being used - although i cant confirm other than the F3 screen - I've cleared out my .Minecraft folder and done a fresh install of forge multiple times, I even reinstalled Java 17 - from what i read this is the recommended for this version of MC, - Graphics drivers are fully up to date and I've tried it on both studio and game ready drivers. I have a spark report but I dont know what to do with it https://spark.lucko.me/BrrJ5vzX6k Would love some help for this as Ive spent three days on this
    • One fateful day, my life took an unexpected turn when I received a phone call that would change everything. The voice on the other end claimed to be from my bank, delivering alarming news: my account had been frozen due to suspicious activity. Panic surged through me as I listened, my heart racing at the thought of losing my hard-earned savings. At that moment, I had about 130,000 USD in my bank, equivalent to around 2 BTC. The caller spoke with such authority and urgency that I felt compelled to act immediately. They insisted that the only way to protect my funds was to transfer Bitcoin BTC to them for "safekeeping. In my fear and confusion, I believed I was making a wise decision to secure my finances. Without fully grasping the implications, I complied and transferred the equivalent of my savings in Bitcoin, convinced I was safeguarding my money. It wasn’t until later that the reality of my situation hit me like a ton of bricks. I had been duped, and the weight of my mistake was unbearable. Shame and disbelief washed over me as I realized how easily I had been manipulated. How could I have let this happen? The feeling of vulnerability was overwhelming, and I was left grappling with the consequences of my actions. I learned about a recovery expert named RAPID DIGITAL RECOVERY. Desperate to reclaim what I had lost, I reached out for help. RAPID DIGITAL RECOVERY was knowledgeable and reassuring, explaining that there was a chance to trace the Bitcoin I had sent. With their expertise, they tracked the stolen funds to a peer-to-peer (P2P) exchanger based in the United Kingdom. This revelation sparked a glimmer of hope within me, a sense that perhaps justice could be served. RAPID DIGITAL RECOVERY collaborated with Action Fraud, the UK's national reporting center for fraud and cybercrime, to take decisive action against the scammers. Knowing that law enforcement was involved provided me with a sense of relief. The thought that the culprits behind my suffering could be brought to justice was comforting. In an incredible turn of events, RAPID DIGITAL RECOVERY successfully recovered all my funds, restoring my faith in the possibility of justice and recovery.
    • My game crashed in 1.12.2 here is the crash log https://pastebin.com/6MYu4mGy
    • I created a Modpack Forge in 1.20.1 for my friend and I. There are 135 mods including "Essential". I was able to play an 8 hour session without problem but when I relaunch my world, I crashed when I opened the menu of the game "ESC" or after about 15 minutes of session. I can't find the source of the problem. Latest.log and Debug.log : https://paste.ee/p/B0npvlRw
    • Hello! Faced with the same problem. Can you please describe in more detail how you rewrote the toNetwork and fromNetwork methods?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.