Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

  • Author

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.