Skip to content

Commit

Permalink
MoC mobs now fight back when attacked by other mobs
Browse files Browse the repository at this point in the history
Closes #88.
  • Loading branch information
IcarussOne committed Dec 31, 2023
1 parent 485f666 commit 09d3565
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
Expand All @@ -27,8 +28,9 @@ public MoCEntityPiranha(World world) {

@Override
protected void initEntityAI() {
this.tasks.addTask(3, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(3, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(4, new EntityAIFollowHerd(this, 0.6D, 4D, 20D, 1));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -40,9 +41,10 @@ public MoCEntityShark(World world) {

@Override
protected void initEntityAI() {
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(5, new EntityAIWanderMoC2(this, 1.0D, 30));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -48,9 +50,11 @@ public MoCEntityHorseMob(World world) {
@Override
protected void initEntityAI() {
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<>(this, EntityIronGolem.class, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -54,10 +55,12 @@ public MoCEntityWerewolf(World world) {
@Override
protected void initEntityAI() {
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, false));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<>(this, EntityIronGolem.class, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
Expand All @@ -42,7 +44,9 @@ public MoCEntityWraith(World world) {
protected void initEntityAI() {
this.tasks.addTask(2, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<>(this, EntityIronGolem.class, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.item.EntityItem;
Expand Down Expand Up @@ -65,11 +66,12 @@ protected void initEntityAI() {
this.tasks.addTask(2, new EntityAIPanicMoC(this, 1.0D));
this.tasks.addTask(3, new EntityAIFollowOwnerPlayer(this, 1D, 2F, 10F));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
//this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityAnimal.class, false));
this.targetTasks.addTask(3, new EntityAIHunt<>(this, EntityPlayer.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -73,12 +74,13 @@ public MoCEntityBigCat(World world) {
@Override
protected void initEntityAI() {
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(1, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIFollowOwnerPlayer(this, 1D, 2F, 10F));
this.tasks.addTask(2, new EntityAIWanderMoC2(this, 0.8D, 30));
//this.targetTasks.addTask(3, new EntityAIHunt<>(this, EntityAnimal.class, true));
this.targetTasks.addTask(4, new EntityAIHunt<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
//this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityAnimal.class, false));
this.targetTasks.addTask(3, new EntityAIHunt<>(this, EntityPlayer.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ protected void initEntityAI() {
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(7, new EntityAIWanderMoC2(this, 0.9D));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));

this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
//this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityAnimal.class, true));
this.targetTasks.addTask(3, new EntityAIHunt<>(this, EntityPlayer.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ protected void initEntityAI() {
this.tasks.addTask(3, new EntityAIFleeFromPlayer(this, 1.0D, 4D));
this.tasks.addTask(3, new EntityAIFollowOwnerPlayer(this, 0.8D, 2F, 10F));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
Expand Down Expand Up @@ -67,11 +68,12 @@ public MoCEntityKomodo(World world) {
protected void initEntityAI() {
this.tasks.addTask(2, new EntityAIPanicMoC(this, 1.1D));
this.tasks.addTask(3, new EntityAIFleeFromPlayer(this, 1.1D, 4D));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(7, new EntityAIWanderMoC2(this, 0.9D));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
//this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityAnimal.class, false));
this.targetTasks.addTask(3, new EntityAIHunt<>(this, EntityPlayer.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ protected void initEntityAI() {
this.tasks.addTask(3, new EntityAIFleeFromPlayer(this, 1.0D, 4D));
this.tasks.addTask(3, new EntityAIFollowOwnerPlayer(this, 0.8D, 2F, 10F));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
Expand Down Expand Up @@ -74,11 +75,12 @@ public MoCEntitySnake(World world) {
protected void initEntityAI() {
this.tasks.addTask(2, new EntityAIPanicMoC(this, 0.8D));
this.tasks.addTask(3, new EntityAIFleeFromPlayer(this, 0.8D, 4D));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(5, new EntityAIWanderMoC2(this, 0.8D, 30));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityPlayer.class, true));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
//this.targetTasks.addTask(2, new EntityAIHunt<>(this, EntityAnimal.class, false));
this.targetTasks.addTask(3, new EntityAIHunt<>(this, EntityPlayer.class, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIFleeFromPlayer(this, 1.0D, 4D));
this.tasks.addTask(3, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(7, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public MoCEntityElephant(World world) {
protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public MoCEntityEnt(World world) {
@Override
protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIPanicMoC(this, 1.0D));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIPanicMoC(this, 1.0D));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderAvoidWater(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public MoCEntityOstrich(World world) {
protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(4, new EntityAIFollowAdult(this, 1.0D));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(6, new EntityAIWanderMoC2(this, 1.0D));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public MoCEntityWyvern(World world) {
@Override
protected void initEntityAI() {
this.tasks.addTask(1, new EntityAISwimming(this));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, true));
this.tasks.addTask(5, new EntityAIAttackMelee(this, 1.0D, false));
this.tasks.addTask(4, this.wander = new EntityAIWanderMoC2(this, 1.0D, 80));
this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
//this.targetTasks.addTask(1, new EntityAIHunt<>(this, EntityAnimal.class, true));
Expand Down

0 comments on commit 09d3565

Please sign in to comment.