Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Inventory not saving on world reload
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
BeardlessBrady

[1.12.2] Inventory not saving on world reload

By BeardlessBrady, May 9 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

BeardlessBrady    0

BeardlessBrady

BeardlessBrady    0

  • Diamond Finder
  • BeardlessBrady
  • Members
  • 0
  • 319 posts
Posted May 9

Hello, so the inventory of my tile entity is not saving/or being loaded correctly on world save/load. 

 

https://github.com/BeardlessBrady/Currency-Mod/blob/433ebdf4e2cc72ad61ebc6ab8459351198eaed5a/src/main/java/beardlessbrady/modcurrency/block/vending/TileVending.java#L71-L164

  • Quote

Share this post


Link to post
Share on other sites

ItsWormy    1

ItsWormy

ItsWormy    1

  • Tree Puncher
  • ItsWormy
  • Members
  • 1
  • 10 posts
Posted May 9

Have you read this? https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/#persisting-chunk-and-tileentity-capabilities

  • Quote

Share this post


Link to post
Share on other sites

BeardlessBrady    0

BeardlessBrady

BeardlessBrady    0

  • Diamond Finder
  • BeardlessBrady
  • Members
  • 0
  • 319 posts
Posted May 9

hmm, Ive never had to implement that before, I'd assume that its auto called with ItemStackHandlers?

  • Quote

Share this post


Link to post
Share on other sites

ItsWormy    1

ItsWormy

ItsWormy    1

  • Tree Puncher
  • ItsWormy
  • Members
  • 1
  • 10 posts
Posted May 9 (edited)

You need to override the method onContentsChanged in your ItemStackHandlers and run markDirty.

Edited May 9 by ItsWormy
  • Quote

Share this post


Link to post
Share on other sites

BeardlessBrady    0

BeardlessBrady

BeardlessBrady    0

  • Diamond Finder
  • BeardlessBrady
  • Members
  • 0
  • 319 posts
Posted May 9

I've never had to do that before, but Ill give it a try.

  • Quote

Share this post


Link to post
Share on other sites

ItsWormy    1

ItsWormy

ItsWormy    1

  • Tree Puncher
  • ItsWormy
  • Members
  • 1
  • 10 posts
Posted May 9
// Line 37 to line 39

private ItemStackHandler inputStackHandler = new ItemStackHandler(TE_INPUT_SLOT_COUNT) {
    @Override
    protected void onContentsChanged(int slot) {
      super.onContentsChanged(slot);
      markDirty();
    }
};
private ItemStackHandler inventoryStackHandler = new ItemStackHandler(TE_INVENTORY_SLOT_COUNT) {
    @Override
    protected void onContentsChanged(int slot) {
      super.onContentsChanged(slot);
      markDirty();
    }
};
private ItemStackHandler outputStackHandler = new ItemStackHandler(TE_OUTPUT_SLOT_COUNT) {
    @Override
    protected void onContentsChanged(int slot) {
      super.onContentsChanged(slot);
      markDirty();
    }
};

This should do it. At least I hope it does.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

BeardlessBrady    0

BeardlessBrady

BeardlessBrady    0

  • Diamond Finder
  • BeardlessBrady
  • Members
  • 0
  • 319 posts
Posted May 23

Little late but it worked! Thanks ItsWormy

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • gudie73
      Memory Heap Thingy!

      By gudie73 · Posted 14 minutes ago

      It gets stuck on that part and doesn’t change
    • gudie73
      Memory Heap Thingy!

      By gudie73 · Posted 15 minutes ago

      Wym  
    • RaphGamingz
      ScreenGui does nothing

      By RaphGamingz · Posted 58 minutes ago

      any errors?
    • RaphGamingz
      Game crashing when the block is activated

      By RaphGamingz · Posted 1 hour ago

      then you    your not assigning a value to the tileEntity try in the constructor tileEntity = world.getTileEntity(pos);
    • GttiqwT
      [1.12.2] Multiple Structure Generation

      By GttiqwT · Posted 1 hour ago

      How did you fix it?   edit: nvm I believed I fixed it too, just had to tweak a few things to use "name" instead of "structureName"...
  • Topics

    • Mizinov
      6
      Memory Heap Thingy!

      By Mizinov
      Started August 24

    • Jaffaaaaa
      2
      ScreenGui does nothing

      By Jaffaaaaa
      Started Wednesday at 07:03 PM

    • jun2040
      5
      Game crashing when the block is activated

      By jun2040
      Started 17 hours ago

    • Merthew
      5
      [1.12.2] Multiple Structure Generation

      By Merthew
      Started November 7, 2018

    • Professional Derp
      16
      Server frequently crashes

      By Professional Derp
      Started 10 hours ago

  • Who's Online (See full list)

    • GttiqwT
    • ZigTheHedge
    • ewew
    • jun2040
    • gudie73
    • Taewinzer
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Inventory not saving on world reload
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community