Jump to content

[1.7.2]Onkeypressed


Jetfan16ladd

Recommended Posts

"You can create a keyhandler."

And that is only the beginning...

 

You will need your KeyBinding to sent Packet to server (Bindings are client-side). The server will have to operate with data sent, which is sender.

You will have to pull inventory from sender (player) and set current slot to different item (current = in hand).

player.inventory.currentItem;

Remember to 1st check if slot is not null. To override slot simply use something like setInventorySlotContents() (Idk if it's exact name)

 

Packet tutorials:

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with

Shorter:

http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

public class KeyHandler
{
public static KeyBinding pawnItem = new KeyBinding("Pawn Item", Keyboard.KEY_K, "key.categories.hud");

public KeyHandler()
{
	ClientRegistry.registerKeyBinding(awnItem);
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void playerTick(PlayerTickEvent event)
{
	if (event.side == Side.SERVER) return;
	if (event.phase == Phase.START)
	{
		Minecraft mc = Minecraft.getMinecraft();
		if (pawnItem.getIsKeyPressed())
		{
			//send packet to server, on receiver side (server) you can get sender (player) and modify his inventory
		}
	}
}
}

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

  • 1 month later...

I am still really lost I have no idea where to put what the key does.

Do I put in in the class of the item?

 

No.  You create a NEW class that is your key event handler.  You then have to do all the networking stuff, which is likely going to involve (at a minimum) two more classes, IIRC: the packet itself and the packet handler.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.