EntityDimensions .java

net.minecraft.world.entity.EntityDimensions (record): members: width, height, eyeHeight, attachments, fixed, defaultEyeHeight, withAttachments, scalable.

net.minecraft.world.entityrecord57 linescommon2.0 KB

API Surface (9)

record EntityDimensions(float width, float height, float eyeHeight, EntityAttachments attachments, boolean fixed)
AABB makeBoundingBox(final Vec3 pos)
AABB makeBoundingBox(final double x, final double y, final double z)
EntityDimensions scale(final float scaleFactor)
EntityDimensions scale(final float widthScaleFactor, final float heightScaleFactor)
EntityDimensions scalable(final float width, final float height)
EntityDimensions fixed(final float width, final float height)
EntityDimensions withEyeHeight(final float eyeHeight)
EntityDimensions withAttachments(final EntityAttachments.Builder attachments)

Code Graph: Dependencies (3)

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

Full Source

EntityDimensions.java57 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity;
2
3
import net.minecraft.world.phys.AABB;
4
import net.minecraft.world.phys.Vec3;
5
6
public record EntityDimensions(float width, float height, float eyeHeight, EntityAttachments attachments, boolean fixed) {
7
	private EntityDimensions(final float width, final float height, final boolean fixed) {
8
		this(width, height, defaultEyeHeight(height), EntityAttachments.createDefault(width, height), fixed);
9
	}
10
11
	private static float defaultEyeHeight(final float height) {
12
		return height * 0.85F;
13
	}
14
15
	public AABB makeBoundingBox(final Vec3 pos) {
16
		return this.makeBoundingBox(pos.x, pos.y, pos.z);
17
	}
18
19
	public AABB makeBoundingBox(final double x, final double y, final double z) {
20
		float w = this.width / 2.0F;
21
		float h = this.height;
22
		return new AABB(x - w, y, z - w, x + w, y + h, z + w);
23
	}
24
25
	public EntityDimensions scale(final float scaleFactor) {
26
		return this.scale(scaleFactor, scaleFactor);
27
	}
28
29
	public EntityDimensions scale(final float widthScaleFactor, final float heightScaleFactor) {
30
		return !this.fixed && (widthScaleFactor != 1.0F || heightScaleFactor != 1.0F)
31
			? new EntityDimensions(
32
				this.width * widthScaleFactor,
33
				this.height * heightScaleFactor,
34
				this.eyeHeight * heightScaleFactor,
35
				this.attachments.scale(widthScaleFactor, heightScaleFactor, widthScaleFactor),
36
				false
37
			)
38
			: this;
39
	}
40
41
	public static EntityDimensions scalable(final float width, final float height) {
42
		return new EntityDimensions(width, height, false);
43
	}
44
45
	public static EntityDimensions fixed(final float width, final float height) {
46
		return new EntityDimensions(width, height, true);
47
	}
48
49
	public EntityDimensions withEyeHeight(final float eyeHeight) {
50
		return new EntityDimensions(this.width, this.height, eyeHeight, this.attachments, this.fixed);
51
	}
52
53
	public EntityDimensions withAttachments(final EntityAttachments.Builder attachments) {
54
		return new EntityDimensions(this.width, this.height, this.eyeHeight, attachments.build(this.width, this.height), this.fixed);
55
	}
56
}
57

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