r/MinecraftModder • u/Morgrimm • Aug 18 '14
Here to help!
Hey guys, I've been modding Minecraft for a few years now, and I'm happy to help to the best of my ability (with code, answering questions, how MC works, etc.) I don't have any public mods at the moment, but I AM currently working on a Blood Magic addon :) Ask away!
1
u/Lothrazar Aug 21 '14
I have modded a bunch of things - items, entities, commands, tweaking vanilla items, and so on. Ran into one thing that was non intuitivie and confusing, not many tutorials.
Do you have a 'getting started' or ELI5 for packets and network handling?
To be precice, I added a key binding (O and P) that do a thing with the players inventory. Now, i know that getMinecraft().thePlayer is client side only, so affecting that inventory doesnt really work, because the server overrides it when you do something in a later tick.
So there is no way to push from client to server, i have to go the other way around. Send the "key pressed" event to the server, and have THAT affect the players inventory.
I dont even know where to start. I have my client procy and i have my ClientRegistry.registerKeyBinding(columnShift); and all that.
2
u/Morgrimm Aug 21 '14
Yeah, packet and network handling is an annoying thing to get into, but once you have a framework set up it's fairly simple to use :) Using Netty (the new networking framework that Forge uses) directly isn't recommended, because it can cause issues, but Forge provides a really handy wrapper for it. This tutorial can explain it much better than I can. If you need an even more in-depth example as to how to set it up, the way Equivalent Exchange 3 handles packets is really nice, and I'd recommend it. The code for EE3 packets and packet handling can be found here. It also includes a good general packet for key handling, which should be useful for you. Hope that helped :D
1
0
Aug 20 '14
[deleted]
1
u/Morgrimm Aug 21 '14
I haven't done this in awhile, and I can't think of the specific code offhand, but the general way I'd go about doing that is creating a container and inventory for the item, as well as a gui, and then adding a player.openGui call within the item's onRightClick method. In order to save inventory, you would actually save it in the item's NBT data (there's a method already provided that can write an itemstack to an NBT tag), but I can't remember exactly how. I'll replay back to this in a bit when I look into the specifics some more :)
1
u/Lothrazar Aug 21 '14
Upvote because I was looking into this too. There is a backpack mod where you click with it and it opens kind of a chest inside the item, so its possible. IM assuming its just the event handler listens to player interact, and detects you are holding the item, and then does something.
1
u/WelshLP Aug 19 '14
I have a question, I would love to start modding, any ways you could tell me where to start? thank you
~WelshLP