File size: 1,149 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package net.minecraft.server.commands;

import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;

@FunctionalInterface
public interface LookAt {
    void perform(CommandSourceStack p_364146_, Entity p_365585_);

    public static record LookAtEntity(Entity entity, EntityAnchorArgument.Anchor anchor) implements LookAt {
        @Override
        public void perform(CommandSourceStack p_367204_, Entity p_361589_) {
            if (p_361589_ instanceof ServerPlayer serverplayer) {
                serverplayer.lookAt(p_367204_.getAnchor(), this.entity, this.anchor);
            } else {
                p_361589_.lookAt(p_367204_.getAnchor(), this.anchor.apply(this.entity));
            }
        }
    }

    public static record LookAtPosition(Vec3 position) implements LookAt {
        @Override
        public void perform(CommandSourceStack p_367941_, Entity p_366583_) {
            p_366583_.lookAt(p_367941_.getAnchor(), this.position);
        }
    }
}