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)
10 hours ago, 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.

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
12 minutes ago, Luis_ST said:

the save and sync of IItemHandler is done automatically, if you create the Capability Correct

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)
44 minutes ago, 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?

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
37 minutes ago, Luis_ST said:

if you don't know how to extends an Interface and a class

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

    • How do I download mods for minecraft pe
    • I've tried multiple ways to get the chunk coordinates and none of them have worked, so I'm guessing it may be getChunk().  Is there another way to forcibly load a chunk on that same tick? If all else fails I guess I can just delay my action by a tick, but that's a pain in the butt and makes it more complex to provide appropriate feedback... Also welcome, Zander.  If you're searching for a similar solution, I hope this (eventually) helps you too 😅
    • My guess would be that you are not getting the chunk coordinates right, or getChunk dosnt work.
    • Hello, Recently I have been hosting an RLcraft server on Minecraft Forge Version 1.12.2 - 14.23.5.2860 I originally had lag issues and I chalked it up to playing on less than perfect hardware so I moved the server to better hardware(i9-9900k with 64GB of RAM for 1 player.) After lots of troubleshooting I discovered a couple of things. World saving was causing the MSPT to spike to over 2000Miliseconds and was happening every minute. This kind of makes sense as the world was pre-generated and is over 100GB. I learned that I could turn off world saving and just schedule that and that resolved that issue. After that issue was resolved I discovered another issue. It appears that when exploring chunks, any chunks explored stay loaded. They persist. I was originally thinking that this had to be a mod issue, but it didn't seem like anyone was talking about it. This isn't really a problem on packs with few worldgen mods or just few mods in general, but on beefier packs it becomes a problem. I went through forge changelogs and found this line. Build: 1.12.2-14.23.5.2841 - Thu Aug 29 01:58:50 GMT 2019 bs2609: Improve performance of persistent chunk checks (#5706) Is this a related item to what I am dealing with or just something else?   I went ahead and created a new dedicated server with Just Forge 14.23.5.2860, spark reforged, and it's core mods. I was able to replicate the issue and log it with spark. Hopefully you're able to see this spark profile. It basically shows that as I explored the chunk loading persisted(2000 chunks loaded over 10 minutes with one player)The view distance is set to 10 so that should be 200 chunks per player. If I don't move the loaded chunks are 200. I was however able to fix the persistent chunk issue if I save the world more frequently. My question is, is this intended function of the game or is this a bug? Everywhere I read seems to indicate Minecraft servers save every 5 minutes and not every minute. Can chunks not unload if the world does not autosave. Additionally. Autosave specifically appears to fix this issue. Manually running save-all does not resolve the issue.   I realize this is kind of a log one, sorry. Please let me know if you require further information. Thanks in advance for your time. https://spark.lucko.me/NvlMtC39Yt https://imgur.com/a/K0oyukx https://pastebin.com/z0qGu1Vh  
  • Topics

×
×
  • Create New...

Important Information

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