Jump to content

Recommended Posts

Posted

Is there a way to prevent the player from being kicked on a multiplayer server for being AFK? For clarity and organizational purposes, let's assume that AFK is defined as "pitch and yaw not changing for two minutes."

 

I have tried using a loop called every tick to change player.rotationPitch and player.rotationYaw, but these don't force my screen to look in that direction like they should. They only change the pitch and yaw when I press a key on my keyboard.

 

So again, is there a way to let the server know that my pitch and yaw are changing? Would this require packets?

 

Thanks!

Posted

Calling

Entity#setAngles

on the client player should add the specified amount of yaw and pitch rotation, which will automatically be synced with the server.

 

I have an example of a block that uses this to rotate the player from the client side here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Thanks, but after just trying the Entity#setAngles way, I have the same issue: My screen only shows me changing pitch/yaw when I move or press a key on my keyboard. If I am stationary in-game and have a pitch/yaw updater every tick, nothing happens. I think your block method works because the player has to move to touch the block.

 

UPDATE: I am currently working around this by using a robot to hold down a generally unused key like KeyEvent.VK_BACK_SLASH. Of course, this would make the mod incompatible with users or mods who have the backslash key in their controls.

Posted

Block#onEntityCollidedWithBlock(World,BlockPos,IBlockState,Entity)

is called every tick while the player is inside the block, not just when they first collide with it.

 

I just added functionality to rotate the player while they're standing on a Block of Iron using

Entity#setAngles

from

TickEvent.ClientTickEvent

and it worked without issue. You can see my implementation here.

 

I've tested this on an integrated and dedicated server in the development environment.

 

Edit: I've recorded a video demonstrating the rotation functionality. You can view it

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Thank you for your continued support! From your example I realized that perhaps I was using the wrong event. I was trying to change the player's rotation while in a KeyInputEvent, so I used some workarounds and got it working in a ClientTickEvent. Although it's strange that the player's direction can't be set in a KeyInputEvent...

My original question has been answered, but on a side note, is there any benefit to checking that event.phase == TickEvent.Phase.END in the ClientTickEvent?

Posted

My original question has been answered, but on a side note, is there any benefit to checking that event.phase == TickEvent.Phase.END in the ClientTickEvent?

 

Each tick event is fired twice per tick of its corresponding system (client, server, world, player or render tick) - once at the start with

Phase.START

and once at the end with

Phase.END

. If you don't check the phase, your code will run twice per tick.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • 1 month later...
Posted

I am interested in obtaining a compiled version of Choonster's TestMod3 mod or a reliable way to adjust the idletimeout in a LAN game setup. I'd attempt to compile the mod myself (if the license allowed for that) but I haven't the foggiest notion of what that requires. Specifically, I am desperately in need of the Anti-AFK block. My LAN game setup frequently experiences the hosting player to be AFK and with 1.8.9 the idletimeout has made playing frustrating with numerous disconnects/LAN server closures.

 

Any suggestions to alleviate my poorly described dilemma would be greatly appreciated.

Posted

You could run a dedicated server and use the

/setidletimeout

command to set the idle timeout to 0.

 

My mod is under the MIT License (see the LICENSE.txt file), which means you can do pretty much whatever you want with it as long as you retain the license/copyright info.

 

To compile my mod, you'll first need to install the JDK and set the

JAVA_HOME

environment variable to its location. You can then download or clone my mod from GitHub and run

gradlew setupDecompWorkspace

to set up the workspace (this only needs to be done once) and

gradlew build

to build it (the compiled mod will be in build/libs).

 

If you want to edit it, you can install Eclipse or IntelliJ IDEA and follow steps 5 and 6 of this tutorial to set up an IDE project for it. I personally use IDEA, but either will work.

 

Like the name suggests, TestMod3 is just a test mod. I make no guarantees that it's stable or balanced (pretty much everything is creative-only), but things should generally work as they're intended to. If you do encounter an issue, please report it on GitHub.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Yes, I know that I could utilize the dedicated server setting for idletimeout. The problem resides in the fact that ONLY 2 computers are available and we BOTH wish to play hence the LAN game setup.

 

You suggest that I setup the SDK and IDE to compile your mod. I could probably accomplish that. However, I was hoping that someone more familiar with doing such a thing would lend a hand. I am confident that every other poster in this thread would be able to run circles around my abilities and could probably compile TestMod3 in their sleep.

 

What I am asking is, would someone be willing to compile that mod for me? Please?

Posted

Yes, I know that I could utilize the dedicated server setting for idletimeout. The problem resides in the fact that ONLY 2 computers are available and we BOTH wish to play hence the LAN game setup.

 

You can run the dedicated server and a client on the same computer, I did this myself for quite a while when I last played Minecraft.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Maybe. There are probably lots of other things I could do. What I would like to do is use your mod to rotate the hosting player in my LAN game setup. What I am trying to avoid is setting up JDK and gradle, env vars, an IDE, learning my way around, fumbling to a working compile, etc etc etc.

 

I have no doubt that someone has already done that and could share the compiled mod with me. That is what I am asking.

Posted

I've just compiled and uploaded the latest version of the code here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.