From 2a61d82c5a4b885903b6bb64873adb7908724813 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 15 Aug 2020 21:24:25 +0200 Subject: [PATCH] balls-o-tron mark zero complete --- .../EntityAINearestAttackableTargetNT.java | 65 +++++++++ .../EntityBallsOTronBase.java | 7 +- .../EntityBallsOTronHead.java | 130 +++++++++++++++++- .../EntityBallsOTronSegment.java | 64 ++++++++- .../mob/sodtekhnologiyah/EntityBurrowing.java | 12 +- .../mob/sodtekhnologiyah/EntityWormBase.java | 28 ++-- .../sodtekhnologiyah/WormMovementBody.java | 58 ++++---- .../sodtekhnologiyah/WormMovementHead.java | 74 ++++++++++ src/main/java/com/hbm/main/MainRegistry.java | 4 + 9 files changed, 389 insertions(+), 53 deletions(-) create mode 100644 src/main/java/com/hbm/entity/mob/EntityAINearestAttackableTargetNT.java diff --git a/src/main/java/com/hbm/entity/mob/EntityAINearestAttackableTargetNT.java b/src/main/java/com/hbm/entity/mob/EntityAINearestAttackableTargetNT.java new file mode 100644 index 000000000..3b3e277e5 --- /dev/null +++ b/src/main/java/com/hbm/entity/mob/EntityAINearestAttackableTargetNT.java @@ -0,0 +1,65 @@ +package com.hbm.entity.mob; + +import java.util.Collections; +import java.util.List; + +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget.Sorter; +import net.minecraft.entity.ai.EntityAITarget; + +public class EntityAINearestAttackableTargetNT extends EntityAITarget { + + private final Class targetClass; + private final int targetChance; + private final Sorter theNearestAttackableTargetSorter; + private final IEntitySelector targetEntitySelector; + private EntityLivingBase targetEntity; + private final double searchRange; + + public EntityAINearestAttackableTargetNT(EntityCreature owner, Class targetClass, int targetChance, boolean shouldCheckSight, boolean nearbyOnly, final IEntitySelector selector, double range) { + super(owner, shouldCheckSight, nearbyOnly); + this.targetClass = targetClass; + this.targetChance = targetChance; + this.theNearestAttackableTargetSorter = new Sorter(owner); + this.searchRange = range; + setMutexBits(1); + + this.targetEntitySelector = new IEntitySelector() { + + @Override + public boolean isEntityApplicable(Entity entity) { + return selector != null && !selector.isEntityApplicable(entity) ? false : !(entity instanceof EntityLivingBase) ? false : EntityAINearestAttackableTargetNT.this.isSuitableTarget((EntityLivingBase) entity, false); + } + }; + } + + @Override + protected double getTargetDistance() { + return this.searchRange; + } + + @Override + public boolean shouldExecute() { + + if((this.targetChance > 0) && (this.taskOwner.getRNG().nextInt(this.targetChance) != 0)) { + return false; + } + double range = getTargetDistance(); + List targets = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(range, range, range), this.targetEntitySelector); + Collections.sort(targets, this.theNearestAttackableTargetSorter); + + if(targets.isEmpty()) { + return false; + } + this.targetEntity = ((EntityLivingBase) targets.get(0)); + return true; + } + + @Override + public void resetTask() { + this.taskOwner.setAttackTarget(targetEntity); + } +} diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronBase.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronBase.java index 4354b0534..a7dc91463 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronBase.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronBase.java @@ -3,8 +3,7 @@ package com.hbm.entity.mob.sodtekhnologiyah; import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.util.DamageSource; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; import net.minecraft.world.World; public abstract class EntityBallsOTronBase extends EntityWormBase { @@ -35,6 +34,10 @@ public abstract class EntityBallsOTronBase extends EntityWormBase { this.dragInGround = 0.98F; this.knockbackDivider = 1.0D; } + + public boolean canEntityBeSeenThroughNonSolids(Entity p_70685_1_) { + return this.worldObj.func_147447_a(Vec3.createVectorHelper(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ), Vec3.createVectorHelper(p_70685_1_.posX, p_70685_1_.posY + (double)p_70685_1_.getEyeHeight(), p_70685_1_.posZ), false, true, false) == null; + } @Override protected void applyEntityAttributes() { diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java index a8ff1eb56..071a2eeaf 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronHead.java @@ -1,8 +1,18 @@ package com.hbm.entity.mob.sodtekhnologiyah; +import com.hbm.entity.mob.EntityAINearestAttackableTargetNT; + import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class EntityBallsOTronHead extends EntityBallsOTronBase implements IBossDisplayData { @@ -13,18 +23,132 @@ public class EntityBallsOTronHead extends EntityBallsOTronBase implements IBossD * |___/_/ \_\____|____|___/ |___| |_| |_|\_\___|_|\_| */ + private final WormMovementHead movement = new WormMovementHead(this); + public EntityBallsOTronHead(World world) { super(world); + this.experienceValue = 1000; + this.wasNearGround = false; + this.attackRange = 150.0D; + this.setSize(3.0F, 3.0F); + this.maxSpeed = 1.0D; + this.fallSpeed = 0.006D; + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTargetNT(this, EntityPlayer.class, 0, false, false, null, 128.0D)); + this.targetTasks.addTask(3, new EntityAINearestAttackableTargetNT(this, Entity.class, 0, false, false, this.selector, 50.0D)); } @Override - public IChatComponent func_145748_c_() { - return null; + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.15D); + } + + @Override + public boolean getIsHead() { + return true; + } + + @Override + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { + + if(super.attackEntityFrom(par1DamageSource, par2)) { + this.dmgCooldown = 4; + return true; + } + + return false; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData data) { + + setUniqueWormID(this.rand.nextInt(4096)); + + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.posY); + int z = MathHelper.floor_double(this.posZ); + + for (int o = 0; o < 119; o++) { + + EntityBallsOTronSegment bodyPart = new EntityBallsOTronSegment(this.worldObj); + bodyPart.setPartID(o); + bodyPart.setPosition(x, y, z); + bodyPart.setUniqueWormID(getUniqueWormID()); + this.worldObj.spawnEntityInWorld(bodyPart); + } + + setPosition(x, y, z); + this.spawnPoint.set(x, y, z); + + this.aggroCooldown = 60; + return super.onSpawnWithEgg(data); + } + + @Override + protected void updateAITasks() { + + super.updateAITasks(); + + this.movement.updateMovement(); + + if ((getHealth() < getMaxHealth()) && (this.ticksExisted % 6 == 0)) { + if (this.targetedEntity != null) { + heal(1.0F); + } else if (this.recentlyHit == 0) { + heal(4.0F); + } + } + if ((this.targetedEntity != null) && (this.targetedEntity.getDistanceSqToEntity(this) < this.attackRange * this.attackRange)) + { + if (canEntityBeSeenThroughNonSolids(this.targetedEntity)) + { + this.attackCounter += 1; + if (this.attackCounter == 10) + { + //useLaser(this.targetedEntity, true); + + this.attackCounter = -20; + } + } + else if (this.attackCounter > 0) + { + this.attackCounter -= 1; + } + } + else if (this.attackCounter > 0) { + this.attackCounter -= 1; + } } @Override public float getAttackStrength(Entity target) { - return 0; + + if(target instanceof EntityLivingBase) { + return ((EntityLivingBase) target).getHealth() * 0.75F; + } + + return 100; } + @Override + public IChatComponent func_145748_c_() { + return super.func_145748_c_(); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("AggroCD", this.aggroCooldown); + par1NBTTagCompound.setInteger("CenterX", this.spawnPoint.posX); + par1NBTTagCompound.setInteger("CenterY", this.spawnPoint.posY); + par1NBTTagCompound.setInteger("CenterZ", this.spawnPoint.posZ); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.aggroCooldown = par1NBTTagCompound.getInteger("AggroCD"); + this.spawnPoint.set(par1NBTTagCompound.getInteger("CenterX"), par1NBTTagCompound.getInteger("CenterY"), par1NBTTagCompound.getInteger("CenterZ")); + } + } diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronSegment.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronSegment.java index 46f861e8b..f698e32f2 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronSegment.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBallsOTronSegment.java @@ -1,6 +1,10 @@ package com.hbm.entity.mob.sodtekhnologiyah; +import com.hbm.entity.mob.EntityAINearestAttackableTargetNT; + import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class EntityBallsOTronSegment extends EntityBallsOTronBase { @@ -9,11 +13,69 @@ public class EntityBallsOTronSegment extends EntityBallsOTronBase { public EntityBallsOTronSegment(World world) { super(world); + this.bodySpeed = 0.6D; + this.rangeForParts = 70.0D; + this.segmentDistance = 1.9D; + this.maxBodySpeed = 1.4D; + this.targetTasks.addTask(1, new EntityAINearestAttackableTargetNT(this, EntityLivingBase.class, 0, true, false, this.selector, 128.0D)); + } + + @Override + protected void entityInit() { + super.entityInit(); + this.dataWatcher.addObject(17, (byte)0); } @Override public float getAttackStrength(Entity target) { - return 0; + + if(target instanceof EntityLivingBase) { + return ((EntityLivingBase) target).getHealth() * 0.75F; + } + + return 100; } + @Override + protected void updateAITasks() { + this.movement.updateMovement(); + + if((this.followed != null) && (getPartID() == 0)) { + //this.dataWatcher.updateObject(17, Byte.valueOf((byte) (((EntityBallsOTronHead) this.followed).isArmored() ? 1 : 0))); + } else if(this.targetedEntity != null) { + this.dataWatcher.updateObject(17, Byte.valueOf(this.targetedEntity.getDataWatcher().getWatchableObjectByte(17))); + } + if(this.didCheck) { + if(this.targetedEntity == null || !this.targetedEntity.isEntityAlive()) { + setHealth(getHealth() - 1999.0F); + } + if(((this.followed == null) || (!this.followed.isEntityAlive())) && (this.rand.nextInt(60) == 0)) { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 2.0F, false); + } + } + if((this.followed != null) && (getAttackTarget() != null)) { + if(canEntityBeSeenThroughNonSolids(getAttackTarget())) { + this.attackCounter += 1; + if(this.attackCounter == 10) { + //useLaser(o(), false); + + this.attackCounter = -20; + } + } else if(this.attackCounter > 0) { + this.attackCounter -= 1; + } + } else if(this.attackCounter > 0) { + this.attackCounter -= 1; + } + } + + public void writeEntityToNBT(NBTTagCompound nbt) { + super.writeEntityToNBT(nbt); + nbt.setInteger("partID", this.getPartID()); + } + + public void readEntityFromNBT(NBTTagCompound nbt) { + super.readEntityFromNBT(nbt); + setPartID(nbt.getInteger("partID")); + } } diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBurrowing.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBurrowing.java index 281184d63..3a9e42ef6 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBurrowing.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityBurrowing.java @@ -71,13 +71,13 @@ public abstract class EntityBurrowing extends EntityCreature { this.motionZ *= drag; this.prevLimbSwingAmount = this.limbSwingAmount; - double var10 = this.posX - this.prevPosX; - double var9 = this.posZ - this.prevPosZ; - float var7 = (float) Math.sqrt(var10 * var10 + var9 * var9) * 4.0F; - if (var7 > 1.0F) { - var7 = 1.0F; + double deltaX = this.posX - this.prevPosX; + double deltaZ = this.posZ - this.prevPosZ; + float dist = (float) Math.sqrt(deltaX * deltaX + deltaZ * deltaZ) * 4.0F; + if (dist > 1.0F) { + dist = 1.0F; } - this.limbSwingAmount += (var7 - this.limbSwingAmount) * 0.4F; + this.limbSwingAmount += (dist - this.limbSwingAmount) * 0.4F; this.limbSwing += this.limbSwingAmount; } diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityWormBase.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityWormBase.java index b602c89cc..f516fa65b 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityWormBase.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/EntityWormBase.java @@ -66,8 +66,8 @@ public abstract class EntityWormBase extends EntityBurrowing { return this.uniqueWormID; } - public void setUniqueWormID(int par1) { - this.uniqueWormID = par1; + public void setUniqueWormID(int id) { + this.uniqueWormID = id; } @Override @@ -107,9 +107,9 @@ public abstract class EntityWormBase extends EntityBurrowing { } } - protected void attackEntitiesInList(List par1List) { + protected void attackEntitiesInList(List targets) { - for(Entity var3 : par1List) { + for(Entity var3 : targets) { if(((var3 instanceof EntityLivingBase)) && (canAttackClass(var3.getClass())) && ((!(var3 instanceof EntityWormBase)) || (((EntityWormBase) var3).getUniqueWormID() != getUniqueWormID()))) { attackEntityAsMob(var3); @@ -123,20 +123,20 @@ public abstract class EntityWormBase extends EntityBurrowing { } @Override - public boolean attackEntityAsMob(Entity par1Entity) { + public boolean attackEntityAsMob(Entity target) { - boolean var2 = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), getAttackStrength(par1Entity)); + boolean var2 = target.attackEntityFrom(DamageSource.causeMobDamage(this), getAttackStrength(target)); if(var2) { this.entityAge = 0; - double var5 = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D; - double var6 = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D; - double var7 = (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D; - double var8 = par1Entity.posX - var5; - double var10 = par1Entity.posZ - var6; - double var11 = par1Entity.posY - var7; - double var12 = this.knockbackDivider * (var8 * var8 + var10 * var10 + var11 * var11 + 0.1D); - par1Entity.addVelocity(var8 / var12, var11 / var12, var10 / var12); + double tx = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D; + double tz = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D; + double ty = (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D; + double deltaX = target.posX - tx; + double deltaZ = target.posZ - tz; + double deltaY = target.posY - ty; + double knockback = this.knockbackDivider * (deltaX * deltaX + deltaZ * deltaZ + deltaY * deltaY + 0.1D); + target.addVelocity(deltaX / knockback, deltaY / knockback, deltaZ / knockback); } return var2; diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementBody.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementBody.java index ef60a13aa..b4ec8fe32 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementBody.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementBody.java @@ -10,54 +10,58 @@ import net.minecraft.util.MathHelper; public class WormMovementBody { private EntityWormBase user; - public WormMovementBody(EntityWormBase par1) { - this.user = par1; + public WormMovementBody(EntityWormBase user) { + this.user = user; } protected void updateMovement() { - double var9 = 128.0D; - if((this.user.targetedEntity != null) && (this.user.targetedEntity.getDistanceSqToEntity(this.user) < var9 * var9)) { + + double targetingRange = 128.0D; + + if((this.user.targetedEntity != null) && (this.user.targetedEntity.getDistanceSqToEntity(this.user) < targetingRange * targetingRange)) { this.user.waypointX = this.user.targetedEntity.posX; this.user.waypointY = this.user.targetedEntity.posY; this.user.waypointZ = this.user.targetedEntity.posZ; } - if(((this.user.ticksExisted % 60 == 0) || (this.user.ticksExisted == 1)) - && ((this.user.targetedEntity == null) || (this.user.followed == null))) { - findEntityToFollow(this.user.worldObj.selectEntitiesWithinAABB(EntityLiving.class, - this.user.boundingBox.expand(this.user.rangeForParts, this.user.rangeForParts, this.user.rangeForParts), - EntityWormBase.wormSelector)); + + if(((this.user.ticksExisted % 60 == 0) || (this.user.ticksExisted == 1)) && ((this.user.targetedEntity == null) || (this.user.followed == null))) { + findEntityToFollow(this.user.worldObj.selectEntitiesWithinAABB(EntityLiving.class, this.user.boundingBox.expand(this.user.rangeForParts, this.user.rangeForParts, this.user.rangeForParts), EntityWormBase.wormSelector)); } - double var1 = this.user.waypointX - this.user.posX; - double var3 = this.user.waypointY - this.user.posY; - double var5 = this.user.waypointZ - this.user.posZ; - double var7 = var1 * var1 + var3 * var3 + var5 * var5; + + double deltaX = this.user.waypointX - this.user.posX; + double deltaY = this.user.waypointY - this.user.posY; + double deltaZ = this.user.waypointZ - this.user.posZ; + double deltaDist = MathHelper.sqrt_double(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); - var7 = MathHelper.sqrt_double(var7); if(this.user.targetedEntity != null) { this.user.faceEntity(this.user.targetedEntity, 180.0F, 180.0F); } - this.user.bodySpeed = Math.max(0.0D, Math.min(var7 - this.user.segmentDistance, this.user.maxBodySpeed)); - if(var7 < this.user.segmentDistance * 0.895D) { + + this.user.bodySpeed = Math.max(0.0D, Math.min(deltaDist - this.user.segmentDistance, this.user.maxBodySpeed)); + + if(deltaDist < this.user.segmentDistance * 0.895D) { this.user.motionX *= 0.8D; this.user.motionY *= 0.8D; this.user.motionZ *= 0.8D; } else { - this.user.motionX = (var1 / var7 * this.user.bodySpeed); - this.user.motionY = (var3 / var7 * this.user.bodySpeed); - this.user.motionZ = (var5 / var7 * this.user.bodySpeed); + this.user.motionX = (deltaX / deltaDist * this.user.bodySpeed); + this.user.motionY = (deltaY / deltaDist * this.user.bodySpeed); + this.user.motionZ = (deltaZ / deltaDist * this.user.bodySpeed); } } - protected void findEntityToFollow(List par1List) { - for(EntityWormBase var3 : par1List) { - if(var3.getUniqueWormID() == this.user.getUniqueWormID()) { - if(var3.getIsHead()) { + protected void findEntityToFollow(List segments) { + + for(EntityWormBase segment : segments) { + if(segment.getUniqueWormID() == this.user.getUniqueWormID()) { + if(segment.getIsHead()) { if(this.user.getPartID() == 0) { - this.user.targetedEntity = ((Entity) var3); + this.user.targetedEntity = ((Entity) segment); } - this.user.followed = ((EntityLivingBase) var3); - } else if(var3.getPartID() == this.user.getPartID() - 1) { - this.user.targetedEntity = ((Entity) var3); + this.user.followed = ((EntityLivingBase) segment); + + } else if(segment.getPartID() == this.user.getPartID() - 1) { + this.user.targetedEntity = ((Entity) segment); } } } diff --git a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementHead.java b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementHead.java index af24befa4..d857fa441 100644 --- a/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementHead.java +++ b/src/main/java/com/hbm/entity/mob/sodtekhnologiyah/WormMovementHead.java @@ -1,5 +1,79 @@ package com.hbm.entity.mob.sodtekhnologiyah; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.util.MathHelper; + public class WormMovementHead { + private EntityWormBase user; + + public WormMovementHead(EntityWormBase user) { + this.user = user; + } + + protected void updateMovement() { + + double var1 = this.user.waypointX - this.user.posX; + double var3 = this.user.waypointY - this.user.posY; + double var5 = this.user.waypointZ - this.user.posZ; + double var7 = var1 * var1 + var3 * var3 + var5 * var5; + if (this.user.courseChangeCooldown-- <= 0) + { + this.user.courseChangeCooldown += this.user.getRNG().nextInt(5) + 2; + var7 = MathHelper.sqrt_double(var7); + if (this.user.motionX * this.user.motionX + this.user.motionY * this.user.motionY + this.user.motionZ * this.user.motionZ < this.user.maxSpeed) + { + if (!this.user.isCourseTraversable()) { + var7 *= 8.0D; + } + double moverSpeed = this.user.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue(); + this.user.motionX += var1 / var7 * moverSpeed; + this.user.motionY += var3 / var7 * moverSpeed; + this.user.motionZ += var5 / var7 * moverSpeed; + } + } + if (!this.user.isCourseTraversable()) { + this.user.motionY -= this.user.fallSpeed; + } + if (this.user.dmgCooldown > 0) { + this.user.dmgCooldown -= 1; + } + this.user.aggroCooldown -= 1; + if (this.user.getAttackTarget() != null) + { + if (this.user.aggroCooldown <= 0) + { + this.user.targetedEntity = this.user.getAttackTarget(); + this.user.aggroCooldown = 20; + } + } + else if (this.user.targetedEntity == null) + { + this.user.waypointX = (this.user.spawnPoint.posX - 30 + this.user.getRNG().nextInt(60)); + this.user.waypointY = (this.user.spawnPoint.posY - 10 + this.user.getRNG().nextInt(20)); + this.user.waypointZ = (this.user.spawnPoint.posZ - 30 + this.user.getRNG().nextInt(60)); + } + this.user.rotationYaw = (-(float)Math.atan2(this.user.motionX, this.user.motionZ) * 180.0F / 3.1415927F); + this.user.rotationPitch = ((float)-(Math.atan2(this.user.motionY, MathHelper.sqrt_double(this.user.motionX * this.user.motionX + this.user.motionZ * this.user.motionZ)) * 180.0D / 3.141592653589793D)); + if ((this.user.targetedEntity != null) && (this.user.targetedEntity.getDistanceSqToEntity(this.user) < this.user.attackRange * this.user.attackRange)) { + if ((this.user.wasNearGround) || (this.user.canFly)) + { + this.user.waypointX = this.user.targetedEntity.posX; + this.user.waypointY = this.user.targetedEntity.posY; + this.user.waypointZ = this.user.targetedEntity.posZ; + if ((this.user.getRNG().nextInt(80) == 0) && (this.user.posY > this.user.surfaceY) && (!this.user.isCourseTraversable())) { + this.user.wasNearGround = false; + } + } + else + { + this.user.waypointX = this.user.targetedEntity.posX; + this.user.waypointY = 10.0D; + this.user.waypointZ = this.user.targetedEntity.posZ; + if (this.user.posY < 15.0D) { + this.user.wasNearGround = true; + } + } + } + } } diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index 5126df58b..33eae541b 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -41,6 +41,7 @@ import com.hbm.entity.item.EntityMovingItem; import com.hbm.entity.logic.*; import com.hbm.entity.missile.*; import com.hbm.entity.mob.*; +import com.hbm.entity.mob.sodtekhnologiyah.*; import com.hbm.entity.particle.*; import com.hbm.entity.projectile.*; import com.hbm.handler.*; @@ -684,6 +685,9 @@ public class MainRegistry EntityRegistry.registerGlobalEntityID(EntityTeslaCrab.class, "entity_tesla_crab", EntityRegistry.findGlobalUniqueEntityId(), 0xAAAAAA, 0x440000); EntityRegistry.registerGlobalEntityID(EntityTaintCrab.class, "entity_taint_crab", EntityRegistry.findGlobalUniqueEntityId(), 0xAAAAAA, 0xFF00FF); EntityRegistry.registerGlobalEntityID(EntityMaskMan.class, "entity_mask_man", EntityRegistry.findGlobalUniqueEntityId(), 0xAAAAAA, 0xAAAAAA); + + EntityRegistry.registerGlobalEntityID(EntityBallsOTronHead.class, "entity_balls_o_tron_mk0", EntityRegistry.findGlobalUniqueEntityId(), 0xAAAAAA, 0xAAAAAA); + EntityRegistry.registerModEntity(EntityBallsOTronSegment.class, "entity_balls_o_tron_mk0_segfault", 148, this, 1000, 1, true); ForgeChunkManager.setForcedChunkLoadingCallback(this, new LoadingCallback() {