| 1 | package net.minecraft.entity.boss;
|
| 2 |
|
| 3 | import com.google.common.base.Predicate;
|
| 4 | import com.google.common.base.Predicates;
|
| 5 | import java.util.List;
|
| 6 | import net.minecraft.block.Block;
|
| 7 | import net.minecraft.block.material.Material;
|
| 8 | import net.minecraft.entity.Entity;
|
| 9 | import net.minecraft.entity.EntityLiving;
|
| 10 | import net.minecraft.entity.EntityLivingBase;
|
| 11 | import net.minecraft.entity.EnumCreatureAttribute;
|
| 12 | import net.minecraft.entity.IRangedAttackMob;
|
| 13 | import net.minecraft.entity.SharedMonsterAttributes;
|
| 14 | import net.minecraft.entity.ai.EntityAIArrowAttack;
|
| 15 | import net.minecraft.entity.ai.EntityAIHurtByTarget;
|
| 16 | import net.minecraft.entity.ai.EntityAILookIdle;
|
| 17 | import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
| 18 | import net.minecraft.entity.ai.EntityAISwimming;
|
| 19 | import net.minecraft.entity.ai.EntityAIWander;
|
| 20 | import net.minecraft.entity.ai.EntityAIWatchClosest;
|
| 21 | import net.minecraft.entity.item.EntityItem;
|
| 22 | import net.minecraft.entity.monster.EntityMob;
|
| 23 | import net.minecraft.entity.player.EntityPlayer;
|
| 24 | import net.minecraft.entity.projectile.EntityArrow;
|
| 25 | import net.minecraft.entity.projectile.EntityWitherSkull;
|
| 26 | import net.minecraft.init.Blocks;
|
| 27 | import net.minecraft.init.Items;
|
| 28 | import net.minecraft.nbt.NBTTagCompound;
|
| 29 | import net.minecraft.pathfinding.PathNavigateGround;
|
| 30 | import net.minecraft.potion.PotionEffect;
|
| 31 | import net.minecraft.stats.AchievementList;
|
| 32 | import net.minecraft.util.BlockPos;
|
| 33 | import net.minecraft.util.DamageSource;
|
| 34 | import net.minecraft.util.EntitySelectors;
|
| 35 | import net.minecraft.util.EnumParticleTypes;
|
| 36 | import net.minecraft.util.MathHelper;
|
| 37 | import net.minecraft.world.EnumDifficulty;
|
| 38 | import net.minecraft.world.World;
|
| 39 |
|
| 40 | public class EntityWither extends EntityMob implements IBossDisplayData, IRangedAttackMob
|
| 41 | {
|
| 42 | private float[] field_82220_d = new float[2];
|
| 43 | private float[] field_82221_e = new float[2];
|
| 44 | private float[] field_82217_f = new float[2];
|
| 45 | private float[] field_82218_g = new float[2];
|
| 46 | private int[] field_82223_h = new int[2];
|
| 47 | private int[] field_82224_i = new int[2];
|
| 48 |
|
| 49 | /** Time before the Wither tries to break blocks */
|
| 50 | private int blockBreakCounter;
|
| 51 | private static final Predicate<Entity> attackEntitySelector = new Predicate<Entity>()
|
| 52 | {
|
| 53 | public boolean apply(Entity p_apply_1_)
|
| 54 | {
|
| 55 | return p_apply_1_ instanceof EntityLivingBase && ((EntityLivingBase)p_apply_1_).getCreatureAttribute() != EnumCreatureAttribute.UNDEAD;
|
| 56 | }
|
| 57 | };
|
| 58 |
|
| 59 | public EntityWither(World worldIn)
|
| 60 | {
|
| 61 | super(worldIn);
|
| 62 | this.setHealth(this.getMaxHealth());
|
| 63 | this.setSize(0.9F, 3.5F);
|
| 64 | this.isImmuneToFire = true;
|
| 65 | ((PathNavigateGround)this.getNavigator()).setCanSwim(true);
|
| 66 | this.tasks.addTask(0, new EntityAISwimming(this));
|
| 67 | this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 40, 20.0F));
|
| 68 | this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
|
| 69 | this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
| 70 | this.tasks.addTask(7, new EntityAILookIdle(this));
|
| 71 | this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
|
| 72 | this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, false, attackEntitySelector));
|
| 73 | this.experienceValue = 50;
|
| 74 | }
|
| 75 |
|
| 76 | protected void entityInit()
|
| 77 | {
|
| 78 | super.entityInit();
|
| 79 | this.dataWatcher.addObject(17, new Integer(0));
|
| 80 | this.dataWatcher.addObject(18, new Integer(0));
|
| 81 | this.dataWatcher.addObject(19, new Integer(0));
|
| 82 | this.dataWatcher.addObject(20, new Integer(0));
|
| 83 | }
|
| 84 |
|
| 85 | /**
|
| 86 | * (abstract) Protected helper method to write subclass entity data to NBT.
|
| 87 | */
|
| 88 | public void writeEntityToNBT(NBTTagCompound tagCompound)
|
| 89 | {
|
| 90 | super.writeEntityToNBT(tagCompound);
|
| 91 | tagCompound.setInteger("Invul", this.getInvulTime());
|
| 92 | }
|
| 93 |
|
| 94 | /**
|
| 95 | * (abstract) Protected helper method to read subclass entity data from NBT.
|
| 96 | */
|
| 97 | public void readEntityFromNBT(NBTTagCompound tagCompund)
|
| 98 | {
|
| 99 | super.readEntityFromNBT(tagCompund);
|
| 100 | this.setInvulTime(tagCompund.getInteger("Invul"));
|
| 101 | }
|
| 102 |
|
| 103 | /**
|
| 104 | * Returns the sound this mob makes while it's alive.
|
| 105 | */
|
| 106 | protected String getLivingSound()
|
| 107 | {
|
| 108 | return "mob.wither.idle";
|
| 109 | }
|
| 110 |
|
| 111 | /**
|
| 112 | * Returns the sound this mob makes when it is hurt.
|
| 113 | */
|
| 114 | protected String getHurtSound()
|
| 115 | {
|
| 116 | return "mob.wither.hurt";
|
| 117 | }
|
| 118 |
|
| 119 | /**
|
| 120 | * Returns the sound this mob makes on death.
|
| 121 | */
|
| 122 | protected String getDeathSound()
|
| 123 | {
|
| 124 | return "mob.wither.death";
|
| 125 | }
|
| 126 |
|
| 127 | /**
|
| 128 | * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
|
| 129 | * use this to react to sunlight and start to burn.
|
| 130 | */
|
| 131 | public void onLivingUpdate()
|
| 132 | {
|
| 133 | this.motionY *= 0.6000000238418579D;
|
| 134 |
|
| 135 | if (!this.worldObj.isRemote && this.getWatchedTargetId(0) > 0)
|
| 136 | {
|
| 137 | Entity entity = this.worldObj.getEntityByID(this.getWatchedTargetId(0));
|
| 138 |
|
| 139 | if (entity != null)
|
| 140 | {
|
| 141 | if (this.posY < entity.posY || !this.isArmored() && this.posY < entity.posY + 5.0D)
|
| 142 | {
|
| 143 | if (this.motionY < 0.0D)
|
| 144 | {
|
| 145 | this.motionY = 0.0D;
|
| 146 | }
|
| 147 |
|
| 148 | this.motionY += (0.5D - this.motionY) * 0.6000000238418579D;
|
| 149 | }
|
| 150 |
|
| 151 | double d0 = entity.posX - this.posX;
|
| 152 | double d1 = entity.posZ - this.posZ;
|
| 153 | double d3 = d0 * d0 + d1 * d1;
|
| 154 |
|
| 155 | if (d3 > 9.0D)
|
| 156 | {
|
| 157 | double d5 = (double)MathHelper.sqrt_double(d3);
|
| 158 | this.motionX += (d0 / d5 * 0.5D - this.motionX) * 0.6000000238418579D;
|
| 159 | this.motionZ += (d1 / d5 * 0.5D - this.motionZ) * 0.6000000238418579D;
|
| 160 | }
|
| 161 | }
|
| 162 | }
|
| 163 |
|
| 164 | if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D)
|
| 165 | {
|
| 166 | this.rotationYaw = (float)MathHelper.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F;
|
| 167 | }
|
| 168 |
|
| 169 | super.onLivingUpdate();
|
| 170 |
|
| 171 | for (int i = 0; i < 2; ++i)
|
| 172 | {
|
| 173 | this.field_82218_g[i] = this.field_82221_e[i];
|
| 174 | this.field_82217_f[i] = this.field_82220_d[i];
|
| 175 | }
|
| 176 |
|
| 177 | for (int j = 0; j < 2; ++j)
|
| 178 | {
|
| 179 | int k = this.getWatchedTargetId(j + 1);
|
| 180 | Entity entity1 = null;
|
| 181 |
|
| 182 | if (k > 0)
|
| 183 | {
|
| 184 | entity1 = this.worldObj.getEntityByID(k);
|
| 185 | }
|
| 186 |
|
| 187 | if (entity1 != null)
|
| 188 | {
|
| 189 | double d11 = this.func_82214_u(j + 1);
|
| 190 | double d12 = this.func_82208_v(j + 1);
|
| 191 | double d13 = this.func_82213_w(j + 1);
|
| 192 | double d6 = entity1.posX - d11;
|
| 193 | double d7 = entity1.posY + (double)entity1.getEyeHeight() - d12;
|
| 194 | double d8 = entity1.posZ - d13;
|
| 195 | double d9 = (double)MathHelper.sqrt_double(d6 * d6 + d8 * d8);
|
| 196 | float f = (float)(MathHelper.atan2(d8, d6) * 180.0D / Math.PI) - 90.0F;
|
| 197 | float f1 = (float)(-(MathHelper.atan2(d7, d9) * 180.0D / Math.PI));
|
| 198 | this.field_82220_d[j] = this.func_82204_b(this.field_82220_d[j], f1, 40.0F);
|
| 199 | this.field_82221_e[j] = this.func_82204_b(this.field_82221_e[j], f, 10.0F);
|
| 200 | }
|
| 201 | else
|
| 202 | {
|
| 203 | this.field_82221_e[j] = this.func_82204_b(this.field_82221_e[j], this.renderYawOffset, 10.0F);
|
| 204 | }
|
| 205 | }
|
| 206 |
|
| 207 | boolean flag = this.isArmored();
|
| 208 |
|
| 209 | for (int l = 0; l < 3; ++l)
|
| 210 | {
|
| 211 | double d10 = this.func_82214_u(l);
|
| 212 | double d2 = this.func_82208_v(l);
|
| 213 | double d4 = this.func_82213_w(l);
|
| 214 | this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d10 + this.rand.nextGaussian() * 0.30000001192092896D, d2 + this.rand.nextGaussian() * 0.30000001192092896D, d4 + this.rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D, new int[0]);
|
| 215 |
|
| 216 | if (flag && this.worldObj.rand.nextInt(4) == 0)
|
| 217 | {
|
| 218 | this.worldObj.spawnParticle(EnumParticleTypes.SPELL_MOB, d10 + this.rand.nextGaussian() * 0.30000001192092896D, d2 + this.rand.nextGaussian() * 0.30000001192092896D, d4 + this.rand.nextGaussian() * 0.30000001192092896D, 0.699999988079071D, 0.699999988079071D, 0.5D, new int[0]);
|
| 219 | }
|
| 220 | }
|
| 221 |
|
| 222 | if (this.getInvulTime() > 0)
|
| 223 | {
|
| 224 | for (int i1 = 0; i1 < 3; ++i1)
|
| 225 | {
|
| 226 | this.worldObj.spawnParticle(EnumParticleTypes.SPELL_MOB, this.posX + this.rand.nextGaussian() * 1.0D, this.posY + (double)(this.rand.nextFloat() * 3.3F), this.posZ + this.rand.nextGaussian() * 1.0D, 0.699999988079071D, 0.699999988079071D, 0.8999999761581421D, new int[0]);
|
| 227 | }
|
| 228 | }
|
| 229 | }
|
| 230 |
|
| 231 | protected void updateAITasks()
|
| 232 | {
|
| 233 | if (this.getInvulTime() > 0)
|
| 234 | {
|
| 235 | int j1 = this.getInvulTime() - 1;
|
| 236 |
|
| 237 | if (j1 <= 0)
|
| 238 | {
|
| 239 | this.worldObj.newExplosion(this, this.posX, this.posY + (double)this.getEyeHeight(), this.posZ, 7.0F, false, this.worldObj.getGameRules().getBoolean("mobGriefing"));
|
| 240 | this.worldObj.playBroadcastSound(1013, new BlockPos(this), 0);
|
| 241 | }
|
| 242 |
|
| 243 | this.setInvulTime(j1);
|
| 244 |
|
| 245 | if (this.ticksExisted % 10 == 0)
|
| 246 | {
|
| 247 | this.heal(10.0F);
|
| 248 | }
|
| 249 | }
|
| 250 | else
|
| 251 | {
|
| 252 | super.updateAITasks();
|
| 253 |
|
| 254 | for (int i = 1; i < 3; ++i)
|
| 255 | {
|
| 256 | if (this.ticksExisted >= this.field_82223_h[i - 1])
|
| 257 | {
|
| 258 | this.field_82223_h[i - 1] = this.ticksExisted + 10 + this.rand.nextInt(10);
|
| 259 |
|
| 260 | if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL || this.worldObj.getDifficulty() == EnumDifficulty.HARD)
|
| 261 | {
|
| 262 | int j3 = i - 1;
|
| 263 | int k3 = this.field_82224_i[i - 1];
|
| 264 | this.field_82224_i[j3] = this.field_82224_i[i - 1] + 1;
|
| 265 |
|
| 266 | if (k3 > 15)
|
| 267 | {
|
| 268 | float f = 10.0F;
|
| 269 | float f1 = 5.0F;
|
| 270 | double d0 = MathHelper.getRandomDoubleInRange(this.rand, this.posX - (double)f, this.posX + (double)f);
|
| 271 | double d1 = MathHelper.getRandomDoubleInRange(this.rand, this.posY - (double)f1, this.posY + (double)f1);
|
| 272 | double d2 = MathHelper.getRandomDoubleInRange(this.rand, this.posZ - (double)f, this.posZ + (double)f);
|
| 273 | this.launchWitherSkullToCoords(i + 1, d0, d1, d2, true);
|
| 274 | this.field_82224_i[i - 1] = 0;
|
| 275 | }
|
| 276 | }
|
| 277 |
|
| 278 | int k1 = this.getWatchedTargetId(i);
|
| 279 |
|
| 280 | if (k1 > 0)
|
| 281 | {
|
| 282 | Entity entity = this.worldObj.getEntityByID(k1);
|
| 283 |
|
| 284 | if (entity != null && entity.isEntityAlive() && this.getDistanceSqToEntity(entity) <= 900.0D && this.canEntityBeSeen(entity))
|
| 285 | {
|
| 286 | if (entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.disableDamage)
|
| 287 | {
|
| 288 | this.updateWatchedTargetId(i, 0);
|
| 289 | }
|
| 290 | else
|
| 291 | {
|
| 292 | this.launchWitherSkullToEntity(i + 1, (EntityLivingBase)entity);
|
| 293 | this.field_82223_h[i - 1] = this.ticksExisted + 40 + this.rand.nextInt(20);
|
| 294 | this.field_82224_i[i - 1] = 0;
|
| 295 | }
|
| 296 | }
|
| 297 | else
|
| 298 | {
|
| 299 | this.updateWatchedTargetId(i, 0);
|
| 300 | }
|
| 301 | }
|
| 302 | else
|
| 303 | {
|
| 304 | List<EntityLivingBase> list = this.worldObj.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expand(20.0D, 8.0D, 20.0D), Predicates.<EntityLivingBase> and (attackEntitySelector, EntitySelectors.NOT_SPECTATING));
|
| 305 |
|
| 306 | for (int j2 = 0; j2 < 10 && !list.isEmpty(); ++j2)
|
| 307 | {
|
| 308 | EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(this.rand.nextInt(list.size()));
|
| 309 |
|
| 310 | if (entitylivingbase != this && entitylivingbase.isEntityAlive() && this.canEntityBeSeen(entitylivingbase))
|
| 311 | {
|
| 312 | if (entitylivingbase instanceof EntityPlayer)
|
| 313 | {
|
| 314 | if (!((EntityPlayer)entitylivingbase).capabilities.disableDamage)
|
| 315 | {
|
| 316 | this.updateWatchedTargetId(i, entitylivingbase.getEntityId());
|
| 317 | }
|
| 318 | }
|
| 319 | else
|
| 320 | {
|
| 321 | this.updateWatchedTargetId(i, entitylivingbase.getEntityId());
|
| 322 | }
|
| 323 |
|
| 324 | break;
|
| 325 | }
|
| 326 |
|
| 327 | list.remove(entitylivingbase);
|
| 328 | }
|
| 329 | }
|
| 330 | }
|
| 331 | }
|
| 332 |
|
| 333 | if (this.getAttackTarget() != null)
|
| 334 | {
|
| 335 | this.updateWatchedTargetId(0, this.getAttackTarget().getEntityId());
|
| 336 | }
|
| 337 | else
|
| 338 | {
|
| 339 | this.updateWatchedTargetId(0, 0);
|
| 340 | }
|
| 341 |
|
| 342 | if (this.blockBreakCounter > 0)
|
| 343 | {
|
| 344 | --this.blockBreakCounter;
|
| 345 |
|
| 346 | if (this.blockBreakCounter == 0 && this.worldObj.getGameRules().getBoolean("mobGriefing"))
|
| 347 | {
|
| 348 | int i1 = MathHelper.floor_double(this.posY);
|
| 349 | int l1 = MathHelper.floor_double(this.posX);
|
| 350 | int i2 = MathHelper.floor_double(this.posZ);
|
| 351 | boolean flag = false;
|
| 352 |
|
| 353 | for (int k2 = -1; k2 <= 1; ++k2)
|
| 354 | {
|
| 355 | for (int l2 = -1; l2 <= 1; ++l2)
|
| 356 | {
|
| 357 | for (int j = 0; j <= 3; ++j)
|
| 358 | {
|
| 359 | int i3 = l1 + k2;
|
| 360 | int k = i1 + j;
|
| 361 | int l = i2 + l2;
|
| 362 | BlockPos blockpos = new BlockPos(i3, k, l);
|
| 363 | Block block = this.worldObj.getBlockState(blockpos).getBlock();
|
| 364 |
|
| 365 | if (block.getMaterial() != Material.air && canDestroyBlock(block))
|
| 366 | {
|
| 367 | flag = this.worldObj.destroyBlock(blockpos, true) || flag;
|
| 368 | }
|
| 369 | }
|
| 370 | }
|
| 371 | }
|
| 372 |
|
| 373 | if (flag)
|
| 374 | {
|
| 375 | this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1012, new BlockPos(this), 0);
|
| 376 | }
|
| 377 | }
|
| 378 | }
|
| 379 |
|
| 380 | if (this.ticksExisted % 20 == 0)
|
| 381 | {
|
| 382 | this.heal(1.0F);
|
| 383 | }
|
| 384 | }
|
| 385 | }
|
| 386 |
|
| 387 | public static boolean canDestroyBlock(Block p_181033_0_)
|
| 388 | {
|
| 389 | return p_181033_0_ != Blocks.bedrock && p_181033_0_ != Blocks.end_portal && p_181033_0_ != Blocks.end_portal_frame && p_181033_0_ != Blocks.command_block && p_181033_0_ != Blocks.barrier;
|
| 390 | }
|
| 391 |
|
| 392 | public void func_82206_m()
|
| 393 | {
|
| 394 | this.setInvulTime(220);
|
| 395 | this.setHealth(this.getMaxHealth() / 3.0F);
|
| 396 | }
|
| 397 |
|
| 398 | /**
|
| 399 | * Sets the Entity inside a web block.
|
| 400 | */
|
| 401 | public void setInWeb()
|
| 402 | {
|
| 403 | }
|
| 404 |
|
| 405 | /**
|
| 406 | * Returns the current armor value as determined by a call to InventoryPlayer.getTotalArmorValue
|
| 407 | */
|
| 408 | public int getTotalArmorValue()
|
| 409 | {
|
| 410 | return 4;
|
| 411 | }
|
| 412 |
|
| 413 | private double func_82214_u(int p_82214_1_)
|
| 414 | {
|
| 415 | if (p_82214_1_ <= 0)
|
| 416 | {
|
| 417 | return this.posX;
|
| 418 | }
|
| 419 | else
|
| 420 | {
|
| 421 | float f = (this.renderYawOffset + (float)(180 * (p_82214_1_ - 1))) / 180.0F * (float)Math.PI;
|
| 422 | float f1 = MathHelper.cos(f);
|
| 423 | return this.posX + (double)f1 * 1.3D;
|
| 424 | }
|
| 425 | }
|
| 426 |
|
| 427 | private double func_82208_v(int p_82208_1_)
|
| 428 | {
|
| 429 | return p_82208_1_ <= 0 ? this.posY + 3.0D : this.posY + 2.2D;
|
| 430 | }
|
| 431 |
|
| 432 | private double func_82213_w(int p_82213_1_)
|
| 433 | {
|
| 434 | if (p_82213_1_ <= 0)
|
| 435 | {
|
| 436 | return this.posZ;
|
| 437 | }
|
| 438 | else
|
| 439 | {
|
| 440 | float f = (this.renderYawOffset + (float)(180 * (p_82213_1_ - 1))) / 180.0F * (float)Math.PI;
|
| 441 | float f1 = MathHelper.sin(f);
|
| 442 | return this.posZ + (double)f1 * 1.3D;
|
| 443 | }
|
| 444 | }
|
| 445 |
|
| 446 | private float func_82204_b(float p_82204_1_, float p_82204_2_, float p_82204_3_)
|
| 447 | {
|
| 448 | float f = MathHelper.wrapAngleTo180_float(p_82204_2_ - p_82204_1_);
|
| 449 |
|
| 450 | if (f > p_82204_3_)
|
| 451 | {
|
| 452 | f = p_82204_3_;
|
| 453 | }
|
| 454 |
|
| 455 | if (f < -p_82204_3_)
|
| 456 | {
|
| 457 | f = -p_82204_3_;
|
| 458 | }
|
| 459 |
|
| 460 | return p_82204_1_ + f;
|
| 461 | }
|
| 462 |
|
| 463 | private void launchWitherSkullToEntity(int p_82216_1_, EntityLivingBase p_82216_2_)
|
| 464 | {
|
| 465 | this.launchWitherSkullToCoords(p_82216_1_, p_82216_2_.posX, p_82216_2_.posY + (double)p_82216_2_.getEyeHeight() * 0.5D, p_82216_2_.posZ, p_82216_1_ == 0 && this.rand.nextFloat() < 0.001F);
|
| 466 | }
|
| 467 |
|
| 468 | /**
|
| 469 | * Launches a Wither skull toward (par2, par4, par6)
|
| 470 | */
|
| 471 | private void launchWitherSkullToCoords(int p_82209_1_, double x, double y, double z, boolean invulnerable)
|
| 472 | {
|
| 473 | this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1014, new BlockPos(this), 0);
|
| 474 | double d0 = this.func_82214_u(p_82209_1_);
|
| 475 | double d1 = this.func_82208_v(p_82209_1_);
|
| 476 | double d2 = this.func_82213_w(p_82209_1_);
|
| 477 | double d3 = x - d0;
|
| 478 | double d4 = y - d1;
|
| 479 | double d5 = z - d2;
|
| 480 | EntityWitherSkull entitywitherskull = new EntityWitherSkull(this.worldObj, this, d3, d4, d5);
|
| 481 |
|
| 482 | if (invulnerable)
|
| 483 | {
|
| 484 | entitywitherskull.setInvulnerable(true);
|
| 485 | }
|
| 486 |
|
| 487 | entitywitherskull.posY = d1;
|
| 488 | entitywitherskull.posX = d0;
|
| 489 | entitywitherskull.posZ = d2;
|
| 490 | this.worldObj.spawnEntityInWorld(entitywitherskull);
|
| 491 | }
|
| 492 |
|
| 493 | /**
|
| 494 | * Attack the specified entity using a ranged attack.
|
| 495 | */
|
| 496 | public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_)
|
| 497 | {
|
| 498 | this.launchWitherSkullToEntity(0, target);
|
| 499 | }
|
| 500 |
|
| 501 | /**
|
| 502 | * Called when the entity is attacked.
|
| 503 | */
|
| 504 | public boolean attackEntityFrom(DamageSource source, float amount)
|
| 505 | {
|
| 506 | if (this.isEntityInvulnerable(source))
|
| 507 | {
|
| 508 | return false;
|
| 509 | }
|
| 510 | else if (source != DamageSource.drown && !(source.getEntity() instanceof EntityWither))
|
| 511 | {
|
| 512 | if (this.getInvulTime() > 0 && source != DamageSource.outOfWorld)
|
| 513 | {
|
| 514 | return false;
|
| 515 | }
|
| 516 | else
|
| 517 | {
|
| 518 | if (this.isArmored())
|
| 519 | {
|
| 520 | Entity entity = source.getSourceOfDamage();
|
| 521 |
|
| 522 | if (entity instanceof EntityArrow)
|
| 523 | {
|
| 524 | return false;
|
| 525 | }
|
| 526 | }
|
| 527 |
|
| 528 | Entity entity1 = source.getEntity();
|
| 529 |
|
| 530 | if (entity1 != null && !(entity1 instanceof EntityPlayer) && entity1 instanceof EntityLivingBase && ((EntityLivingBase)entity1).getCreatureAttribute() == this.getCreatureAttribute())
|
| 531 | {
|
| 532 | return false;
|
| 533 | }
|
| 534 | else
|
| 535 | {
|
| 536 | if (this.blockBreakCounter <= 0)
|
| 537 | {
|
| 538 | this.blockBreakCounter = 20;
|
| 539 | }
|
| 540 |
|
| 541 | for (int i = 0; i < this.field_82224_i.length; ++i)
|
| 542 | {
|
| 543 | this.field_82224_i[i] += 3;
|
| 544 | }
|
| 545 |
|
| 546 | return super.attackEntityFrom(source, amount);
|
| 547 | }
|
| 548 | }
|
| 549 | }
|
| 550 | else
|
| 551 | {
|
| 552 | return false;
|
| 553 | }
|
| 554 | }
|
| 555 |
|
| 556 | /**
|
| 557 | * Drop 0-2 items of this living's type
|
| 558 | *
|
| 559 | * @param wasRecentlyHit true if this this entity was recently hit by appropriate entity (generally only if player
|
| 560 | * or tameable)
|
| 561 | * @param lootingModifier level of enchanment to be applied to this drop
|
| 562 | */
|
| 563 | protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier)
|
| 564 | {
|
| 565 | EntityItem entityitem = this.dropItem(Items.nether_star, 1);
|
| 566 |
|
| 567 | if (entityitem != null)
|
| 568 | {
|
| 569 | entityitem.setNoDespawn();
|
| 570 | }
|
| 571 |
|
| 572 | if (!this.worldObj.isRemote)
|
| 573 | {
|
| 574 | for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
|
| 575 | {
|
| 576 | entityplayer.triggerAchievement(AchievementList.killWither);
|
| 577 | }
|
| 578 | }
|
| 579 | }
|
| 580 |
|
| 581 | /**
|
| 582 | * Makes the entity despawn if requirements are reached
|
| 583 | */
|
| 584 | protected void despawnEntity()
|
| 585 | {
|
| 586 | this.entityAge = 0;
|
| 587 | }
|
| 588 |
|
| 589 | public int getBrightnessForRender(float partialTicks)
|
| 590 | {
|
| 591 | return 15728880;
|
| 592 | }
|
| 593 |
|
| 594 | public void fall(float distance, float damageMultiplier)
|
| 595 | {
|
| 596 | }
|
| 597 |
|
| 598 | /**
|
| 599 | * adds a PotionEffect to the entity
|
| 600 | */
|
| 601 | public void addPotionEffect(PotionEffect potioneffectIn)
|
| 602 | {
|
| 603 | }
|
| 604 |
|
| 605 | protected void applyEntityAttributes()
|
| 606 | {
|
| 607 | super.applyEntityAttributes();
|
| 608 | this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D);
|
| 609 | this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6000000238418579D);
|
| 610 | this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
|
| 611 | }
|
| 612 |
|
| 613 | public float func_82207_a(int p_82207_1_)
|
| 614 | {
|
| 615 | return this.field_82221_e[p_82207_1_];
|
| 616 | }
|
| 617 |
|
| 618 | public float func_82210_r(int p_82210_1_)
|
| 619 | {
|
| 620 | return this.field_82220_d[p_82210_1_];
|
| 621 | }
|
| 622 |
|
| 623 | public int getInvulTime()
|
| 624 | {
|
| 625 | return this.dataWatcher.getWatchableObjectInt(20);
|
| 626 | }
|
| 627 |
|
| 628 | public void setInvulTime(int p_82215_1_)
|
| 629 | {
|
| 630 | this.dataWatcher.updateObject(20, Integer.valueOf(p_82215_1_));
|
| 631 | }
|
| 632 |
|
| 633 | /**
|
| 634 | * Returns the target entity ID if present, or -1 if not @param par1 The target offset, should be from 0-2
|
| 635 | */
|
| 636 | public int getWatchedTargetId(int p_82203_1_)
|
| 637 | {
|
| 638 | return this.dataWatcher.getWatchableObjectInt(17 + p_82203_1_);
|
| 639 | }
|
| 640 |
|
| 641 | /**
|
| 642 | * Updates the target entity ID
|
| 643 | */
|
| 644 | public void updateWatchedTargetId(int targetOffset, int newId)
|
| 645 | {
|
| 646 | this.dataWatcher.updateObject(17 + targetOffset, Integer.valueOf(newId));
|
| 647 | }
|
| 648 |
|
| 649 | /**
|
| 650 | * Returns whether the wither is armored with its boss armor or not by checking whether its health is below half of
|
| 651 | * its maximum.
|
| 652 | */
|
| 653 | public boolean isArmored()
|
| 654 | {
|
| 655 | return this.getHealth() <= this.getMaxHealth() / 2.0F;
|
| 656 | }
|
| 657 |
|
| 658 | /**
|
| 659 | * Get this Entity's EnumCreatureAttribute
|
| 660 | */
|
| 661 | public EnumCreatureAttribute getCreatureAttribute()
|
| 662 | {
|
| 663 | return EnumCreatureAttribute.UNDEAD;
|
| 664 | }
|
| 665 |
|
| 666 | /**
|
| 667 | * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
|
| 668 | */
|
| 669 | public void mountEntity(Entity entityIn)
|
| 670 | {
|
| 671 | this.ridingEntity = null;
|
| 672 | }
|
| 673 | }
|
| 674 |
|