Jump to content

[SOLVED] Buttons, PacketHandlers and Container Inventorys


dvd604

Recommended Posts

So I have a block, that has two slots, and 11 buttons. Buttons from 0 to 9, increase and decrease important variables, and 10, should convert the item in the slot, to a defined item / block. This works fine on a server (Me hosting the server and joining via a client), but when playing single player,  it does not accept the item properly, making a ghost copy of it in the slot, and when the item is converted, it almost instantly removes itself.

 

Code:

 

PacketHandler: http://paste.minecraftforge.net/view/765c6e9a

TileEntity (Useful Methods): http://paste.minecraftforge.net/view/1dc73dde

GUI (Parts that send packets): http://paste.minecraftforge.net/view/96b9161f

 

If you need anything else, just ask

 

Any help is much appricated, dvd604

 

EDIT: Here's the GitHub, that's all of my code. https://github.com/dvd604/Xperium

 

EDIT 2: It was a problem with decrStackSize, spotted by a friend. Thank's everyone!

Link to comment
Share on other sites

Hi

 

I'm not sure I'm fully understanding what you are trying to do, but I suspect that you can probably accomplish it by deriving from Container and looking at (eg) ContainerChest for guidance.  There are a number of vanilla methods used to automatically synchronise the client and server Containers when the player has it open and is manipulating it, for example EntityPlayerMP.sendContainerAndContentsToPlayer.  I suspect your problem might be caused by some sort of mixup between your client and server responsibilities i.e. who creates what.  It might help to plan that out more explicitly and add asserts to your code to make sure you're on the side that you think you are.

 

Otherwise I'm out of ideas...

  TGG

 

 

 

Link to comment
Share on other sites

It isn't the server that is the problem. It works fine on a server.

 

Basically what I'm trying to do is, depending on what value people put into my GUI, it output a different block / item.

 

It works well on a server, but when you bring it to a single player game, it starts to break, ghosting items and removing the converted items. I can't see why tho, since Minecraft singleplayer is run off of a localized server, it should work on both sides, no?

 

,dvd604

Link to comment
Share on other sites

Hi

 

What I meant by a client/server mixup is that I suspect your code is writing to an object on the wrong side compared to what you expect.  Perhaps  you are accessing World or similar object from a location which is different when the client and server are on the same machine.  Have you tried playing single player then opening to LAN and connecting with a second client, to see if the problem disappears when you open to LAN, and whether it is always the same for all clients or whether it depends on where the client code is running.

 

You're right, even in single player the game still runs Client and Server (IntegratedServer).

 

The symptoms you describe sound very much like a Client <--> Server synchronisation problem.  Although it's normally the other way round (works in single player, not in multiplayer).    The difference is that local Clients can access all sorts of objects that remote clients can't (or if they do, it has no effect because the objects are unused), which is what makes me think your client code or server code is writing data or calling methods somewhere it shouldn't.

 

-TGG

 

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



×
×
  • Create New...

Important Information

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