Jump to content

[SOLVED] Buttons, PacketHandlers and Container Inventorys


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.




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



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





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?



Link to comment
Share on other sites



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.




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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 🎰 Mainkan Slot Online dengan Hanya 5 Ribu Via Dana, Proses Cepat! 🎰 Buka pintu ke dunia hiburan tanpa batas di UANG69 Slot Online! Bersiaplah untuk merasakan sensasi kemenangan di ujung jari Anda dengan taruhan serendah 5 ribu rupiah saja, melalui metode pembayaran yang mudah via Dana! ⚡ Proses Cepat, Nikmati Keuntungan dalam Sekejap ⚡ Bergabunglah dengan komunitas slot paling dinamis dan terpanas, dengan puluhan permainan slot yang menakjubkan, serta kesempatan untuk memenangkan jackpot besar! Rasakan gemerlapnya Las Vegas langsung dari kenyamanan rumah Anda sendiri. 🔥 Keunggulan UANG69 Slot Online: 🔥 ✅ Taruhan Serendah 5 Ribu Rupiah ✅ Metode Pembayaran Mudah via Dana ✅ Proses Cepat, Penarikan Lancar ✅ Puluhan Permainan Slot Terbaik ✅ Jackpot Besar Menanti untuk Dimenangkan Bergabunglah dengan UANG69 hari ini dan jadilah bagian dari petualangan slot yang tak terlupakan. Nikmati keseruan, kemenangan, dan hiburan di ujung jari Anda! Jangan lewatkan kesempatan ini, bergabunglah sekarang dan mulailah memenangkan hadiah besar! 💰💎🎉
    • Hello, I am trying to play Minecraft (premium version) with the All Of Create mod from CurseForge. When I launch it from the Minecraft launcher I get an error "The game has stopped working" Error code: 1. I tried to create a modpack, without mods, and launch it (in case there was any incompatibility) but it doesn't work either.... Error with mod: https://paste.ee/p/zzvJY I hope someone can help me. Thanks in advance.
    • Jika Anda mencari maxwin secepat kilat, maka Slot Kilat77 adalah tempatnya! Dengan koleksi slot terbaik yang dirancang untuk memberikan kemenangan instan, setiap putaran di Slot Kilat77 adalah kesempatan untuk memenangkan hadiah besar dalam sekejap. Bergabunglah sekarang dan rasakan sensasi kemenangan kilat di setiap gulungan. Jadi, jangan ragu lagi, mari bergabung dan raih maxwin secepat kilat hanya di Slot Kilat77!
    • Jos77 adalah pilihan terbaik untuk meraih maxwin hari ini! Dengan koleksi permainan slot terbaik dan peluang kemenangan yang tinggi, setiap putaran di Jos77 adalah kesempatan untuk memenangkan hadiah besar. Bergabunglah sekarang dan rasakan sensasi kemenangan yang luar biasa di setiap gulungan. Jadi, jangan lewatkan kesempatan untuk menjadi pemenang hari ini di Jos77 Mulailah petualangan slot Anda sekarang di Jos77 dan temukan sendiri mengapa kami adalah pilihan utama para pencari maxwin. Dengan grafis yang memukau, fitur bonus yang menggiurkan, dan dukungan pelanggan yang luar biasa, kami siap membawa pengalaman bermain Anda ke level berikutnya. Tidak peduli apakah Anda seorang pemula atau ahli slot, Jos77 menyediakan lingkungan yang ramah dan menyenangkan bagi semua pemain. Jadi, bersiaplah untuk meraih maxwin dan nikmati kesuksesan Anda di Jos77 hari ini!  
    • BARBAR77 adalah destinasi utama bagi para pecinta slot online yang mencari sensasi paling barbar! Dengan koleksi slot paling mengagumkan dan peluang kemenangan yang tinggi, BARBAR77 menawarkan pengalaman bermain yang tidak akan Anda temukan di tempat lain. Bergabunglah dengan komunitas kami dan rasakan kegembiraan dari kemenangan yang mengagumkan di setiap putaran. Jadi, siapkan diri Anda untuk petualangan slot yang paling barbar di BARBAR77!
  • Topics

  • Create New...

Important Information

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