Input .java

net.minecraft.world.entity.player.Input (record): members: forward, backward, left, right, jump, shift, sprint, FLAG_BACKWARD, FLAG_FORWARD, FLAG_SPRINT.

net.minecraft.world.entity.playerrecord41 linescommon1.7 KB

API Surface (3)

record Input(boolean forward, boolean backward, boolean left, boolean right, boolean jump, boolean shift, boolean sprint)
void encode(final FriendlyByteBuf output, final Input value)
Input decode(final FriendlyByteBuf input)

Fields & Constants (9)

FLAG_FORWARD
FLAG_BACKWARD
FLAG_LEFT
FLAG_RIGHT
FLAG_JUMP
FLAG_SHIFT
FLAG_SPRINT
STREAM_CODEC
EMPTY

Code Graph: Dependencies (2)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

Input.java41 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.player;
2
3
import net.minecraft.network.FriendlyByteBuf;
4
import net.minecraft.network.codec.StreamCodec;
5
6
public record Input(boolean forward, boolean backward, boolean left, boolean right, boolean jump, boolean shift, boolean sprint) {
7
	private static final byte FLAG_FORWARD = 1;
8
	private static final byte FLAG_BACKWARD = 2;
9
	private static final byte FLAG_LEFT = 4;
10
	private static final byte FLAG_RIGHT = 8;
11
	private static final byte FLAG_JUMP = 16;
12
	private static final byte FLAG_SHIFT = 32;
13
	private static final byte FLAG_SPRINT = 64;
14
	public static final StreamCodec<FriendlyByteBuf, Input> STREAM_CODEC = new StreamCodec<FriendlyByteBuf, Input>() {
15
		public void encode(final FriendlyByteBuf output, final Input value) {
16
			byte flags = 0;
17
			flags = (byte)(flags | (value.forward() ? 1 : 0));
18
			flags = (byte)(flags | (value.backward() ? 2 : 0));
19
			flags = (byte)(flags | (value.left() ? 4 : 0));
20
			flags = (byte)(flags | (value.right() ? 8 : 0));
21
			flags = (byte)(flags | (value.jump() ? 16 : 0));
22
			flags = (byte)(flags | (value.shift() ? 32 : 0));
23
			flags = (byte)(flags | (value.sprint() ? 64 : 0));
24
			output.writeByte(flags);
25
		}
26
27
		public Input decode(final FriendlyByteBuf input) {
28
			byte flags = input.readByte();
29
			boolean forward = (flags & 1) != 0;
30
			boolean backward = (flags & 2) != 0;
31
			boolean left = (flags & 4) != 0;
32
			boolean right = (flags & 8) != 0;
33
			boolean jump = (flags & 16) != 0;
34
			boolean shift = (flags & 32) != 0;
35
			boolean sprint = (flags & 64) != 0;
36
			return new Input(forward, backward, left, right, jump, shift, sprint);
37
		}
38
	};
39
	public static final Input EMPTY = new Input(false, false, false, false, false, false, false);
40
}
41

Decompiled Minecraft 26.3 source of Input (net/minecraft/world/entity/player/Input.java) with Mojang official mappings, stored verbatim on the site.