LookAt .java

net.minecraft.server.commands.LookAt (interface): members: LookAtPosition, LookAtEntity, perform. ann: @FunctionalInterface. imports: EntityAnchorArgument.

net.minecraft.server.commandsinterface31 linesserver999 B

API Surface (2)

void perform(final CommandSourceStack source, final Entity target)
void perform(final CommandSourceStack source, final Entity target)

Code Graph: Dependencies (5)

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

Full Source

LookAt.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.commands;
2
3
import net.minecraft.commands.CommandSourceStack;
4
import net.minecraft.commands.arguments.EntityAnchorArgument;
5
import net.minecraft.server.level.ServerPlayer;
6
import net.minecraft.world.entity.Entity;
7
import net.minecraft.world.phys.Vec3;
8
9
@FunctionalInterface
10
public interface LookAt {
11
	void perform(CommandSourceStack source, Entity target);
12
13
	record LookAtEntity(Entity entity, EntityAnchorArgument.Anchor anchor) implements LookAt {
14
		@Override
15
		public void perform(final CommandSourceStack source, final Entity target) {
16
			if (target instanceof ServerPlayer targetPlayer) {
17
				targetPlayer.lookAt(source.getAnchor(), this.entity, this.anchor);
18
			} else {
19
				target.lookAt(source.getAnchor(), this.anchor.apply(this.entity));
20
			}
21
		}
22
	}
23
24
	record LookAtPosition(Vec3 position) implements LookAt {
25
		@Override
26
		public void perform(final CommandSourceStack source, final Entity target) {
27
			target.lookAt(source.getAnchor(), this.position);
28
		}
29
	}
30
}
31

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