Jump to content

Setting player sneaking


AntiRix

Recommended Posts

Hi,

 

I've tried several methods to get the player to sneak, including:

 

mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));

 

and

 

mc.player.setSneaking(true);
mc.player.onUpdate();

 

Neither seem to work. Am I missing something? It's not registering the sneaking on either the client or the server side.

Link to comment
Share on other sites

4 minutes ago, AntiRix said:

It's literally what I put in the original post. Neither works.

You haven't provided any context as to what you have. All we know is that is what you are calling. When are you calling it, where are you calling it, how often are you calling it? On the other hand what you posted isn't what diesieben said to do.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

"when the client detects an AFK message in chat"

 

ClientChatReceivedEvent

 

If the message equals something, do either of the two code blocks, neither of which works. I know the code is running, because otherwise I'd fix that before posting here.

 

"On the other hand what you posted isn't what diesieben said to do."

 

That is my updated code. I can't go any further.

Edited by AntiRix
Link to comment
Share on other sites

It's still not working for me. onInputUpdate is being fired and sneak = true, but the sneaking isn't working.

 

@SubscribeEvent
	public void onChatMessageReceived(ClientChatReceivedEvent event)
	{
		String message = event.getMessage().getFormattedText().replaceAll("\u00a7.", "");
		
		if (message.equals("You are AFK. Move around to return from AFK."))
		{
			event.setCanceled(true);
			
			if (anti_afk)
			{
				sneak = true;
			}
			else
			{
				mc.player.sendMessage(new TextComponentString(""));
				mc.player.sendMessage(new TextComponentString("\u00a7c[HypixelAFK] You're AFK!"));
				mc.player.sendMessage(new TextComponentString(""));
			}
			
			return;
		}
	}
	
	@SubscribeEvent
	public void onInputUpdate(InputUpdateEvent event)
	{
		if (!sneak) return;
		
		event.getMovementInput().sneak = true;
		sneak = false;
	}

 

Edited by AntiRix
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.



×
×
  • Create New...

Important Information

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