36
36
import com .github .alexthe666 .iceandfire .message .MessageSwingArm ;
37
37
import com .github .alexthe666 .iceandfire .misc .IafDamageRegistry ;
38
38
import com .github .alexthe666 .iceandfire .misc .IafTagRegistry ;
39
- import com .github .alexthe666 .iceandfire .pathfinding .raycoms .AdvancedPathNavigate ;
40
- import com .github .alexthe666 .iceandfire .pathfinding .raycoms .Pathfinding ;
41
39
import com .github .alexthe666 .iceandfire .recipe .IafRecipeRegistry ;
42
40
import com .github .alexthe666 .iceandfire .world .gen .WorldGenFireDragonCave ;
43
41
import com .github .alexthe666 .iceandfire .world .gen .WorldGenIceDragonCave ;
49
47
import net .minecraft .block .WallBlock ;
50
48
import net .minecraft .enchantment .EnchantmentHelper ;
51
49
import net .minecraft .enchantment .Enchantments ;
52
- import net .minecraft .entity .CreatureEntity ;
53
- import net .minecraft .entity .Entity ;
54
- import net .minecraft .entity .LivingEntity ;
55
- import net .minecraft .entity .MobEntity ;
56
- import net .minecraft .entity .SpawnReason ;
50
+ import net .minecraft .entity .*;
57
51
import net .minecraft .entity .ai .attributes .Attribute ;
58
52
import net .minecraft .entity .ai .attributes .AttributeModifier ;
59
53
import net .minecraft .entity .ai .attributes .Attributes ;
63
57
import net .minecraft .entity .monster .WitherSkeletonEntity ;
64
58
import net .minecraft .entity .passive .AnimalEntity ;
65
59
import net .minecraft .entity .passive .TameableEntity ;
66
- import net .minecraft .entity .passive .horse .AbstractHorseEntity ;
67
60
import net .minecraft .entity .player .PlayerEntity ;
68
61
import net .minecraft .entity .projectile .AbstractArrowEntity ;
69
62
import net .minecraft .inventory .EquipmentSlotType ;
82
75
import net .minecraft .potion .EffectInstance ;
83
76
import net .minecraft .potion .Effects ;
84
77
import net .minecraft .tags .EntityTypeTags ;
85
- import net .minecraft .util .CombatEntry ;
86
- import net .minecraft .util .CombatTracker ;
87
- import net .minecraft .util .DamageSource ;
88
- import net .minecraft .util .SoundEvents ;
78
+ import net .minecraft .tags .ITag ;
79
+ import net .minecraft .util .*;
89
80
import net .minecraft .util .math .AxisAlignedBB ;
90
81
import net .minecraft .util .math .EntityRayTraceResult ;
91
82
import net .minecraft .util .math .MathHelper ;
@@ -217,25 +208,29 @@ public static float updateRotation(float angle, float targetAngle, float maxIncr
217
208
return angle + f ;
218
209
}
219
210
220
- public static boolean isLivestock (Entity entity ) {
221
- return entity != null && EntityTypeTags .getCollection ().get (IafTagRegistry .FEAR_DRAGONS ).contains (entity .getType ());
211
+ private static boolean isInEntityTag (ResourceLocation loc , EntityType type ) {
212
+ ITag <EntityType <?>> tag = EntityTypeTags .getCollection ().get (loc );
213
+ return tag != null && tag .contains (type );
214
+ }
222
215
216
+ public static boolean isLivestock (Entity entity ) {
217
+ return entity != null && isInEntityTag (IafTagRegistry .FEAR_DRAGONS , entity .getType ());
223
218
}
224
219
225
220
public static boolean isVillager (Entity entity ) {
226
- return entity != null && EntityTypeTags . getCollection (). get ( IafTagRegistry .VILLAGERS ). contains ( entity .getType ());
221
+ return entity != null && isInEntityTag ( IafTagRegistry .VILLAGERS , entity .getType ());
227
222
}
228
223
229
- public static boolean isAnimaniaSheep (Entity entity ) {
230
- return entity != null && EntityTypeTags . getCollection (). get ( IafTagRegistry .SHEEP ). contains ( entity .getType ());
224
+ public static boolean isSheep (Entity entity ) {
225
+ return entity != null && isInEntityTag ( IafTagRegistry .SHEEP , entity .getType ());
231
226
}
232
227
233
- public static boolean isAnimaniaChicken (Entity entity ) {
234
- return entity != null && EntityTypeTags . getCollection (). get ( IafTagRegistry .CHICKENS ). contains ( entity .getType ());
228
+ public static boolean isChicken (Entity entity ) {
229
+ return entity != null && isInEntityTag ( IafTagRegistry .CHICKENS , entity .getType ());
235
230
}
236
231
237
- public static boolean isAnimaniaFerret (Entity entity ) {
238
- return entity != null && EntityTypeTags . getCollection (). get ( IafTagRegistry .SCARES_COCKATRICES ). contains ( entity .getType ());
232
+ public static boolean doesScareCockatrice (Entity entity ) {
233
+ return entity != null && isInEntityTag ( IafTagRegistry .SCARES_COCKATRICES , entity .getType ());
239
234
}
240
235
241
236
public static boolean isRidingOrBeingRiddenBy (Entity first , Entity entityIn ) {
@@ -388,7 +383,7 @@ public void onLivingAttacked(LivingAttackEvent event) {
388
383
if (properties != null && properties .inLoveTicks > 0 ) {
389
384
event .setCanceled (true );
390
385
}
391
- if (isAnimaniaChicken (event .getEntityLiving ()) && attacker instanceof LivingEntity ) {
386
+ if (isChicken (event .getEntityLiving ()) && attacker instanceof LivingEntity ) {
392
387
signalChickenAlarm (event .getEntityLiving (), (LivingEntity ) attacker );
393
388
}
394
389
if (DragonUtils .isVillager (event .getEntityLiving ()) && attacker instanceof LivingEntity ) {
@@ -403,7 +398,7 @@ public void onLivingAttacked(LivingAttackEvent event) {
403
398
public void onLivingSetTarget (LivingSetAttackTargetEvent event ) {
404
399
if (event .getTarget () != null ) {
405
400
LivingEntity attacker = event .getEntityLiving ();
406
- if (isAnimaniaChicken (event .getTarget ())) {
401
+ if (isChicken (event .getTarget ())) {
407
402
signalChickenAlarm (event .getTarget (), attacker );
408
403
}
409
404
if (DragonUtils .isVillager (event .getTarget ())) {
@@ -414,7 +409,7 @@ public void onLivingSetTarget(LivingSetAttackTargetEvent event) {
414
409
415
410
@ SubscribeEvent
416
411
public void onPlayerAttack (AttackEntityEvent event ) {
417
- if (event .getTarget () != null && isAnimaniaSheep (event .getTarget ())) {
412
+ if (event .getTarget () != null && isSheep (event .getTarget ())) {
418
413
float dist = IafConfig .cyclopesSheepSearchLength ;
419
414
List <Entity > list = event .getTarget ().world .getEntitiesWithinAABBExcludingEntity (event .getPlayer (), event .getPlayer ().getBoundingBox ().expand (dist , dist , dist ));
420
415
if (!list .isEmpty ()) {
@@ -566,7 +561,7 @@ public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
566
561
} catch (Exception e ) {
567
562
568
563
}
569
- if (IafConfig .chickensLayRottenEggs && !event .getEntityLiving ().world .isRemote && isAnimaniaChicken (event .getEntityLiving ()) && !event .getEntityLiving ().isChild () && event .getEntityLiving () instanceof AnimalEntity ) {
564
+ if (IafConfig .chickensLayRottenEggs && !event .getEntityLiving ().world .isRemote && isChicken (event .getEntityLiving ()) && !event .getEntityLiving ().isChild () && event .getEntityLiving () instanceof AnimalEntity ) {
570
565
ChickenEntityProperties chickenProps = EntityPropertiesHandler .INSTANCE .getProperties (event .getEntityLiving (), ChickenEntityProperties .class );
571
566
if (chickenProps != null ) {
572
567
if (chickenProps .timeUntilNextEgg < 0 ) {
@@ -882,7 +877,7 @@ public void onEntityJoinWorld(LivingSpawnEvent.SpecialSpawn event) {
882
877
IceAndFire .LOGGER .warn ("could not instantiate chain properties for " + event .getEntity ().getName ());
883
878
}
884
879
}
885
- if (event .getEntity () != null && isAnimaniaSheep (event .getEntity ()) && event .getEntity () instanceof AnimalEntity ) {
880
+ if (event .getEntity () != null && isSheep (event .getEntity ()) && event .getEntity () instanceof AnimalEntity ) {
886
881
AnimalEntity animal = (AnimalEntity ) event .getEntity ();
887
882
animal .goalSelector .addGoal (8 , new EntitySheepAIFollowCyclops (animal , 1.2D ));
888
883
}
0 commit comments