Jump to content

Do I have to send Packets for this and is there a limit for # of Packets?


Recommended Posts

Hello, I am making mod where each player has a bank, to store their items in. I have the gui made and I have the button I needed placed, but I was wondering if I need to send packets for something that I will now explain. I have two right and left arrow buttons that switch between each tab, there are nine tabs in total. The player can also select each tab by clicking on it , similar to creative tabs. When the player switches the tab it increments and decrements a variable that keeps track of what tab the player is currently selecting. Right now I have buttons directly increments and decrements this variable, but I have experienced a bug with it. when I put something in a slot, lets just use the first slot as a an example, then I switch to tab 2, every thing look OK because the item in slot one disappears because it is stored in a different ItemStack array, then I try to put something in slot 1 of the second tab and it puts the item in, but also gives me a copy of the item in the first tab in the first slot. I am not sure if this has to do with not sending packets and the variable not being synchronized in the server, or it is due to my incompetence to write code and I have made some error in my code. If you believe that it is due to my incompetence to write code, lol, then please just ask for my code, then I will gladly share it. Also is there a limit for how many packets you can send per mod, or is there some sort of contribution to lag caused by sending too many packets. All help is appreciated, Thank You!

Don't be afraid to ask question when modding, there are no stupid question! Unless you don't know java then all your questions are stupid!

Link to comment
Share on other sites

You don't need to send packets for switching tabs or doing anything that changes what is presented on the screen; you DO need to send packets any time you want to change something on the server from the client, which usually includes things like changing what ItemStacks are in an inventory, but if you set up your inventory properly with a Container, then the Container will do all that work for you and you don't need any packets for that. For item duplication, it seems like you are not differentiating correctly between your tabs, as in each tab is referencing the same set of slots in your Container. I suggest you look more closely at the GuiContainerCreative class as an example of a similar system.

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.

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.


  • Create New...

Important Information

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