diff --git a/common/biomesoplenty/entities/EntityFlyingMob.java b/common/biomesoplenty/entities/EntityFlyingMob.java new file mode 100644 index 000000000..8e14fa2f5 --- /dev/null +++ b/common/biomesoplenty/entities/EntityFlyingMob.java @@ -0,0 +1,95 @@ +package biomesoplenty.entities; + +import net.minecraft.block.Block; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityFlyingMob extends EntityMob +{ + public EntityFlyingMob(World par1World) + { + super(par1World); + } + + @Override + protected void fall(float par1) {} + + @Override + protected void updateFallState(double par1, boolean par3) {} + + @Override + public void moveEntityWithHeading(float par1, float par2) + { + if (this.isInWater()) + { + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + } + else if (this.handleLavaMovement()) + { + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + else + { + float f2 = 0.91F; + + if (this.onGround) + { + f2 = 0.54600006F; + int i = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)); + + if (i > 0) + { + f2 = Block.blocksList[i].slipperiness * 0.91F; + } + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + this.moveFlying(par1, par2, this.onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; + + if (this.onGround) + { + f2 = 0.54600006F; + int j = this.worldObj.getBlockId(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)); + + if (j > 0) + { + f2 = Block.blocksList[j].slipperiness * 0.91F; + } + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= (double)f2; + this.motionY *= (double)f2; + this.motionZ *= (double)f2; + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double d0 = this.posX - this.prevPosX; + double d1 = this.posZ - this.prevPosZ; + float f4 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; + + if (f4 > 1.0F) + { + f4 = 1.0F; + } + + this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } + + @Override + public boolean isOnLadder() + { + return false; + } +} diff --git a/common/biomesoplenty/entities/EntityWasp.java b/common/biomesoplenty/entities/EntityWasp.java index 6de8fb61f..a7f7436bc 100644 --- a/common/biomesoplenty/entities/EntityWasp.java +++ b/common/biomesoplenty/entities/EntityWasp.java @@ -1,30 +1,168 @@ package biomesoplenty.entities; -import org.lwjgl.opengl.GL11; - -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.ai.EntityAIWatchClosest; -import net.minecraft.entity.passive.EntityAmbientCreature; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; -public class EntityWasp extends EntityLiving +public class EntityWasp extends EntityFlyingMob { + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + private Entity targetedEntity; + + /** Cooldown time between target loss and new target aquirement. */ + private int aggroCooldown; + public int prevAttackCounter; + public int attackCounter; + public EntityWasp(World world) { super(world); - this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.setSize(1.0F, 1.0F); } - public boolean isAIEnabled() + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(2.5D); + } + + @Override + protected void updateEntityActionState() + { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == 0) + { + this.setDead(); + } + + this.despawnEntity(); + this.prevAttackCounter = this.attackCounter; + double d0 = this.waypointX - this.posX; + double d1 = this.waypointY - this.posY; + double d2 = this.waypointZ - this.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d3 < 1.0D || d3 > 3600.0D) + { + this.waypointX = this.posX + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointY = this.posY + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointZ = this.posZ + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + } + + if (this.courseChangeCooldown-- <= 0) + { + this.courseChangeCooldown += this.rand.nextInt(5) + 2; + d3 = (double)MathHelper.sqrt_double(d3); + + if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) + { + this.motionX += d0 / d3 * 0.1D; + this.motionY += d1 / d3 * 0.1D; + this.motionZ += d2 / d3 * 0.1D; + } + else + { + this.waypointX = this.posX; + this.waypointY = this.posY; + this.waypointZ = this.posZ; + } + } + + if (this.targetedEntity != null && this.targetedEntity.isDead) + { + this.targetedEntity = null; + } + + if (this.targetedEntity == null || this.aggroCooldown-- <= 0) + { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) + { + this.aggroCooldown = 20; + } + } + + double d4 = 64.0D; + + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4) + { + double d5 = this.targetedEntity.posX - this.posX; + double d6 = this.targetedEntity.boundingBox.minY + (double)(this.targetedEntity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F)); + double d7 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(d5, d7)) * 180.0F / (float)Math.PI; + + if (this.canEntityBeSeen(this.targetedEntity)) + { + this.waypointX = targetedEntity.posX; + this.waypointY = targetedEntity.posY; + this.waypointZ = targetedEntity.posZ; + + float f1 = this.targetedEntity.getDistanceToEntity(this); + + this.attackEntity(this.targetedEntity, f1); + + ++this.attackCounter; + } + else if (this.attackCounter > 0) + { + --this.attackCounter; + } + } + else + { + this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI; + + if (this.attackCounter > 0) + { + --this.attackCounter; + } + } + } + + private boolean isCourseTraversable(double par1, double par3, double par5, double par7) + { + double d4 = (this.waypointX - this.posX) / par7; + double d5 = (this.waypointY - this.posY) / par7; + double d6 = (this.waypointZ - this.posZ) / par7; + AxisAlignedBB axisalignedbb = this.boundingBox.copy(); + + for (int i = 1; (double)i < par7; ++i) + { + axisalignedbb.offset(d4, d5, d6); + + if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) + { + return false; + } + } + return true; } @Override - public boolean allowLeashing() + protected String getLivingSound() { - return false; + return "biomesoplenty:mob.wasp.say"; + } + + @Override + protected String getHurtSound() + { + return "biomesoplenty:mob.wasp.say"; + } + + @Override + protected String getDeathSound() + { + return "biomesoplenty:mob.wasp.say"; } } diff --git a/common/biomesoplenty/entities/models/ModelWasp.java b/common/biomesoplenty/entities/models/ModelWasp.java index 5ab4da74e..2a2d18bfe 100644 --- a/common/biomesoplenty/entities/models/ModelWasp.java +++ b/common/biomesoplenty/entities/models/ModelWasp.java @@ -131,33 +131,22 @@ public class ModelWasp extends ModelBase Abdomen.addChild(Stinger); } + @Override public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.75F, 0.0F); + + this.setRotationAngles(f, f1, f2, f3, f4, f5, entity); /*Head*/ - float headspeed = 0.1F * (float)(entity.entityId % 10); - Head.rotateAngleX = MathHelper.sin((float)entity.ticksExisted * headspeed) * 2.5F * (float)Math.PI / 180.0F; - Head.rotateAngleY = 0.0F; - Head.rotateAngleZ = MathHelper.cos((float)entity.ticksExisted * headspeed) * 1.5F * (float)Math.PI / 180.0F; - Head.render(f5); - /*Wings*/ - Right_Wing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.25F; - Left_Wing.rotateAngleY = -Right_Wing.rotateAngleY; - Right_Wing.rotateAngleZ = Right_Wing.rotateAngleY; - Left_Wing.rotateAngleZ = -Right_Wing.rotateAngleY; - + /*Wings*/ Left_Wing.render(f5); Right_Wing.render(f5); - /*Body*/ - float thoraxspeed = 0.05F * (float)(entity.entityId % 10); - Thorax.rotateAngleX = MathHelper.sin((float)entity.ticksExisted * thoraxspeed) * 2.5F * (float)Math.PI / 180.0F; - Thorax.rotateAngleY = 0.0F; - Thorax.rotateAngleZ = MathHelper.cos((float)entity.ticksExisted * thoraxspeed) * 1.5F * (float)Math.PI / 180.0F; - + /*Body*/ Thorax.render(f5); /*float nosespeed = 0.5F * (float)(entity.entityId % 10); @@ -166,11 +155,6 @@ public class ModelWasp extends ModelBase Nose.rotateAngleZ = MathHelper.cos((float)entity.ticksExisted * nosespeed) * 1.5F * (float)Math.PI / 180.0F;*/ /*Stinger*/ - float abdomenspeed = 0.6F * (float)(entity.entityId % 10); - Abdomen.rotateAngleX = MathHelper.sin((float)entity.ticksExisted * abdomenspeed) * 2.5F * (float)Math.PI / 180.0F; - Abdomen.rotateAngleY = 0.0F; - Abdomen.rotateAngleZ = MathHelper.cos((float)entity.ticksExisted * abdomenspeed) * 1.5F * (float)Math.PI / 180.0F; - Abdomen.render(f5); } @@ -178,5 +162,22 @@ public class ModelWasp extends ModelBase public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + + float headspeed = 0.1F * (float)(entity.entityId % 10); + Head.rotateAngleX = MathHelper.sin(f2 * headspeed) * 2.5F * (float)Math.PI / 180.0F; + Head.rotateAngleZ = MathHelper.cos(f2 * headspeed) * 1.5F * (float)Math.PI / 180.0F; + + float thoraxspeed = 0.075F * (float)(entity.entityId % 10); + Thorax.rotateAngleX = MathHelper.sin(f2 * thoraxspeed) * 2.5F * (float)Math.PI / 180.0F; + Thorax.rotateAngleZ = MathHelper.cos(f2 * thoraxspeed) * 1.5F * (float)Math.PI / 180.0F; + + Right_Wing.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.25F; + Left_Wing.rotateAngleY = -Right_Wing.rotateAngleY; + Right_Wing.rotateAngleZ = Right_Wing.rotateAngleY; + Left_Wing.rotateAngleZ = -Right_Wing.rotateAngleY; + + float abdomenspeed = 0.6F * (float)(entity.entityId % 10); + Abdomen.rotateAngleX = MathHelper.sin(f2 * abdomenspeed) * 2.5F * (float)Math.PI / 180.0F; + Abdomen.rotateAngleZ = MathHelper.cos(f2 * abdomenspeed) * 1.5F * (float)Math.PI / 180.0F; } } diff --git a/common/biomesoplenty/entities/render/RenderWasp.java b/common/biomesoplenty/entities/render/RenderWasp.java index 17adb8f27..98d186f97 100644 --- a/common/biomesoplenty/entities/render/RenderWasp.java +++ b/common/biomesoplenty/entities/render/RenderWasp.java @@ -14,6 +14,7 @@ public class RenderWasp extends RenderLiving public RenderWasp() { super(new ModelWasp(), 0.25F); + this.shadowSize = 0.0F; } @Override diff --git a/common/biomesoplenty/handlers/SoundHandler.java b/common/biomesoplenty/handlers/SoundHandler.java index 6cec5d6fa..08e040972 100644 --- a/common/biomesoplenty/handlers/SoundHandler.java +++ b/common/biomesoplenty/handlers/SoundHandler.java @@ -13,7 +13,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class SoundHandler { static String[] recordSoundFiles = { "biomesoplenty:bopdisc.ogg", "biomesoplenty:bopdiscmud.ogg" }; - static String[] soundFiles = { "biomesoplenty:mob/phantom/say.ogg", "biomesoplenty:mob/phantom/hurt.ogg", "biomesoplenty:mob/phantom/death.ogg" }; + static String[] soundFiles = { "biomesoplenty:mob/phantom/say.ogg", "biomesoplenty:mob/phantom/hurt.ogg", "biomesoplenty:mob/phantom/death.ogg", "biomesoplenty:mob/wasp/say.ogg" }; @SideOnly(Side.CLIENT) @ForgeSubscribe diff --git a/resources/assets/biomesoplenty/sound/mob/wasp/say.ogg b/resources/assets/biomesoplenty/sound/mob/wasp/say.ogg new file mode 100644 index 000000000..2681e3da6 Binary files /dev/null and b/resources/assets/biomesoplenty/sound/mob/wasp/say.ogg differ