| 1 | package net.minecraft.entity.passive;
|
| 2 |
|
| 3 | import com.google.common.base.Predicate;
|
| 4 | import net.minecraft.block.Block;
|
| 5 | import net.minecraft.entity.Entity;
|
| 6 | import net.minecraft.entity.EntityAgeable;
|
| 7 | import net.minecraft.entity.EntityLivingBase;
|
| 8 | import net.minecraft.entity.SharedMonsterAttributes;
|
| 9 | import net.minecraft.entity.ai.EntityAIAttackOnCollide;
|
| 10 | import net.minecraft.entity.ai.EntityAIBeg;
|
| 11 | import net.minecraft.entity.ai.EntityAIFollowOwner;
|
| 12 | import net.minecraft.entity.ai.EntityAIHurtByTarget;
|
| 13 | import net.minecraft.entity.ai.EntityAILeapAtTarget;
|
| 14 | import net.minecraft.entity.ai.EntityAILookIdle;
|
| 15 | import net.minecraft.entity.ai.EntityAIMate;
|
| 16 | import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
| 17 | import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
|
| 18 | import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
|
| 19 | import net.minecraft.entity.ai.EntityAISwimming;
|
| 20 | import net.minecraft.entity.ai.EntityAITargetNonTamed;
|
| 21 | import net.minecraft.entity.ai.EntityAIWander;
|
| 22 | import net.minecraft.entity.ai.EntityAIWatchClosest;
|
| 23 | import net.minecraft.entity.monster.EntityCreeper;
|
| 24 | import net.minecraft.entity.monster.EntityGhast;
|
| 25 | import net.minecraft.entity.monster.EntitySkeleton;
|
| 26 | import net.minecraft.entity.player.EntityPlayer;
|
| 27 | import net.minecraft.entity.projectile.EntityArrow;
|
| 28 | import net.minecraft.init.Items;
|
| 29 | import net.minecraft.item.EnumDyeColor;
|
| 30 | import net.minecraft.item.Item;
|
| 31 | import net.minecraft.item.ItemFood;
|
| 32 | import net.minecraft.item.ItemStack;
|
| 33 | import net.minecraft.nbt.NBTTagCompound;
|
| 34 | import net.minecraft.pathfinding.PathNavigateGround;
|
| 35 | import net.minecraft.util.BlockPos;
|
| 36 | import net.minecraft.util.DamageSource;
|
| 37 | import net.minecraft.util.EnumParticleTypes;
|
| 38 | import net.minecraft.util.MathHelper;
|
| 39 | import net.minecraft.world.World;
|
| 40 |
|
| 41 | public class EntityWolf extends EntityTameable
|
| 42 | {
|
| 43 | /** Float used to smooth the rotation of the wolf head */
|
| 44 | private float headRotationCourse;
|
| 45 | private float headRotationCourseOld;
|
| 46 |
|
| 47 | /** true is the wolf is wet else false */
|
| 48 | private boolean isWet;
|
| 49 |
|
| 50 | /** True if the wolf is shaking else False */
|
| 51 | private boolean isShaking;
|
| 52 |
|
| 53 | /**
|
| 54 | * This time increases while wolf is shaking and emitting water particles.
|
| 55 | */
|
| 56 | private float timeWolfIsShaking;
|
| 57 | private float prevTimeWolfIsShaking;
|
| 58 |
|
| 59 | public EntityWolf(World worldIn)
|
| 60 | {
|
| 61 | super(worldIn);
|
| 62 | this.setSize(0.6F, 0.8F);
|
| 63 | ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
|
| 64 | this.tasks.addTask(1, new EntityAISwimming(this));
|
| 65 | this.tasks.addTask(2, this.aiSit);
|
| 66 | this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
|
| 67 | this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
|
| 68 | this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
|
| 69 | this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
|
| 70 | this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
|
| 71 | this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
|
| 72 | this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
| 73 | this.tasks.addTask(9, new EntityAILookIdle(this));
|
| 74 | this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
|
| 75 | this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
|
| 76 | this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0]));
|
| 77 | this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityAnimal.class, false, new Predicate<Entity>()
|
| 78 | {
|
| 79 | public boolean apply(Entity p_apply_1_)
|
| 80 | {
|
| 81 | return p_apply_1_ instanceof EntitySheep || p_apply_1_ instanceof EntityRabbit;
|
| 82 | }
|
| 83 | }));
|
| 84 | this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, false));
|
| 85 | this.setTamed(false);
|
| 86 | }
|
| 87 |
|
| 88 | protected void applyEntityAttributes()
|
| 89 | {
|
| 90 | super.applyEntityAttributes();
|
| 91 | this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
|
| 92 |
|
| 93 | if (this.isTamed())
|
| 94 | {
|
| 95 | this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
|
| 96 | }
|
| 97 | else
|
| 98 | {
|
| 99 | this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
|
| 100 | }
|
| 101 |
|
| 102 | this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
|
| 103 | this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D);
|
| 104 | }
|
| 105 |
|
| 106 | /**
|
| 107 | * Sets the active target the Task system uses for tracking
|
| 108 | */
|
| 109 | public void setAttackTarget(EntityLivingBase entitylivingbaseIn)
|
| 110 | {
|
| 111 | super.setAttackTarget(entitylivingbaseIn);
|
| 112 |
|
| 113 | if (entitylivingbaseIn == null)
|
| 114 | {
|
| 115 | this.setAngry(false);
|
| 116 | }
|
| 117 | else if (!this.isTamed())
|
| 118 | {
|
| 119 | this.setAngry(true);
|
| 120 | }
|
| 121 | }
|
| 122 |
|
| 123 | protected void updateAITasks()
|
| 124 | {
|
| 125 | this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
|
| 126 | }
|
| 127 |
|
| 128 | protected void entityInit()
|
| 129 | {
|
| 130 | super.entityInit();
|
| 131 | this.dataWatcher.addObject(18, new Float(this.getHealth()));
|
| 132 | this.dataWatcher.addObject(19, new Byte((byte)0));
|
| 133 | this.dataWatcher.addObject(20, new Byte((byte)EnumDyeColor.RED.getMetadata()));
|
| 134 | }
|
| 135 |
|
| 136 | protected void playStepSound(BlockPos pos, Block blockIn)
|
| 137 | {
|
| 138 | this.playSound("mob.wolf.step", 0.15F, 1.0F);
|
| 139 | }
|
| 140 |
|
| 141 | /**
|
| 142 | * (abstract) Protected helper method to write subclass entity data to NBT.
|
| 143 | */
|
| 144 | public void writeEntityToNBT(NBTTagCompound tagCompound)
|
| 145 | {
|
| 146 | super.writeEntityToNBT(tagCompound);
|
| 147 | tagCompound.setBoolean("Angry", this.isAngry());
|
| 148 | tagCompound.setByte("CollarColor", (byte)this.getCollarColor().getDyeDamage());
|
| 149 | }
|
| 150 |
|
| 151 | /**
|
| 152 | * (abstract) Protected helper method to read subclass entity data from NBT.
|
| 153 | */
|
| 154 | public void readEntityFromNBT(NBTTagCompound tagCompund)
|
| 155 | {
|
| 156 | super.readEntityFromNBT(tagCompund);
|
| 157 | this.setAngry(tagCompund.getBoolean("Angry"));
|
| 158 |
|
| 159 | if (tagCompund.hasKey("CollarColor", 99))
|
| 160 | {
|
| 161 | this.setCollarColor(EnumDyeColor.byDyeDamage(tagCompund.getByte("CollarColor")));
|
| 162 | }
|
| 163 | }
|
| 164 |
|
| 165 | /**
|
| 166 | * Returns the sound this mob makes while it's alive.
|
| 167 | */
|
| 168 | protected String getLivingSound()
|
| 169 | {
|
| 170 | return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
|
| 171 | }
|
| 172 |
|
| 173 | /**
|
| 174 | * Returns the sound this mob makes when it is hurt.
|
| 175 | */
|
| 176 | protected String getHurtSound()
|
| 177 | {
|
| 178 | return "mob.wolf.hurt";
|
| 179 | }
|
| 180 |
|
| 181 | /**
|
| 182 | * Returns the sound this mob makes on death.
|
| 183 | */
|
| 184 | protected String getDeathSound()
|
| 185 | {
|
| 186 | return "mob.wolf.death";
|
| 187 | }
|
| 188 |
|
| 189 | /**
|
| 190 | * Returns the volume for the sounds this mob makes.
|
| 191 | */
|
| 192 | protected float getSoundVolume()
|
| 193 | {
|
| 194 | return 0.4F;
|
| 195 | }
|
| 196 |
|
| 197 | protected Item getDropItem()
|
| 198 | {
|
| 199 | return Item.getItemById(-1);
|
| 200 | }
|
| 201 |
|
| 202 | /**
|
| 203 | * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
|
| 204 | * use this to react to sunlight and start to burn.
|
| 205 | */
|
| 206 | public void onLivingUpdate()
|
| 207 | {
|
| 208 | super.onLivingUpdate();
|
| 209 |
|
| 210 | if (!this.worldObj.isRemote && this.isWet && !this.isShaking && !this.hasPath() && this.onGround)
|
| 211 | {
|
| 212 | this.isShaking = true;
|
| 213 | this.timeWolfIsShaking = 0.0F;
|
| 214 | this.prevTimeWolfIsShaking = 0.0F;
|
| 215 | this.worldObj.setEntityState(this, (byte)8);
|
| 216 | }
|
| 217 |
|
| 218 | if (!this.worldObj.isRemote && this.getAttackTarget() == null && this.isAngry())
|
| 219 | {
|
| 220 | this.setAngry(false);
|
| 221 | }
|
| 222 | }
|
| 223 |
|
| 224 | /**
|
| 225 | * Called to update the entity's position/logic.
|
| 226 | */
|
| 227 | public void onUpdate()
|
| 228 | {
|
| 229 | super.onUpdate();
|
| 230 | this.headRotationCourseOld = this.headRotationCourse;
|
| 231 |
|
| 232 | if (this.isBegging())
|
| 233 | {
|
| 234 | this.headRotationCourse += (1.0F - this.headRotationCourse) * 0.4F;
|
| 235 | }
|
| 236 | else
|
| 237 | {
|
| 238 | this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F;
|
| 239 | }
|
| 240 |
|
| 241 | if (this.isWet())
|
| 242 | {
|
| 243 | this.isWet = true;
|
| 244 | this.isShaking = false;
|
| 245 | this.timeWolfIsShaking = 0.0F;
|
| 246 | this.prevTimeWolfIsShaking = 0.0F;
|
| 247 | }
|
| 248 | else if ((this.isWet || this.isShaking) && this.isShaking)
|
| 249 | {
|
| 250 | if (this.timeWolfIsShaking == 0.0F)
|
| 251 | {
|
| 252 | this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
|
| 253 | }
|
| 254 |
|
| 255 | this.prevTimeWolfIsShaking = this.timeWolfIsShaking;
|
| 256 | this.timeWolfIsShaking += 0.05F;
|
| 257 |
|
| 258 | if (this.prevTimeWolfIsShaking >= 2.0F)
|
| 259 | {
|
| 260 | this.isWet = false;
|
| 261 | this.isShaking = false;
|
| 262 | this.prevTimeWolfIsShaking = 0.0F;
|
| 263 | this.timeWolfIsShaking = 0.0F;
|
| 264 | }
|
| 265 |
|
| 266 | if (this.timeWolfIsShaking > 0.4F)
|
| 267 | {
|
| 268 | float f = (float)this.getEntityBoundingBox().minY;
|
| 269 | int i = (int)(MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float)Math.PI) * 7.0F);
|
| 270 |
|
| 271 | for (int j = 0; j < i; ++j)
|
| 272 | {
|
| 273 | float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
|
| 274 | float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
|
| 275 | this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ, new int[0]);
|
| 276 | }
|
| 277 | }
|
| 278 | }
|
| 279 | }
|
| 280 |
|
| 281 | /**
|
| 282 | * True if the wolf is wet
|
| 283 | */
|
| 284 | public boolean isWolfWet()
|
| 285 | {
|
| 286 | return this.isWet;
|
| 287 | }
|
| 288 |
|
| 289 | /**
|
| 290 | * Used when calculating the amount of shading to apply while the wolf is wet.
|
| 291 | */
|
| 292 | public float getShadingWhileWet(float p_70915_1_)
|
| 293 | {
|
| 294 | return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F;
|
| 295 | }
|
| 296 |
|
| 297 | public float getShakeAngle(float p_70923_1_, float p_70923_2_)
|
| 298 | {
|
| 299 | float f = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F;
|
| 300 |
|
| 301 | if (f < 0.0F)
|
| 302 | {
|
| 303 | f = 0.0F;
|
| 304 | }
|
| 305 | else if (f > 1.0F)
|
| 306 | {
|
| 307 | f = 1.0F;
|
| 308 | }
|
| 309 |
|
| 310 | return MathHelper.sin(f * (float)Math.PI) * MathHelper.sin(f * (float)Math.PI * 11.0F) * 0.15F * (float)Math.PI;
|
| 311 | }
|
| 312 |
|
| 313 | public float getInterestedAngle(float p_70917_1_)
|
| 314 | {
|
| 315 | return (this.headRotationCourseOld + (this.headRotationCourse - this.headRotationCourseOld) * p_70917_1_) * 0.15F * (float)Math.PI;
|
| 316 | }
|
| 317 |
|
| 318 | public float getEyeHeight()
|
| 319 | {
|
| 320 | return this.height * 0.8F;
|
| 321 | }
|
| 322 |
|
| 323 | /**
|
| 324 | * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
|
| 325 | * use in wolves.
|
| 326 | */
|
| 327 | public int getVerticalFaceSpeed()
|
| 328 | {
|
| 329 | return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
|
| 330 | }
|
| 331 |
|
| 332 | /**
|
| 333 | * Called when the entity is attacked.
|
| 334 | */
|
| 335 | public boolean attackEntityFrom(DamageSource source, float amount)
|
| 336 | {
|
| 337 | if (this.isEntityInvulnerable(source))
|
| 338 | {
|
| 339 | return false;
|
| 340 | }
|
| 341 | else
|
| 342 | {
|
| 343 | Entity entity = source.getEntity();
|
| 344 | this.aiSit.setSitting(false);
|
| 345 |
|
| 346 | if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
|
| 347 | {
|
| 348 | amount = (amount + 1.0F) / 2.0F;
|
| 349 | }
|
| 350 |
|
| 351 | return super.attackEntityFrom(source, amount);
|
| 352 | }
|
| 353 | }
|
| 354 |
|
| 355 | public boolean attackEntityAsMob(Entity entityIn)
|
| 356 | {
|
| 357 | boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue()));
|
| 358 |
|
| 359 | if (flag)
|
| 360 | {
|
| 361 | this.applyEnchantments(this, entityIn);
|
| 362 | }
|
| 363 |
|
| 364 | return flag;
|
| 365 | }
|
| 366 |
|
| 367 | public void setTamed(boolean tamed)
|
| 368 | {
|
| 369 | super.setTamed(tamed);
|
| 370 |
|
| 371 | if (tamed)
|
| 372 | {
|
| 373 | this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
|
| 374 | }
|
| 375 | else
|
| 376 | {
|
| 377 | this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
|
| 378 | }
|
| 379 |
|
| 380 | this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
|
| 381 | }
|
| 382 |
|
| 383 | /**
|
| 384 | * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
|
| 385 | */
|
| 386 | public boolean interact(EntityPlayer player)
|
| 387 | {
|
| 388 | ItemStack itemstack = player.inventory.getCurrentItem();
|
| 389 |
|
| 390 | if (this.isTamed())
|
| 391 | {
|
| 392 | if (itemstack != null)
|
| 393 | {
|
| 394 | if (itemstack.getItem() instanceof ItemFood)
|
| 395 | {
|
| 396 | ItemFood itemfood = (ItemFood)itemstack.getItem();
|
| 397 |
|
| 398 | if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F)
|
| 399 | {
|
| 400 | if (!player.capabilities.isCreativeMode)
|
| 401 | {
|
| 402 | --itemstack.stackSize;
|
| 403 | }
|
| 404 |
|
| 405 | this.heal((float)itemfood.getHealAmount(itemstack));
|
| 406 |
|
| 407 | if (itemstack.stackSize <= 0)
|
| 408 | {
|
| 409 | player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
| 410 | }
|
| 411 |
|
| 412 | return true;
|
| 413 | }
|
| 414 | }
|
| 415 | else if (itemstack.getItem() == Items.dye)
|
| 416 | {
|
| 417 | EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(itemstack.getMetadata());
|
| 418 |
|
| 419 | if (enumdyecolor != this.getCollarColor())
|
| 420 | {
|
| 421 | this.setCollarColor(enumdyecolor);
|
| 422 |
|
| 423 | if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
|
| 424 | {
|
| 425 | player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
| 426 | }
|
| 427 |
|
| 428 | return true;
|
| 429 | }
|
| 430 | }
|
| 431 | }
|
| 432 |
|
| 433 | if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
|
| 434 | {
|
| 435 | this.aiSit.setSitting(!this.isSitting());
|
| 436 | this.isJumping = false;
|
| 437 | this.navigator.clearPathEntity();
|
| 438 | this.setAttackTarget((EntityLivingBase)null);
|
| 439 | }
|
| 440 | }
|
| 441 | else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry())
|
| 442 | {
|
| 443 | if (!player.capabilities.isCreativeMode)
|
| 444 | {
|
| 445 | --itemstack.stackSize;
|
| 446 | }
|
| 447 |
|
| 448 | if (itemstack.stackSize <= 0)
|
| 449 | {
|
| 450 | player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
|
| 451 | }
|
| 452 |
|
| 453 | if (!this.worldObj.isRemote)
|
| 454 | {
|
| 455 | if (this.rand.nextInt(3) == 0)
|
| 456 | {
|
| 457 | this.setTamed(true);
|
| 458 | this.navigator.clearPathEntity();
|
| 459 | this.setAttackTarget((EntityLivingBase)null);
|
| 460 | this.aiSit.setSitting(true);
|
| 461 | this.setHealth(20.0F);
|
| 462 | this.setOwnerId(player.getUniqueID().toString());
|
| 463 | this.playTameEffect(true);
|
| 464 | this.worldObj.setEntityState(this, (byte)7);
|
| 465 | }
|
| 466 | else
|
| 467 | {
|
| 468 | this.playTameEffect(false);
|
| 469 | this.worldObj.setEntityState(this, (byte)6);
|
| 470 | }
|
| 471 | }
|
| 472 |
|
| 473 | return true;
|
| 474 | }
|
| 475 |
|
| 476 | return super.interact(player);
|
| 477 | }
|
| 478 |
|
| 479 | public void handleStatusUpdate(byte id)
|
| 480 | {
|
| 481 | if (id == 8)
|
| 482 | {
|
| 483 | this.isShaking = true;
|
| 484 | this.timeWolfIsShaking = 0.0F;
|
| 485 | this.prevTimeWolfIsShaking = 0.0F;
|
| 486 | }
|
| 487 | else
|
| 488 | {
|
| 489 | super.handleStatusUpdate(id);
|
| 490 | }
|
| 491 | }
|
| 492 |
|
| 493 | public float getTailRotation()
|
| 494 | {
|
| 495 | return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float)Math.PI : ((float)Math.PI / 5F));
|
| 496 | }
|
| 497 |
|
| 498 | /**
|
| 499 | * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
|
| 500 | * the animal type)
|
| 501 | */
|
| 502 | public boolean isBreedingItem(ItemStack stack)
|
| 503 | {
|
| 504 | return stack == null ? false : (!(stack.getItem() instanceof ItemFood) ? false : ((ItemFood)stack.getItem()).isWolfsFavoriteMeat());
|
| 505 | }
|
| 506 |
|
| 507 | /**
|
| 508 | * Will return how many at most can spawn in a chunk at once.
|
| 509 | */
|
| 510 | public int getMaxSpawnedInChunk()
|
| 511 | {
|
| 512 | return 8;
|
| 513 | }
|
| 514 |
|
| 515 | /**
|
| 516 | * Determines whether this wolf is angry or not.
|
| 517 | */
|
| 518 | public boolean isAngry()
|
| 519 | {
|
| 520 | return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
|
| 521 | }
|
| 522 |
|
| 523 | /**
|
| 524 | * Sets whether this wolf is angry or not.
|
| 525 | */
|
| 526 | public void setAngry(boolean angry)
|
| 527 | {
|
| 528 | byte b0 = this.dataWatcher.getWatchableObjectByte(16);
|
| 529 |
|
| 530 | if (angry)
|
| 531 | {
|
| 532 | this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
|
| 533 | }
|
| 534 | else
|
| 535 | {
|
| 536 | this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
|
| 537 | }
|
| 538 | }
|
| 539 |
|
| 540 | public EnumDyeColor getCollarColor()
|
| 541 | {
|
| 542 | return EnumDyeColor.byDyeDamage(this.dataWatcher.getWatchableObjectByte(20) & 15);
|
| 543 | }
|
| 544 |
|
| 545 | public void setCollarColor(EnumDyeColor collarcolor)
|
| 546 | {
|
| 547 | this.dataWatcher.updateObject(20, Byte.valueOf((byte)(collarcolor.getDyeDamage() & 15)));
|
| 548 | }
|
| 549 |
|
| 550 | public EntityWolf createChild(EntityAgeable ageable)
|
| 551 | {
|
| 552 | EntityWolf entitywolf = new EntityWolf(this.worldObj);
|
| 553 | String s = this.getOwnerId();
|
| 554 |
|
| 555 | if (s != null && s.trim().length() > 0)
|
| 556 | {
|
| 557 | entitywolf.setOwnerId(s);
|
| 558 | entitywolf.setTamed(true);
|
| 559 | }
|
| 560 |
|
| 561 | return entitywolf;
|
| 562 | }
|
| 563 |
|
| 564 | public void setBegging(boolean beg)
|
| 565 | {
|
| 566 | if (beg)
|
| 567 | {
|
| 568 | this.dataWatcher.updateObject(19, Byte.valueOf((byte)1));
|
| 569 | }
|
| 570 | else
|
| 571 | {
|
| 572 | this.dataWatcher.updateObject(19, Byte.valueOf((byte)0));
|
| 573 | }
|
| 574 | }
|
| 575 |
|
| 576 | /**
|
| 577 | * Returns true if the mob is currently able to mate with the specified mob.
|
| 578 | */
|
| 579 | public boolean canMateWith(EntityAnimal otherAnimal)
|
| 580 | {
|
| 581 | if (otherAnimal == this)
|
| 582 | {
|
| 583 | return false;
|
| 584 | }
|
| 585 | else if (!this.isTamed())
|
| 586 | {
|
| 587 | return false;
|
| 588 | }
|
| 589 | else if (!(otherAnimal instanceof EntityWolf))
|
| 590 | {
|
| 591 | return false;
|
| 592 | }
|
| 593 | else
|
| 594 | {
|
| 595 | EntityWolf entitywolf = (EntityWolf)otherAnimal;
|
| 596 | return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove());
|
| 597 | }
|
| 598 | }
|
| 599 |
|
| 600 | public boolean isBegging()
|
| 601 | {
|
| 602 | return this.dataWatcher.getWatchableObjectByte(19) == 1;
|
| 603 | }
|
| 604 |
|
| 605 | /**
|
| 606 | * Determines if an entity can be despawned, used on idle far away entities
|
| 607 | */
|
| 608 | protected boolean canDespawn()
|
| 609 | {
|
| 610 | return !this.isTamed() && this.ticksExisted > 2400;
|
| 611 | }
|
| 612 |
|
| 613 | public boolean shouldAttackEntity(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_)
|
| 614 | {
|
| 615 | if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast))
|
| 616 | {
|
| 617 | if (p_142018_1_ instanceof EntityWolf)
|
| 618 | {
|
| 619 | EntityWolf entitywolf = (EntityWolf)p_142018_1_;
|
| 620 |
|
| 621 | if (entitywolf.isTamed() && entitywolf.getOwner() == p_142018_2_)
|
| 622 | {
|
| 623 | return false;
|
| 624 | }
|
| 625 | }
|
| 626 |
|
| 627 | return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer && !((EntityPlayer)p_142018_2_).canAttackPlayer((EntityPlayer)p_142018_1_) ? false : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse)p_142018_1_).isTame();
|
| 628 | }
|
| 629 | else
|
| 630 | {
|
| 631 | return false;
|
| 632 | }
|
| 633 | }
|
| 634 |
|
| 635 | public boolean allowLeashing()
|
| 636 | {
|
| 637 | return !this.isAngry() && super.allowLeashing();
|
| 638 | }
|
| 639 | }
|
| 640 |
|