| 1 | package net.minecraft.entity.player;
|
| 2 |
|
| 3 | import java.util.Collection;
|
| 4 | import java.util.Iterator;
|
| 5 | import java.util.List;
|
| 6 | import java.util.UUID;
|
| 7 |
|
| 8 | import com.google.common.base.Charsets;
|
| 9 | import com.google.common.collect.Lists;
|
| 10 | import com.mojang.authlib.GameProfile;
|
| 11 |
|
| 12 | import info.sigmaclient.Client;
|
| 13 | import info.sigmaclient.event.Event;
|
| 14 | import info.sigmaclient.event.EventSystem;
|
| 15 | import info.sigmaclient.event.impl.EventDeath;
|
| 16 | import info.sigmaclient.event.impl.EventTick;
|
| 17 | import info.sigmaclient.module.impl.combat.Criticals;
|
| 18 | import info.sigmaclient.module.impl.combat.Killaura;
|
| 19 | import info.sigmaclient.module.impl.player.Scaffold;
|
| 20 | import info.sigmaclient.util.misc.ChatUtil;
|
| 21 | import net.minecraft.block.Block;
|
| 22 | import net.minecraft.block.BlockBed;
|
| 23 | import net.minecraft.block.BlockDirectional;
|
| 24 | import net.minecraft.block.material.Material;
|
| 25 | import net.minecraft.block.state.IBlockState;
|
| 26 | import net.minecraft.client.Minecraft;
|
| 27 | import net.minecraft.command.server.CommandBlockLogic;
|
| 28 | import net.minecraft.enchantment.EnchantmentHelper;
|
| 29 | import net.minecraft.entity.Entity;
|
| 30 | import net.minecraft.entity.EntityList;
|
| 31 | import net.minecraft.entity.EntityLiving;
|
| 32 | import net.minecraft.entity.EntityLivingBase;
|
| 33 | import net.minecraft.entity.EnumCreatureAttribute;
|
| 34 | import net.minecraft.entity.IEntityMultiPart;
|
| 35 | import net.minecraft.entity.IMerchant;
|
| 36 | import net.minecraft.entity.SharedMonsterAttributes;
|
| 37 | import net.minecraft.entity.ai.attributes.IAttributeInstance;
|
| 38 | import net.minecraft.entity.boss.EntityDragonPart;
|
| 39 | import net.minecraft.entity.item.EntityBoat;
|
| 40 | import net.minecraft.entity.item.EntityItem;
|
| 41 | import net.minecraft.entity.item.EntityMinecart;
|
| 42 | import net.minecraft.entity.monster.EntityMob;
|
| 43 | import net.minecraft.entity.monster.IMob;
|
| 44 | import net.minecraft.entity.passive.EntityHorse;
|
| 45 | import net.minecraft.entity.passive.EntityPig;
|
| 46 | import net.minecraft.entity.projectile.EntityArrow;
|
| 47 | import net.minecraft.entity.projectile.EntityFishHook;
|
| 48 | import net.minecraft.event.ClickEvent;
|
| 49 | import net.minecraft.init.Blocks;
|
| 50 | import net.minecraft.init.Items;
|
| 51 | import net.minecraft.inventory.Container;
|
| 52 | import net.minecraft.inventory.ContainerPlayer;
|
| 53 | import net.minecraft.inventory.IInventory;
|
| 54 | import net.minecraft.inventory.InventoryEnderChest;
|
| 55 | import net.minecraft.item.EnumAction;
|
| 56 | import net.minecraft.item.Item;
|
| 57 | import net.minecraft.item.ItemArmor;
|
| 58 | import net.minecraft.item.ItemBlock;
|
| 59 | import net.minecraft.item.ItemStack;
|
| 60 | import net.minecraft.nbt.NBTTagCompound;
|
| 61 | import net.minecraft.nbt.NBTTagList;
|
| 62 | import net.minecraft.network.play.client.C03PacketPlayer;
|
| 63 | import net.minecraft.network.play.server.S12PacketEntityVelocity;
|
| 64 | import net.minecraft.potion.Potion;
|
| 65 | import net.minecraft.scoreboard.IScoreObjectiveCriteria;
|
| 66 | import net.minecraft.scoreboard.Score;
|
| 67 | import net.minecraft.scoreboard.ScoreObjective;
|
| 68 | import net.minecraft.scoreboard.ScorePlayerTeam;
|
| 69 | import net.minecraft.scoreboard.Scoreboard;
|
| 70 | import net.minecraft.scoreboard.Team;
|
| 71 | import net.minecraft.server.MinecraftServer;
|
| 72 | import net.minecraft.stats.AchievementList;
|
| 73 | import net.minecraft.stats.StatBase;
|
| 74 | import net.minecraft.stats.StatList;
|
| 75 | import net.minecraft.tileentity.TileEntitySign;
|
| 76 | import net.minecraft.util.AxisAlignedBB;
|
| 77 | import net.minecraft.util.BlockPos;
|
| 78 | import net.minecraft.util.ChatComponentText;
|
| 79 | import net.minecraft.util.DamageSource;
|
| 80 | import net.minecraft.util.EnumFacing;
|
| 81 | import net.minecraft.util.EnumParticleTypes;
|
| 82 | import net.minecraft.util.FoodStats;
|
| 83 | import net.minecraft.util.IChatComponent;
|
| 84 | import net.minecraft.util.MathHelper;
|
| 85 | import net.minecraft.util.Vec3;
|
| 86 | import net.minecraft.world.EnumDifficulty;
|
| 87 | import net.minecraft.world.IInteractionObject;
|
| 88 | import net.minecraft.world.LockCode;
|
| 89 | import net.minecraft.world.World;
|
| 90 | import net.minecraft.world.WorldSettings;
|
| 91 |
|
| 92 | public abstract class EntityPlayer extends EntityLivingBase {
|
| 93 | /**
|
| 94 | * Inventory of the player
|
| 95 | */
|
| 96 | protected final static Minecraft mc = Minecraft.getMinecraft();
|
| 97 | public InventoryPlayer inventory = new InventoryPlayer(this);
|
| 98 | private InventoryEnderChest theInventoryEnderChest = new InventoryEnderChest();
|
| 99 | public boolean isMurderer;
|
| 100 | public int onGroundTicks;
|
| 101 | /**
|
| 102 | * The Container for the player's inventory (which opens when they press E)
|
| 103 | */
|
| 104 | public Container inventoryContainer;
|
| 105 |
|
| 106 | /**
|
| 107 | * The Container the player has open.
|
| 108 | */
|
| 109 | public Container openContainer;
|
| 110 |
|
| 111 | /**
|
| 112 | * The food object of the player, the general hunger logic.
|
| 113 | */
|
| 114 | protected FoodStats foodStats = new FoodStats();
|
| 115 |
|
| 116 | /**
|
| 117 | * Used to tell if the player pressed jump twice. If this is at 0 and it's
|
| 118 | * pressed (And they are allowed to fly, as defined in the player's
|
| 119 | * movementInput) it sets this to 7. If it's pressed and it's greater than 0
|
| 120 | * enable fly.
|
| 121 | */
|
| 122 | protected int flyToggleTimer;
|
| 123 | public float prevCameraYaw;
|
| 124 | public float cameraYaw;
|
| 125 |
|
| 126 | /**
|
| 127 | * Used by EntityPlayer to prevent too many xp orbs from getting absorbed at
|
| 128 | * once.
|
| 129 | */
|
| 130 | public int xpCooldown;
|
| 131 | public double field_71091_bM;
|
| 132 | public double field_71096_bN;
|
| 133 | public double field_71097_bO;
|
| 134 | public double field_71094_bP;
|
| 135 | public double field_71095_bQ;
|
| 136 | public double field_71085_bR;
|
| 137 |
|
| 138 | /**
|
| 139 | * Boolean value indicating weather a player is sleeping or not
|
| 140 | */
|
| 141 | protected boolean sleeping;
|
| 142 |
|
| 143 | /**
|
| 144 | * the current location of the player
|
| 145 | */
|
| 146 | public BlockPos playerLocation;
|
| 147 | private int sleepTimer;
|
| 148 | public float field_71079_bU;
|
| 149 | public float field_71082_cx;
|
| 150 | public float field_71089_bV;
|
| 151 |
|
| 152 | /**
|
| 153 | * holds the spawn chunk of the player
|
| 154 | */
|
| 155 | private BlockPos spawnChunk;
|
| 156 |
|
| 157 | /**
|
| 158 | * Whether this player's spawn point is forced, preventing execution of bed
|
| 159 | * checks.
|
| 160 | */
|
| 161 | private boolean spawnForced;
|
| 162 |
|
| 163 | /**
|
| 164 | * Holds the coordinate of the player when enter a minecraft to ride.
|
| 165 | */
|
| 166 | private BlockPos startMinecartRidingCoordinate;
|
| 167 |
|
| 168 | /**
|
| 169 | * The player's capabilities. (See class PlayerCapabilities)
|
| 170 | */
|
| 171 | public PlayerCapabilities capabilities = new PlayerCapabilities();
|
| 172 |
|
| 173 | /**
|
| 174 | * The current experience level the player is on.
|
| 175 | */
|
| 176 | public int experienceLevel;
|
| 177 |
|
| 178 | /**
|
| 179 | * The total amount of experience the player has. This also includes the
|
| 180 | * amount of experience within their Experience Bar.
|
| 181 | */
|
| 182 | public int experienceTotal;
|
| 183 |
|
| 184 | /**
|
| 185 | * The current amount of experience the player has within their Experience
|
| 186 | * Bar.
|
| 187 | */
|
| 188 | public float experience;
|
| 189 | private int field_175152_f;
|
| 190 |
|
| 191 | /**
|
| 192 | * This is the item that is in use when the player is holding down the
|
| 193 | * useItemButton (e.g., bow, food, sword)
|
| 194 | */
|
| 195 | private ItemStack itemInUse;
|
| 196 |
|
| 197 | /**
|
| 198 | * This field starts off equal to getMaxItemUseDuration and is decremented
|
| 199 | * on each tick
|
| 200 | */
|
| 201 | public int itemInUseCount;
|
| 202 | protected float speedOnGround = 0.1F;
|
| 203 | protected float speedInAir = 0.02F;
|
| 204 | private int field_82249_h;
|
| 205 |
|
| 206 | /**
|
| 207 | * The player's unique game profile
|
| 208 | */
|
| 209 | private final GameProfile gameProfile;
|
| 210 | private boolean field_175153_bG = false;
|
| 211 |
|
| 212 | /**
|
| 213 | * An instance of a fishing rod's hook. If this isn't null, the icon image
|
| 214 | * of the fishing rod is slightly different
|
| 215 | */
|
| 216 | public EntityFishHook fishEntity;
|
| 217 | private static final String __OBFID = "CL_00001711";
|
| 218 |
|
| 219 | public EntityPlayer(World worldIn, GameProfile p_i45324_2_) {
|
| 220 | super(worldIn);
|
| 221 | this.entityUniqueID = getUUID(p_i45324_2_);
|
| 222 | this.gameProfile = p_i45324_2_;
|
| 223 | this.inventoryContainer = new ContainerPlayer(this.inventory, !worldIn.isRemote, this);
|
| 224 | this.openContainer = this.inventoryContainer;
|
| 225 | BlockPos var3 = worldIn.getSpawnPoint();
|
| 226 | this.setLocationAndAngles((double) var3.getX() + 0.5D, (double) (var3.getY() + 1), (double) var3.getZ() + 0.5D, 0.0F, 0.0F);
|
| 227 | this.field_70741_aB = 180.0F;
|
| 228 | this.fireResistance = 20;
|
| 229 | }
|
| 230 |
|
| 231 | protected void applyEntityAttributes() {
|
| 232 | super.applyEntityAttributes();
|
| 233 | this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.0D);
|
| 234 | this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.10000000149011612D);
|
| 235 | }
|
| 236 |
|
| 237 | protected void entityInit() {
|
| 238 | super.entityInit();
|
| 239 | this.dataWatcher.addObject(16, Byte.valueOf((byte) 0));
|
| 240 | this.dataWatcher.addObject(17, Float.valueOf(0.0F));
|
| 241 | this.dataWatcher.addObject(18, Integer.valueOf(0));
|
| 242 | this.dataWatcher.addObject(10, Byte.valueOf((byte) 0));
|
| 243 | }
|
| 244 |
|
| 245 | /**
|
| 246 | * returns the ItemStack containing the itemInUse
|
| 247 | */
|
| 248 | public ItemStack getItemInUse() {
|
| 249 | return this.itemInUse;
|
| 250 | }
|
| 251 |
|
| 252 | /**
|
| 253 | * Returns the item in use count
|
| 254 | */
|
| 255 | public int getItemInUseCount() {
|
| 256 | return this.itemInUseCount;
|
| 257 | }
|
| 258 |
|
| 259 | /**
|
| 260 | * Checks if the entity is currently using an item (e.g., bow, food, sword)
|
| 261 | * by holding down the useItemButton
|
| 262 | */
|
| 263 | public boolean isUsingItem() {
|
| 264 | return this.itemInUse != null;
|
| 265 | }
|
| 266 |
|
| 267 | /**
|
| 268 | * gets the duration for how long the current itemInUse has been in use
|
| 269 | */
|
| 270 | public int getItemInUseDuration() {
|
| 271 | return this.isUsingItem() ? this.itemInUse.getMaxItemUseDuration() - this.itemInUseCount : 0;
|
| 272 | }
|
| 273 |
|
| 274 | public void stopUsingItem() {
|
| 275 | if (this.itemInUse != null) {
|
| 276 | this.itemInUse.onPlayerStoppedUsing(this.worldObj, this, this.itemInUseCount);
|
| 277 | }
|
| 278 |
|
| 279 | this.clearItemInUse();
|
| 280 | }
|
| 281 |
|
| 282 | public void clearItemInUse() {
|
| 283 | this.itemInUse = null;
|
| 284 | this.itemInUseCount = 0;
|
| 285 |
|
| 286 | if (!this.worldObj.isRemote) {
|
| 287 | this.setEating(false);
|
| 288 | }
|
| 289 | }
|
| 290 |
|
| 291 | public boolean isBlocking() {
|
| 292 | return this.isUsingItem() && this.itemInUse.getItem().getItemUseAction(this.itemInUse) == EnumAction.BLOCK;
|
| 293 | }
|
| 294 |
|
| 295 | /**
|
| 296 | * Called to update the entity's position/logic.
|
| 297 | */
|
| 298 | public void onUpdate() {
|
| 299 | Event e = EventSystem.getInstance(EventTick.class);
|
| 300 | e.fire();
|
| 301 | if (e.isCancelled()) {
|
| 302 | return;
|
| 303 | }
|
| 304 | this.noClip = this.func_175149_v();
|
| 305 |
|
| 306 | if (this.func_175149_v()) {
|
| 307 | this.onGround = false;
|
| 308 | }
|
| 309 |
|
| 310 | if (this.itemInUse != null) {
|
| 311 | ItemStack var1 = this.inventory.getCurrentItem();
|
| 312 |
|
| 313 | if (var1 == this.itemInUse) {
|
| 314 | if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) {
|
| 315 | this.updateItemUse(var1, 5);
|
| 316 | }
|
| 317 |
|
| 318 | if (--this.itemInUseCount == 0 && !this.worldObj.isRemote) {
|
| 319 | this.onItemUseFinish();
|
| 320 | }
|
| 321 | } else {
|
| 322 | this.clearItemInUse();
|
| 323 | }
|
| 324 | }
|
| 325 |
|
| 326 | if (this.xpCooldown > 0) {
|
| 327 | --this.xpCooldown;
|
| 328 | }
|
| 329 |
|
| 330 | if (this.isPlayerSleeping()) {
|
| 331 | ++this.sleepTimer;
|
| 332 |
|
| 333 | if (this.sleepTimer > 100) {
|
| 334 | this.sleepTimer = 100;
|
| 335 | }
|
| 336 |
|
| 337 | if (!this.worldObj.isRemote) {
|
| 338 | if (!this.func_175143_p()) {
|
| 339 | this.wakeUpPlayer(true, true, false);
|
| 340 | } else if (this.worldObj.isDaytime()) {
|
| 341 | this.wakeUpPlayer(false, true, true);
|
| 342 | }
|
| 343 | }
|
| 344 | } else if (this.sleepTimer > 0) {
|
| 345 | ++this.sleepTimer;
|
| 346 |
|
| 347 | if (this.sleepTimer >= 110) {
|
| 348 | this.sleepTimer = 0;
|
| 349 | }
|
| 350 | }
|
| 351 |
|
| 352 | super.onUpdate();
|
| 353 |
|
| 354 | if (!this.worldObj.isRemote && this.openContainer != null && !this.openContainer.canInteractWith(this)) {
|
| 355 | this.closeScreen();
|
| 356 | this.openContainer = this.inventoryContainer;
|
| 357 | }
|
| 358 |
|
| 359 | if (this.isBurning() && this.capabilities.disableDamage) {
|
| 360 | this.extinguish();
|
| 361 | }
|
| 362 |
|
| 363 | this.field_71091_bM = this.field_71094_bP;
|
| 364 | this.field_71096_bN = this.field_71095_bQ;
|
| 365 | this.field_71097_bO = this.field_71085_bR;
|
| 366 | double var14 = this.posX - this.field_71094_bP;
|
| 367 | double var3 = this.posY - this.field_71095_bQ;
|
| 368 | double var5 = this.posZ - this.field_71085_bR;
|
| 369 | double var7 = 10.0D;
|
| 370 |
|
| 371 | if (var14 > var7) {
|
| 372 | this.field_71091_bM = this.field_71094_bP = this.posX;
|
| 373 | }
|
| 374 |
|
| 375 | if (var5 > var7) {
|
| 376 | this.field_71097_bO = this.field_71085_bR = this.posZ;
|
| 377 | }
|
| 378 |
|
| 379 | if (var3 > var7) {
|
| 380 | this.field_71096_bN = this.field_71095_bQ = this.posY;
|
| 381 | }
|
| 382 |
|
| 383 | if (var14 < -var7) {
|
| 384 | this.field_71091_bM = this.field_71094_bP = this.posX;
|
| 385 | }
|
| 386 |
|
| 387 | if (var5 < -var7) {
|
| 388 | this.field_71097_bO = this.field_71085_bR = this.posZ;
|
| 389 | }
|
| 390 |
|
| 391 | if (var3 < -var7) {
|
| 392 | this.field_71096_bN = this.field_71095_bQ = this.posY;
|
| 393 | }
|
| 394 |
|
| 395 | this.field_71094_bP += var14 * 0.25D;
|
| 396 | this.field_71085_bR += var5 * 0.25D;
|
| 397 | this.field_71095_bQ += var3 * 0.25D;
|
| 398 |
|
| 399 | if (this.ridingEntity == null) {
|
| 400 | this.startMinecartRidingCoordinate = null;
|
| 401 | }
|
| 402 |
|
| 403 | if (!this.worldObj.isRemote) {
|
| 404 | this.foodStats.onUpdate(this);
|
| 405 | this.triggerAchievement(StatList.minutesPlayedStat);
|
| 406 |
|
| 407 | if (this.isEntityAlive()) {
|
| 408 | this.triggerAchievement(StatList.timeSinceDeathStat);
|
| 409 | }
|
| 410 | }
|
| 411 |
|
| 412 | int var9 = 29999999;
|
| 413 | double var10 = MathHelper.clamp_double(this.posX, -2.9999999E7D, 2.9999999E7D);
|
| 414 | double var12 = MathHelper.clamp_double(this.posZ, -2.9999999E7D, 2.9999999E7D);
|
| 415 |
|
| 416 | if (var10 != this.posX || var12 != this.posZ) {
|
| 417 | this.setPosition(var10, this.posY, var12);
|
| 418 | }
|
| 419 | }
|
| 420 |
|
| 421 | /**
|
| 422 | * Return the amount of time this entity should stay in a portal before
|
| 423 | * being transported.
|
| 424 | */
|
| 425 | public int getMaxInPortalTime() {
|
| 426 | return this.capabilities.disableDamage ? 0 : 80;
|
| 427 | }
|
| 428 |
|
| 429 | protected String getSwimSound() {
|
| 430 | return "game.player.swim";
|
| 431 | }
|
| 432 |
|
| 433 | protected String getSplashSound() {
|
| 434 | return "game.player.swim.splash";
|
| 435 | }
|
| 436 |
|
| 437 | /**
|
| 438 | * Return the amount of cooldown before this entity can use a portal again.
|
| 439 | */
|
| 440 | public int getPortalCooldown() {
|
| 441 | return 10;
|
| 442 | }
|
| 443 |
|
| 444 | public void playSound(String name, float volume, float pitch) {
|
| 445 | this.worldObj.playSoundToNearExcept(this, name, volume, pitch);
|
| 446 | }
|
| 447 |
|
| 448 | /**
|
| 449 | * Plays sounds and makes particles for item in use state
|
| 450 | */
|
| 451 | protected void updateItemUse(ItemStack itemStackIn, int p_71010_2_) {
|
| 452 | if (itemStackIn.getItemUseAction() == EnumAction.DRINK) {
|
| 453 | this.playSound("random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
|
| 454 | }
|
| 455 |
|
| 456 | if (itemStackIn.getItemUseAction() == EnumAction.EAT) {
|
| 457 | for (int var3 = 0; var3 < p_71010_2_; ++var3) {
|
| 458 | Vec3 var4 = new Vec3(((double) this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
|
| 459 | var4 = var4.rotatePitch(-this.rotationPitch * (float) Math.PI / 180.0F);
|
| 460 | var4 = var4.rotateYaw(-this.rotationYaw * (float) Math.PI / 180.0F);
|
| 461 | double var5 = (double) (-this.rand.nextFloat()) * 0.6D - 0.3D;
|
| 462 | Vec3 var7 = new Vec3(((double) this.rand.nextFloat() - 0.5D) * 0.3D, var5, 0.6D);
|
| 463 | var7 = var7.rotatePitch(-this.rotationPitch * (float) Math.PI / 180.0F);
|
| 464 | var7 = var7.rotateYaw(-this.rotationYaw * (float) Math.PI / 180.0F);
|
| 465 | var7 = var7.addVector(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ);
|
| 466 |
|
| 467 | if (itemStackIn.getHasSubtypes()) {
|
| 468 | this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, var7.xCoord, var7.yCoord, var7.zCoord, var4.xCoord, var4.yCoord + 0.05D, var4.zCoord, new int[]{Item.getIdFromItem(itemStackIn.getItem()), itemStackIn.getMetadata()});
|
| 469 | } else {
|
| 470 | this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, var7.xCoord, var7.yCoord, var7.zCoord, var4.xCoord, var4.yCoord + 0.05D, var4.zCoord, new int[]{Item.getIdFromItem(itemStackIn.getItem())});
|
| 471 | }
|
| 472 | }
|
| 473 |
|
| 474 | this.playSound("random.eat", 0.5F + 0.5F * (float) this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
|
| 475 | }
|
| 476 | }
|
| 477 |
|
| 478 | /**
|
| 479 | * Used for when item use count runs out, ie: eating completed
|
| 480 | */
|
| 481 | protected void onItemUseFinish() {
|
| 482 | if (this.itemInUse != null) {
|
| 483 | this.updateItemUse(this.itemInUse, 16);
|
| 484 | int var1 = this.itemInUse.stackSize;
|
| 485 | ItemStack var2 = this.itemInUse.onItemUseFinish(this.worldObj, this);
|
| 486 |
|
| 487 | if (var2 != this.itemInUse || var2 != null && var2.stackSize != var1) {
|
| 488 | this.inventory.mainInventory[this.inventory.currentItem] = var2;
|
| 489 |
|
| 490 | if (var2.stackSize == 0) {
|
| 491 | this.inventory.mainInventory[this.inventory.currentItem] = null;
|
| 492 | }
|
| 493 | }
|
| 494 |
|
| 495 | this.clearItemInUse();
|
| 496 | }
|
| 497 | }
|
| 498 |
|
| 499 | public void handleHealthUpdate(byte p_70103_1_) {
|
| 500 | if (p_70103_1_ == 9) {
|
| 501 | this.onItemUseFinish();
|
| 502 | } else if (p_70103_1_ == 23) {
|
| 503 | this.field_175153_bG = false;
|
| 504 | } else if (p_70103_1_ == 22) {
|
| 505 | this.field_175153_bG = true;
|
| 506 | } else {
|
| 507 | super.handleHealthUpdate(p_70103_1_);
|
| 508 | }
|
| 509 | }
|
| 510 |
|
| 511 | /**
|
| 512 | * Dead and sleeping entities cannot move
|
| 513 | */
|
| 514 | protected boolean isMovementBlocked() {
|
| 515 | return this.getHealth() <= 0.0F || this.isPlayerSleeping();
|
| 516 | }
|
| 517 |
|
| 518 | /**
|
| 519 | * set current crafting inventory back to the 2x2 square
|
| 520 | */
|
| 521 | protected void closeScreen() {
|
| 522 | this.openContainer = this.inventoryContainer;
|
| 523 | }
|
| 524 |
|
| 525 | /**
|
| 526 | * Handles updating while being ridden by an entity
|
| 527 | */
|
| 528 | public void updateRidden() {
|
| 529 | if (!this.worldObj.isRemote && this.isSneaking()) {
|
| 530 | this.mountEntity((Entity) null);
|
| 531 | this.setSneaking(false);
|
| 532 | } else {
|
| 533 | double var1 = this.posX;
|
| 534 | double var3 = this.posY;
|
| 535 | double var5 = this.posZ;
|
| 536 | float var7 = this.rotationYaw;
|
| 537 | float var8 = this.rotationPitch;
|
| 538 | super.updateRidden();
|
| 539 | this.prevCameraYaw = this.cameraYaw;
|
| 540 | this.cameraYaw = 0.0F;
|
| 541 | this.addMountedMovementStat(this.posX - var1, this.posY - var3, this.posZ - var5);
|
| 542 |
|
| 543 | if (this.ridingEntity instanceof EntityPig) {
|
| 544 | this.rotationPitch = var8;
|
| 545 | this.rotationYaw = var7;
|
| 546 | this.renderYawOffset = ((EntityPig) this.ridingEntity).renderYawOffset;
|
| 547 | }
|
| 548 | }
|
| 549 | }
|
| 550 |
|
| 551 | /**
|
| 552 | * Keeps moving the entity up so it isn't colliding with blocks and other
|
| 553 | * requirements for this entity to be spawned (only actually used on players
|
| 554 | * though its also on Entity)
|
| 555 | */
|
| 556 | public void preparePlayerToSpawn() {
|
| 557 | this.setSize(0.6F, 1.8F);
|
| 558 | super.preparePlayerToSpawn();
|
| 559 | this.setHealth(this.getMaxHealth());
|
| 560 | this.deathTime = 0;
|
| 561 | }
|
| 562 |
|
| 563 | protected void updateEntityActionState() {
|
| 564 | super.updateEntityActionState();
|
| 565 | this.updateArmSwingProgress();
|
| 566 | this.rotationYawHead = this.rotationYaw;
|
| 567 | }
|
| 568 |
|
| 569 | /**
|
| 570 | * Called frequently so the entity can update its state every tick as
|
| 571 | * required. For example, zombies and skeletons use this to react to
|
| 572 | * sunlight and start to burn.
|
| 573 | */
|
| 574 | public void onLivingUpdate() {
|
| 575 | if (this.flyToggleTimer > 0) {
|
| 576 | --this.flyToggleTimer;
|
| 577 | }
|
| 578 |
|
| 579 | if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL && this.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration")) {
|
| 580 | if (this.getHealth() < this.getMaxHealth() && this.ticksExisted % 20 == 0) {
|
| 581 | this.heal(1.0F);
|
| 582 | }
|
| 583 |
|
| 584 | if (this.foodStats.needFood() && this.ticksExisted % 10 == 0) {
|
| 585 | this.foodStats.setFoodLevel(this.foodStats.getFoodLevel() + 1);
|
| 586 | }
|
| 587 | }
|
| 588 |
|
| 589 | this.inventory.decrementAnimations();
|
| 590 | this.prevCameraYaw = this.cameraYaw;
|
| 591 | super.onLivingUpdate();
|
| 592 | IAttributeInstance var1 = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
|
| 593 |
|
| 594 | if (!this.worldObj.isRemote) {
|
| 595 | var1.setBaseValue((double) this.capabilities.getWalkSpeed());
|
| 596 | }
|
| 597 |
|
| 598 | this.jumpMovementFactor = this.speedInAir;
|
| 599 |
|
| 600 | if (this.isSprinting()) {
|
| 601 | this.jumpMovementFactor = (float) ((double) this.jumpMovementFactor + (double) this.speedInAir * 0.3D);
|
| 602 | }
|
| 603 |
|
| 604 | this.setAIMoveSpeed((float) var1.getAttributeValue());
|
| 605 | float var2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
| 606 | float var3 = (float) (Math.atan(-this.motionY * 0.20000000298023224D) * 15.0D);
|
| 607 |
|
| 608 | if (var2 > 0.1F) {
|
| 609 | var2 = 0.1F;
|
| 610 | }
|
| 611 |
|
| 612 | if (!this.onGround || this.getHealth() <= 0.0F) {
|
| 613 | var2 = 0.0F;
|
| 614 | }
|
| 615 |
|
| 616 | if (this.onGround || this.getHealth() <= 0.0F) {
|
| 617 | var3 = 0.0F;
|
| 618 | }
|
| 619 |
|
| 620 | this.cameraYaw += (var2 - this.cameraYaw) * 0.4F;
|
| 621 | this.cameraPitch += (var3 - this.cameraPitch) * 0.8F;
|
| 622 |
|
| 623 | if (this.getHealth() > 0.0F && !this.func_175149_v()) {
|
| 624 | AxisAlignedBB var4 = null;
|
| 625 |
|
| 626 | if (this.ridingEntity != null && !this.ridingEntity.isDead) {
|
| 627 | var4 = this.getEntityBoundingBox().union(this.ridingEntity.getEntityBoundingBox()).expand(1.0D, 0.0D, 1.0D);
|
| 628 | } else {
|
| 629 | var4 = this.getEntityBoundingBox().expand(1.0D, 0.5D, 1.0D);
|
| 630 | }
|
| 631 |
|
| 632 | List var5 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, var4);
|
| 633 |
|
| 634 | for (int var6 = 0; var6 < var5.size(); ++var6) {
|
| 635 | Entity var7 = (Entity) var5.get(var6);
|
| 636 |
|
| 637 | if (!var7.isDead) {
|
| 638 | this.collideWithPlayer(var7);
|
| 639 | }
|
| 640 | }
|
| 641 | }
|
| 642 | }
|
| 643 |
|
| 644 | private void collideWithPlayer(Entity p_71044_1_) {
|
| 645 | p_71044_1_.onCollideWithPlayer(this);
|
| 646 | }
|
| 647 |
|
| 648 | public int getScore() {
|
| 649 | return this.dataWatcher.getWatchableObjectInt(18);
|
| 650 | }
|
| 651 |
|
| 652 | /**
|
| 653 | * Set player's score
|
| 654 | */
|
| 655 | public void setScore(int p_85040_1_) {
|
| 656 | this.dataWatcher.updateObject(18, Integer.valueOf(p_85040_1_));
|
| 657 | }
|
| 658 |
|
| 659 | /**
|
| 660 | * Add to player's score
|
| 661 | */
|
| 662 | public void addScore(int p_85039_1_) {
|
| 663 | int var2 = this.getScore();
|
| 664 | this.dataWatcher.updateObject(18, Integer.valueOf(var2 + p_85039_1_));
|
| 665 | }
|
| 666 |
|
| 667 | /**
|
| 668 | * Called when the mob's health reaches 0.
|
| 669 | */
|
| 670 | public void onDeath(DamageSource cause) {
|
| 671 | Event event = EventSystem.getInstance(EventDeath.class);
|
| 672 | event.fire();
|
| 673 | if (event.isCancelled()) {
|
| 674 | return;
|
| 675 | }
|
| 676 | super.onDeath(cause);
|
| 677 | this.setSize(0.2F, 0.2F);
|
| 678 | this.setPosition(this.posX, this.posY, this.posZ);
|
| 679 | this.motionY = 0.10000000149011612D;
|
| 680 |
|
| 681 | if (this.getName().equals("Notch")) {
|
| 682 | this.func_146097_a(new ItemStack(Items.apple, 1), true, false);
|
| 683 | }
|
| 684 |
|
| 685 | if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
|
| 686 | this.inventory.dropAllItems();
|
| 687 | }
|
| 688 |
|
| 689 | if (cause != null) {
|
| 690 | this.motionX = (double) (-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float) Math.PI / 180.0F) * 0.1F);
|
| 691 | this.motionZ = (double) (-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float) Math.PI / 180.0F) * 0.1F);
|
| 692 | } else {
|
| 693 | this.motionX = this.motionZ = 0.0D;
|
| 694 | }
|
| 695 |
|
| 696 | this.triggerAchievement(StatList.deathsStat);
|
| 697 | this.func_175145_a(StatList.timeSinceDeathStat);
|
| 698 | }
|
| 699 |
|
| 700 | /**
|
| 701 | * Returns the sound this mob makes when it is hurt.
|
| 702 | */
|
| 703 | protected String getHurtSound() {
|
| 704 | return "game.player.hurt";
|
| 705 | }
|
| 706 |
|
| 707 | /**
|
| 708 | * Returns the sound this mob makes on death.
|
| 709 | */
|
| 710 | protected String getDeathSound() {
|
| 711 | return "game.player.die";
|
| 712 | }
|
| 713 |
|
| 714 | /**
|
| 715 | * Adds a value to the player score. Currently not actually used and the
|
| 716 | * entity passed in does nothing. Args: entity, scoreToAdd
|
| 717 | */
|
| 718 | public void addToPlayerScore(Entity entityIn, int amount) {
|
| 719 | this.addScore(amount);
|
| 720 | Collection var3 = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.totalKillCount);
|
| 721 |
|
| 722 | if (entityIn instanceof EntityPlayer) {
|
| 723 | this.triggerAchievement(StatList.playerKillsStat);
|
| 724 | var3.addAll(this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.playerKillCount));
|
| 725 | var3.addAll(this.func_175137_e(entityIn));
|
| 726 | } else {
|
| 727 | this.triggerAchievement(StatList.mobKillsStat);
|
| 728 | }
|
| 729 |
|
| 730 | Iterator var4 = var3.iterator();
|
| 731 |
|
| 732 | while (var4.hasNext()) {
|
| 733 | ScoreObjective var5 = (ScoreObjective) var4.next();
|
| 734 | Score var6 = this.getWorldScoreboard().getValueFromObjective(this.getName(), var5);
|
| 735 | var6.func_96648_a();
|
| 736 | }
|
| 737 | }
|
| 738 |
|
| 739 | private Collection func_175137_e(Entity p_175137_1_) {
|
| 740 | ScorePlayerTeam var2 = this.getWorldScoreboard().getPlayersTeam(this.getName());
|
| 741 |
|
| 742 | if (var2 != null) {
|
| 743 | int var3 = var2.func_178775_l().func_175746_b();
|
| 744 |
|
| 745 | if (var3 >= 0 && var3 < IScoreObjectiveCriteria.field_178793_i.length) {
|
| 746 | Iterator var4 = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.field_178793_i[var3]).iterator();
|
| 747 |
|
| 748 | while (var4.hasNext()) {
|
| 749 | ScoreObjective var5 = (ScoreObjective) var4.next();
|
| 750 | Score var6 = this.getWorldScoreboard().getValueFromObjective(p_175137_1_.getName(), var5);
|
| 751 | var6.func_96648_a();
|
| 752 | }
|
| 753 | }
|
| 754 | }
|
| 755 |
|
| 756 | ScorePlayerTeam var7 = this.getWorldScoreboard().getPlayersTeam(p_175137_1_.getName());
|
| 757 |
|
| 758 | if (var7 != null) {
|
| 759 | int var8 = var7.func_178775_l().func_175746_b();
|
| 760 |
|
| 761 | if (var8 >= 0 && var8 < IScoreObjectiveCriteria.field_178792_h.length) {
|
| 762 | return this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.field_178792_h[var8]);
|
| 763 | }
|
| 764 | }
|
| 765 |
|
| 766 | return Lists.newArrayList();
|
| 767 | }
|
| 768 |
|
| 769 | /**
|
| 770 | * Called when player presses the drop item key
|
| 771 | */
|
| 772 | public EntityItem dropOneItem(boolean p_71040_1_) {
|
| 773 | return this.func_146097_a(this.inventory.decrStackSize(this.inventory.currentItem, p_71040_1_ && this.inventory.getCurrentItem() != null ? this.inventory.getCurrentItem().stackSize : 1), false, true);
|
| 774 | }
|
| 775 |
|
| 776 | /**
|
| 777 | * Args: itemstack, flag
|
| 778 | */
|
| 779 | public EntityItem dropPlayerItemWithRandomChoice(ItemStack itemStackIn, boolean p_71019_2_) {
|
| 780 | return this.func_146097_a(itemStackIn, false, false);
|
| 781 | }
|
| 782 |
|
| 783 | public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_) {
|
| 784 | if (p_146097_1_ == null) {
|
| 785 | return null;
|
| 786 | } else if (p_146097_1_.stackSize == 0) {
|
| 787 | return null;
|
| 788 | } else {
|
| 789 | double var4 = this.posY - 0.30000001192092896D + (double) this.getEyeHeight();
|
| 790 | EntityItem var6 = new EntityItem(this.worldObj, this.posX, var4, this.posZ, p_146097_1_);
|
| 791 | var6.setPickupDelay(40);
|
| 792 |
|
| 793 | if (p_146097_3_) {
|
| 794 | var6.setThrower(this.getName());
|
| 795 | }
|
| 796 |
|
| 797 | float var7;
|
| 798 | float var8;
|
| 799 |
|
| 800 | if (p_146097_2_) {
|
| 801 | var7 = this.rand.nextFloat() * 0.5F;
|
| 802 | var8 = this.rand.nextFloat() * (float) Math.PI * 2.0F;
|
| 803 | var6.motionX = (double) (-MathHelper.sin(var8) * var7);
|
| 804 | var6.motionZ = (double) (MathHelper.cos(var8) * var7);
|
| 805 | var6.motionY = 0.20000000298023224D;
|
| 806 | } else {
|
| 807 | var7 = 0.3F;
|
| 808 | var6.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI) * var7);
|
| 809 | var6.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI) * var7);
|
| 810 | var6.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI) * var7 + 0.1F);
|
| 811 | var8 = this.rand.nextFloat() * (float) Math.PI * 2.0F;
|
| 812 | var7 = 0.02F * this.rand.nextFloat();
|
| 813 | var6.motionX += Math.cos((double) var8) * (double) var7;
|
| 814 | var6.motionY += (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
|
| 815 | var6.motionZ += Math.sin((double) var8) * (double) var7;
|
| 816 | }
|
| 817 |
|
| 818 | this.joinEntityItemWithWorld(var6);
|
| 819 |
|
| 820 | if (p_146097_3_) {
|
| 821 | this.triggerAchievement(StatList.dropStat);
|
| 822 | }
|
| 823 |
|
| 824 | return var6;
|
| 825 | }
|
| 826 | }
|
| 827 |
|
| 828 | /**
|
| 829 | * Joins the passed in entity item with the world. Args: entityItem
|
| 830 | */
|
| 831 | protected void joinEntityItemWithWorld(EntityItem p_71012_1_) {
|
| 832 | this.worldObj.spawnEntityInWorld(p_71012_1_);
|
| 833 | }
|
| 834 |
|
| 835 | public float func_180471_a(Block p_180471_1_) {
|
| 836 | float var2 = this.inventory.getStrVsBlock(p_180471_1_);
|
| 837 |
|
| 838 | if (var2 > 1.0F) {
|
| 839 | int var3 = EnchantmentHelper.getEfficiencyModifier(this);
|
| 840 | ItemStack var4 = this.inventory.getCurrentItem();
|
| 841 |
|
| 842 | if (var3 > 0 && var4 != null) {
|
| 843 | var2 += (float) (var3 * var3 + 1);
|
| 844 | }
|
| 845 | }
|
| 846 |
|
| 847 | if (this.isPotionActive(Potion.digSpeed)) {
|
| 848 | var2 *= 1.0F + (float) (this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
|
| 849 | }
|
| 850 |
|
| 851 | if (this.isPotionActive(Potion.digSlowdown)) {
|
| 852 | float var5 = 1.0F;
|
| 853 |
|
| 854 | switch (this.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) {
|
| 855 | case 0:
|
| 856 | var5 = 0.3F;
|
| 857 | break;
|
| 858 |
|
| 859 | case 1:
|
| 860 | var5 = 0.09F;
|
| 861 | break;
|
| 862 |
|
| 863 | case 2:
|
| 864 | var5 = 0.0027F;
|
| 865 | break;
|
| 866 |
|
| 867 | case 3:
|
| 868 | default:
|
| 869 | var5 = 8.1E-4F;
|
| 870 | }
|
| 871 |
|
| 872 | var2 *= var5;
|
| 873 | }
|
| 874 |
|
| 875 | if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this)) {
|
| 876 | var2 /= 5.0F;
|
| 877 | }
|
| 878 |
|
| 879 | if (!this.onGround) {
|
| 880 | var2 /= 5.0F;
|
| 881 | }
|
| 882 |
|
| 883 | return var2;
|
| 884 | }
|
| 885 |
|
| 886 | /**
|
| 887 | * Checks if the player has the ability to harvest a block (checks current
|
| 888 | * inventory item for a tool if necessary)
|
| 889 | */
|
| 890 | public boolean canHarvestBlock(Block p_146099_1_) {
|
| 891 | return this.inventory.func_146025_b(p_146099_1_);
|
| 892 | }
|
| 893 |
|
| 894 | /**
|
| 895 | * (abstract) Protected helper method to read subclass entity data from NBT.
|
| 896 | */
|
| 897 | public void readEntityFromNBT(NBTTagCompound tagCompund) {
|
| 898 | super.readEntityFromNBT(tagCompund);
|
| 899 | this.entityUniqueID = getUUID(this.gameProfile);
|
| 900 | NBTTagList var2 = tagCompund.getTagList("Inventory", 10);
|
| 901 | this.inventory.readFromNBT(var2);
|
| 902 | this.inventory.currentItem = tagCompund.getInteger("SelectedItemSlot");
|
| 903 | this.sleeping = tagCompund.getBoolean("Sleeping");
|
| 904 | this.sleepTimer = tagCompund.getShort("SleepTimer");
|
| 905 | this.experience = tagCompund.getFloat("XpP");
|
| 906 | this.experienceLevel = tagCompund.getInteger("XpLevel");
|
| 907 | this.experienceTotal = tagCompund.getInteger("XpTotal");
|
| 908 | this.field_175152_f = tagCompund.getInteger("XpSeed");
|
| 909 |
|
| 910 | if (this.field_175152_f == 0) {
|
| 911 | this.field_175152_f = this.rand.nextInt();
|
| 912 | }
|
| 913 |
|
| 914 | this.setScore(tagCompund.getInteger("Score"));
|
| 915 |
|
| 916 | if (this.sleeping) {
|
| 917 | this.playerLocation = new BlockPos(this);
|
| 918 | this.wakeUpPlayer(true, true, false);
|
| 919 | }
|
| 920 |
|
| 921 | if (tagCompund.hasKey("SpawnX", 99) && tagCompund.hasKey("SpawnY", 99) && tagCompund.hasKey("SpawnZ", 99)) {
|
| 922 | this.spawnChunk = new BlockPos(tagCompund.getInteger("SpawnX"), tagCompund.getInteger("SpawnY"), tagCompund.getInteger("SpawnZ"));
|
| 923 | this.spawnForced = tagCompund.getBoolean("SpawnForced");
|
| 924 | }
|
| 925 |
|
| 926 | this.foodStats.readNBT(tagCompund);
|
| 927 | this.capabilities.readCapabilitiesFromNBT(tagCompund);
|
| 928 |
|
| 929 | if (tagCompund.hasKey("EnderItems", 9)) {
|
| 930 | NBTTagList var3 = tagCompund.getTagList("EnderItems", 10);
|
| 931 | this.theInventoryEnderChest.loadInventoryFromNBT(var3);
|
| 932 | }
|
| 933 | }
|
| 934 |
|
| 935 | /**
|
| 936 | * (abstract) Protected helper method to write subclass entity data to NBT.
|
| 937 | */
|
| 938 | public void writeEntityToNBT(NBTTagCompound tagCompound) {
|
| 939 | super.writeEntityToNBT(tagCompound);
|
| 940 | tagCompound.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList()));
|
| 941 | tagCompound.setInteger("SelectedItemSlot", this.inventory.currentItem);
|
| 942 | tagCompound.setBoolean("Sleeping", this.sleeping);
|
| 943 | tagCompound.setShort("SleepTimer", (short) this.sleepTimer);
|
| 944 | tagCompound.setFloat("XpP", this.experience);
|
| 945 | tagCompound.setInteger("XpLevel", this.experienceLevel);
|
| 946 | tagCompound.setInteger("XpTotal", this.experienceTotal);
|
| 947 | tagCompound.setInteger("XpSeed", this.field_175152_f);
|
| 948 | tagCompound.setInteger("Score", this.getScore());
|
| 949 |
|
| 950 | if (this.spawnChunk != null) {
|
| 951 | tagCompound.setInteger("SpawnX", this.spawnChunk.getX());
|
| 952 | tagCompound.setInteger("SpawnY", this.spawnChunk.getY());
|
| 953 | tagCompound.setInteger("SpawnZ", this.spawnChunk.getZ());
|
| 954 | tagCompound.setBoolean("SpawnForced", this.spawnForced);
|
| 955 | }
|
| 956 |
|
| 957 | this.foodStats.writeNBT(tagCompound);
|
| 958 | this.capabilities.writeCapabilitiesToNBT(tagCompound);
|
| 959 | tagCompound.setTag("EnderItems", this.theInventoryEnderChest.saveInventoryToNBT());
|
| 960 | ItemStack var2 = this.inventory.getCurrentItem();
|
| 961 |
|
| 962 | if (var2 != null && var2.getItem() != null) {
|
| 963 | tagCompound.setTag("SelectedItem", var2.writeToNBT(new NBTTagCompound()));
|
| 964 | }
|
| 965 | }
|
| 966 |
|
| 967 | /**
|
| 968 | * Called when the entity is attacked.
|
| 969 | */
|
| 970 | public boolean attackEntityFrom(DamageSource source, float amount) {
|
| 971 | if (this.func_180431_b(source)) {
|
| 972 | return false;
|
| 973 | } else if (this.capabilities.disableDamage && !source.canHarmInCreative()) {
|
| 974 | return false;
|
| 975 | } else {
|
| 976 | this.entityAge = 0;
|
| 977 |
|
| 978 | if (this.getHealth() <= 0.0F) {
|
| 979 | return false;
|
| 980 | } else {
|
| 981 | if (this.isPlayerSleeping() && !this.worldObj.isRemote) {
|
| 982 | this.wakeUpPlayer(true, true, false);
|
| 983 | }
|
| 984 |
|
| 985 | if (source.isDifficultyScaled()) {
|
| 986 | if (this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
| 987 | amount = 0.0F;
|
| 988 | }
|
| 989 |
|
| 990 | if (this.worldObj.getDifficulty() == EnumDifficulty.EASY) {
|
| 991 | amount = amount / 2.0F + 1.0F;
|
| 992 | }
|
| 993 |
|
| 994 | if (this.worldObj.getDifficulty() == EnumDifficulty.HARD) {
|
| 995 | amount = amount * 3.0F / 2.0F;
|
| 996 | }
|
| 997 | }
|
| 998 |
|
| 999 | if (amount == 0.0F) {
|
| 1000 | return false;
|
| 1001 | } else {
|
| 1002 | Entity var3 = source.getEntity();
|
| 1003 |
|
| 1004 | if (var3 instanceof EntityArrow && ((EntityArrow) var3).shootingEntity != null) {
|
| 1005 | var3 = ((EntityArrow) var3).shootingEntity;
|
| 1006 | }
|
| 1007 |
|
| 1008 | return super.attackEntityFrom(source, amount);
|
| 1009 | }
|
| 1010 | }
|
| 1011 | }
|
| 1012 | }
|
| 1013 |
|
| 1014 | public boolean canAttackPlayer(EntityPlayer other) {
|
| 1015 | Team var2 = this.getTeam();
|
| 1016 | Team var3 = other.getTeam();
|
| 1017 | return var2 == null ? true : (!var2.isSameTeam(var3) ? true : var2.getAllowFriendlyFire());
|
| 1018 | }
|
| 1019 |
|
| 1020 | protected void damageArmor(float p_70675_1_) {
|
| 1021 | this.inventory.damageArmor(p_70675_1_);
|
| 1022 | }
|
| 1023 |
|
| 1024 | /**
|
| 1025 | * Returns the current armor value as determined by a call to
|
| 1026 | * InventoryPlayer.getTotalArmorValue
|
| 1027 | */
|
| 1028 | public int getTotalArmorValue() {
|
| 1029 | return this.inventory.getTotalArmorValue();
|
| 1030 | }
|
| 1031 |
|
| 1032 | /**
|
| 1033 | * When searching for vulnerable players, if a player is invisible, the
|
| 1034 | * return value of this is the chance of seeing them anyway.
|
| 1035 | */
|
| 1036 | public float getArmorVisibility() {
|
| 1037 | int var1 = 0;
|
| 1038 | ItemStack[] var2 = this.inventory.armorInventory;
|
| 1039 | int var3 = var2.length;
|
| 1040 |
|
| 1041 | for (int var4 = 0; var4 < var3; ++var4) {
|
| 1042 | ItemStack var5 = var2[var4];
|
| 1043 |
|
| 1044 | if (var5 != null) {
|
| 1045 | ++var1;
|
| 1046 | }
|
| 1047 | }
|
| 1048 |
|
| 1049 | return (float) var1 / (float) this.inventory.armorInventory.length;
|
| 1050 | }
|
| 1051 |
|
| 1052 | /**
|
| 1053 | * Deals damage to the entity. If its a EntityPlayer then will take damage
|
| 1054 | * from the armor first and then health second with the reduced value. Args:
|
| 1055 | * damageAmount
|
| 1056 | */
|
| 1057 | protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_) {
|
| 1058 | if (!this.func_180431_b(p_70665_1_)) {
|
| 1059 | if (!p_70665_1_.isUnblockable() && this.isBlocking() && p_70665_2_ > 0.0F) {
|
| 1060 | p_70665_2_ = (1.0F + p_70665_2_) * 0.5F;
|
| 1061 | }
|
| 1062 |
|
| 1063 | p_70665_2_ = this.applyArmorCalculations(p_70665_1_, p_70665_2_);
|
| 1064 | p_70665_2_ = this.applyPotionDamageCalculations(p_70665_1_, p_70665_2_);
|
| 1065 | float var3 = p_70665_2_;
|
| 1066 | p_70665_2_ = Math.max(p_70665_2_ - this.getAbsorptionAmount(), 0.0F);
|
| 1067 | this.setAbsorptionAmount(this.getAbsorptionAmount() - (var3 - p_70665_2_));
|
| 1068 |
|
| 1069 | if (p_70665_2_ != 0.0F) {
|
| 1070 | this.addExhaustion(p_70665_1_.getHungerDamage());
|
| 1071 | float var4 = this.getHealth();
|
| 1072 | this.setHealth(this.getHealth() - p_70665_2_);
|
| 1073 | this.getCombatTracker().func_94547_a(p_70665_1_, var4, p_70665_2_);
|
| 1074 |
|
| 1075 | if (p_70665_2_ < 3.4028235E37F) {
|
| 1076 | this.addStat(StatList.damageTakenStat, Math.round(p_70665_2_ * 10.0F));
|
| 1077 | }
|
| 1078 | }
|
| 1079 | }
|
| 1080 | }
|
| 1081 |
|
| 1082 | public void func_175141_a(TileEntitySign p_175141_1_) {
|
| 1083 | }
|
| 1084 |
|
| 1085 | public void func_146095_a(CommandBlockLogic p_146095_1_) {
|
| 1086 | }
|
| 1087 |
|
| 1088 | public void displayVillagerTradeGui(IMerchant villager) {
|
| 1089 | }
|
| 1090 |
|
| 1091 | /**
|
| 1092 | * Displays the GUI for interacting with a chest inventory. Args:
|
| 1093 | * chestInventory
|
| 1094 | */
|
| 1095 | public void displayGUIChest(IInventory chestInventory) {
|
| 1096 | }
|
| 1097 |
|
| 1098 | public void displayGUIHorse(EntityHorse p_110298_1_, IInventory p_110298_2_) {
|
| 1099 | }
|
| 1100 |
|
| 1101 | public void displayGui(IInteractionObject guiOwner) {
|
| 1102 | }
|
| 1103 |
|
| 1104 | /**
|
| 1105 | * Displays the GUI for interacting with a book.
|
| 1106 | */
|
| 1107 | public void displayGUIBook(ItemStack bookStack) {
|
| 1108 | }
|
| 1109 |
|
| 1110 | public boolean interactWith(Entity p_70998_1_) {
|
| 1111 | if (this.func_175149_v()) {
|
| 1112 | if (p_70998_1_ instanceof IInventory) {
|
| 1113 | this.displayGUIChest((IInventory) p_70998_1_);
|
| 1114 | }
|
| 1115 |
|
| 1116 | return false;
|
| 1117 | } else {
|
| 1118 | ItemStack var2 = this.getCurrentEquippedItem();
|
| 1119 | ItemStack var3 = var2 != null ? var2.copy() : null;
|
| 1120 |
|
| 1121 | if (!p_70998_1_.interactFirst(this)) {
|
| 1122 | if (var2 != null && p_70998_1_ instanceof EntityLivingBase) {
|
| 1123 | if (this.capabilities.isCreativeMode) {
|
| 1124 | var2 = var3;
|
| 1125 | }
|
| 1126 |
|
| 1127 | if (var2.interactWithEntity(this, (EntityLivingBase) p_70998_1_)) {
|
| 1128 | if (var2.stackSize <= 0 && !this.capabilities.isCreativeMode) {
|
| 1129 | this.destroyCurrentEquippedItem();
|
| 1130 | }
|
| 1131 |
|
| 1132 | return true;
|
| 1133 | }
|
| 1134 | }
|
| 1135 |
|
| 1136 | return false;
|
| 1137 | } else {
|
| 1138 | if (var2 != null && var2 == this.getCurrentEquippedItem()) {
|
| 1139 | if (var2.stackSize <= 0 && !this.capabilities.isCreativeMode) {
|
| 1140 | this.destroyCurrentEquippedItem();
|
| 1141 | } else if (var2.stackSize < var3.stackSize && this.capabilities.isCreativeMode) {
|
| 1142 | var2.stackSize = var3.stackSize;
|
| 1143 | }
|
| 1144 | }
|
| 1145 |
|
| 1146 | return true;
|
| 1147 | }
|
| 1148 | }
|
| 1149 | }
|
| 1150 |
|
| 1151 | /**
|
| 1152 | * Returns the currently being used item by the player.
|
| 1153 | */
|
| 1154 | public ItemStack getCurrentEquippedItem() {
|
| 1155 | return this.inventory.getCurrentItem();
|
| 1156 | }
|
| 1157 |
|
| 1158 | /**
|
| 1159 | * Destroys the currently equipped item from the player's inventory.
|
| 1160 | */
|
| 1161 | public void destroyCurrentEquippedItem() {
|
| 1162 | this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack) null);
|
| 1163 | }
|
| 1164 |
|
| 1165 | /**
|
| 1166 | * Returns the Y Offset of this entity.
|
| 1167 | */
|
| 1168 | public double getYOffset() {
|
| 1169 | return -0.35D;
|
| 1170 | }
|
| 1171 |
|
| 1172 | /**
|
| 1173 | * Attacks for the player the targeted entity with the currently equipped
|
| 1174 | * item. The equipped item has hitEntity called on it. Args: targetEntity
|
| 1175 | */
|
| 1176 | public void attackTargetEntityWithCurrentItem(Entity targetEntity) {
|
| 1177 | if (targetEntity.canAttackWithItem()) {
|
| 1178 | if (!targetEntity.hitByEntity(this)) {
|
| 1179 | float var2 = (float) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
|
| 1180 | byte var3 = 0;
|
| 1181 | float enchantedCrit = 0.0F;
|
| 1182 | if (targetEntity instanceof EntityLivingBase) {
|
| 1183 | enchantedCrit = EnchantmentHelper.func_152377_a(this.getHeldItem(), ((EntityLivingBase) targetEntity).getCreatureAttribute());
|
| 1184 | } else {
|
| 1185 | enchantedCrit = EnchantmentHelper.func_152377_a(this.getHeldItem(), EnumCreatureAttribute.UNDEFINED);
|
| 1186 | }
|
| 1187 | int knockback = var3 + EnchantmentHelper.getRespiration(this);
|
| 1188 | if (this.isSprinting()) {
|
| 1189 | ++knockback;
|
| 1190 | }
|
| 1191 | if (var2 > 0.0F || enchantedCrit > 0.0F) {
|
| 1192 | boolean shouldCrit = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null && targetEntity instanceof EntityLivingBase;
|
| 1193 | if (shouldCrit && var2 > 0.0F) {
|
| 1194 | var2 *= 1.5F;
|
| 1195 | }
|
| 1196 | var2 += enchantedCrit;
|
| 1197 | boolean var6 = false;
|
| 1198 | int fire = EnchantmentHelper.getFireAspectModifier(this);
|
| 1199 | if (targetEntity instanceof EntityLivingBase && fire > 0 && !targetEntity.isBurning()) {
|
| 1200 | var6 = true;
|
| 1201 | targetEntity.setFire(1);
|
| 1202 | }
|
| 1203 | double targetMotionX = targetEntity.motionX;
|
| 1204 | double targetMotionY = targetEntity.motionY;
|
| 1205 | double targetMotionZ = targetEntity.motionZ;
|
| 1206 | boolean hasDamaged = targetEntity.attackEntityFrom(DamageSource.causePlayerDamage(this), var2);
|
| 1207 | if (hasDamaged) {
|
| 1208 | if (knockback > 0) {
|
| 1209 | targetEntity.addVelocity((double) (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F), 0.1D, (double) (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F) * (float) knockback * 0.5F));
|
| 1210 | //this.motionX *= 0.6D;
|
| 1211 | //this.motionZ *= 0.6D;
|
| 1212 | //this.setSprinting(false);
|
| 1213 | }
|
| 1214 | if (targetEntity instanceof EntityPlayerMP && targetEntity.velocityChanged) {
|
| 1215 | ((EntityPlayerMP) targetEntity).playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(targetEntity));
|
| 1216 | targetEntity.velocityChanged = false;
|
| 1217 | targetEntity.motionX = targetMotionX;
|
| 1218 | targetEntity.motionY = targetMotionY;
|
| 1219 | targetEntity.motionZ = targetMotionZ;
|
| 1220 | }
|
| 1221 | if (shouldCrit) {
|
| 1222 | this.onCriticalHit(targetEntity);
|
| 1223 | }
|
| 1224 | if (enchantedCrit > 0.0F) {
|
| 1225 | this.onEnchantmentCritical(targetEntity);
|
| 1226 | }
|
| 1227 | if (var2 >= 18.0F) {
|
| 1228 | this.triggerAchievement(AchievementList.overkill);
|
| 1229 | }
|
| 1230 | this.setLastAttacker(targetEntity);
|
| 1231 | if (targetEntity instanceof EntityLivingBase) {
|
| 1232 | EnchantmentHelper.func_151384_a((EntityLivingBase) targetEntity, this);
|
| 1233 | }
|
| 1234 | EnchantmentHelper.func_151385_b(this, targetEntity);
|
| 1235 | ItemStack currentItem = this.getCurrentEquippedItem();
|
| 1236 | Object targetEntityObject = targetEntity;
|
| 1237 | if (targetEntity instanceof EntityDragonPart) {
|
| 1238 | IEntityMultiPart var17 = ((EntityDragonPart) targetEntity).entityDragonObj;
|
| 1239 | if (var17 instanceof EntityLivingBase) {
|
| 1240 | targetEntityObject = (EntityLivingBase) var17;
|
| 1241 | }
|
| 1242 | }
|
| 1243 | if (currentItem != null && targetEntityObject instanceof EntityLivingBase) {
|
| 1244 | currentItem.hitEntity((EntityLivingBase) targetEntityObject, this);
|
| 1245 |
|
| 1246 | if (currentItem.stackSize <= 0) {
|
| 1247 | this.destroyCurrentEquippedItem();
|
| 1248 | }
|
| 1249 | }
|
| 1250 | if (targetEntity instanceof EntityLivingBase) {
|
| 1251 | this.addStat(StatList.damageDealtStat, Math.round(var2 * 10.0F));
|
| 1252 | if (fire > 0) {
|
| 1253 | targetEntity.setFire(fire * 4);
|
| 1254 | }
|
| 1255 | }
|
| 1256 | this.addExhaustion(0.3F);
|
| 1257 | } else if (var6) {
|
| 1258 | targetEntity.extinguish();
|
| 1259 | }
|
| 1260 | }
|
| 1261 | }
|
| 1262 | }
|
| 1263 | }
|
| 1264 |
|
| 1265 | /**
|
| 1266 | * Called when the player performs a critical hit on the Entity. Args:
|
| 1267 | * entity that was hit critically
|
| 1268 | */
|
| 1269 | public void onCriticalHit(Entity p_71009_1_) {
|
| 1270 | }
|
| 1271 |
|
| 1272 | public void onEnchantmentCritical(Entity p_71047_1_) {
|
| 1273 | }
|
| 1274 |
|
| 1275 | public void respawnPlayer() {
|
| 1276 | }
|
| 1277 |
|
| 1278 | /**
|
| 1279 | * Will get destroyed next tick.
|
| 1280 | */
|
| 1281 | public void setDead() {
|
| 1282 | super.setDead();
|
| 1283 | this.inventoryContainer.onContainerClosed(this);
|
| 1284 |
|
| 1285 | if (this.openContainer != null) {
|
| 1286 | this.openContainer.onContainerClosed(this);
|
| 1287 | }
|
| 1288 | }
|
| 1289 |
|
| 1290 | /**
|
| 1291 | * Checks if this entity is inside of an opaque block
|
| 1292 | */
|
| 1293 | public boolean isEntityInsideOpaqueBlock() {
|
| 1294 | return !this.sleeping && super.isEntityInsideOpaqueBlock();
|
| 1295 | }
|
| 1296 |
|
| 1297 | public boolean func_175144_cb() {
|
| 1298 | return false;
|
| 1299 | }
|
| 1300 |
|
| 1301 | /**
|
| 1302 | * Returns the GameProfile for this player
|
| 1303 | */
|
| 1304 | public GameProfile getGameProfile() {
|
| 1305 | return this.gameProfile;
|
| 1306 | }
|
| 1307 |
|
| 1308 | public EntityPlayer.EnumStatus func_180469_a(BlockPos p_180469_1_) {
|
| 1309 | if (!this.worldObj.isRemote) {
|
| 1310 | if (this.isPlayerSleeping() || !this.isEntityAlive()) {
|
| 1311 | return EntityPlayer.EnumStatus.OTHER_PROBLEM;
|
| 1312 | }
|
| 1313 |
|
| 1314 | if (!this.worldObj.provider.isSurfaceWorld()) {
|
| 1315 | return EntityPlayer.EnumStatus.NOT_POSSIBLE_HERE;
|
| 1316 | }
|
| 1317 |
|
| 1318 | if (this.worldObj.isDaytime()) {
|
| 1319 | return EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW;
|
| 1320 | }
|
| 1321 |
|
| 1322 | if (Math.abs(this.posX - (double) p_180469_1_.getX()) > 3.0D || Math.abs(this.posY - (double) p_180469_1_.getY()) > 2.0D || Math.abs(this.posZ - (double) p_180469_1_.getZ()) > 3.0D) {
|
| 1323 | return EntityPlayer.EnumStatus.TOO_FAR_AWAY;
|
| 1324 | }
|
| 1325 |
|
| 1326 | double var2 = 8.0D;
|
| 1327 | double var4 = 5.0D;
|
| 1328 | List var6 = this.worldObj.getEntitiesWithinAABB(EntityMob.class, new AxisAlignedBB((double) p_180469_1_.getX() - var2, (double) p_180469_1_.getY() - var4, (double) p_180469_1_.getZ() - var2, (double) p_180469_1_.getX() + var2, (double) p_180469_1_.getY() + var4, (double) p_180469_1_.getZ() + var2));
|
| 1329 |
|
| 1330 | if (!var6.isEmpty()) {
|
| 1331 | return EntityPlayer.EnumStatus.NOT_SAFE;
|
| 1332 | }
|
| 1333 | }
|
| 1334 |
|
| 1335 | if (this.isRiding()) {
|
| 1336 | this.mountEntity((Entity) null);
|
| 1337 | }
|
| 1338 |
|
| 1339 | this.setSize(0.2F, 0.2F);
|
| 1340 |
|
| 1341 | if (this.worldObj.isBlockLoaded(p_180469_1_)) {
|
| 1342 | EnumFacing var7 = (EnumFacing) this.worldObj.getBlockState(p_180469_1_).getValue(BlockDirectional.AGE);
|
| 1343 | float var3 = 0.5F;
|
| 1344 | float var8 = 0.5F;
|
| 1345 |
|
| 1346 | switch (EntityPlayer.SwitchEnumFacing.field_179420_a[var7.ordinal()]) {
|
| 1347 | case 1:
|
| 1348 | var8 = 0.9F;
|
| 1349 | break;
|
| 1350 |
|
| 1351 | case 2:
|
| 1352 | var8 = 0.1F;
|
| 1353 | break;
|
| 1354 |
|
| 1355 | case 3:
|
| 1356 | var3 = 0.1F;
|
| 1357 | break;
|
| 1358 |
|
| 1359 | case 4:
|
| 1360 | var3 = 0.9F;
|
| 1361 | }
|
| 1362 |
|
| 1363 | this.func_175139_a(var7);
|
| 1364 | this.setPosition((double) ((float) p_180469_1_.getX() + var3), (double) ((float) p_180469_1_.getY() + 0.6875F), (double) ((float) p_180469_1_.getZ() + var8));
|
| 1365 | } else {
|
| 1366 | this.setPosition((double) ((float) p_180469_1_.getX() + 0.5F), (double) ((float) p_180469_1_.getY() + 0.6875F), (double) ((float) p_180469_1_.getZ() + 0.5F));
|
| 1367 | }
|
| 1368 |
|
| 1369 | this.sleeping = true;
|
| 1370 | this.sleepTimer = 0;
|
| 1371 | this.playerLocation = p_180469_1_;
|
| 1372 | this.motionX = this.motionZ = this.motionY = 0.0D;
|
| 1373 |
|
| 1374 | if (!this.worldObj.isRemote) {
|
| 1375 | this.worldObj.updateAllPlayersSleepingFlag();
|
| 1376 | }
|
| 1377 |
|
| 1378 | return EntityPlayer.EnumStatus.OK;
|
| 1379 | }
|
| 1380 |
|
| 1381 | private void func_175139_a(EnumFacing p_175139_1_) {
|
| 1382 | this.field_71079_bU = 0.0F;
|
| 1383 | this.field_71089_bV = 0.0F;
|
| 1384 |
|
| 1385 | switch (EntityPlayer.SwitchEnumFacing.field_179420_a[p_175139_1_.ordinal()]) {
|
| 1386 | case 1:
|
| 1387 | this.field_71089_bV = -1.8F;
|
| 1388 | break;
|
| 1389 |
|
| 1390 | case 2:
|
| 1391 | this.field_71089_bV = 1.8F;
|
| 1392 | break;
|
| 1393 |
|
| 1394 | case 3:
|
| 1395 | this.field_71079_bU = 1.8F;
|
| 1396 | break;
|
| 1397 |
|
| 1398 | case 4:
|
| 1399 | this.field_71079_bU = -1.8F;
|
| 1400 | }
|
| 1401 | }
|
| 1402 |
|
| 1403 | /**
|
| 1404 | * Wake up the player if they're sleeping.
|
| 1405 | */
|
| 1406 | public void wakeUpPlayer(boolean p_70999_1_, boolean updateWorldFlag, boolean setSpawn) {
|
| 1407 | this.setSize(0.6F, 1.8F);
|
| 1408 | IBlockState var4 = this.worldObj.getBlockState(this.playerLocation);
|
| 1409 |
|
| 1410 | if (this.playerLocation != null && var4.getBlock() == Blocks.bed) {
|
| 1411 | this.worldObj.setBlockState(this.playerLocation, var4.withProperty(BlockBed.OCCUPIED_PROP, Boolean.valueOf(false)), 4);
|
| 1412 | BlockPos var5 = BlockBed.getSafeExitLocation(this.worldObj, this.playerLocation, 0);
|
| 1413 |
|
| 1414 | if (var5 == null) {
|
| 1415 | var5 = this.playerLocation.offsetUp();
|
| 1416 | }
|
| 1417 |
|
| 1418 | this.setPosition((double) ((float) var5.getX() + 0.5F), (double) ((float) var5.getY() + 0.1F), (double) ((float) var5.getZ() + 0.5F));
|
| 1419 | }
|
| 1420 |
|
| 1421 | this.sleeping = false;
|
| 1422 |
|
| 1423 | if (!this.worldObj.isRemote && updateWorldFlag) {
|
| 1424 | this.worldObj.updateAllPlayersSleepingFlag();
|
| 1425 | }
|
| 1426 |
|
| 1427 | this.sleepTimer = p_70999_1_ ? 0 : 100;
|
| 1428 |
|
| 1429 | if (setSpawn) {
|
| 1430 | this.func_180473_a(this.playerLocation, false);
|
| 1431 | }
|
| 1432 | }
|
| 1433 |
|
| 1434 | private boolean func_175143_p() {
|
| 1435 | return this.worldObj.getBlockState(this.playerLocation).getBlock() == Blocks.bed;
|
| 1436 | }
|
| 1437 |
|
| 1438 | public static BlockPos func_180467_a(World worldIn, BlockPos p_180467_1_, boolean p_180467_2_) {
|
| 1439 | if (worldIn.getBlockState(p_180467_1_).getBlock() != Blocks.bed) {
|
| 1440 | if (!p_180467_2_) {
|
| 1441 | return null;
|
| 1442 | } else {
|
| 1443 | Material var3 = worldIn.getBlockState(p_180467_1_).getBlock().getMaterial();
|
| 1444 | Material var4 = worldIn.getBlockState(p_180467_1_.offsetUp()).getBlock().getMaterial();
|
| 1445 | boolean var5 = !var3.isSolid() && !var3.isLiquid();
|
| 1446 | boolean var6 = !var4.isSolid() && !var4.isLiquid();
|
| 1447 | return var5 && var6 ? p_180467_1_ : null;
|
| 1448 | }
|
| 1449 | } else {
|
| 1450 | return BlockBed.getSafeExitLocation(worldIn, p_180467_1_, 0);
|
| 1451 | }
|
| 1452 | }
|
| 1453 |
|
| 1454 | /**
|
| 1455 | * Returns the orientation of the bed in degrees.
|
| 1456 | */
|
| 1457 | public float getBedOrientationInDegrees() {
|
| 1458 | if (this.playerLocation != null) {
|
| 1459 | EnumFacing var1 = (EnumFacing) this.worldObj.getBlockState(this.playerLocation).getValue(BlockDirectional.AGE);
|
| 1460 |
|
| 1461 | switch (EntityPlayer.SwitchEnumFacing.field_179420_a[var1.ordinal()]) {
|
| 1462 | case 1:
|
| 1463 | return 90.0F;
|
| 1464 |
|
| 1465 | case 2:
|
| 1466 | return 270.0F;
|
| 1467 |
|
| 1468 | case 3:
|
| 1469 | return 0.0F;
|
| 1470 |
|
| 1471 | case 4:
|
| 1472 | return 180.0F;
|
| 1473 | }
|
| 1474 | }
|
| 1475 |
|
| 1476 | return 0.0F;
|
| 1477 | }
|
| 1478 |
|
| 1479 | /**
|
| 1480 | * Returns whether player is sleeping or not
|
| 1481 | */
|
| 1482 | public boolean isPlayerSleeping() {
|
| 1483 | return this.sleeping;
|
| 1484 | }
|
| 1485 |
|
| 1486 | /**
|
| 1487 | * Returns whether or not the player is asleep and the screen has fully
|
| 1488 | * faded.
|
| 1489 | */
|
| 1490 | public boolean isPlayerFullyAsleep() {
|
| 1491 | return this.sleeping && this.sleepTimer >= 100;
|
| 1492 | }
|
| 1493 |
|
| 1494 | public int getSleepTimer() {
|
| 1495 | return this.sleepTimer;
|
| 1496 | }
|
| 1497 |
|
| 1498 | public void addChatComponentMessage(IChatComponent p_146105_1_) {
|
| 1499 | }
|
| 1500 |
|
| 1501 | public BlockPos func_180470_cg() {
|
| 1502 | return this.spawnChunk;
|
| 1503 | }
|
| 1504 |
|
| 1505 | public boolean isSpawnForced() {
|
| 1506 | return this.spawnForced;
|
| 1507 | }
|
| 1508 |
|
| 1509 | public void func_180473_a(BlockPos p_180473_1_, boolean p_180473_2_) {
|
| 1510 | if (p_180473_1_ != null) {
|
| 1511 | this.spawnChunk = p_180473_1_;
|
| 1512 | this.spawnForced = p_180473_2_;
|
| 1513 | } else {
|
| 1514 | this.spawnChunk = null;
|
| 1515 | this.spawnForced = false;
|
| 1516 | }
|
| 1517 | }
|
| 1518 |
|
| 1519 | /**
|
| 1520 | * Will trigger the specified trigger.
|
| 1521 | */
|
| 1522 | public void triggerAchievement(StatBase p_71029_1_) {
|
| 1523 | this.addStat(p_71029_1_, 1);
|
| 1524 | }
|
| 1525 |
|
| 1526 | /**
|
| 1527 | * Adds a value to a statistic field.
|
| 1528 | */
|
| 1529 | public void addStat(StatBase p_71064_1_, int p_71064_2_) {
|
| 1530 | }
|
| 1531 |
|
| 1532 | public void func_175145_a(StatBase p_175145_1_) {
|
| 1533 | }
|
| 1534 |
|
| 1535 | /**
|
| 1536 | * Causes this entity to do an upwards motion (jumping).
|
| 1537 | */
|
| 1538 | public void jump() {
|
| 1539 |
|
| 1540 | super.jump();
|
| 1541 | this.triggerAchievement(StatList.jumpStat);
|
| 1542 |
|
| 1543 | if (this.isSprinting()) {
|
| 1544 | this.addExhaustion(0.8F);
|
| 1545 | } else {
|
| 1546 | this.addExhaustion(0.2F);
|
| 1547 | }
|
| 1548 | }
|
| 1549 |
|
| 1550 | /**
|
| 1551 | * Moves the entity based on the specified heading. Args: strafe, forward
|
| 1552 | */
|
| 1553 | public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_) {
|
| 1554 | double var3 = this.posX;
|
| 1555 | double var5 = this.posY;
|
| 1556 | double var7 = this.posZ;
|
| 1557 |
|
| 1558 | if (this.capabilities.isFlying && this.ridingEntity == null) {
|
| 1559 | double var9 = this.motionY;
|
| 1560 | float var11 = this.jumpMovementFactor;
|
| 1561 | this.jumpMovementFactor = this.capabilities.getFlySpeed() * (float) (this.isSprinting() ? 2 : 1);
|
| 1562 | super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
| 1563 | this.motionY = var9 * 0.6D;
|
| 1564 | this.jumpMovementFactor = var11;
|
| 1565 | } else {
|
| 1566 | super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
|
| 1567 | }
|
| 1568 |
|
| 1569 | this.addMovementStat(this.posX - var3, this.posY - var5, this.posZ - var7);
|
| 1570 | }
|
| 1571 |
|
| 1572 | /**
|
| 1573 | * the movespeed used for the new AI system
|
| 1574 | */
|
| 1575 | public float getAIMoveSpeed() {
|
| 1576 | return (float) this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
|
| 1577 | }
|
| 1578 |
|
| 1579 | /**
|
| 1580 | * Adds a value to a movement statistic field - like run, walk, swin or
|
| 1581 | * climb.
|
| 1582 | */
|
| 1583 | public void addMovementStat(double p_71000_1_, double p_71000_3_, double p_71000_5_) {
|
| 1584 | if (this.ridingEntity == null) {
|
| 1585 | int var7;
|
| 1586 |
|
| 1587 | if (this.isInsideOfMaterial(Material.water)) {
|
| 1588 | var7 = Math.round(MathHelper.sqrt_double(p_71000_1_ * p_71000_1_ + p_71000_3_ * p_71000_3_ + p_71000_5_ * p_71000_5_) * 100.0F);
|
| 1589 |
|
| 1590 | if (var7 > 0) {
|
| 1591 | this.addStat(StatList.distanceDoveStat, var7);
|
| 1592 | this.addExhaustion(0.015F * (float) var7 * 0.01F);
|
| 1593 | }
|
| 1594 | } else if (this.isInWater()) {
|
| 1595 | var7 = Math.round(MathHelper.sqrt_double(p_71000_1_ * p_71000_1_ + p_71000_5_ * p_71000_5_) * 100.0F);
|
| 1596 |
|
| 1597 | if (var7 > 0) {
|
| 1598 | this.addStat(StatList.distanceSwumStat, var7);
|
| 1599 | this.addExhaustion(0.015F * (float) var7 * 0.01F);
|
| 1600 | }
|
| 1601 | } else if (this.isOnLadder()) {
|
| 1602 | if (p_71000_3_ > 0.0D) {
|
| 1603 | this.addStat(StatList.distanceClimbedStat, (int) Math.round(p_71000_3_ * 100.0D));
|
| 1604 | }
|
| 1605 | } else if (this.onGround) {
|
| 1606 | var7 = Math.round(MathHelper.sqrt_double(p_71000_1_ * p_71000_1_ + p_71000_5_ * p_71000_5_) * 100.0F);
|
| 1607 |
|
| 1608 | if (var7 > 0) {
|
| 1609 | this.addStat(StatList.distanceWalkedStat, var7);
|
| 1610 |
|
| 1611 | if (this.isSprinting()) {
|
| 1612 | this.addStat(StatList.distanceSprintedStat, var7);
|
| 1613 | this.addExhaustion(0.099999994F * (float) var7 * 0.01F);
|
| 1614 | } else {
|
| 1615 | if (this.isSneaking()) {
|
| 1616 | this.addStat(StatList.distanceCrouchedStat, var7);
|
| 1617 | }
|
| 1618 |
|
| 1619 | this.addExhaustion(0.01F * (float) var7 * 0.01F);
|
| 1620 | }
|
| 1621 | }
|
| 1622 | } else {
|
| 1623 | var7 = Math.round(MathHelper.sqrt_double(p_71000_1_ * p_71000_1_ + p_71000_5_ * p_71000_5_) * 100.0F);
|
| 1624 |
|
| 1625 | if (var7 > 25) {
|
| 1626 | this.addStat(StatList.distanceFlownStat, var7);
|
| 1627 | }
|
| 1628 | }
|
| 1629 | }
|
| 1630 | }
|
| 1631 |
|
| 1632 | /**
|
| 1633 | * Adds a value to a mounted movement statistic field - by minecart, boat,
|
| 1634 | * or pig.
|
| 1635 | */
|
| 1636 | private void addMountedMovementStat(double p_71015_1_, double p_71015_3_, double p_71015_5_) {
|
| 1637 | if (this.ridingEntity != null) {
|
| 1638 | int var7 = Math.round(MathHelper.sqrt_double(p_71015_1_ * p_71015_1_ + p_71015_3_ * p_71015_3_ + p_71015_5_ * p_71015_5_) * 100.0F);
|
| 1639 |
|
| 1640 | if (var7 > 0) {
|
| 1641 | if (this.ridingEntity instanceof EntityMinecart) {
|
| 1642 | this.addStat(StatList.distanceByMinecartStat, var7);
|
| 1643 |
|
| 1644 | if (this.startMinecartRidingCoordinate == null) {
|
| 1645 | this.startMinecartRidingCoordinate = new BlockPos(this);
|
| 1646 | } else if (this.startMinecartRidingCoordinate.distanceSq((double) MathHelper.floor_double(this.posX), (double) MathHelper.floor_double(this.posY), (double) MathHelper.floor_double(this.posZ)) >= 1000000.0D) {
|
| 1647 | this.triggerAchievement(AchievementList.onARail);
|
| 1648 | }
|
| 1649 | } else if (this.ridingEntity instanceof EntityBoat) {
|
| 1650 | this.addStat(StatList.distanceByBoatStat, var7);
|
| 1651 | } else if (this.ridingEntity instanceof EntityPig) {
|
| 1652 | this.addStat(StatList.distanceByPigStat, var7);
|
| 1653 | } else if (this.ridingEntity instanceof EntityHorse) {
|
| 1654 | this.addStat(StatList.distanceByHorseStat, var7);
|
| 1655 | }
|
| 1656 | }
|
| 1657 | }
|
| 1658 | }
|
| 1659 |
|
| 1660 | public void fall(float distance, float damageMultiplier) {
|
| 1661 | if (!this.capabilities.allowFlying) {
|
| 1662 | if (distance >= 2.0F) {
|
| 1663 | this.addStat(StatList.distanceFallenStat, (int) Math.round((double) distance * 100.0D));
|
| 1664 | }
|
| 1665 |
|
| 1666 | super.fall(distance, damageMultiplier);
|
| 1667 | }
|
| 1668 | }
|
| 1669 |
|
| 1670 | /**
|
| 1671 | * sets the players height back to normal after doing things like sleeping
|
| 1672 | * and dieing
|
| 1673 | */
|
| 1674 | public void resetHeight() {
|
| 1675 | if (!this.func_175149_v()) {
|
| 1676 | super.resetHeight();
|
| 1677 | }
|
| 1678 | }
|
| 1679 |
|
| 1680 | protected String func_146067_o(int p_146067_1_) {
|
| 1681 | return p_146067_1_ > 4 ? "game.player.hurt.fall.big" : "game.player.hurt.fall.small";
|
| 1682 | }
|
| 1683 |
|
| 1684 | /**
|
| 1685 | * This method gets called when the entity kills another one.
|
| 1686 | */
|
| 1687 | public void onKillEntity(EntityLivingBase entityLivingIn) {
|
| 1688 | if (entityLivingIn instanceof IMob) {
|
| 1689 | this.triggerAchievement(AchievementList.killEnemy);
|
| 1690 | }
|
| 1691 |
|
| 1692 | EntityList.EntityEggInfo var2 = (EntityList.EntityEggInfo) EntityList.entityEggs.get(Integer.valueOf(EntityList.getEntityID(entityLivingIn)));
|
| 1693 |
|
| 1694 | if (var2 != null) {
|
| 1695 | this.triggerAchievement(var2.field_151512_d);
|
| 1696 | }
|
| 1697 | }
|
| 1698 |
|
| 1699 | /**
|
| 1700 | * Sets the Entity inside a web block.
|
| 1701 | */
|
| 1702 | public void setInWeb() {
|
| 1703 | if (!this.capabilities.isFlying) {
|
| 1704 | super.setInWeb();
|
| 1705 | }
|
| 1706 | }
|
| 1707 |
|
| 1708 | public ItemStack getCurrentArmor(int p_82169_1_) {
|
| 1709 | return this.inventory.armorItemInSlot(p_82169_1_);
|
| 1710 | }
|
| 1711 |
|
| 1712 | /**
|
| 1713 | * Add experience points to player.
|
| 1714 | */
|
| 1715 | public void addExperience(int p_71023_1_) {
|
| 1716 | this.addScore(p_71023_1_);
|
| 1717 | int var2 = Integer.MAX_VALUE - this.experienceTotal;
|
| 1718 |
|
| 1719 | if (p_71023_1_ > var2) {
|
| 1720 | p_71023_1_ = var2;
|
| 1721 | }
|
| 1722 |
|
| 1723 | this.experience += (float) p_71023_1_ / (float) this.xpBarCap();
|
| 1724 |
|
| 1725 | for (this.experienceTotal += p_71023_1_; this.experience >= 1.0F; this.experience /= (float) this.xpBarCap()) {
|
| 1726 | this.experience = (this.experience - 1.0F) * (float) this.xpBarCap();
|
| 1727 | this.addExperienceLevel(1);
|
| 1728 | }
|
| 1729 | }
|
| 1730 |
|
| 1731 | public int func_175138_ci() {
|
| 1732 | return this.field_175152_f;
|
| 1733 | }
|
| 1734 |
|
| 1735 | public void func_71013_b(int p_71013_1_) {
|
| 1736 | this.experienceLevel -= p_71013_1_;
|
| 1737 |
|
| 1738 | if (this.experienceLevel < 0) {
|
| 1739 | this.experienceLevel = 0;
|
| 1740 | this.experience = 0.0F;
|
| 1741 | this.experienceTotal = 0;
|
| 1742 | }
|
| 1743 |
|
| 1744 | this.field_175152_f = this.rand.nextInt();
|
| 1745 | }
|
| 1746 |
|
| 1747 | /**
|
| 1748 | * Add experience levels to this player.
|
| 1749 | */
|
| 1750 | public void addExperienceLevel(int p_82242_1_) {
|
| 1751 | this.experienceLevel += p_82242_1_;
|
| 1752 |
|
| 1753 | if (this.experienceLevel < 0) {
|
| 1754 | this.experienceLevel = 0;
|
| 1755 | this.experience = 0.0F;
|
| 1756 | this.experienceTotal = 0;
|
| 1757 | }
|
| 1758 |
|
| 1759 | if (p_82242_1_ > 0 && this.experienceLevel % 5 == 0 && (float) this.field_82249_h < (float) this.ticksExisted - 100.0F) {
|
| 1760 | float var2 = this.experienceLevel > 30 ? 1.0F : (float) this.experienceLevel / 30.0F;
|
| 1761 | this.worldObj.playSoundAtEntity(this, "random.levelup", var2 * 0.75F, 1.0F);
|
| 1762 | this.field_82249_h = this.ticksExisted;
|
| 1763 | }
|
| 1764 | }
|
| 1765 |
|
| 1766 | /**
|
| 1767 | * This method returns the cap amount of experience that the experience bar
|
| 1768 | * can hold. With each level, the experience cap on the player's experience
|
| 1769 | * bar is raised by 10.
|
| 1770 | */
|
| 1771 | public int xpBarCap() {
|
| 1772 | return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
|
| 1773 | }
|
| 1774 |
|
| 1775 | /**
|
| 1776 | * increases exhaustion level by supplied amount
|
| 1777 | */
|
| 1778 | public void addExhaustion(float p_71020_1_) {
|
| 1779 | if (!this.capabilities.disableDamage) {
|
| 1780 | if (!this.worldObj.isRemote) {
|
| 1781 | this.foodStats.addExhaustion(p_71020_1_);
|
| 1782 | }
|
| 1783 | }
|
| 1784 | }
|
| 1785 |
|
| 1786 | /**
|
| 1787 | * Returns the player's FoodStats object.
|
| 1788 | */
|
| 1789 | public FoodStats getFoodStats() {
|
| 1790 | return this.foodStats;
|
| 1791 | }
|
| 1792 |
|
| 1793 | public boolean canEat(boolean p_71043_1_) {
|
| 1794 | return (p_71043_1_ || this.foodStats.needFood()) && !this.capabilities.disableDamage;
|
| 1795 | }
|
| 1796 |
|
| 1797 | /**
|
| 1798 | * Checks if the player's health is not full and not zero.
|
| 1799 | */
|
| 1800 | public boolean shouldHeal() {
|
| 1801 | return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth();
|
| 1802 | }
|
| 1803 |
|
| 1804 | /**
|
| 1805 | * sets the itemInUse when the use item button is clicked. Args: itemstack,
|
| 1806 | * int maxItemUseDuration
|
| 1807 | */
|
| 1808 | public void setItemInUse(ItemStack p_71008_1_, int p_71008_2_) {
|
| 1809 | if (p_71008_1_ != this.itemInUse) {
|
| 1810 | this.itemInUse = p_71008_1_;
|
| 1811 | this.itemInUseCount = p_71008_2_;
|
| 1812 |
|
| 1813 | if (!this.worldObj.isRemote) {
|
| 1814 | this.setEating(true);
|
| 1815 | }
|
| 1816 | }
|
| 1817 | }
|
| 1818 |
|
| 1819 | public boolean func_175142_cm() {
|
| 1820 | return this.capabilities.allowEdit;
|
| 1821 | }
|
| 1822 |
|
| 1823 | public boolean func_175151_a(BlockPos p_175151_1_, EnumFacing p_175151_2_, ItemStack p_175151_3_) {
|
| 1824 | if (this.capabilities.allowEdit) {
|
| 1825 | return true;
|
| 1826 | } else if (p_175151_3_ == null) {
|
| 1827 | return false;
|
| 1828 | } else {
|
| 1829 | BlockPos var4 = p_175151_1_.offset(p_175151_2_.getOpposite());
|
| 1830 | Block var5 = this.worldObj.getBlockState(var4).getBlock();
|
| 1831 | return p_175151_3_.canPlaceOn(var5) || p_175151_3_.canEditBlocks();
|
| 1832 | }
|
| 1833 | }
|
| 1834 |
|
| 1835 | /**
|
| 1836 | * Get the experience points the entity currently has.
|
| 1837 | */
|
| 1838 | protected int getExperiencePoints(EntityPlayer p_70693_1_) {
|
| 1839 | if (this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
|
| 1840 | return 0;
|
| 1841 | } else {
|
| 1842 | int var2 = this.experienceLevel * 7;
|
| 1843 | return var2 > 100 ? 100 : var2;
|
| 1844 | }
|
| 1845 | }
|
| 1846 |
|
| 1847 | /**
|
| 1848 | * Only use is to identify if class is an instance of player for experience
|
| 1849 | * dropping
|
| 1850 | */
|
| 1851 | protected boolean isPlayer() {
|
| 1852 | return true;
|
| 1853 | }
|
| 1854 |
|
| 1855 | public boolean getAlwaysRenderNameTagForRender() {
|
| 1856 | return true;
|
| 1857 | }
|
| 1858 |
|
| 1859 | /**
|
| 1860 | * Copies the values from the given player into this player if boolean par2
|
| 1861 | * is true. Always clones Ender Chest Inventory.
|
| 1862 | */
|
| 1863 | public void clonePlayer(EntityPlayer p_71049_1_, boolean p_71049_2_) {
|
| 1864 | if (p_71049_2_) {
|
| 1865 | this.inventory.copyInventory(p_71049_1_.inventory);
|
| 1866 | this.setHealth(p_71049_1_.getHealth());
|
| 1867 | this.foodStats = p_71049_1_.foodStats;
|
| 1868 | this.experienceLevel = p_71049_1_.experienceLevel;
|
| 1869 | this.experienceTotal = p_71049_1_.experienceTotal;
|
| 1870 | this.experience = p_71049_1_.experience;
|
| 1871 | this.setScore(p_71049_1_.getScore());
|
| 1872 | this.teleportDirection = p_71049_1_.teleportDirection;
|
| 1873 | } else if (this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
|
| 1874 | this.inventory.copyInventory(p_71049_1_.inventory);
|
| 1875 | this.experienceLevel = p_71049_1_.experienceLevel;
|
| 1876 | this.experienceTotal = p_71049_1_.experienceTotal;
|
| 1877 | this.experience = p_71049_1_.experience;
|
| 1878 | this.setScore(p_71049_1_.getScore());
|
| 1879 | }
|
| 1880 |
|
| 1881 | this.theInventoryEnderChest = p_71049_1_.theInventoryEnderChest;
|
| 1882 | this.getDataWatcher().updateObject(10, Byte.valueOf(p_71049_1_.getDataWatcher().getWatchableObjectByte(10)));
|
| 1883 | }
|
| 1884 |
|
| 1885 | /**
|
| 1886 | * returns if this entity triggers Block.onEntityWalking on the blocks they
|
| 1887 | * walk on. used for spiders and wolves to prevent them from trampling crops
|
| 1888 | */
|
| 1889 | protected boolean canTriggerWalking() {
|
| 1890 | return !this.capabilities.isFlying;
|
| 1891 | }
|
| 1892 |
|
| 1893 | /**
|
| 1894 | * Sends the player's abilities to the server (if there is one).
|
| 1895 | */
|
| 1896 | public void sendPlayerAbilities() {
|
| 1897 | }
|
| 1898 |
|
| 1899 | /**
|
| 1900 | * Sets the player's game mode and sends it to them.
|
| 1901 | */
|
| 1902 | public void setGameType(WorldSettings.GameType gameType) {
|
| 1903 | }
|
| 1904 |
|
| 1905 | /**
|
| 1906 | * Gets the name of this command sender (usually username, but possibly
|
| 1907 | * "Rcon")
|
| 1908 | */
|
| 1909 | public String getName() {
|
| 1910 | return this.gameProfile.getName();
|
| 1911 | }
|
| 1912 |
|
| 1913 | /**
|
| 1914 | * Returns the InventoryEnderChest of this player.
|
| 1915 | */
|
| 1916 | public InventoryEnderChest getInventoryEnderChest() {
|
| 1917 | return this.theInventoryEnderChest;
|
| 1918 | }
|
| 1919 |
|
| 1920 | /**
|
| 1921 | * 0: Tool in Hand; 1-4: Armor
|
| 1922 | */
|
| 1923 | public ItemStack getEquipmentInSlot(int p_71124_1_) {
|
| 1924 | return p_71124_1_ == 0 ? this.inventory.getCurrentItem() : this.inventory.armorInventory[p_71124_1_ - 1];
|
| 1925 | }
|
| 1926 |
|
| 1927 | /**
|
| 1928 | * Returns the item that this EntityLiving is holding, if any.
|
| 1929 | */
|
| 1930 | public ItemStack getHeldItem() {
|
| 1931 | return this.inventory.getCurrentItem();
|
| 1932 | }
|
| 1933 |
|
| 1934 | /**
|
| 1935 | * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is
|
| 1936 | * armor. Params: Item, slot
|
| 1937 | */
|
| 1938 | public void setCurrentItemOrArmor(int slotIn, ItemStack itemStackIn) {
|
| 1939 | this.inventory.armorInventory[slotIn] = itemStackIn;
|
| 1940 | }
|
| 1941 |
|
| 1942 | /**
|
| 1943 | * Only used by renderer in EntityLivingBase subclasses. Determines if an
|
| 1944 | * entity is visible or not to a specfic player, if the entity is normally
|
| 1945 | * invisible. For EntityLivingBase subclasses, returning false when
|
| 1946 | * invisible will render the entity semitransparent.
|
| 1947 | */
|
| 1948 | public boolean isInvisibleToPlayer(EntityPlayer playerIn) {
|
| 1949 | if (!this.isInvisible()) {
|
| 1950 | return false;
|
| 1951 | } else if (playerIn.func_175149_v()) {
|
| 1952 | return false;
|
| 1953 | } else {
|
| 1954 | Team var2 = this.getTeam();
|
| 1955 | return var2 == null || playerIn == null || playerIn.getTeam() != var2 || !var2.func_98297_h();
|
| 1956 | }
|
| 1957 | }
|
| 1958 |
|
| 1959 | public abstract boolean func_175149_v();
|
| 1960 |
|
| 1961 | /**
|
| 1962 | * returns the inventory of this entity (only used in EntityPlayerMP it
|
| 1963 | * seems)
|
| 1964 | */
|
| 1965 | public ItemStack[] getInventory() {
|
| 1966 | return this.inventory.armorInventory;
|
| 1967 | }
|
| 1968 |
|
| 1969 | public boolean isPushedByWater() {
|
| 1970 | return !this.capabilities.isFlying;
|
| 1971 | }
|
| 1972 |
|
| 1973 | public Scoreboard getWorldScoreboard() {
|
| 1974 | return this.worldObj.getScoreboard();
|
| 1975 | }
|
| 1976 |
|
| 1977 | public Team getTeam() {
|
| 1978 | return this.getWorldScoreboard().getPlayersTeam(this.getName());
|
| 1979 | }
|
| 1980 |
|
| 1981 | public IChatComponent getDisplayName() {
|
| 1982 | ChatComponentText var1 = new ChatComponentText(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getName()));
|
| 1983 | var1.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
|
| 1984 | var1.getChatStyle().setChatHoverEvent(this.func_174823_aP());
|
| 1985 | var1.getChatStyle().setInsertion(this.getName());
|
| 1986 | return var1;
|
| 1987 | }
|
| 1988 |
|
| 1989 | public float getEyeHeight() {
|
| 1990 | float var1 = 1.62F;
|
| 1991 |
|
| 1992 | if (this.isPlayerSleeping()) {
|
| 1993 | var1 = 0.2F;
|
| 1994 | }
|
| 1995 |
|
| 1996 | if (this.isSneaking()) {
|
| 1997 | var1 -= 0.08F;
|
| 1998 | }
|
| 1999 |
|
| 2000 | return var1;
|
| 2001 | }
|
| 2002 |
|
| 2003 | public void setAbsorptionAmount(float p_110149_1_) {
|
| 2004 | if (p_110149_1_ < 0.0F) {
|
| 2005 | p_110149_1_ = 0.0F;
|
| 2006 | }
|
| 2007 |
|
| 2008 | this.getDataWatcher().updateObject(17, Float.valueOf(p_110149_1_));
|
| 2009 | }
|
| 2010 |
|
| 2011 | public float getAbsorptionAmount() {
|
| 2012 | return this.getDataWatcher().getWatchableObjectFloat(17);
|
| 2013 | }
|
| 2014 |
|
| 2015 | /**
|
| 2016 | * Gets a players UUID given their GameProfie
|
| 2017 | */
|
| 2018 | public static UUID getUUID(GameProfile p_146094_0_) {
|
| 2019 | UUID var1 = p_146094_0_.getId();
|
| 2020 |
|
| 2021 | if (var1 == null) {
|
| 2022 | var1 = func_175147_b(p_146094_0_.getName());
|
| 2023 | }
|
| 2024 |
|
| 2025 | return var1;
|
| 2026 | }
|
| 2027 |
|
| 2028 | public static UUID func_175147_b(String p_175147_0_) {
|
| 2029 | return UUID.nameUUIDFromBytes(("OfflinePlayer:" + p_175147_0_).getBytes(Charsets.UTF_8));
|
| 2030 | }
|
| 2031 |
|
| 2032 | public boolean func_175146_a(LockCode p_175146_1_) {
|
| 2033 | if (p_175146_1_.isEmpty()) {
|
| 2034 | return true;
|
| 2035 | } else {
|
| 2036 | ItemStack var2 = this.getCurrentEquippedItem();
|
| 2037 | return var2 != null && var2.hasDisplayName() ? var2.getDisplayName().equals(p_175146_1_.getLock()) : false;
|
| 2038 | }
|
| 2039 | }
|
| 2040 |
|
| 2041 | public boolean func_175148_a(EnumPlayerModelParts p_175148_1_) {
|
| 2042 | return (this.getDataWatcher().getWatchableObjectByte(10) & p_175148_1_.func_179327_a()) == p_175148_1_.func_179327_a();
|
| 2043 | }
|
| 2044 |
|
| 2045 | public boolean sendCommandFeedback() {
|
| 2046 | return MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("sendCommandFeedback");
|
| 2047 | }
|
| 2048 |
|
| 2049 | public boolean func_174820_d(int p_174820_1_, ItemStack p_174820_2_) {
|
| 2050 | if (p_174820_1_ >= 0 && p_174820_1_ < this.inventory.mainInventory.length) {
|
| 2051 | this.inventory.setInventorySlotContents(p_174820_1_, p_174820_2_);
|
| 2052 | return true;
|
| 2053 | } else {
|
| 2054 | int var3 = p_174820_1_ - 100;
|
| 2055 | int var4;
|
| 2056 |
|
| 2057 | if (var3 >= 0 && var3 < this.inventory.armorInventory.length) {
|
| 2058 | var4 = var3 + 1;
|
| 2059 |
|
| 2060 | if (p_174820_2_ != null && p_174820_2_.getItem() != null) {
|
| 2061 | if (p_174820_2_.getItem() instanceof ItemArmor) {
|
| 2062 | if (EntityLiving.getArmorPosition(p_174820_2_) != var4) {
|
| 2063 | return false;
|
| 2064 | }
|
| 2065 | } else if (var4 != 4 || p_174820_2_.getItem() != Items.skull && !(p_174820_2_.getItem() instanceof ItemBlock)) {
|
| 2066 | return false;
|
| 2067 | }
|
| 2068 | }
|
| 2069 |
|
| 2070 | this.inventory.setInventorySlotContents(var3 + this.inventory.mainInventory.length, p_174820_2_);
|
| 2071 | return true;
|
| 2072 | } else {
|
| 2073 | var4 = p_174820_1_ - 200;
|
| 2074 |
|
| 2075 | if (var4 >= 0 && var4 < this.theInventoryEnderChest.getSizeInventory()) {
|
| 2076 | this.theInventoryEnderChest.setInventorySlotContents(var4, p_174820_2_);
|
| 2077 | return true;
|
| 2078 | } else {
|
| 2079 | return false;
|
| 2080 | }
|
| 2081 | }
|
| 2082 | }
|
| 2083 | }
|
| 2084 |
|
| 2085 | public boolean func_175140_cp() {
|
| 2086 | return this.field_175153_bG;
|
| 2087 | }
|
| 2088 |
|
| 2089 | public void func_175150_k(boolean p_175150_1_) {
|
| 2090 | this.field_175153_bG = p_175150_1_;
|
| 2091 | }
|
| 2092 |
|
| 2093 | public static enum EnumChatVisibility {
|
| 2094 | FULL("FULL", 0, 0, "options.chat.visibility.full"), SYSTEM("SYSTEM", 1, 1, "options.chat.visibility.system"), HIDDEN("HIDDEN", 2, 2, "options.chat.visibility.hidden");
|
| 2095 | private static final EntityPlayer.EnumChatVisibility[] field_151432_d = new EntityPlayer.EnumChatVisibility[values().length];
|
| 2096 | private final int chatVisibility;
|
| 2097 | private final String resourceKey;
|
| 2098 |
|
| 2099 | private static final EntityPlayer.EnumChatVisibility[] $VALUES = new EntityPlayer.EnumChatVisibility[]{FULL, SYSTEM, HIDDEN};
|
| 2100 | private static final String __OBFID = "CL_00001714";
|
| 2101 |
|
| 2102 | private EnumChatVisibility(String p_i45323_1_, int p_i45323_2_, int p_i45323_3_, String p_i45323_4_) {
|
| 2103 | this.chatVisibility = p_i45323_3_;
|
| 2104 | this.resourceKey = p_i45323_4_;
|
| 2105 | }
|
| 2106 |
|
| 2107 | public int getChatVisibility() {
|
| 2108 | return this.chatVisibility;
|
| 2109 | }
|
| 2110 |
|
| 2111 | public static EntityPlayer.EnumChatVisibility getEnumChatVisibility(int p_151426_0_) {
|
| 2112 | return field_151432_d[p_151426_0_ % field_151432_d.length];
|
| 2113 | }
|
| 2114 |
|
| 2115 | public String getResourceKey() {
|
| 2116 | return this.resourceKey;
|
| 2117 | }
|
| 2118 |
|
| 2119 | static {
|
| 2120 | EntityPlayer.EnumChatVisibility[] var0 = values();
|
| 2121 | int var1 = var0.length;
|
| 2122 |
|
| 2123 | for (int var2 = 0; var2 < var1; ++var2) {
|
| 2124 | EntityPlayer.EnumChatVisibility var3 = var0[var2];
|
| 2125 | field_151432_d[var3.chatVisibility] = var3;
|
| 2126 | }
|
| 2127 | }
|
| 2128 | }
|
| 2129 |
|
| 2130 | public static enum EnumStatus {
|
| 2131 | OK("OK", 0), NOT_POSSIBLE_HERE("NOT_POSSIBLE_HERE", 1), NOT_POSSIBLE_NOW("NOT_POSSIBLE_NOW", 2), TOO_FAR_AWAY("TOO_FAR_AWAY", 3), OTHER_PROBLEM("OTHER_PROBLEM", 4), NOT_SAFE("NOT_SAFE", 5);
|
| 2132 |
|
| 2133 | private static final EntityPlayer.EnumStatus[] $VALUES = new EntityPlayer.EnumStatus[]{OK, NOT_POSSIBLE_HERE, NOT_POSSIBLE_NOW, TOO_FAR_AWAY, OTHER_PROBLEM, NOT_SAFE};
|
| 2134 | private static final String __OBFID = "CL_00001712";
|
| 2135 |
|
| 2136 | private EnumStatus(String p_i1751_1_, int p_i1751_2_) {
|
| 2137 | }
|
| 2138 | }
|
| 2139 |
|
| 2140 | static final class SwitchEnumFacing {
|
| 2141 | static final int[] field_179420_a = new int[EnumFacing.values().length];
|
| 2142 | private static final String __OBFID = "CL_00002188";
|
| 2143 |
|
| 2144 | static {
|
| 2145 | try {
|
| 2146 | field_179420_a[EnumFacing.SOUTH.ordinal()] = 1;
|
| 2147 | } catch (NoSuchFieldError var4) {
|
| 2148 | ;
|
| 2149 | }
|
| 2150 |
|
| 2151 | try {
|
| 2152 | field_179420_a[EnumFacing.NORTH.ordinal()] = 2;
|
| 2153 | } catch (NoSuchFieldError var3) {
|
| 2154 | ;
|
| 2155 | }
|
| 2156 |
|
| 2157 | try {
|
| 2158 | field_179420_a[EnumFacing.WEST.ordinal()] = 3;
|
| 2159 | } catch (NoSuchFieldError var2) {
|
| 2160 | ;
|
| 2161 | }
|
| 2162 |
|
| 2163 | try {
|
| 2164 | field_179420_a[EnumFacing.EAST.ordinal()] = 4;
|
| 2165 | } catch (NoSuchFieldError var1) {
|
| 2166 | ;
|
| 2167 | }
|
| 2168 | }
|
| 2169 | }
|
| 2170 | }
|