BreezeUtil .java

net.minecraft.world.entity.monster.breeze.BreezeUtil (class, 33 lines): members: randomPointBehindTarget, MAX_LINE_OF_SIGHT_TEST_RANGE, hasLineOfSight.

net.minecraft.world.entity.monster.breezeclass33 linescommon1.3 KB

API Surface (2)

Vec3 randomPointBehindTarget(final LivingEntity enemy, final RandomSource random)
boolean hasLineOfSight(final Breeze breeze, final Vec3 target)

Fields & Constants (1)

MAX_LINE_OF_SIGHT_TEST_RANGE

Code Graph: Dependencies (8)

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

Full Source

BreezeUtil.java33 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity.monster.breeze;
2
3
import net.minecraft.util.Mth;
4
import net.minecraft.util.RandomSource;
5
import net.minecraft.world.entity.LivingEntity;
6
import net.minecraft.world.entity.ai.attributes.Attributes;
7
import net.minecraft.world.level.ClipContext;
8
import net.minecraft.world.phys.HitResult;
9
import net.minecraft.world.phys.Vec3;
10
11
public class BreezeUtil {
12
	private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 50.0;
13
14
	public static Vec3 randomPointBehindTarget(final LivingEntity enemy, final RandomSource random) {
15
		int spreadDegrees = 90;
16
		float viewAngle = enemy.yHeadRot + 180.0F + (float)random.nextGaussian() * 90.0F / 2.0F;
17
		float r = Mth.lerp(random.nextFloat(), 4.0F, 8.0F);
18
		Vec3 direction = Vec3.directionFromRotation(0.0F, viewAngle).scale(r);
19
		return enemy.position().add(direction);
20
	}
21
22
	public static boolean hasLineOfSight(final Breeze breeze, final Vec3 target) {
23
		Vec3 from = new Vec3(breeze.getX(), breeze.getY(), breeze.getZ());
24
		return target.distanceTo(from) > getMaxLineOfSightTestRange(breeze)
25
			? false
26
			: breeze.level().clip(new ClipContext(from, target, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, breeze)).getType() == HitResult.Type.MISS;
27
	}
28
29
	private static double getMaxLineOfSightTestRange(final Breeze breeze) {
30
		return Math.max(50.0, breeze.getAttributeValue(Attributes.FOLLOW_RANGE));
31
	}
32
}
33

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