diff --git a/README.md b/README.md index 1f67935..2807f75 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo ### Endermen +- Endermen sometimes try to teleport their attack target when they cannot reach them. - Players' gloom level rapidly increase when starring at an enderman. - Players' gloom level rapidly increase when being too close to an enderman. @@ -124,6 +125,8 @@ This is a Minecraft Better Than Wolves addon that aims to slightly strengthen mo - Villagers and pigs try to flee from explosions. - Pigs counterattack at high health. - Some cows counterattack to protect weaker ones in the herd. +- Players' view is locked on first person when head crabbed by a squid. - Animals have enhanced fleeing AI. +- Animals panic when pushed by a player. - Players' reputation decrease if they attack villagers in a village. - Villagers refuse to trade with players who have low reputation. \ No newline at end of file diff --git a/src/main/java/btw/community/mobsenhancement/MobsEnhancementAddon.java b/src/main/java/btw/community/mobsenhancement/MobsEnhancementAddon.java index 5dffd30..f540e27 100644 --- a/src/main/java/btw/community/mobsenhancement/MobsEnhancementAddon.java +++ b/src/main/java/btw/community/mobsenhancement/MobsEnhancementAddon.java @@ -9,7 +9,7 @@ public class MobsEnhancementAddon extends BTWAddon { private static MobsEnhancementAddon instance; private MobsEnhancementAddon() { - super("Mobs Enhancement", "0.3.0", "MEA"); + super("Mobs Enhancement", "0.3.1", "MEA"); } @Override diff --git a/src/main/java/net/pottx/mobsenhancement/AnimalCombatBehavior.java b/src/main/java/net/pottx/mobsenhancement/AnimalCombatBehavior.java index 5e652ca..3223fcb 100644 --- a/src/main/java/net/pottx/mobsenhancement/AnimalCombatBehavior.java +++ b/src/main/java/net/pottx/mobsenhancement/AnimalCombatBehavior.java @@ -88,7 +88,7 @@ public void updateTask() { } this.attackTimer = Math.max(this.attackTimer - 1, 0); - double reach = theAnimal.width + targetEntity.width; + double reach = theAnimal.width + targetEntity.width + 0.5D; if ( targetEntity == this.theAnimal.riddenByEntity ) { return; diff --git a/src/main/java/net/pottx/mobsenhancement/mixin/CowEntityMixin.java b/src/main/java/net/pottx/mobsenhancement/mixin/CowEntityMixin.java index a41197e..289f1c3 100644 --- a/src/main/java/net/pottx/mobsenhancement/mixin/CowEntityMixin.java +++ b/src/main/java/net/pottx/mobsenhancement/mixin/CowEntityMixin.java @@ -23,6 +23,11 @@ public CowEntityMixin(World par1World) { super(par1World); } + @Override + public int getMeleeAttackStrength(Entity target) { + return 4; + } + @Inject( method = "", at = @At(value = "TAIL") @@ -35,9 +40,9 @@ private void addExtraDataAndTasks(CallbackInfo ci) { this.tasks.removeAllTasksOfClass(EntityAIWatchClosest.class); if (this.getIsAggressive() == (byte)1) { - tasks.addTask(1, new AnimalCombatBehavior(this, 0.28F, 0.33F, ZombieEntity.class, 4)); + tasks.addTask(1, new AnimalCombatBehavior(this, 0.38F, 0.33F, ZombieEntity.class, 4)); } else { - tasks.addTask(1, new AnimalCombatBehavior(this, 0.28F, 0.33F, ZombieEntity.class, 15)); + tasks.addTask(1, new AnimalCombatBehavior(this, 0.38F, 0.33F, ZombieEntity.class, 15)); } } @@ -81,7 +86,7 @@ public boolean attackEntityFrom(DamageSource par1DamageSource, int par2) { boolean isSpeciesSame = tempAnimal instanceof CowEntity; - if (!tempAnimal.isLivingDead && isSpeciesSame && !tempAnimal.hasAttackTarget()) + if (!tempAnimal.isLivingDead && isSpeciesSame && !tempAnimal.hasAttackTarget() && tempAnimal.canEntityBeSeen(this)) { tempAnimal.setAttackTarget((EntityLiving)attacker); } diff --git a/src/main/java/net/pottx/mobsenhancement/mixin/EndermanEntityMixin.java b/src/main/java/net/pottx/mobsenhancement/mixin/EndermanEntityMixin.java new file mode 100644 index 0000000..c6a63d6 --- /dev/null +++ b/src/main/java/net/pottx/mobsenhancement/mixin/EndermanEntityMixin.java @@ -0,0 +1,105 @@ +package net.pottx.mobsenhancement.mixin; + +import btw.entity.mob.EndermanEntity; +import net.minecraft.src.*; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(EndermanEntity.class) +public class EndermanEntityMixin extends EntityEnderman { + @Shadow protected int teleportDelay; + + public EndermanEntityMixin(World par1World) { + super(par1World); + } + + @Inject( + method = "onLivingUpdate", + at = @At(value = "INVOKE", target = "Lbtw/entity/mob/EndermanEntity;entityMobOnLivingUpdate()V") + ) + private void updateEnemyTeleport(CallbackInfo ci) + { + if (!this.worldObj.isRemote && this.isEntityAlive() && this.entityToAttack != null) { + if (entityToAttack.getDistanceSqToEntity(this) > 6.0D && entityToAttack.getDistanceSqToEntity(this) < 64D) { + if (teleportDelay++ >= 120 && this.teleportEnemy()) { + this.teleportDelay = 0; + } + } else if (entityToAttack.getDistanceSqToEntity(this) < 256D) { + this.teleportDelay = 0; + } + } + } + + protected boolean teleportEnemy() { + if (this.entityToAttack != null) { + Entity target = this.entityToAttack; + Vec3 vec = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX - target.posX, this.boundingBox.minY + (double)(this.height / 2.0F) - target.posY + (double)target.getEyeHeight(), this.posZ - target.posZ); + vec = vec.normalize(); + double x0 = target.posX; + double y0 = target.posY; + double z0 = target.posZ; + target.posX = x0 + (this.rand.nextDouble() - 0.5D) * 8.0D + vec.xCoord * 0.8D; + target.posY = y0 + (double)(this.rand.nextInt(16) - 8) + vec.yCoord * 0.8D; + target.posZ = z0 + (this.rand.nextDouble() - 0.5D) * 8.0D + vec.zCoord * 0.8D; + int xb = MathHelper.floor_double(target.posX); + int yb = MathHelper.floor_double(target.posY); + int zb = MathHelper.floor_double(target.posZ); + int blockId; + + if (this.worldObj.blockExists(xb, yb, zb)) { + boolean canTeleport = false; + + while (!canTeleport && yb > 0) { + blockId = this.worldObj.getBlockId(xb, yb, zb); + if (blockId != 0 && Block.blocksList[blockId].blockMaterial.blocksMovement()) { + canTeleport = true; + for (int i = 1; i <= MathHelper.ceiling_float_int(target.height); i++) { + blockId = this.worldObj.getBlockId(xb, yb + i, zb); + if (blockId != 0 && Block.blocksList[blockId].blockMaterial.blocksMovement()) { + canTeleport = false; + target.posY -= MathHelper.ceiling_float_int(target.height) + 1; + yb -= MathHelper.ceiling_float_int(target.height) + 1; + break; + } + } + ++target.posY; + } + else { + --target.posY; + --yb; + } + } + + if (canTeleport) { + if (target instanceof EntityPlayer) { + ((EntityPlayer) target).setPositionAndUpdate(target.posX, target.posY, target.posZ); + } else { + target.setPosition(target.posX, target.posY, target.posZ); + } + + short var30 = 128; + for (blockId = 0; blockId < var30; ++blockId) { + double var19 = (double)blockId / ((double)var30 - 1.0D); + float var21 = (this.rand.nextFloat() - 0.5F) * 0.2F; + float var22 = (this.rand.nextFloat() - 0.5F) * 0.2F; + float var23 = (this.rand.nextFloat() - 0.5F) * 0.2F; + double var24 = x0 + (target.posX - x0) * var19 + (this.rand.nextDouble() - 0.5D) * (double)target.width * 2.0D; + double var26 = y0 + (target.posY - y0) * var19 + this.rand.nextDouble() * (double)target.height; + double var28 = z0 + (target.posZ - z0) * var19 + (this.rand.nextDouble() - 0.5D) * (double)target.width * 2.0D; + this.worldObj.spawnParticle("portal", var24, var26, var28, (double)var21, (double)var22, (double)var23); + } + this.worldObj.playSoundEffect(x0, y0, z0, "mob.endermen.portal", 1.0F, 1.0F); + target.playSound("mob.endermen.portal", 1.0F, 1.0F); + + return true; + } else { + target.setPosition(x0, y0, z0); + } + } + } + return false; + } +} diff --git a/src/main/java/net/pottx/mobsenhancement/mixin/EntityAnimalMixin.java b/src/main/java/net/pottx/mobsenhancement/mixin/EntityAnimalMixin.java new file mode 100644 index 0000000..e8c285e --- /dev/null +++ b/src/main/java/net/pottx/mobsenhancement/mixin/EntityAnimalMixin.java @@ -0,0 +1,39 @@ +package net.pottx.mobsenhancement.mixin; + +import net.minecraft.src.*; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(EntityAnimal.class) +public abstract class EntityAnimalMixin extends EntityAgeable { + @Shadow public abstract void setRevengeTarget(EntityLiving targetEntity); + + @Unique + private int pushedCounter = 0; + + public EntityAnimalMixin(World par1World) { + super(par1World); + } + + @Inject( + method = "onLivingUpdate", + at = @At(value = "TAIL") + ) + private void updatePushed(CallbackInfo ci) { + EntityPlayer player = (EntityPlayer) this.worldObj.findNearestEntityWithinAABB(EntityPlayer.class, this.boundingBox.expand(1.5D, 1D, 1.5D), this); + if (player != null && this.boundingBox.expand(0.35D, 0.35D, 0.35D).intersectsWith(player.boundingBox)) { + if (this.pushedCounter < 10) { + ++this.pushedCounter; + } else { + this.setRevengeTarget(player); + } + } else if (this.pushedCounter > 0) { + this.pushedCounter = 0; + } + + } +} diff --git a/src/main/java/net/pottx/mobsenhancement/mixin/PigEntityMixin.java b/src/main/java/net/pottx/mobsenhancement/mixin/PigEntityMixin.java index 6d74c30..c7d138f 100644 --- a/src/main/java/net/pottx/mobsenhancement/mixin/PigEntityMixin.java +++ b/src/main/java/net/pottx/mobsenhancement/mixin/PigEntityMixin.java @@ -21,6 +21,12 @@ public PigEntityMixin(World par1World) { super(par1World); } + @Override + public int getMeleeAttackStrength(Entity target) { + return 3; + } + + @Inject( method = "", at = @At(value = "TAIL") @@ -52,7 +58,7 @@ private void setAttackTargetWhenAttacked(DamageSource par1DamageSource, int par2 boolean isSpeciesSame = tempAnimal instanceof PigEntity; - if (!tempAnimal.isLivingDead && isSpeciesSame && !tempAnimal.hasAttackTarget()) + if (!tempAnimal.isLivingDead && isSpeciesSame && !tempAnimal.hasAttackTarget() && tempAnimal.canEntityBeSeen(this)) { tempAnimal.setAttackTarget((EntityLiving)attacker); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1a93522..9c2e7bc 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "mobsenhancement", - "version": "0.3.0", + "version": "0.3.1", "name": "Mobs Enhancement Addon", "description": "Slightly strengthens monsters.", diff --git a/src/main/resources/mobsenhancement.mixins.json b/src/main/resources/mobsenhancement.mixins.json index 54c0b82..269561f 100644 --- a/src/main/resources/mobsenhancement.mixins.json +++ b/src/main/resources/mobsenhancement.mixins.json @@ -10,10 +10,12 @@ "CreeperEntityAccess", "CreeperEntityMixin", "CreeperSwellBehaviorMixin", + "EndermanEntityMixin", "EntityAccess", "EntityAILookIdleMixin", "EntityAITargetMixin", "EntityAITradePlayerMixin", + "EntityAnimalMixin", "EntityArrowMixin", "EntityCreeperAccess", "EntityCreeperMixin",