Jump to content

[1.6.4] Server and client synchronization problem in TileEntity - "ghost" items


MadModder

Recommended Posts

Hi everyone,

 

I have a little problem with my "machine", but it will probably apply to it more like a "chest". When I place any item in my input slot, nothing strange happens, but if I try to take that item out then it seems copied.

It looks that my machine has that item in the input slot, but it stops working (if(inputSlot.stackSize == 0) progress = 0). It's something like ghost item: it disappears if I try to take it out or reopen the GUI. I had the same problem with shift-clicking, but it was solved by:

 

if(te.worldObj.isRemote) return null;

 

in Container.transferStackInSlot. I know that it is client-server sync problem, but I have no idea what piece of code I should modify in that case.

 

My TileEntity: http://pastebin.com/VxFVf8qj

and Container: http://pastebin.com/edwPCweR

 

Did anyone had similar problem?

Sorry if I write something wrong in English, I'm not native English speaker.

Link to comment
Share on other sites

You shouldn't need to check if the world is remote in your transferStackInSlot method - it can run the same on both sides.

 

#onInventoryChanged is when you are supposed to iterate through all the stacks and replace any that have stack size of 0 with null.

 

Calling super on an interface method (e.g. #onInventoryChanged) does absolutely nothing - interfaces do not provide implementations.

 

You really shouldn't need to constantly mark your block for an update. Look at TileEntityFurnace and you'll see it never calls that method; you probably shouldn't, either. Use your Container properly for sending data to the client side via #detectAndSendChanges etc.

 

In fact, the best advice I can give you is seriously look more closely at TileEntityFurnace and model your methods off of those. You are all over the place in there.

 

Also, don't use FMLCommonHandler#getEffectiveSide when you already have a world object; world.isRemote gives you the side much more efficiently.

Link to comment
Share on other sites

Thanks! It finally works!

 

I checked worldObj.isRemote in #transferStackInSlot because it seemed to remove that issue when shift-clicking. Now, when I iterate through stacks in #onInventoryChanged, I don't need that.

 

When I was changing my code basing on your advises, I observed one interesting thing:

 

Calling super on #onInventoryChanged should do something, because it's implemented in Basic TileEntity from Minecraft. Also, I found out that TileEntityFurnace doesn't implement onInventoryChanged.

 

When I'm implementing a method and super does nothing, then eclipse shows an error if I try to call it.

 

Anyways, I removed that super - it did nothing in my case.

Sorry if I write something wrong in English, I'm not native English speaker.

Link to comment
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.
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

    • They are heartless scammers, they ruined my life, by making me develop an interest in investing my hard-earned money. I deposited 67,000 USD which was later turned into 110,450 USD including my payout bonus, there was an impressive improvement in a few weeks, later I had an emergency and needed money to pay my insurance fee, I tried reaching out to them to collect the money I invested, they cut the live chats and got me harassed then I realized that I was being scammed. I just wanted my money back! I was advised by a friend to seek help from a recovery firm to assist me in recovering my invested funds, God was so kind I came across some great positive reviews about BETAFORT ONLINE on how they helped scammed victims like me to recover their lost cryptocurrency assets, I took no delay and got in touch with BETAFORT ONLINE, the Expert immediately looked into my case and after providing all the required information they need, and it took them less then a day to recover all my funds. And now I really feel obligated to recommend BETAFORT ONLINE and their team, their recovery strategies, and for working relentlessly to help me recover my funds. Feel free to reach out to BETAFORT ONLINE via google search and they will guide you on how to recover your invested funds, I advise everyone to be careful with these heartless cryptocurrency scammers.  
    • yeah I believe so, its been something deep with the modpack I'm guessing. ill fix each error it states if its saying to replace or download a mod but I'm not sure where to go from here. I have been spending days and have yet to find the issue    
    • It worked, thank you very much 😭
    • https://spark.lucko.me/0ZaR1OAi2F I use spark mod to do a scan and send it here to search for help and if someone know about this issue I dont know to much about, but one thing i see in the record of the minecraft launcher when i play says: can't keep up server overloaded and etc, etc.  I assign 6GB ram to minecraft from the 16 GB of my pc, and fps is not a problem...(no to much) its something about tic rate/second and i am in SINGLE PLAYER. The funny thing is, minecraft vanilla (No mods) works normaly. My mods list (130): https://imgur.com/a/kY3yQr1  Datapacks: https://imgur.com/CTDBe7D ResourcePacks: https://imgur.com/AztTOOw so plis, is someone help me T_T a work  a loot of time in downloading and trying to all mods work but i dont know what to do anymore. Last thing  I SPEAK SPANISH so... sorry if my english is a little scuff or ... werever... bad. Thanks :3
    • Whenever I try to create an world my game crashes. I´ve tried to figure it out myself but wasnt able to do it.   Here are the logs
  • Topics

×
×
  • Create New...

Important Information

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