Skip to content

Commit dcb82db

Browse files
committed
lemur will fight back when attacked, other lemurs will join also.
1 parent f2023d8 commit dcb82db

2 files changed

Lines changed: 9 additions & 106 deletions

File tree

src/main/java/com/crowsofwar/avatar/common/entity/EntityAscendedFlyingLemur.java

Lines changed: 6 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,12 @@ public EntityAscendedFlyingLemur(World worldIn)
6464
this.moveHelper = new EntityFlyHelper(this);
6565
experienceValue = 200;
6666
}
67-
68-
69-
7067
@Nullable
7168
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
7269
{
7370
this.setVariant(this.rand.nextInt(2));
7471
return super.onInitialSpawn(difficulty, livingdata);
7572
}
76-
77-
7873
@Override
7974
protected void initEntityAI()
8075
{
@@ -86,13 +81,11 @@ protected void initEntityAI()
8681
this.tasks.addTask(2, new EntityAIFollowOwner(this, 1.0F, 10.0F, 2.0F));
8782
this.tasks.addTask(2, new EntityAIFollowOwnerFlying(this, 1.0D, 5.0F, 1.0F));
8883
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 16.0F));
89-
this.tasks.addTask(3, new EntityAIFollow(this, 1.0D, 3.0F, 7.0F));
9084
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.2D, true));
9185
this.tasks.addTask(6, new EntityAIMate(this, 1.5D));
9286
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
9387
this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
9488
this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0]));
95-
9689
}
9790

9891
@Override
@@ -197,7 +190,7 @@ public void onLivingUpdate()
197190
this.moveHelper = new EntityMoveHelper(this);
198191
}
199192
else {
200-
if(!this.isInWater() && !this.isInLove() && !this.isAngry()) {
193+
if(!this.isInWater() && !this.isInLove()) {
201194
this.moveHelper = new EntityFlyHelper(this);
202195
}
203196
}
@@ -229,11 +222,6 @@ public void onLivingUpdate()
229222
}
230223

231224
}
232-
if (!this.world.isRemote && this.getAttackTarget() == null && this.isAngry())
233-
{
234-
this.setAngry(false);
235-
}
236-
237225
}
238226

239227
@SideOnly(Side.CLIENT)
@@ -443,19 +431,7 @@ protected void applyEntityAttributes()
443431
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(30.0D);
444432
this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2.0D);
445433
}
446-
public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn)
447-
{
448-
super.setAttackTarget(entitylivingbaseIn);
449434

450-
if (entitylivingbaseIn == null)
451-
{
452-
this.setAngry(false);
453-
}
454-
else if (!this.isTamed())
455-
{
456-
this.setAngry(true);
457-
}
458-
}
459435
/*
460436
* Config - End
461437
*/
@@ -539,7 +515,7 @@ public boolean processInteract(EntityPlayer player, EnumHand hand)
539515
this.setAttackTarget((EntityLivingBase)null);
540516
}
541517
}
542-
else if (TAME_ITEMS.contains(itemstack.getItem()) && !this.isAngry())
518+
else if (TAME_ITEMS.contains(itemstack.getItem()))
543519
{
544520
if (!player.capabilities.isCreativeMode)
545521
{
@@ -572,77 +548,13 @@ else if (TAME_ITEMS.contains(itemstack.getItem()) && !this.isAngry())
572548
}
573549
public boolean canBeLeashedTo(EntityPlayer player)
574550
{
575-
return !this.isAngry() && super.canBeLeashedTo(player);
551+
return super.canBeLeashedTo(player);
576552
}
577553
public int getMaxSpawnedInChunk()
578554
{
579555
return 8;
580556
}
581557

582-
public boolean shouldAttackEntity(EntityLivingBase target, EntityLivingBase owner)
583-
{
584-
if (!(target instanceof EntityCreeper) && !(target instanceof EntityGhast))
585-
{
586-
if (target instanceof EntityFlyingLemur)
587-
{
588-
EntityAscendedFlyingLemur entitylemur = (EntityAscendedFlyingLemur)target;
589-
590-
if (entitylemur.isTamed() && entitylemur.getOwner() == owner)
591-
{
592-
return false;
593-
}
594-
}
595-
596-
if (target instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer)owner).canAttackPlayer((EntityPlayer)target))
597-
{
598-
return false;
599-
}
600-
else
601-
{
602-
return !(target instanceof AbstractHorse) || !((AbstractHorse)target).isTame();
603-
}
604-
}
605-
else
606-
{
607-
return false;
608-
}
609-
}
610-
611-
/*
612-
* Emotions - Start
613-
*/
614-
@Override
615-
public void writeEntityToNBT(NBTTagCompound compound)
616-
{
617-
super.writeEntityToNBT(compound);
618-
compound.setBoolean("Angry", this.isAngry());
619-
}
620-
@Override
621-
public void readEntityFromNBT(NBTTagCompound compound)
622-
{
623-
super.readEntityFromNBT(compound);
624-
this.setAngry(compound.getBoolean("Angry"));
625-
}
626-
public boolean isAngry()
627-
{
628-
return (((Byte)this.dataManager.get(TAMED)).byteValue() & 2) != 0;
629-
}
630-
public void setAngry(boolean angry)
631-
{
632-
byte b0 = ((Byte)this.dataManager.get(TAMED)).byteValue();
633-
634-
if (angry)
635-
{
636-
this.dataManager.set(TAMED, Byte.valueOf((byte)(b0 | 2)));
637-
}
638-
else
639-
{
640-
this.dataManager.set(TAMED, Byte.valueOf((byte)(b0 & -3)));
641-
}
642-
}
643-
/*
644-
* Emotions - End
645-
*/
646558
public void setVariant(int variantIn)
647559
{
648560
this.dataManager.set(VARIANT, Integer.valueOf(variantIn));
@@ -745,7 +657,7 @@ public void playRideEffect(boolean play) {
745657
this.world.spawnParticle(enumparticletypes, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2);
746658
}
747659
}
748-
/*
749-
* Particle Effects - End
750-
*/
660+
/*
661+
* Particle Effects - End
662+
*/
751663
}

src/main/java/com/crowsofwar/avatar/common/entity/EntityFlyingLemur.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ public EntityFlyingLemur(World worldIn)
7171
experienceValue = 200;
7272
}
7373

74-
7574
@Override
7675
protected void initEntityAI()
7776
{
@@ -83,7 +82,6 @@ protected void initEntityAI()
8382
this.tasks.addTask(2, new EntityAIFollowOwner(this, 1.0F, 10.0F, 2.0F));
8483
this.tasks.addTask(2, new EntityAIFollowOwnerFlying(this, 1.0D, 5.0F, 1.0F));
8584
this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 16.0F));
86-
this.tasks.addTask(3, new EntityAIFollow(this, 1.0D, 3.0F, 7.0F));
8785
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.2D, true));
8886
this.tasks.addTask(6, new EntityAIMate(this, 1.5D));
8987
this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
@@ -114,15 +112,7 @@ protected PathNavigate createNavigator(World worldIn)
114112

115113
return null;
116114
}
117-
/*
118-
protected PathNavigate createNavigator(World worldIn)
119-
{
120-
PathNavigateFlying pathnavigateflying = new PathNavigateFlying(this, worldIn);
121-
pathnavigateflying.setCanOpenDoors(false);
122-
pathnavigateflying.setCanFloat(true);
123-
pathnavigateflying.setCanEnterDoors(true);
124-
return pathnavigateflying;
125-
}*/
115+
126116
@Override
127117
public EnumActionResult applyPlayerInteraction(EntityPlayer player, Vec3d vec, EnumHand hand)
128118
{
@@ -553,7 +543,7 @@ public int getMaxSpawnedInChunk()
553543

554544
public boolean shouldAttackEntity(EntityLivingBase target, EntityLivingBase owner)
555545
{
556-
if (!(target instanceof EntityCreeper) && !(target instanceof EntityGhast))
546+
if (!(target instanceof EntityCreeper) && !(target instanceof EntityGhast) && !(target instanceof EntityAscendedFlyingLemur))
557547
{
558548
if (target instanceof EntityFlyingLemur)
559549
{
@@ -572,6 +562,7 @@ public boolean shouldAttackEntity(EntityLivingBase target, EntityLivingBase owne
572562
else
573563
{
574564
return !(target instanceof AbstractHorse) || !((AbstractHorse)target).isTame();
565+
575566
}
576567
}
577568
else

0 commit comments

Comments
 (0)