Rotations .java

net.minecraft.core.Rotations (record, 34 lines): record with 3 components. members: STREAM_CODEC, CODEC. imports: ByteBuf.

net.minecraft.corerecord34 linescommon1.2 KB

API Surface (3)

record Rotations(float x, float y, float z)
Rotations decode(final ByteBuf input)
void encode(final ByteBuf output, final Rotations value)

Fields & Constants (2)

CODEC
STREAM_CODEC

Code Graph: Dependencies (2)

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

Full Source

Rotations.java34 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.core;
2
3
import com.mojang.serialization.Codec;
4
import io.netty.buffer.ByteBuf;
5
import java.util.List;
6
import net.minecraft.network.codec.StreamCodec;
7
import net.minecraft.util.Util;
8
9
public record Rotations(float x, float y, float z) {
10
	public static final Codec<Rotations> CODEC = Codec.FLOAT
11
		.listOf()
12
		.comapFlatMap(
13
			input -> Util.fixedSize((List<Float>)input, 3).map(floats -> new Rotations(floats.get(0), floats.get(1), floats.get(2))),
14
			rotations -> List.of(rotations.x(), rotations.y(), rotations.z())
15
		);
16
	public static final StreamCodec<ByteBuf, Rotations> STREAM_CODEC = new StreamCodec<ByteBuf, Rotations>() {
17
		public Rotations decode(final ByteBuf input) {
18
			return new Rotations(input.readFloat(), input.readFloat(), input.readFloat());
19
		}
20
21
		public void encode(final ByteBuf output, final Rotations value) {
22
			output.writeFloat(value.x);
23
			output.writeFloat(value.y);
24
			output.writeFloat(value.z);
25
		}
26
	};
27
28
	public Rotations {
29
		x = !Float.isInfinite(x) && !Float.isNaN(x) ? x % 360.0F : 0.0F;
30
		y = !Float.isInfinite(y) && !Float.isNaN(y) ? y % 360.0F : 0.0F;
31
		z = !Float.isInfinite(z) && !Float.isNaN(z) ? z % 360.0F : 0.0F;
32
	}
33
}
34

Decompiled Minecraft 26.3 source of Rotations (net/minecraft/core/Rotations.java) with Mojang official mappings, stored verbatim on the site.