1
1
package galena .oreganized .world ;
2
2
3
- import galena .oreganized .Oreganized ;
4
3
import net .minecraft .nbt .NbtUtils ;
5
- import net .minecraft .world .entity .Mob ;
4
+ import net .minecraft .world .entity .Entity ;
6
5
import net .minecraft .world .entity .MobType ;
7
6
import net .minecraft .world .entity .PathfinderMob ;
8
7
import net .minecraft .world .entity .ai .goal .Goal ;
9
8
import net .minecraft .world .entity .ai .navigation .PathNavigation ;
10
9
import net .minecraft .world .entity .ai .util .DefaultRandomPos ;
11
10
import net .minecraft .world .level .pathfinder .Path ;
12
11
import net .minecraft .world .phys .Vec3 ;
13
- import net .minecraftforge .event .entity .EntityEvent ;
14
- import net .minecraftforge .eventbus .api .SubscribeEvent ;
15
- import net .minecraftforge .fml .common .Mod ;
16
12
17
13
import javax .annotation .Nullable ;
14
+ import java .util .EnumSet ;
18
15
19
- @ Mod .EventBusSubscriber (modid = Oreganized .MOD_ID )
20
16
public class ScaredOfGargoyleGoal extends Goal {
21
17
22
18
public static final String AVOID_TAG_KEY = "ScaredByGargoyle" ;
@@ -25,11 +21,9 @@ public class ScaredOfGargoyleGoal extends Goal {
25
21
26
22
private final PathfinderMob mob ;
27
23
28
- @ SubscribeEvent
29
- public static void onMobSpawn (EntityEvent .EntityConstructing event ) {
30
- if (!(event .getEntity () instanceof Mob entity )) return ;
31
- if (entity .getMobType () == MobType .UNDEAD && entity instanceof PathfinderMob mob ) {
32
- entity .goalSelector .addGoal (1 , new ScaredOfGargoyleGoal (mob ));
24
+ public static void addGoal (Entity entity ) {
25
+ if (entity instanceof PathfinderMob mob && mob .getMobType () == MobType .UNDEAD ) {
26
+ mob .goalSelector .addGoal (1 , new ScaredOfGargoyleGoal (mob ));
33
27
}
34
28
}
35
29
@@ -43,6 +37,7 @@ public static void onMobSpawn(EntityEvent.EntityConstructing event) {
43
37
public ScaredOfGargoyleGoal (PathfinderMob mob ) {
44
38
this .mob = mob ;
45
39
this .navigation = mob .getNavigation ();
40
+ this .setFlags (EnumSet .of (Flag .MOVE , Flag .LOOK ));
46
41
}
47
42
48
43
@ Override
0 commit comments