Jump to content

Recommended Posts

Posted

I'm adapting a mod I wrote for ModLoader 1.3 and SSP to Forge and SMP and have hit a bit of a sticking point.

 

I use an inventory which is particular to the player rather than to a block / tile entity (a la ender chests/pouches or alchemy bags) and am having trouble reading and writing those inventories to disk in an SMP-friendly manner.  I've gotten a lot of mileage out of the forum and wiki here and by following along with existing code (cpw, you're a life-saver), but I haven't been able to dig up any examples of this kind of data storage and I'm apparently not yet familiar enough with Forge and the current state of MC modding to work it out on my own.  :-)

 

Originally, when I was only worried about SSP, I wrote the Inventory class to handle reading and writing (called from the container's constructor and the inventory's closeChest, respectively) to a file located under the integrated server's save directory, and after converting that to use FML's getMinecraftServerInstance, it works just fine under Forge SSP.  Under SMP, predictably, it's an absolute mess.  The client crashes with a NullPointerException trying to find the save folder (no SaveHandler, so no surprise there) and the server never tries to read the inventory at all.

 

So!  Any advice?  I'd be perfectly happy to just scrap my current approach, as it's pretty hacky, but I haven't yet managed to find an addon which hits the trifecta of having blockless inventories, using Forge, and being open-source.  The vanilla Ender Chest is sub-optimal because it stores its inventory within the player and I need something that's "owned" by a single player, but visible to all.

 

(I can post code if any want it, but I'm pretty convinced that the problem is a bad approach, rather than bad code.)

Posted

The server side has a save handler.

 

I realize that; my issue isn't determining where to save the files, but rather the whole approach to communicating an inventory between server and client which isn't based on a tile entity.  My slapped-together approach doesn't work in SMP because the client tries to perform the file reading, but the server the writing.  If I move it all into the server, the client never sees the contents of the inventory at all and presents an empty container.

 

More than anything else, I'm looking for the basics of how to communicate an inventory between client and server when there's no tile entity to do the bridging (as with EE's alchemy bags).

Posted

Take a look at how the player inventory works.

Thats how you should do yours.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Take a look at how the player inventory works.

Thats how you should do yours.

 

Hmm.  Player inventory seems to be handled by the entity-spawning packet, which doesn't do me much good, but it led me to NetClientHandler.  I can see a lot of very interesting code there related to map data, which is handled pretty similarly to how I want my inventory to be; I'm going to see what I can do with it.

 

Thanks for the advice!

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 tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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