broken-arrow

Untitled

Dec 4th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 77.36 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by FernFlower decompiler)
  4. //
  5.  
  6. package net.minecraft.world.entity.player;
  7.  
  8. import com.destroystokyo.paper.event.player.PlayerReadyArrowEvent;
  9. import com.google.common.collect.ImmutableList;
  10. import com.google.common.collect.ImmutableMap;
  11. import com.google.common.collect.Lists;
  12. import com.mojang.authlib.GameProfile;
  13. import com.mojang.datafixers.util.Either;
  14. import io.papermc.paper.event.player.PlayerDeepSleepEvent;
  15. import java.nio.charset.StandardCharsets;
  16. import java.util.Collection;
  17. import java.util.Iterator;
  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.Optional;
  21. import java.util.OptionalInt;
  22. import java.util.UUID;
  23. import java.util.function.Predicate;
  24. import javax.annotation.Nullable;
  25. import net.minecraft.SharedConstants;
  26. import net.minecraft.SystemUtils;
  27. import net.minecraft.advancements.CriterionTriggers;
  28. import net.minecraft.core.BlockPosition;
  29. import net.minecraft.core.EnumDirection;
  30. import net.minecraft.core.particles.ParticleParam;
  31. import net.minecraft.core.particles.Particles;
  32. import net.minecraft.nbt.NBTTagCompound;
  33. import net.minecraft.nbt.NBTTagList;
  34. import net.minecraft.network.chat.ChatClickable;
  35. import net.minecraft.network.chat.ChatComponentText;
  36. import net.minecraft.network.chat.ChatMessage;
  37. import net.minecraft.network.chat.IChatBaseComponent;
  38. import net.minecraft.network.chat.IChatMutableComponent;
  39. import net.minecraft.network.chat.ChatClickable.EnumClickAction;
  40. import net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity;
  41. import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect;
  42. import net.minecraft.network.syncher.DataWatcher;
  43. import net.minecraft.network.syncher.DataWatcherObject;
  44. import net.minecraft.network.syncher.DataWatcherRegistry;
  45. import net.minecraft.resources.MinecraftKey;
  46. import net.minecraft.server.level.EntityPlayer;
  47. import net.minecraft.server.level.WorldServer;
  48. import net.minecraft.sounds.SoundCategory;
  49. import net.minecraft.sounds.SoundEffect;
  50. import net.minecraft.sounds.SoundEffects;
  51. import net.minecraft.stats.Statistic;
  52. import net.minecraft.stats.StatisticList;
  53. import net.minecraft.tags.Tag;
  54. import net.minecraft.tags.TagsFluid;
  55. import net.minecraft.util.MathHelper;
  56. import net.minecraft.util.Unit;
  57. import net.minecraft.world.EnumDifficulty;
  58. import net.minecraft.world.EnumHand;
  59. import net.minecraft.world.EnumInteractionResult;
  60. import net.minecraft.world.IInventory;
  61. import net.minecraft.world.ITileInventory;
  62. import net.minecraft.world.damagesource.DamageSource;
  63. import net.minecraft.world.effect.MobEffect;
  64. import net.minecraft.world.effect.MobEffectUtil;
  65. import net.minecraft.world.effect.MobEffects;
  66. import net.minecraft.world.entity.Entity;
  67. import net.minecraft.world.entity.EntityInsentient;
  68. import net.minecraft.world.entity.EntityLiving;
  69. import net.minecraft.world.entity.EntityPose;
  70. import net.minecraft.world.entity.EntitySize;
  71. import net.minecraft.world.entity.EntityTameableAnimal;
  72. import net.minecraft.world.entity.EntityTypes;
  73. import net.minecraft.world.entity.EnumItemSlot;
  74. import net.minecraft.world.entity.EnumMainHand;
  75. import net.minecraft.world.entity.EnumMonsterType;
  76. import net.minecraft.world.entity.EnumMoveType;
  77. import net.minecraft.world.entity.SlotAccess;
  78. import net.minecraft.world.entity.Entity.MovementEmission;
  79. import net.minecraft.world.entity.Entity.RemovalReason;
  80. import net.minecraft.world.entity.EnumItemSlot.Function;
  81. import net.minecraft.world.entity.ai.attributes.AttributeBase;
  82. import net.minecraft.world.entity.ai.attributes.GenericAttributes;
  83. import net.minecraft.world.entity.ai.attributes.AttributeProvider.Builder;
  84. import net.minecraft.world.entity.animal.EntityParrot;
  85. import net.minecraft.world.entity.animal.EntityPig;
  86. import net.minecraft.world.entity.animal.horse.EntityHorseAbstract;
  87. import net.minecraft.world.entity.boss.EntityComplexPart;
  88. import net.minecraft.world.entity.decoration.EntityArmorStand;
  89. import net.minecraft.world.entity.item.EntityItem;
  90. import net.minecraft.world.entity.monster.EntityStrider;
  91. import net.minecraft.world.entity.projectile.EntityFishingHook;
  92. import net.minecraft.world.entity.vehicle.EntityBoat;
  93. import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
  94. import net.minecraft.world.food.FoodMetaData;
  95. import net.minecraft.world.inventory.ClickAction;
  96. import net.minecraft.world.inventory.Container;
  97. import net.minecraft.world.inventory.ContainerPlayer;
  98. import net.minecraft.world.inventory.InventoryEnderChest;
  99. import net.minecraft.world.item.ItemAxe;
  100. import net.minecraft.world.item.ItemCooldown;
  101. import net.minecraft.world.item.ItemElytra;
  102. import net.minecraft.world.item.ItemProjectileWeapon;
  103. import net.minecraft.world.item.ItemStack;
  104. import net.minecraft.world.item.ItemSword;
  105. import net.minecraft.world.item.ItemWorldMap;
  106. import net.minecraft.world.item.Items;
  107. import net.minecraft.world.item.crafting.IRecipe;
  108. import net.minecraft.world.item.enchantment.EnchantmentManager;
  109. import net.minecraft.world.item.trading.MerchantRecipeList;
  110. import net.minecraft.world.level.CommandBlockListenerAbstract;
  111. import net.minecraft.world.level.EnumGamemode;
  112. import net.minecraft.world.level.GameRules;
  113. import net.minecraft.world.level.World;
  114. import net.minecraft.world.level.block.Block;
  115. import net.minecraft.world.level.block.BlockBed;
  116. import net.minecraft.world.level.block.BlockRespawnAnchor;
  117. import net.minecraft.world.level.block.entity.TileEntityCommand;
  118. import net.minecraft.world.level.block.entity.TileEntityJigsaw;
  119. import net.minecraft.world.level.block.entity.TileEntitySign;
  120. import net.minecraft.world.level.block.entity.TileEntityStructure;
  121. import net.minecraft.world.level.block.state.IBlockData;
  122. import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock;
  123. import net.minecraft.world.level.saveddata.maps.WorldMap;
  124. import net.minecraft.world.phys.AxisAlignedBB;
  125. import net.minecraft.world.phys.Vec3D;
  126. import net.minecraft.world.scores.Scoreboard;
  127. import net.minecraft.world.scores.ScoreboardTeam;
  128. import org.bukkit.Bukkit;
  129. import org.bukkit.OfflinePlayer;
  130. import org.bukkit.craftbukkit.v1_17_R1.entity.CraftHumanEntity;
  131. import org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory;
  132. import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
  133. import org.bukkit.craftbukkit.v1_17_R1.util.CraftVector;
  134. import org.bukkit.entity.Item;
  135. import org.bukkit.entity.Player;
  136. import org.bukkit.event.entity.EntityCombustByEntityEvent;
  137. import org.bukkit.event.entity.EntityExhaustionEvent;
  138. import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
  139. import org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason;
  140. import org.bukkit.event.entity.EntityPotionEffectEvent.Cause;
  141. import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
  142. import org.bukkit.event.inventory.InventoryCloseEvent.Reason;
  143. import org.bukkit.event.player.PlayerDropItemEvent;
  144. import org.bukkit.event.player.PlayerVelocityEvent;
  145. import org.bukkit.scoreboard.Team;
  146. import org.bukkit.util.Vector;
  147.  
  148. public abstract class EntityHuman extends EntityLiving {
  149.     public static final String bE = "OfflinePlayer:";
  150.     public static final int bF = 16;
  151.     public static final int bG = 20;
  152.     public static final int bH = 100;
  153.     public static final int bI = 10;
  154.     public static final int bJ = 200;
  155.     public static final float bK = 1.5F;
  156.     public static final float bL = 0.6F;
  157.     public static final float bM = 0.6F;
  158.     public static final float bN = 1.62F;
  159.     public static final EntitySize bO = EntitySize.b(0.6F, 1.8F);
  160.     private static final Map<EntityPose, EntitySize> b;
  161.     private static final int c = 25;
  162.     private static final DataWatcherObject<Float> d;
  163.     private static final DataWatcherObject<Integer> e;
  164.     public static final DataWatcherObject<Byte> bP;
  165.     protected static final DataWatcherObject<Byte> bQ;
  166.     protected static final DataWatcherObject<NBTTagCompound> bR;
  167.     protected static final DataWatcherObject<NBTTagCompound> bS;
  168.     private long f;
  169.     private final PlayerInventory co = new PlayerInventory(this);
  170.     protected InventoryEnderChest bT = new InventoryEnderChest(this);
  171.     public final ContainerPlayer bU;
  172.     public Container bV;
  173.     protected FoodMetaData bW = new FoodMetaData(this);
  174.     protected int bX;
  175.     public float bY;
  176.     public float bZ;
  177.     public int ca;
  178.     public double cb;
  179.     public double cc;
  180.     public double cd;
  181.     public double ce;
  182.     public double cf;
  183.     public double cg;
  184.     public int cp;
  185.     protected boolean ch;
  186.     private final PlayerAbilities cq = new PlayerAbilities();
  187.     public int ci;
  188.     public int cj;
  189.     public float ck;
  190.     protected int cl;
  191.     protected final float cm = 0.02F;
  192.     private int cr;
  193.     public GameProfile cs;
  194.     private boolean ct;
  195.     private ItemStack cu;
  196.     private final ItemCooldown cv;
  197.     @Nullable
  198.     public EntityFishingHook cn;
  199.     public boolean affectsSpawning = true;
  200.     public boolean fauxSleeping;
  201.     public int oldLevel = -1;
  202.  
  203.     public CraftHumanEntity getBukkitEntity() {
  204.         return (CraftHumanEntity)super.getBukkitEntity();
  205.     }
  206.  
  207.     public EntityHuman(World world, BlockPosition pos, float yaw, GameProfile profile) {
  208.         super(EntityTypes.bi, world);
  209.         this.cu = ItemStack.b;
  210.         this.cv = this.j();
  211.         this.a_(a(profile));
  212.         this.cs = profile;
  213.         this.bU = new ContainerPlayer(this.co, !world.y, this);
  214.         this.bV = this.bU;
  215.         this.setPositionRotation((double)pos.getX() + 0.5D, (double)(pos.getY() + 1), (double)pos.getZ() + 0.5D, yaw, 0.0F);
  216.         super.bk = 180.0F;
  217.     }
  218.  
  219.     public boolean a(World world, BlockPosition pos, EnumGamemode gameMode) {
  220.         if (!gameMode.e()) {
  221.             return false;
  222.         } else if (gameMode == EnumGamemode.d) {
  223.             return true;
  224.         } else if (this.fv()) {
  225.             return false;
  226.         } else {
  227.             ItemStack itemstack = this.getItemInMainHand();
  228.             return itemstack.isEmpty() || !itemstack.a(world.r(), new ShapeDetectorBlock(world, pos, false));
  229.         }
  230.     }
  231.  
  232.     public static Builder eY() {
  233.         return EntityLiving.dq().a(GenericAttributes.f, 1.0D).a(GenericAttributes.d, 0.10000000149011612D).a(GenericAttributes.h).a(GenericAttributes.k);
  234.     }
  235.  
  236.     protected void initDatawatcher() {
  237.         super.initDatawatcher();
  238.         super.Y.register(d, 0.0F);
  239.         super.Y.register(e, 0);
  240.         super.Y.register(bP, (byte)0);
  241.         super.Y.register(bQ, (byte)1);
  242.         super.Y.register(bR, new NBTTagCompound());
  243.         super.Y.register(bS, new NBTTagCompound());
  244.     }
  245.  
  246.     public void tick() {
  247.         super.P = this.isSpectator();
  248.         if (this.isSpectator()) {
  249.             super.z = false;
  250.         }
  251.  
  252.         if (this.ca > 0) {
  253.             --this.ca;
  254.         }
  255.  
  256.         if (this.isSleeping()) {
  257.             ++this.cp;
  258.             if (this.cp == 100 && !(new PlayerDeepSleepEvent((Player)this.getBukkitEntity())).callEvent()) {
  259.                 this.cp = -2147483648;
  260.             }
  261.  
  262.             if (this.cp > 100) {
  263.                 this.cp = 100;
  264.             }
  265.  
  266.             if (!super.t.y && super.t.isDay()) {
  267.                 this.wakeup(false, true);
  268.             }
  269.         } else if (this.cp > 0) {
  270.             ++this.cp;
  271.             if (this.cp >= 110) {
  272.                 this.cp = 0;
  273.             }
  274.         }
  275.  
  276.         this.fc();
  277.         super.tick();
  278.         if (!super.t.y && this.bV != null && !this.bV.canUse(this)) {
  279.             this.closeContainer(Reason.CANT_USE);
  280.             this.bV = this.bU;
  281.         }
  282.  
  283.         this.q();
  284.         if (!super.t.y) {
  285.             this.bW.a(this);
  286.             this.a(StatisticList.k);
  287.             this.a(StatisticList.l);
  288.             if (this.isAlive()) {
  289.                 this.a(StatisticList.m);
  290.             }
  291.  
  292.             if (this.bG()) {
  293.                 this.a(StatisticList.o);
  294.             }
  295.  
  296.             if (!this.isSleeping()) {
  297.                 this.a(StatisticList.n);
  298.             }
  299.         }
  300.  
  301.         int i = 29999999;
  302.         double d0 = MathHelper.a(this.locX(), -2.9999999E7D, 2.9999999E7D);
  303.         double d1 = MathHelper.a(this.locZ(), -2.9999999E7D, 2.9999999E7D);
  304.         if (d0 != this.locX() || d1 != this.locZ()) {
  305.             this.setPosition(d0, this.locY(), d1);
  306.         }
  307.  
  308.         ++super.aQ;
  309.         ItemStack itemstack = this.getItemInMainHand();
  310.         if (!ItemStack.matches(this.cu, itemstack)) {
  311.             if (!ItemStack.d(this.cu, itemstack)) {
  312.                 this.resetAttackCooldown();
  313.             }
  314.  
  315.             this.cu = itemstack.cloneItemStack();
  316.         }
  317.  
  318.         this.p();
  319.         this.cv.a();
  320.         this.fd();
  321.     }
  322.  
  323.     public boolean eZ() {
  324.         return this.isSneaking();
  325.     }
  326.  
  327.     protected boolean fa() {
  328.         return this.isSneaking();
  329.     }
  330.  
  331.     protected boolean fb() {
  332.         return this.isSneaking();
  333.     }
  334.  
  335.     protected boolean fc() {
  336.         this.ch = this.a((Tag)TagsFluid.b);
  337.         return this.ch;
  338.     }
  339.  
  340.     private void p() {
  341.         ItemStack itemstack = this.getEquipment(EnumItemSlot.f);
  342.         if (itemstack.a(Items.mc) && !this.a((Tag)TagsFluid.b)) {
  343.             this.addEffect(new MobEffect(MobEffects.m, 200, 0, false, false, true), Cause.TURTLE_HELMET);
  344.         }
  345.  
  346.     }
  347.  
  348.     protected ItemCooldown j() {
  349.         return new ItemCooldown();
  350.     }
  351.  
  352.     private void q() {
  353.         this.cb = this.ce;
  354.         this.cc = this.cf;
  355.         this.cd = this.cg;
  356.         double d0 = this.locX() - this.ce;
  357.         double d1 = this.locY() - this.cf;
  358.         double d2 = this.locZ() - this.cg;
  359.         double d3 = 10.0D;
  360.         if (d0 > 10.0D) {
  361.             this.ce = this.locX();
  362.             this.cb = this.ce;
  363.         }
  364.  
  365.         if (d2 > 10.0D) {
  366.             this.cg = this.locZ();
  367.             this.cd = this.cg;
  368.         }
  369.  
  370.         if (d1 > 10.0D) {
  371.             this.cf = this.locY();
  372.             this.cc = this.cf;
  373.         }
  374.  
  375.         if (d0 < -10.0D) {
  376.             this.ce = this.locX();
  377.             this.cb = this.ce;
  378.         }
  379.  
  380.         if (d2 < -10.0D) {
  381.             this.cg = this.locZ();
  382.             this.cd = this.cg;
  383.         }
  384.  
  385.         if (d1 < -10.0D) {
  386.             this.cf = this.locY();
  387.             this.cc = this.cf;
  388.         }
  389.  
  390.         this.ce += d0 * 0.25D;
  391.         this.cg += d2 * 0.25D;
  392.         this.cf += d1 * 0.25D;
  393.     }
  394.  
  395.     protected void fd() {
  396.         if (this.c((EntityPose)EntityPose.d)) {
  397.             EntityPose entitypose;
  398.             if (this.isGliding()) {
  399.                 entitypose = EntityPose.b;
  400.             } else if (this.isSleeping()) {
  401.                 entitypose = EntityPose.c;
  402.             } else if (this.isSwimming()) {
  403.                 entitypose = EntityPose.d;
  404.             } else if (this.isRiptiding()) {
  405.                 entitypose = EntityPose.e;
  406.             } else if (this.isSneaking() && !this.cq.b) {
  407.                 entitypose = EntityPose.f;
  408.             } else {
  409.                 entitypose = EntityPose.a;
  410.             }
  411.  
  412.             EntityPose entitypose1;
  413.             if (!this.isSpectator() && !this.isPassenger() && !this.c((EntityPose)entitypose)) {
  414.                 if (this.c((EntityPose)EntityPose.f)) {
  415.                     entitypose1 = EntityPose.f;
  416.                 } else {
  417.                     entitypose1 = EntityPose.d;
  418.                 }
  419.             } else {
  420.                 entitypose1 = entitypose;
  421.             }
  422.  
  423.             this.setPose(entitypose1);
  424.         }
  425.  
  426.     }
  427.  
  428.     public int am() {
  429.         return this.cq.a ? 1 : 80;
  430.     }
  431.  
  432.     protected SoundEffect getSoundSwim() {
  433.         return SoundEffects.oC;
  434.     }
  435.  
  436.     protected SoundEffect getSoundSplash() {
  437.         return SoundEffects.oA;
  438.     }
  439.  
  440.     protected SoundEffect getSoundSplashHighSpeed() {
  441.         return SoundEffects.oB;
  442.     }
  443.  
  444.     public int getDefaultPortalCooldown() {
  445.         return 10;
  446.     }
  447.  
  448.     public void playSound(SoundEffect sound, float volume, float pitch) {
  449.         super.t.playSound(this, this.locX(), this.locY(), this.locZ(), sound, this.getSoundCategory(), volume, pitch);
  450.     }
  451.  
  452.     public void a(SoundEffect event, SoundCategory category, float volume, float pitch) {
  453.     }
  454.  
  455.     public SoundCategory getSoundCategory() {
  456.         return SoundCategory.h;
  457.     }
  458.  
  459.     public int getMaxFireTicks() {
  460.         return 20;
  461.     }
  462.  
  463.     public void a(byte status) {
  464.         if (status == 9) {
  465.             this.s();
  466.         } else if (status == 23) {
  467.             this.ct = false;
  468.         } else if (status == 22) {
  469.             this.ct = true;
  470.         } else if (status == 43) {
  471.             this.a((ParticleParam)Particles.g);
  472.         } else {
  473.             super.a(status);
  474.         }
  475.  
  476.     }
  477.  
  478.     private void a(ParticleParam parameters) {
  479.         for(int i = 0; i < 5; ++i) {
  480.             double d0 = super.Q.nextGaussian() * 0.02D;
  481.             double d1 = super.Q.nextGaussian() * 0.02D;
  482.             double d2 = super.Q.nextGaussian() * 0.02D;
  483.             super.t.addParticle(parameters, this.d(1.0D), this.da() + 1.0D, this.g(1.0D), d0, d1, d2);
  484.         }
  485.  
  486.     }
  487.  
  488.     public void closeContainer(Reason reason) {
  489.         this.closeInventory();
  490.         this.bV = this.bU;
  491.     }
  492.  
  493.     public void closeUnloadedInventory(Reason reason) {
  494.         this.bV = this.bU;
  495.     }
  496.  
  497.     public void closeInventory() {
  498.         this.bV = this.bU;
  499.     }
  500.  
  501.     public void passengerTick() {
  502.         if (!super.t.y && this.fa() && this.isPassenger()) {
  503.             this.stopRiding();
  504.             this.setSneaking(false);
  505.         } else {
  506.             double d0 = this.locX();
  507.             double d1 = this.locY();
  508.             double d2 = this.locZ();
  509.             super.passengerTick();
  510.             this.bY = this.bZ;
  511.             this.bZ = 0.0F;
  512.             this.r(this.locX() - d0, this.locY() - d1, this.locZ() - d2);
  513.         }
  514.  
  515.     }
  516.  
  517.     protected void doTick() {
  518.         super.doTick();
  519.         this.ei();
  520.         super.aZ = this.getYRot();
  521.     }
  522.  
  523.     public void movementTick() {
  524.         if (this.bX > 0) {
  525.             --this.bX;
  526.         }
  527.  
  528.         if (super.t.getDifficulty() == EnumDifficulty.a && super.t.getGameRules().getBoolean(GameRules.j)) {
  529.             if (this.getHealth() < this.getMaxHealth() && super.R % 20 == 0) {
  530.                 this.heal(1.0F, RegainReason.REGEN);
  531.             }
  532.  
  533.             if (this.bW.c() && super.R % 10 == 0) {
  534.                 this.bW.a(this.bW.getFoodLevel() + 1);
  535.             }
  536.         }
  537.  
  538.         this.co.j();
  539.         this.bY = this.bZ;
  540.         super.movementTick();
  541.         super.bb = 0.02F;
  542.         if (this.isSprinting()) {
  543.             super.bb = (float)((double)super.bb + 0.005999999865889549D);
  544.         }
  545.  
  546.         this.r((float)this.b((AttributeBase)GenericAttributes.d));
  547.         float f;
  548.         if (super.z && !this.dV() && !this.isSwimming()) {
  549.             f = Math.min(0.1F, (float)this.getMot().h());
  550.         } else {
  551.             f = 0.0F;
  552.         }
  553.  
  554.         this.bZ += (f - this.bZ) * 0.4F;
  555.         if (this.getHealth() > 0.0F && !this.isSpectator()) {
  556.             AxisAlignedBB axisalignedbb;
  557.             if (this.isPassenger() && !this.getVehicle().isRemoved()) {
  558.                 axisalignedbb = this.getBoundingBox().b(this.getVehicle().getBoundingBox()).grow(1.0D, 0.0D, 1.0D);
  559.             } else {
  560.                 axisalignedbb = this.getBoundingBox().grow(1.0D, 0.5D, 1.0D);
  561.             }
  562.  
  563.             List<Entity> list = super.t.getEntities(this, axisalignedbb);
  564.             List<Entity> list1 = Lists.newArrayList();
  565.  
  566.             for(int i = 0; i < list.size(); ++i) {
  567.                 Entity entity = (Entity)list.get(i);
  568.                 if (entity.getEntityType() == EntityTypes.A) {
  569.                     list1.add(entity);
  570.                 } else if (!entity.isRemoved()) {
  571.                     this.c(entity);
  572.                 }
  573.             }
  574.  
  575.             if (!list1.isEmpty()) {
  576.                 this.c((Entity)SystemUtils.a(list1, super.Q));
  577.             }
  578.         }
  579.  
  580.         this.c(this.getShoulderEntityLeft());
  581.         this.c(this.getShoulderEntityRight());
  582.         if ((!super.t.y && (super.K > 0.5F || this.isInWater()) || this.cq.b || this.isSleeping() || super.al) && !super.t.paperConfig.parrotsHangOnBetter) {
  583.             this.releaseShoulderEntities();
  584.         }
  585.  
  586.     }
  587.  
  588.     private void c(@Nullable NBTTagCompound entityNbt) {
  589.         if (entityNbt != null && (!entityNbt.hasKey("Silent") || !entityNbt.getBoolean("Silent")) && super.t.w.nextInt(200) == 0) {
  590.             String s = entityNbt.getString("id");
  591.             EntityTypes.a(s).filter((entitytypes) -> {
  592.                 return entitytypes == EntityTypes.al;
  593.             }).ifPresent((entitytypes) -> {
  594.                 if (!EntityParrot.a(super.t, this)) {
  595.                     super.t.playSound((EntityHuman)null, this.locX(), this.locY(), this.locZ(), EntityParrot.a(super.t, super.t.w), this.getSoundCategory(), 1.0F, EntityParrot.a(super.t.w));
  596.                 }
  597.  
  598.             });
  599.         }
  600.  
  601.     }
  602.  
  603.     private void c(Entity entity) {
  604.         entity.pickup(this);
  605.     }
  606.  
  607.     public int getScore() {
  608.         return (Integer)super.Y.get(e);
  609.     }
  610.  
  611.     public void setScore(int score) {
  612.         super.Y.set(e, score);
  613.     }
  614.  
  615.     public void addScore(int score) {
  616.         int j = this.getScore();
  617.         super.Y.set(e, j + score);
  618.     }
  619.  
  620.     public void die(DamageSource source) {
  621.         super.die(source);
  622.         this.ah();
  623.         if (!this.isSpectator()) {
  624.             this.dropAllDeathLoot(source);
  625.         }
  626.  
  627.         if (source != null) {
  628.             this.setMot((double)(-MathHelper.cos((super.aM + this.getYRot()) * 0.017453292F) * 0.1F), 0.10000000149011612D, (double)(-MathHelper.sin((super.aM + this.getYRot()) * 0.017453292F) * 0.1F));
  629.         } else {
  630.             this.setMot(0.0D, 0.1D, 0.0D);
  631.         }
  632.  
  633.         this.a(StatisticList.N);
  634.         this.a(StatisticList.i.b(StatisticList.m));
  635.         this.a(StatisticList.i.b(StatisticList.n));
  636.         this.extinguish();
  637.         this.a_(false);
  638.     }
  639.  
  640.     protected void dropInventory() {
  641.         super.dropInventory();
  642.         if (!super.t.getGameRules().getBoolean(GameRules.d)) {
  643.             this.removeCursedItems();
  644.             this.co.dropContents();
  645.         }
  646.  
  647.     }
  648.  
  649.     protected void removeCursedItems() {
  650.         for(int i = 0; i < this.co.getSize(); ++i) {
  651.             ItemStack itemstack = this.co.getItem(i);
  652.             if (!itemstack.isEmpty() && EnchantmentManager.shouldNotDrop(itemstack)) {
  653.                 this.co.splitWithoutUpdate(i);
  654.             }
  655.         }
  656.  
  657.     }
  658.  
  659.     protected SoundEffect getSoundHurt(DamageSource source) {
  660.         return source == DamageSource.c ? SoundEffects.ow : (source == DamageSource.h ? SoundEffects.ou : (source == DamageSource.u ? SoundEffects.ox : (source == DamageSource.v ? SoundEffects.ov : SoundEffects.ot)));
  661.     }
  662.  
  663.     public SoundEffect getSoundDeath() {
  664.         return SoundEffects.os;
  665.     }
  666.  
  667.     @Nullable
  668.     public EntityItem drop(ItemStack stack, boolean retainOwnership) {
  669.         return this.a(stack, false, retainOwnership);
  670.     }
  671.  
  672.     @Nullable
  673.     public EntityItem a(ItemStack stack, boolean throwRandomly, boolean retainOwnership) {
  674.         return this.drop(stack, throwRandomly, retainOwnership, false);
  675.     }
  676.  
  677.     @Nullable
  678.     public EntityItem drop(ItemStack stack, boolean throwRandomly, boolean retainOwnership, boolean alwaysSucceed) {
  679.         if (stack.isEmpty()) {
  680.             return null;
  681.         } else {
  682.             if (super.t.y) {
  683.                 this.swingHand(EnumHand.a);
  684.             }
  685.  
  686.             double d0 = this.getHeadY() - 0.30000001192092896D;
  687.             ItemStack tmp = stack.cloneItemStack();
  688.             stack.setCount(0);
  689.             EntityItem entityitem = new EntityItem(super.t, this.locX(), d0, this.locZ(), tmp);
  690.             entityitem.setPickupDelay(40);
  691.             if (retainOwnership) {
  692.                 entityitem.setThrower(this.getUniqueID());
  693.             }
  694.  
  695.             float f;
  696.             float f1;
  697.             if (throwRandomly) {
  698.                 f = super.Q.nextFloat() * 0.5F;
  699.                 f1 = super.Q.nextFloat() * 6.2831855F;
  700.                 entityitem.setMot((double)(-MathHelper.sin(f1) * f), 0.20000000298023224D, (double)(MathHelper.cos(f1) * f));
  701.             } else {
  702.                 f = 0.3F;
  703.                 f1 = MathHelper.sin(this.getXRot() * 0.017453292F);
  704.                 float f2 = MathHelper.cos(this.getXRot() * 0.017453292F);
  705.                 float f3 = MathHelper.sin(this.getYRot() * 0.017453292F);
  706.                 float f4 = MathHelper.cos(this.getYRot() * 0.017453292F);
  707.                 float f5 = super.Q.nextFloat() * 6.2831855F;
  708.                 float f6 = 0.02F * super.Q.nextFloat();
  709.                 entityitem.setMot((double)(-f3 * f2 * 0.3F) + Math.cos((double)f5) * (double)f6, (double)(-f1 * 0.3F + 0.1F + (super.Q.nextFloat() - super.Q.nextFloat()) * 0.1F), (double)(f4 * f2 * 0.3F) + Math.sin((double)f5) * (double)f6);
  710.             }
  711.  
  712.             Player player = (Player)this.getBukkitEntity();
  713.             Item drop = (Item)entityitem.getBukkitEntity();
  714.             PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
  715.             super.t.getCraftServer().getPluginManager().callEvent(event);
  716.             if (event.isCancelled() && !alwaysSucceed) {
  717.                 org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
  718.                 if (retainOwnership && (cur == null || cur.getAmount() == 0)) {
  719.                     player.getInventory().setItemInHand(drop.getItemStack());
  720.                 } else if (retainOwnership && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
  721.                     cur.setAmount(cur.getAmount() + 1);
  722.                     player.getInventory().setItemInHand(cur);
  723.                 } else {
  724.                     player.getInventory().addItem(new org.bukkit.inventory.ItemStack[]{drop.getItemStack()});
  725.                 }
  726.  
  727.                 return null;
  728.             } else {
  729.                 if (tmp.getItem() == Items.pp) {
  730.                     WorldMap worldmap = ItemWorldMap.getSavedMap(tmp, super.t);
  731.                     if (worldmap != null) {
  732.                         worldmap.a(this, tmp);
  733.                     }
  734.                 }
  735.  
  736.                 return entityitem;
  737.             }
  738.         }
  739.     }
  740.  
  741.     public float c(IBlockData block) {
  742.         float f = this.co.a(block);
  743.         if (f > 1.0F) {
  744.             int i = EnchantmentManager.getDigSpeedEnchantmentLevel(this);
  745.             ItemStack itemstack = this.getItemInMainHand();
  746.             if (i > 0 && !itemstack.isEmpty()) {
  747.                 f += (float)(i * i + 1);
  748.             }
  749.         }
  750.  
  751.         if (MobEffectUtil.a(this)) {
  752.             f *= 1.0F + (float)(MobEffectUtil.b(this) + 1) * 0.2F;
  753.         }
  754.  
  755.         if (this.hasEffect(MobEffects.d)) {
  756.             float f1;
  757.             switch(this.getEffect(MobEffects.d).getAmplifier()) {
  758.             case 0:
  759.                 f1 = 0.3F;
  760.                 break;
  761.             case 1:
  762.                 f1 = 0.09F;
  763.                 break;
  764.             case 2:
  765.                 f1 = 0.0027F;
  766.                 break;
  767.             case 3:
  768.             default:
  769.                 f1 = 8.1E-4F;
  770.             }
  771.  
  772.             f *= f1;
  773.         }
  774.  
  775.         if (this.a((Tag)TagsFluid.b) && !EnchantmentManager.h(this)) {
  776.             f /= 5.0F;
  777.         }
  778.  
  779.         if (!super.z) {
  780.             f /= 5.0F;
  781.         }
  782.  
  783.         return f;
  784.     }
  785.  
  786.     public boolean hasBlock(IBlockData state) {
  787.         return !state.isRequiresSpecialTool() || this.co.getItemInHand().canDestroySpecialBlock(state);
  788.     }
  789.  
  790.     public void loadData(NBTTagCompound nbt) {
  791.         super.loadData(nbt);
  792.         this.a_(a(this.cs));
  793.         NBTTagList nbttaglist = nbt.getList("Inventory", 10);
  794.         this.co.b(nbttaglist);
  795.         this.co.k = nbt.getInt("SelectedItemSlot");
  796.         this.cp = nbt.getShort("SleepTimer");
  797.         this.ck = nbt.getFloat("XpP");
  798.         this.ci = nbt.getInt("XpLevel");
  799.         this.cj = nbt.getInt("XpTotal");
  800.         this.cl = nbt.getInt("XpSeed");
  801.         if (this.cl == 0) {
  802.             this.cl = super.Q.nextInt();
  803.         }
  804.  
  805.         this.setScore(nbt.getInt("Score"));
  806.         this.bW.a(nbt);
  807.         this.cq.b(nbt);
  808.         this.getAttributeInstance(GenericAttributes.d).setValue((double)this.cq.b());
  809.         if (nbt.hasKeyOfType("EnderItems", 9)) {
  810.             this.bT.a(nbt.getList("EnderItems", 10));
  811.         }
  812.  
  813.         if (nbt.hasKeyOfType("ShoulderEntityLeft", 10)) {
  814.             this.setShoulderEntityLeft(nbt.getCompound("ShoulderEntityLeft"));
  815.         }
  816.  
  817.         if (nbt.hasKeyOfType("ShoulderEntityRight", 10)) {
  818.             this.setShoulderEntityRight(nbt.getCompound("ShoulderEntityRight"));
  819.         }
  820.  
  821.     }
  822.  
  823.     public void saveData(NBTTagCompound nbt) {
  824.         super.saveData(nbt);
  825.         nbt.setInt("DataVersion", SharedConstants.getGameVersion().getWorldVersion());
  826.         nbt.set("Inventory", this.co.a(new NBTTagList()));
  827.         nbt.setInt("SelectedItemSlot", this.co.k);
  828.         nbt.setShort("SleepTimer", (short)this.cp);
  829.         nbt.setFloat("XpP", this.ck);
  830.         nbt.setInt("XpLevel", this.ci);
  831.         nbt.setInt("XpTotal", this.cj);
  832.         nbt.setInt("XpSeed", this.cl);
  833.         nbt.setInt("Score", this.getScore());
  834.         this.bW.b(nbt);
  835.         this.cq.a(nbt);
  836.         nbt.set("EnderItems", this.bT.g());
  837.         if (!this.getShoulderEntityLeft().isEmpty()) {
  838.             nbt.set("ShoulderEntityLeft", this.getShoulderEntityLeft());
  839.         }
  840.  
  841.         if (!this.getShoulderEntityRight().isEmpty()) {
  842.             nbt.set("ShoulderEntityRight", this.getShoulderEntityRight());
  843.         }
  844.  
  845.     }
  846.  
  847.     public boolean isInvulnerable(DamageSource damageSource) {
  848.         return super.isInvulnerable(damageSource) ? true : (damageSource == DamageSource.h ? !super.t.getGameRules().getBoolean(GameRules.B) : (damageSource.z() ? !super.t.getGameRules().getBoolean(GameRules.C) : (damageSource.isFire() ? !super.t.getGameRules().getBoolean(GameRules.D) : (damageSource == DamageSource.v ? !super.t.getGameRules().getBoolean(GameRules.E) : false))));
  849.     }
  850.  
  851.     public boolean damageEntity(DamageSource source, float amount) {
  852.         if (this.isInvulnerable(source)) {
  853.             return false;
  854.         } else if (this.cq.a && !source.ignoresInvulnerability()) {
  855.             super.forceExplosionKnockback = true;
  856.             return false;
  857.         } else {
  858.             super.bf = 0;
  859.             if (this.dV()) {
  860.                 return false;
  861.             } else {
  862.                 if (source.w()) {
  863.                     if (super.t.getDifficulty() == EnumDifficulty.a) {
  864.                         return false;
  865.                     }
  866.  
  867.                     if (super.t.getDifficulty() == EnumDifficulty.b) {
  868.                         amount = Math.min(amount / 2.0F + 1.0F, amount);
  869.                     }
  870.  
  871.                     if (super.t.getDifficulty() == EnumDifficulty.d) {
  872.                         amount = amount * 3.0F / 2.0F;
  873.                     }
  874.                 }
  875.  
  876.                 boolean damaged = super.damageEntity(source, amount);
  877.                 if (damaged) {
  878.                     this.releaseShoulderEntities();
  879.                 }
  880.  
  881.                 return damaged;
  882.             }
  883.         }
  884.     }
  885.  
  886.     protected void shieldBlock(EntityLiving attacker) {
  887.         super.shieldBlock(attacker);
  888.         if (attacker.getItemInMainHand().getItem() instanceof ItemAxe) {
  889.             this.r(true);
  890.         }
  891.  
  892.     }
  893.  
  894.     public boolean dN() {
  895.         return !this.getAbilities().a && super.dN();
  896.     }
  897.  
  898.     public boolean a(EntityHuman player) {
  899.         Team team;
  900.         if (player instanceof EntityPlayer) {
  901.             EntityPlayer thatPlayer = (EntityPlayer)player;
  902.             team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
  903.             if (team == null || team.allowFriendlyFire()) {
  904.                 return true;
  905.             }
  906.         } else {
  907.             OfflinePlayer thisPlayer = player.t.getCraftServer().getOfflinePlayer(player.getName());
  908.             team = player.t.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
  909.             if (team == null || team.allowFriendlyFire()) {
  910.                 return true;
  911.             }
  912.         }
  913.  
  914.         if (this instanceof EntityPlayer) {
  915.             return !team.hasPlayer(((EntityPlayer)this).getBukkitEntity());
  916.         } else {
  917.             return !team.hasPlayer(super.t.getCraftServer().getOfflinePlayer(this.getName()));
  918.         }
  919.     }
  920.  
  921.     protected void damageArmor(DamageSource source, float amount) {
  922.         this.co.a(source, amount, PlayerInventory.f);
  923.     }
  924.  
  925.     protected void damageHelmet(DamageSource source, float amount) {
  926.         this.co.a(source, amount, PlayerInventory.g);
  927.     }
  928.  
  929.     protected void damageShield(float amount) {
  930.         if (super.bz.a(Items.sv)) {
  931.             if (!super.t.y) {
  932.                 this.b(StatisticList.c.b(super.bz.getItem()));
  933.             }
  934.  
  935.             if (amount >= 3.0F) {
  936.                 int i = 1 + MathHelper.d(amount);
  937.                 EnumHand enumhand = this.getRaisedHand();
  938.                 super.bz.damage(i, this, (entityhuman) -> {
  939.                     entityhuman.broadcastItemBreak(enumhand);
  940.                 });
  941.                 if (super.bz.isEmpty()) {
  942.                     if (enumhand == EnumHand.a) {
  943.                         this.setSlot(EnumItemSlot.a, ItemStack.b);
  944.                     } else {
  945.                         this.setSlot(EnumItemSlot.b, ItemStack.b);
  946.                     }
  947.  
  948.                     super.bz = ItemStack.b;
  949.                     this.playSound(SoundEffects.qn, 0.8F, 0.8F + super.t.w.nextFloat() * 0.4F);
  950.                 }
  951.             }
  952.         }
  953.  
  954.     }
  955.  
  956.     protected boolean damageEntity0(DamageSource damagesource, float f) {
  957.         return super.damageEntity0(damagesource, f);
  958.     }
  959.  
  960.     protected boolean du() {
  961.         return !this.cq.b && super.du();
  962.     }
  963.  
  964.     public void openSign(TileEntitySign sign) {
  965.     }
  966.  
  967.     public void a(CommandBlockListenerAbstract commandBlockExecutor) {
  968.     }
  969.  
  970.     public void a(TileEntityCommand commandBlock) {
  971.     }
  972.  
  973.     public void a(TileEntityStructure structureBlock) {
  974.     }
  975.  
  976.     public void a(TileEntityJigsaw jigsaw) {
  977.     }
  978.  
  979.     public void openHorseInventory(EntityHorseAbstract horse, IInventory inventory) {
  980.     }
  981.  
  982.     public OptionalInt openContainer(@Nullable ITileInventory factory) {
  983.         return OptionalInt.empty();
  984.     }
  985.  
  986.     public void openTrade(int syncId, MerchantRecipeList offers, int levelProgress, int experience, boolean leveled, boolean refreshable) {
  987.     }
  988.  
  989.     public void openBook(ItemStack book, EnumHand hand) {
  990.     }
  991.  
  992.     public EnumInteractionResult a(Entity entity, EnumHand hand) {
  993.         if (this.isSpectator()) {
  994.             if (entity instanceof ITileInventory) {
  995.                 this.openContainer((ITileInventory)entity);
  996.             }
  997.  
  998.             return EnumInteractionResult.d;
  999.         } else {
  1000.             ItemStack itemstack = this.b((EnumHand)hand);
  1001.             ItemStack itemstack1 = itemstack.cloneItemStack();
  1002.             EnumInteractionResult enuminteractionresult = entity.a(this, hand);
  1003.             if (enuminteractionresult.a()) {
  1004.                 if (this.cq.d && itemstack == this.b((EnumHand)hand) && itemstack.getCount() < itemstack1.getCount()) {
  1005.                     itemstack.setCount(itemstack1.getCount());
  1006.                 }
  1007.  
  1008.                 return enuminteractionresult;
  1009.             } else {
  1010.                 if (!itemstack.isEmpty() && entity instanceof EntityLiving) {
  1011.                     if (this.cq.d) {
  1012.                         itemstack = itemstack1;
  1013.                     }
  1014.  
  1015.                     EnumInteractionResult enuminteractionresult1 = itemstack.a(this, (EntityLiving)entity, hand);
  1016.                     if (enuminteractionresult1.a()) {
  1017.                         if (itemstack.isEmpty() && !this.cq.d) {
  1018.                             this.a((EnumHand)hand, (ItemStack)ItemStack.b);
  1019.                         }
  1020.  
  1021.                         return enuminteractionresult1;
  1022.                     }
  1023.                 }
  1024.  
  1025.                 return EnumInteractionResult.d;
  1026.             }
  1027.         }
  1028.     }
  1029.  
  1030.     public double bk() {
  1031.         return -0.35D;
  1032.     }
  1033.  
  1034.     public void bo() {
  1035.         this.stopRiding(false);
  1036.     }
  1037.  
  1038.     public void stopRiding(boolean suppressCancellation) {
  1039.         super.stopRiding(suppressCancellation);
  1040.         super.s = 0;
  1041.     }
  1042.  
  1043.     protected boolean isFrozen() {
  1044.         return super.isFrozen() || this.isSleeping() || this.isRemoved() || !super.valid;
  1045.     }
  1046.  
  1047.     public boolean dA() {
  1048.         return !this.cq.b;
  1049.     }
  1050.  
  1051.     protected Vec3D a(Vec3D movement, EnumMoveType type) {
  1052.         if (!this.cq.b && (type == EnumMoveType.a || type == EnumMoveType.b) && this.fb() && this.v()) {
  1053.             double d0 = movement.b;
  1054.             double d1 = movement.d;
  1055.             double var7 = 0.05D;
  1056.  
  1057.             while(true) {
  1058.                 while(d0 != 0.0D && super.t.getCubes(this, this.getBoundingBox().d(d0, (double)(-super.O), 0.0D))) {
  1059.                     if (d0 < 0.05D && d0 >= -0.05D) {
  1060.                         d0 = 0.0D;
  1061.                     } else if (d0 > 0.0D) {
  1062.                         d0 -= 0.05D;
  1063.                     } else {
  1064.                         d0 += 0.05D;
  1065.                     }
  1066.                 }
  1067.  
  1068.                 while(true) {
  1069.                     while(d1 != 0.0D && super.t.getCubes(this, this.getBoundingBox().d(0.0D, (double)(-super.O), d1))) {
  1070.                         if (d1 < 0.05D && d1 >= -0.05D) {
  1071.                             d1 = 0.0D;
  1072.                         } else if (d1 > 0.0D) {
  1073.                             d1 -= 0.05D;
  1074.                         } else {
  1075.                             d1 += 0.05D;
  1076.                         }
  1077.                     }
  1078.  
  1079.                     while(true) {
  1080.                         while(d0 != 0.0D && d1 != 0.0D && super.t.getCubes(this, this.getBoundingBox().d(d0, (double)(-super.O), d1))) {
  1081.                             if (d0 < 0.05D && d0 >= -0.05D) {
  1082.                                 d0 = 0.0D;
  1083.                             } else if (d0 > 0.0D) {
  1084.                                 d0 -= 0.05D;
  1085.                             } else {
  1086.                                 d0 += 0.05D;
  1087.                             }
  1088.  
  1089.                             if (d1 < 0.05D && d1 >= -0.05D) {
  1090.                                 d1 = 0.0D;
  1091.                             } else if (d1 > 0.0D) {
  1092.                                 d1 -= 0.05D;
  1093.                             } else {
  1094.                                 d1 += 0.05D;
  1095.                             }
  1096.                         }
  1097.  
  1098.                         movement = new Vec3D(d0, movement.c, d1);
  1099.                         return movement;
  1100.                     }
  1101.                 }
  1102.             }
  1103.         } else {
  1104.             return movement;
  1105.         }
  1106.     }
  1107.  
  1108.     private boolean v() {
  1109.         return super.z || super.K < super.O && !super.t.getCubes(this, this.getBoundingBox().d(0.0D, (double)(super.K - super.O), 0.0D));
  1110.     }
  1111.  
  1112.     public void attack(Entity target) {
  1113.         if (target.ca() && !target.r(this)) {
  1114.             float f = (float)this.b((AttributeBase)GenericAttributes.f);
  1115.             float f1;
  1116.             if (target instanceof EntityLiving) {
  1117.                 f1 = EnchantmentManager.a(this.getItemInMainHand(), ((EntityLiving)target).getMonsterType());
  1118.             } else {
  1119.                 f1 = EnchantmentManager.a(this.getItemInMainHand(), EnumMonsterType.a);
  1120.             }
  1121.  
  1122.             float f2 = this.getAttackCooldown(0.5F);
  1123.             f *= 0.2F + f2 * f2 * 0.8F;
  1124.             f1 *= f2;
  1125.             if (f > 0.0F || f1 > 0.0F) {
  1126.                 boolean flag = f2 > 0.9F;
  1127.                 boolean flag1 = false;
  1128.                 byte b0 = 0;
  1129.                 int i = b0 + EnchantmentManager.b(this);
  1130.                 if (this.isSprinting() && flag) {
  1131.                     sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ok, this.getSoundCategory(), 1.0F, 1.0F);
  1132.                     ++i;
  1133.                     flag1 = true;
  1134.                 }
  1135.  
  1136.                 boolean flag2 = flag && super.K > 0.0F && !super.z && !this.isClimbing() && !this.isInWater() && !this.hasEffect(MobEffects.o) && !this.isPassenger() && target instanceof EntityLiving;
  1137.                 flag2 = flag2 && !super.t.paperConfig.disablePlayerCrits;
  1138.                 flag2 = flag2 && !this.isSprinting();
  1139.                 if (flag2) {
  1140.                     f *= 1.5F;
  1141.                 }
  1142.  
  1143.                 f += f1;
  1144.                 boolean flag3 = false;
  1145.                 double d0 = (double)(super.H - super.G);
  1146.                 if (flag && !flag2 && !flag1 && super.z && d0 < (double)this.ew()) {
  1147.                     ItemStack itemstack = this.b((EnumHand)EnumHand.a);
  1148.                     if (itemstack.getItem() instanceof ItemSword) {
  1149.                         flag3 = true;
  1150.                     }
  1151.                 }
  1152.  
  1153.                 float f3 = 0.0F;
  1154.                 boolean flag4 = false;
  1155.                 int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
  1156.                 if (target instanceof EntityLiving) {
  1157.                     f3 = ((EntityLiving)target).getHealth();
  1158.                     if (j > 0 && !target.isBurning()) {
  1159.                         EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), target.getBukkitEntity(), 1);
  1160.                         Bukkit.getPluginManager().callEvent(combustEvent);
  1161.                         if (!combustEvent.isCancelled()) {
  1162.                             flag4 = true;
  1163.                             target.setOnFire(combustEvent.getDuration(), false);
  1164.                         }
  1165.                     }
  1166.                 }
  1167.  
  1168.                 Vec3D vec3d = target.getMot();
  1169.                 boolean flag5 = target.damageEntity(DamageSource.playerAttack(this).critical(flag2), f);
  1170.                 if (flag5) {
  1171.                     if (i > 0) {
  1172.                         if (target instanceof EntityLiving) {
  1173.                             ((EntityLiving)target).knockback((double)((float)i * 0.5F), (double)MathHelper.sin(this.getYRot() * 0.017453292F), (double)(-MathHelper.cos(this.getYRot() * 0.017453292F)), this);
  1174.                         } else {
  1175.                             target.i((double)(-MathHelper.sin(this.getYRot() * 0.017453292F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.getYRot() * 0.017453292F) * (float)i * 0.5F));
  1176.                         }
  1177.  
  1178.                         this.setMot(this.getMot().d(0.6D, 1.0D, 0.6D));
  1179.                         if (!super.t.paperConfig.disableSprintInterruptionOnAttack) {
  1180.                             this.setSprinting(false);
  1181.                         }
  1182.                     }
  1183.  
  1184.                     if (flag3) {
  1185.                         float f4 = 1.0F + EnchantmentManager.a(this) * f;
  1186.                         List<EntityLiving> list = super.t.a(EntityLiving.class, target.getBoundingBox().grow(1.0D, 0.25D, 1.0D));
  1187.                         Iterator iterator = list.iterator();
  1188.  
  1189.                         label186:
  1190.                         while(true) {
  1191.                             EntityLiving entityliving;
  1192.                             do {
  1193.                                 do {
  1194.                                     do {
  1195.                                         do {
  1196.                                             if (!iterator.hasNext()) {
  1197.                                                 sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.on, this.getSoundCategory(), 1.0F, 1.0F);
  1198.                                                 this.fg();
  1199.                                                 break label186;
  1200.                                             }
  1201.  
  1202.                                             entityliving = (EntityLiving)iterator.next();
  1203.                                         } while(entityliving == this);
  1204.                                     } while(entityliving == target);
  1205.                                 } while(this.p(entityliving));
  1206.                             } while(entityliving instanceof EntityArmorStand && ((EntityArmorStand)entityliving).isMarker());
  1207.  
  1208.                             if (this.f(entityliving) < 9.0D && entityliving.damageEntity(DamageSource.playerAttack(this).sweep().critical(flag2), f4)) {
  1209.                                 entityliving.knockback(0.4000000059604645D, (double)MathHelper.sin(this.getYRot() * 0.017453292F), (double)(-MathHelper.cos(this.getYRot() * 0.017453292F)), this);
  1210.                             }
  1211.                         }
  1212.                     }
  1213.  
  1214.                     if (target instanceof EntityPlayer && target.C) {
  1215.                         boolean cancelled = false;
  1216.                         Player player = (Player)target.getBukkitEntity();
  1217.                         Vector velocity = CraftVector.toBukkit(vec3d);
  1218.                         PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
  1219.                         super.t.getCraftServer().getPluginManager().callEvent(event);
  1220.                         if (event.isCancelled()) {
  1221.                             cancelled = true;
  1222.                         } else if (!velocity.equals(event.getVelocity())) {
  1223.                             player.setVelocity(event.getVelocity());
  1224.                         }
  1225.  
  1226.                         if (!cancelled) {
  1227.                             ((EntityPlayer)target).b.sendPacket(new PacketPlayOutEntityVelocity(target));
  1228.                             target.C = false;
  1229.                             target.setMot(vec3d);
  1230.                         }
  1231.                     }
  1232.  
  1233.                     if (flag2) {
  1234.                         sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.oj, this.getSoundCategory(), 1.0F, 1.0F);
  1235.                         this.a(target);
  1236.                     }
  1237.  
  1238.                     if (!flag2 && !flag3) {
  1239.                         if (flag) {
  1240.                             sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.om, this.getSoundCategory(), 1.0F, 1.0F);
  1241.                         } else {
  1242.                             sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.oo, this.getSoundCategory(), 1.0F, 1.0F);
  1243.                         }
  1244.                     }
  1245.  
  1246.                     if (f1 > 0.0F) {
  1247.                         this.b(target);
  1248.                     }
  1249.  
  1250.                     this.x(target);
  1251.                     if (target instanceof EntityLiving) {
  1252.                         EnchantmentManager.a((EntityLiving)target, this);
  1253.                     }
  1254.  
  1255.                     EnchantmentManager.b(this, target);
  1256.                     ItemStack itemstack1 = this.getItemInMainHand();
  1257.                     Object object = target;
  1258.                     if (target instanceof EntityComplexPart) {
  1259.                         object = ((EntityComplexPart)target).b;
  1260.                     }
  1261.  
  1262.                     if (!super.t.y && !itemstack1.isEmpty() && object instanceof EntityLiving) {
  1263.                         itemstack1.a((EntityLiving)object, this);
  1264.                         if (itemstack1.isEmpty()) {
  1265.                             this.a((EnumHand)EnumHand.a, (ItemStack)ItemStack.b);
  1266.                         }
  1267.                     }
  1268.  
  1269.                     if (target instanceof EntityLiving) {
  1270.                         float f5 = f3 - ((EntityLiving)target).getHealth();
  1271.                         this.a(StatisticList.G, Math.round(f5 * 10.0F));
  1272.                         if (j > 0) {
  1273.                             EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), target.getBukkitEntity(), j * 4);
  1274.                             Bukkit.getPluginManager().callEvent(combustEvent);
  1275.                             if (!combustEvent.isCancelled()) {
  1276.                                 target.setOnFire(combustEvent.getDuration(), false);
  1277.                             }
  1278.                         }
  1279.  
  1280.                         if (super.t instanceof WorldServer && f5 > 2.0F) {
  1281.                             int k = (int)((double)f5 * 0.5D);
  1282.                             ((WorldServer)super.t).a(Particles.i, target.locX(), target.e(0.5D), target.locZ(), k, 0.1D, 0.0D, 0.1D, 0.2D);
  1283.                         }
  1284.                     }
  1285.  
  1286.                     this.applyExhaustion(super.t.spigotConfig.combatExhaustion, ExhaustionReason.ATTACK);
  1287.                 } else {
  1288.                     sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ol, this.getSoundCategory(), 1.0F, 1.0F);
  1289.                     if (flag4) {
  1290.                         target.extinguish();
  1291.                     }
  1292.  
  1293.                     if (this instanceof EntityPlayer) {
  1294.                         ((EntityPlayer)this).getBukkitEntity().updateInventory();
  1295.                     }
  1296.                 }
  1297.             }
  1298.         }
  1299.  
  1300.     }
  1301.  
  1302.     protected void g(EntityLiving target) {
  1303.         this.attack(target);
  1304.     }
  1305.  
  1306.     public void r(boolean sprinting) {
  1307.         float f = 0.25F + (float)EnchantmentManager.getDigSpeedEnchantmentLevel(this) * 0.05F;
  1308.         if (sprinting) {
  1309.             f += 0.75F;
  1310.         }
  1311.  
  1312.         if (super.Q.nextFloat() < f) {
  1313.             this.getCooldownTracker().setCooldown(Items.sv, 100);
  1314.             this.clearActiveItem();
  1315.             super.t.broadcastEntityEffect(this, (byte)30);
  1316.         }
  1317.  
  1318.     }
  1319.  
  1320.     public void a(Entity target) {
  1321.     }
  1322.  
  1323.     public void b(Entity target) {
  1324.     }
  1325.  
  1326.     public void fg() {
  1327.         double d0 = (double)(-MathHelper.sin(this.getYRot() * 0.017453292F));
  1328.         double d1 = (double)MathHelper.cos(this.getYRot() * 0.017453292F);
  1329.         if (super.t instanceof WorldServer) {
  1330.             ((WorldServer)super.t).a(Particles.Z, this.locX() + d0, this.e(0.5D), this.locZ() + d1, 0, d0, 0.0D, d1, 0.0D);
  1331.         }
  1332.  
  1333.     }
  1334.  
  1335.     public void fh() {
  1336.     }
  1337.  
  1338.     public void a(RemovalReason reason) {
  1339.         super.a(reason);
  1340.         this.bU.b(this);
  1341.         if (this.bV != null) {
  1342.             this.bV.b(this);
  1343.         }
  1344.  
  1345.     }
  1346.  
  1347.     public boolean fi() {
  1348.         return false;
  1349.     }
  1350.  
  1351.     public GameProfile getProfile() {
  1352.         return this.cs;
  1353.     }
  1354.  
  1355.     public PlayerInventory getInventory() {
  1356.         return this.co;
  1357.     }
  1358.  
  1359.     public PlayerAbilities getAbilities() {
  1360.         return this.cq;
  1361.     }
  1362.  
  1363.     public void a(ItemStack cursorStack, ItemStack slotStack, ClickAction clickType) {
  1364.     }
  1365.  
  1366.     public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition pos) {
  1367.         return this.sleep(pos, false);
  1368.     }
  1369.  
  1370.     public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition, boolean force) {
  1371.         this.entitySleep(blockposition);
  1372.         this.cp = 0;
  1373.         return Either.right(Unit.a);
  1374.     }
  1375.  
  1376.     public void wakeup(boolean flag, boolean updateSleepingPlayers) {
  1377.         super.entityWakeup();
  1378.         if (super.t instanceof WorldServer && updateSleepingPlayers) {
  1379.             ((WorldServer)super.t).everyoneSleeping();
  1380.         }
  1381.  
  1382.         this.cp = flag ? 0 : 100;
  1383.     }
  1384.  
  1385.     public void entityWakeup() {
  1386.         this.wakeup(true, true);
  1387.     }
  1388.  
  1389.     public static Optional<Vec3D> getBed(WorldServer world, BlockPosition pos, float f, boolean flag, boolean flag1) {
  1390.         IBlockData iblockdata = world.getType(pos);
  1391.         Block block = iblockdata.getBlock();
  1392.         if (block instanceof BlockRespawnAnchor && (Integer)iblockdata.get(BlockRespawnAnchor.c) > 0 && BlockRespawnAnchor.a(world)) {
  1393.             Optional<Vec3D> optional = BlockRespawnAnchor.a(EntityTypes.bi, world, pos);
  1394.             if (!flag1 && optional.isPresent()) {
  1395.                 world.setTypeAndData(pos, (IBlockData)iblockdata.set(BlockRespawnAnchor.c, (Integer)iblockdata.get(BlockRespawnAnchor.c) - 1), 3);
  1396.             }
  1397.  
  1398.             return optional;
  1399.         } else if (block instanceof BlockBed && BlockBed.a(world)) {
  1400.             return BlockBed.a(EntityTypes.bi, world, pos, f);
  1401.         } else if (!flag) {
  1402.             return Optional.empty();
  1403.         } else {
  1404.             boolean flag2 = block.W_();
  1405.             boolean flag3 = world.getType(pos.up()).getBlock().W_();
  1406.             return flag2 && flag3 ? Optional.of(new Vec3D((double)pos.getX() + 0.5D, (double)pos.getY() + 0.1D, (double)pos.getZ() + 0.5D)) : Optional.empty();
  1407.         }
  1408.     }
  1409.  
  1410.     public boolean isDeeplySleeping() {
  1411.         return this.isSleeping() && this.cp >= 100;
  1412.     }
  1413.  
  1414.     public int fn() {
  1415.         return this.cp;
  1416.     }
  1417.  
  1418.     public void a(IChatBaseComponent message, boolean actionBar) {
  1419.     }
  1420.  
  1421.     public void a(MinecraftKey stat) {
  1422.         this.b(StatisticList.i.b(stat));
  1423.     }
  1424.  
  1425.     public void a(MinecraftKey stat, int amount) {
  1426.         this.a(StatisticList.i.b(stat), amount);
  1427.     }
  1428.  
  1429.     public void b(Statistic<?> stat) {
  1430.         this.a((Statistic)stat, 1);
  1431.     }
  1432.  
  1433.     public void a(Statistic<?> stat, int amount) {
  1434.     }
  1435.  
  1436.     public void a(Statistic<?> stat) {
  1437.     }
  1438.  
  1439.     public int discoverRecipes(Collection<IRecipe<?>> recipes) {
  1440.         return 0;
  1441.     }
  1442.  
  1443.     public void a(MinecraftKey[] ids) {
  1444.     }
  1445.  
  1446.     public int undiscoverRecipes(Collection<IRecipe<?>> recipes) {
  1447.         return 0;
  1448.     }
  1449.  
  1450.     public void jump() {
  1451.         super.jump();
  1452.         this.a(StatisticList.E);
  1453.         if (this.isSprinting()) {
  1454.             this.applyExhaustion(super.t.spigotConfig.jumpSprintExhaustion, ExhaustionReason.JUMP_SPRINT);
  1455.         } else {
  1456.             this.applyExhaustion(super.t.spigotConfig.jumpWalkExhaustion, ExhaustionReason.JUMP);
  1457.         }
  1458.  
  1459.     }
  1460.  
  1461.     public void g(Vec3D movementInput) {
  1462.         double d0 = this.locX();
  1463.         double d1 = this.locY();
  1464.         double d2 = this.locZ();
  1465.         double d3;
  1466.         if (this.isSwimming() && !this.isPassenger()) {
  1467.             d3 = this.getLookDirection().c;
  1468.             double d4 = d3 < -0.2D ? 0.085D : 0.06D;
  1469.             if (d3 <= 0.0D || super.bn || !super.t.getType(new BlockPosition(this.locX(), this.locY() + 1.0D - 0.1D, this.locZ())).getFluid().isEmpty()) {
  1470.                 Vec3D vec3d1 = this.getMot();
  1471.                 this.setMot(vec3d1.add(0.0D, (d3 - vec3d1.c) * d4, 0.0D));
  1472.             }
  1473.         }
  1474.  
  1475.         if (this.cq.b && !this.isPassenger()) {
  1476.             d3 = this.getMot().c;
  1477.             float f = super.bb;
  1478.             super.bb = this.cq.a() * (float)(this.isSprinting() ? 2 : 1);
  1479.             super.g(movementInput);
  1480.             Vec3D vec3d2 = this.getMot();
  1481.             this.setMot(vec3d2.b, d3 * 0.6D, vec3d2.d);
  1482.             super.bb = f;
  1483.             super.K = 0.0F;
  1484.             if (this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
  1485.                 this.setFlag(7, false);
  1486.             }
  1487.         } else {
  1488.             super.g(movementInput);
  1489.         }
  1490.  
  1491.         this.checkMovement(this.locX() - d0, this.locY() - d1, this.locZ() - d2);
  1492.     }
  1493.  
  1494.     public void aQ() {
  1495.         if (this.cq.b) {
  1496.             this.setSwimming(false);
  1497.         } else {
  1498.             super.aQ();
  1499.         }
  1500.  
  1501.     }
  1502.  
  1503.     protected boolean f(BlockPosition pos) {
  1504.         return !super.t.getType(pos).o(super.t, pos);
  1505.     }
  1506.  
  1507.     public float ew() {
  1508.         return (float)this.b((AttributeBase)GenericAttributes.d);
  1509.     }
  1510.  
  1511.     public void checkMovement(double dx, double dy, double dz) {
  1512.         if (!this.isPassenger()) {
  1513.             int i;
  1514.             if (this.isSwimming()) {
  1515.                 i = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
  1516.                 if (i > 0) {
  1517.                     this.a(StatisticList.C, i);
  1518.                     this.applyExhaustion(super.t.spigotConfig.swimMultiplier * (float)i * 0.01F, ExhaustionReason.SWIM);
  1519.                 }
  1520.             } else if (this.a((Tag)TagsFluid.b)) {
  1521.                 i = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
  1522.                 if (i > 0) {
  1523.                     this.a(StatisticList.w, i);
  1524.                     this.applyExhaustion(super.t.spigotConfig.swimMultiplier * (float)i * 0.01F, ExhaustionReason.WALK_UNDERWATER);
  1525.                 }
  1526.             } else if (this.isInWater()) {
  1527.                 i = Math.round((float)Math.sqrt(dx * dx + dz * dz) * 100.0F);
  1528.                 if (i > 0) {
  1529.                     this.a(StatisticList.s, i);
  1530.                     this.applyExhaustion(super.t.spigotConfig.swimMultiplier * (float)i * 0.01F, ExhaustionReason.WALK_ON_WATER);
  1531.                 }
  1532.             } else if (this.isClimbing()) {
  1533.                 if (dy > 0.0D) {
  1534.                     this.a(StatisticList.u, (int)Math.round(dy * 100.0D));
  1535.                 }
  1536.             } else if (super.z) {
  1537.                 i = Math.round((float)Math.sqrt(dx * dx + dz * dz) * 100.0F);
  1538.                 if (i > 0) {
  1539.                     if (this.isSprinting()) {
  1540.                         this.a(StatisticList.r, i);
  1541.                         this.applyExhaustion(super.t.spigotConfig.sprintMultiplier * (float)i * 0.01F, ExhaustionReason.SPRINT);
  1542.                     } else if (this.isCrouching()) {
  1543.                         this.a(StatisticList.q, i);
  1544.                         this.applyExhaustion(super.t.spigotConfig.otherMultiplier * (float)i * 0.01F, ExhaustionReason.CROUCH);
  1545.                     } else {
  1546.                         this.a(StatisticList.p, i);
  1547.                         this.applyExhaustion(super.t.spigotConfig.otherMultiplier * (float)i * 0.01F, ExhaustionReason.WALK);
  1548.                     }
  1549.                 }
  1550.             } else if (this.isGliding()) {
  1551.                 i = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
  1552.                 this.a(StatisticList.B, i);
  1553.             } else {
  1554.                 i = Math.round((float)Math.sqrt(dx * dx + dz * dz) * 100.0F);
  1555.                 if (i > 25) {
  1556.                     this.a(StatisticList.v, i);
  1557.                 }
  1558.             }
  1559.         }
  1560.  
  1561.     }
  1562.  
  1563.     private void r(double dx, double dy, double dz) {
  1564.         if (this.isPassenger()) {
  1565.             int i = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
  1566.             if (i > 0) {
  1567.                 Entity entity = this.getVehicle();
  1568.                 if (entity instanceof EntityMinecartAbstract) {
  1569.                     this.a(StatisticList.x, i);
  1570.                 } else if (entity instanceof EntityBoat) {
  1571.                     this.a(StatisticList.y, i);
  1572.                 } else if (entity instanceof EntityPig) {
  1573.                     this.a(StatisticList.z, i);
  1574.                 } else if (entity instanceof EntityHorseAbstract) {
  1575.                     this.a(StatisticList.A, i);
  1576.                 } else if (entity instanceof EntityStrider) {
  1577.                     this.a(StatisticList.D, i);
  1578.                 }
  1579.             }
  1580.         }
  1581.  
  1582.     }
  1583.  
  1584.     public boolean a(float fallDistance, float damageMultiplier, DamageSource damageSource) {
  1585.         if (this.cq.c) {
  1586.             return false;
  1587.         } else {
  1588.             if (fallDistance >= 2.0F) {
  1589.                 this.a(StatisticList.t, (int)Math.round((double)fallDistance * 100.0D));
  1590.             }
  1591.  
  1592.             return super.a(fallDistance, damageMultiplier, damageSource);
  1593.         }
  1594.     }
  1595.  
  1596.     public boolean fo() {
  1597.         if (!super.z && !this.isGliding() && !this.isInWater() && !this.hasEffect(MobEffects.y)) {
  1598.             ItemStack itemstack = this.getEquipment(EnumItemSlot.e);
  1599.             if (itemstack.a(Items.lT) && ItemElytra.d(itemstack)) {
  1600.                 this.startGliding();
  1601.                 return true;
  1602.             }
  1603.         }
  1604.  
  1605.         return false;
  1606.     }
  1607.  
  1608.     public void startGliding() {
  1609.         if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) {
  1610.             this.setFlag(7, true);
  1611.         } else {
  1612.             this.setFlag(7, true);
  1613.             this.setFlag(7, false);
  1614.         }
  1615.  
  1616.     }
  1617.  
  1618.     public void stopGliding() {
  1619.         if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
  1620.             this.setFlag(7, true);
  1621.             this.setFlag(7, false);
  1622.         }
  1623.  
  1624.     }
  1625.  
  1626.     protected void aT() {
  1627.         if (!this.isSpectator()) {
  1628.             super.aT();
  1629.         }
  1630.  
  1631.     }
  1632.  
  1633.     protected SoundEffect getSoundFall(int distance) {
  1634.         return distance > 4 ? SoundEffects.op : SoundEffects.oz;
  1635.     }
  1636.  
  1637.     public void a(WorldServer world, EntityLiving other) {
  1638.         this.b(StatisticList.g.b(other.getEntityType()));
  1639.     }
  1640.  
  1641.     public void a(IBlockData state, Vec3D multiplier) {
  1642.         if (!this.cq.b) {
  1643.             super.a(state, multiplier);
  1644.         }
  1645.  
  1646.     }
  1647.  
  1648.     public void giveExp(int experience) {
  1649.         this.addScore(experience);
  1650.         this.ck += (float)experience / (float)this.getExpToLevel();
  1651.         this.cj = MathHelper.clamp(this.cj + experience, 0, 2147483647);
  1652.  
  1653.         while(this.ck < 0.0F) {
  1654.             float f = this.ck * (float)this.getExpToLevel();
  1655.             if (this.ci > 0) {
  1656.                 this.levelDown(-1);
  1657.                 this.ck = 1.0F + f / (float)this.getExpToLevel();
  1658.             } else {
  1659.                 this.levelDown(-1);
  1660.                 this.ck = 0.0F;
  1661.             }
  1662.         }
  1663.  
  1664.         while(this.ck >= 1.0F) {
  1665.             this.ck = (this.ck - 1.0F) * (float)this.getExpToLevel();
  1666.             this.levelDown(1);
  1667.             this.ck /= (float)this.getExpToLevel();
  1668.         }
  1669.  
  1670.     }
  1671.  
  1672.     public int fr() {
  1673.         return this.cl;
  1674.     }
  1675.  
  1676.     public void enchantDone(ItemStack enchantedItem, int experienceLevels) {
  1677.         this.ci -= experienceLevels;
  1678.         if (this.ci < 0) {
  1679.             this.ci = 0;
  1680.             this.ck = 0.0F;
  1681.             this.cj = 0;
  1682.         }
  1683.  
  1684.         this.cl = super.Q.nextInt();
  1685.     }
  1686.  
  1687.     public void levelDown(int levels) {
  1688.         this.ci += levels;
  1689.         if (this.ci < 0) {
  1690.             this.ci = 0;
  1691.             this.ck = 0.0F;
  1692.             this.cj = 0;
  1693.         }
  1694.  
  1695.         if (levels > 0 && this.ci % 5 == 0 && (float)this.cr < (float)super.R - 100.0F) {
  1696.             float f = this.ci > 30 ? 1.0F : (float)this.ci / 30.0F;
  1697.             super.t.playSound((EntityHuman)null, this.locX(), this.locY(), this.locZ(), SoundEffects.oy, this.getSoundCategory(), f * 0.75F, 1.0F);
  1698.             this.cr = super.R;
  1699.         }
  1700.  
  1701.     }
  1702.  
  1703.     public int getExpToLevel() {
  1704.         return this.ci >= 30 ? 112 + (this.ci - 30) * 9 : (this.ci >= 15 ? 37 + (this.ci - 15) * 5 : 7 + this.ci * 2);
  1705.     }
  1706.  
  1707.     private static void sendSoundEffect(EntityHuman fromEntity, double x, double y, double z, SoundEffect soundEffect, SoundCategory soundCategory, float volume, float pitch) {
  1708.         fromEntity.t.playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch);
  1709.         if (fromEntity instanceof EntityPlayer) {
  1710.             ((EntityPlayer)fromEntity).b.sendPacket(new PacketPlayOutNamedSoundEffect(soundEffect, soundCategory, x, y, z, volume, pitch));
  1711.         }
  1712.  
  1713.     }
  1714.  
  1715.     public void applyExhaustion(float exhaustion) {
  1716.         this.applyExhaustion(exhaustion, ExhaustionReason.UNKNOWN);
  1717.     }
  1718.  
  1719.     public void applyExhaustion(float f, ExhaustionReason reason) {
  1720.         if (!this.cq.a && !super.t.y) {
  1721.             EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f);
  1722.             if (!event.isCancelled()) {
  1723.                 this.bW.a(event.getExhaustion());
  1724.             }
  1725.         }
  1726.  
  1727.     }
  1728.  
  1729.     public FoodMetaData getFoodData() {
  1730.         return this.bW;
  1731.     }
  1732.  
  1733.     public boolean s(boolean ignoreHunger) {
  1734.         return this.cq.a || ignoreHunger || this.bW.c();
  1735.     }
  1736.  
  1737.     public boolean fu() {
  1738.         return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth();
  1739.     }
  1740.  
  1741.     public boolean fv() {
  1742.         return this.cq.e;
  1743.     }
  1744.  
  1745.     public boolean a(BlockPosition pos, EnumDirection facing, ItemStack stack) {
  1746.         if (this.cq.e) {
  1747.             return true;
  1748.         } else {
  1749.             BlockPosition blockposition1 = pos.shift(facing.opposite());
  1750.             ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(super.t, blockposition1, false);
  1751.             return stack.b(super.t.r(), shapedetectorblock);
  1752.         }
  1753.     }
  1754.  
  1755.     protected int getExpValue(EntityHuman player) {
  1756.         if (!super.t.getGameRules().getBoolean(GameRules.d) && !this.isSpectator()) {
  1757.             int i = this.ci * 7;
  1758.             return i > 100 ? 100 : i;
  1759.         } else {
  1760.             return 0;
  1761.         }
  1762.     }
  1763.  
  1764.     protected boolean alwaysGivesExp() {
  1765.         return true;
  1766.     }
  1767.  
  1768.     public boolean cn() {
  1769.         return true;
  1770.     }
  1771.  
  1772.     protected MovementEmission aI() {
  1773.         return this.cq.b || super.z && this.bG() ? MovementEmission.a : MovementEmission.d;
  1774.     }
  1775.  
  1776.     public void updateAbilities() {
  1777.     }
  1778.  
  1779.     public IChatBaseComponent getDisplayName() {
  1780.         return new ChatComponentText(this.cs.getName());
  1781.     }
  1782.  
  1783.     public InventoryEnderChest getEnderChest() {
  1784.         return this.bT;
  1785.     }
  1786.  
  1787.     public ItemStack getEquipment(EnumItemSlot slot) {
  1788.         return slot == EnumItemSlot.a ? this.co.getItemInHand() : (slot == EnumItemSlot.b ? (ItemStack)this.co.j.get(0) : (slot.a() == Function.b ? (ItemStack)this.co.i.get(slot.b()) : ItemStack.b));
  1789.     }
  1790.  
  1791.     public void setSlot(EnumItemSlot slot, ItemStack stack) {
  1792.         this.setSlot(slot, stack, false);
  1793.     }
  1794.  
  1795.     public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
  1796.         this.f(itemstack);
  1797.         if (enumitemslot == EnumItemSlot.a) {
  1798.             this.playEquipSound(itemstack, silent);
  1799.             this.co.h.set(this.co.k, itemstack);
  1800.         } else if (enumitemslot == EnumItemSlot.b) {
  1801.             this.playEquipSound(itemstack, silent);
  1802.             this.co.j.set(0, itemstack);
  1803.         } else if (enumitemslot.a() == Function.b) {
  1804.             this.playEquipSound(itemstack, silent);
  1805.             this.co.i.set(enumitemslot.b(), itemstack);
  1806.         }
  1807.  
  1808.     }
  1809.  
  1810.     public boolean j(ItemStack stack) {
  1811.         this.playEquipSound(stack);
  1812.         return this.co.pickup(stack);
  1813.     }
  1814.  
  1815.     public Iterable<ItemStack> bw() {
  1816.         return Lists.newArrayList(new ItemStack[]{this.getItemInMainHand(), this.getItemInOffHand()});
  1817.     }
  1818.  
  1819.     public Iterable<ItemStack> getArmorItems() {
  1820.         return this.co.i;
  1821.     }
  1822.  
  1823.     public boolean h(NBTTagCompound entityNbt) {
  1824.         if (!this.isPassenger() && super.z && !this.isInWater() && !super.al) {
  1825.             if (this.getShoulderEntityLeft().isEmpty()) {
  1826.                 this.setShoulderEntityLeft(entityNbt);
  1827.                 this.f = super.t.getTime();
  1828.                 return true;
  1829.             } else if (this.getShoulderEntityRight().isEmpty()) {
  1830.                 this.setShoulderEntityRight(entityNbt);
  1831.                 this.f = super.t.getTime();
  1832.                 return true;
  1833.             } else {
  1834.                 return false;
  1835.             }
  1836.         } else {
  1837.             return false;
  1838.         }
  1839.     }
  1840.  
  1841.     public void releaseShoulderEntities() {
  1842.         if (this.f + 20L < super.t.getTime()) {
  1843.             if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) {
  1844.                 this.setShoulderEntityLeft(new NBTTagCompound());
  1845.             }
  1846.  
  1847.             if (this.spawnEntityFromShoulder(this.getShoulderEntityRight())) {
  1848.                 this.setShoulderEntityRight(new NBTTagCompound());
  1849.             }
  1850.         }
  1851.  
  1852.     }
  1853.  
  1854.     public Entity releaseLeftShoulderEntity() {
  1855.         Entity entity = this.spawnEntityFromShoulder0(this.getShoulderEntityLeft());
  1856.         if (entity != null) {
  1857.             this.setShoulderEntityLeft(new NBTTagCompound());
  1858.         }
  1859.  
  1860.         return entity;
  1861.     }
  1862.  
  1863.     public Entity releaseRightShoulderEntity() {
  1864.         Entity entity = this.spawnEntityFromShoulder0(this.getShoulderEntityRight());
  1865.         if (entity != null) {
  1866.             this.setShoulderEntityRight(new NBTTagCompound());
  1867.         }
  1868.  
  1869.         return entity;
  1870.     }
  1871.  
  1872.     private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) {
  1873.         return this.spawnEntityFromShoulder0(nbttagcompound) != null;
  1874.     }
  1875.  
  1876.     private Entity spawnEntityFromShoulder0(@Nullable NBTTagCompound nbttagcompound) {
  1877.         return !super.t.y && nbttagcompound != null && !nbttagcompound.isEmpty() ? (Entity)EntityTypes.a(nbttagcompound, super.t).map((entity) -> {
  1878.             if (entity instanceof EntityTameableAnimal) {
  1879.                 ((EntityTameableAnimal)entity).setOwnerUUID(super.aj);
  1880.             }
  1881.  
  1882.             entity.setPosition(this.locX(), this.locY() + 0.699999988079071D, this.locZ());
  1883.             boolean addedToWorld = ((WorldServer)super.t).addEntitySerialized(entity, SpawnReason.SHOULDER_ENTITY);
  1884.             return addedToWorld ? entity : null;
  1885.         }).orElse((Object)null) : null;
  1886.     }
  1887.  
  1888.     public abstract boolean isSpectator();
  1889.  
  1890.     public boolean isSwimming() {
  1891.         return !this.cq.b && !this.isSpectator() && super.isSwimming();
  1892.     }
  1893.  
  1894.     public abstract boolean isCreative();
  1895.  
  1896.     public boolean ck() {
  1897.         return !this.cq.b;
  1898.     }
  1899.  
  1900.     public Scoreboard getScoreboard() {
  1901.         return super.t.getScoreboard();
  1902.     }
  1903.  
  1904.     public IChatBaseComponent getScoreboardDisplayName() {
  1905.         IChatMutableComponent ichatmutablecomponent = ScoreboardTeam.a(this.getScoreboardTeam(), this.getDisplayName());
  1906.         return this.a(ichatmutablecomponent);
  1907.     }
  1908.  
  1909.     private IChatMutableComponent a(IChatMutableComponent component) {
  1910.         String s = this.getProfile().getName();
  1911.         return component.format((chatmodifier) -> {
  1912.             return chatmodifier.setChatClickable(new ChatClickable(EnumClickAction.d, "/tell " + s + " ")).setChatHoverable(this.cq()).setInsertion(s);
  1913.         });
  1914.     }
  1915.  
  1916.     public String getName() {
  1917.         return this.getProfile().getName();
  1918.     }
  1919.  
  1920.     public float b(EntityPose pose, EntitySize dimensions) {
  1921.         switch(pose) {
  1922.         case d:
  1923.         case b:
  1924.         case e:
  1925.             return 0.4F;
  1926.         case f:
  1927.             return 1.27F;
  1928.         default:
  1929.             return 1.62F;
  1930.         }
  1931.     }
  1932.  
  1933.     public void setAbsorptionHearts(float amount) {
  1934.         if (amount < 0.0F) {
  1935.             amount = 0.0F;
  1936.         }
  1937.  
  1938.         this.getDataWatcher().set(d, amount);
  1939.     }
  1940.  
  1941.     public float getAbsorptionHearts() {
  1942.         return (Float)this.getDataWatcher().get(d);
  1943.     }
  1944.  
  1945.     public static UUID a(GameProfile profile) {
  1946.         UUID uuid = profile.getId();
  1947.         if (uuid == null) {
  1948.             uuid = getOfflineUUID(profile.getName());
  1949.         }
  1950.  
  1951.         return uuid;
  1952.     }
  1953.  
  1954.     public static UUID getOfflineUUID(String nickname) {
  1955.         return UUID.nameUUIDFromBytes(("OfflinePlayer:" + nickname).getBytes(StandardCharsets.UTF_8));
  1956.     }
  1957.  
  1958.     public boolean a(PlayerModelPart modelPart) {
  1959.         return ((Byte)this.getDataWatcher().get(bP) & modelPart.a()) == modelPart.a();
  1960.     }
  1961.  
  1962.     public SlotAccess k(int mappedIndex) {
  1963.         if (mappedIndex >= 0 && mappedIndex < this.co.h.size()) {
  1964.             return SlotAccess.a(this.co, mappedIndex);
  1965.         } else {
  1966.             int j = mappedIndex - 200;
  1967.             return j >= 0 && j < this.bT.getSize() ? SlotAccess.a(this.bT, j) : super.k(mappedIndex);
  1968.         }
  1969.     }
  1970.  
  1971.     public boolean fz() {
  1972.         return this.ct;
  1973.     }
  1974.  
  1975.     public void t(boolean reducedDebugInfo) {
  1976.         this.ct = reducedDebugInfo;
  1977.     }
  1978.  
  1979.     public void setFireTicks(int ticks) {
  1980.         super.setFireTicks(this.cq.a ? Math.min(ticks, 1) : ticks);
  1981.     }
  1982.  
  1983.     public EnumMainHand getMainHand() {
  1984.         return (Byte)super.Y.get(bQ) == 0 ? EnumMainHand.a : EnumMainHand.b;
  1985.     }
  1986.  
  1987.     public void a(EnumMainHand arm) {
  1988.         super.Y.set(bQ, (byte)(arm == EnumMainHand.a ? 0 : 1));
  1989.     }
  1990.  
  1991.     public NBTTagCompound getShoulderEntityLeft() {
  1992.         return (NBTTagCompound)super.Y.get(bR);
  1993.     }
  1994.  
  1995.     public void setShoulderEntityLeft(NBTTagCompound entityNbt) {
  1996.         super.Y.set(bR, entityNbt);
  1997.     }
  1998.  
  1999.     public NBTTagCompound getShoulderEntityRight() {
  2000.         return (NBTTagCompound)super.Y.get(bS);
  2001.     }
  2002.  
  2003.     public void setShoulderEntityRight(NBTTagCompound entityNbt) {
  2004.         super.Y.set(bS, entityNbt);
  2005.     }
  2006.  
  2007.     public float fC() {
  2008.         return (float)(1.0D / this.b((AttributeBase)GenericAttributes.h) * 20.0D);
  2009.     }
  2010.  
  2011.     public float getAttackCooldown(float baseTime) {
  2012.         return MathHelper.a(((float)super.aQ + baseTime) / this.fC(), 0.0F, 1.0F);
  2013.     }
  2014.  
  2015.     public void resetAttackCooldown() {
  2016.         super.aQ = 0;
  2017.     }
  2018.  
  2019.     public ItemCooldown getCooldownTracker() {
  2020.         return this.cv;
  2021.     }
  2022.  
  2023.     protected float getBlockSpeedFactor() {
  2024.         return !this.cq.b && !this.isGliding() ? super.getBlockSpeedFactor() : 1.0F;
  2025.     }
  2026.  
  2027.     public float fF() {
  2028.         return (float)this.b((AttributeBase)GenericAttributes.k);
  2029.     }
  2030.  
  2031.     public boolean isCreativeAndOp() {
  2032.         return this.cq.d && this.y() >= 2;
  2033.     }
  2034.  
  2035.     public boolean g(ItemStack stack) {
  2036.         EnumItemSlot enumitemslot = EntityInsentient.getEquipmentSlotForItem(stack);
  2037.         return this.getEquipment(enumitemslot).isEmpty();
  2038.     }
  2039.  
  2040.     public EntitySize a(EntityPose pose) {
  2041.         return (EntitySize)b.getOrDefault(pose, bO);
  2042.     }
  2043.  
  2044.     public ImmutableList<EntityPose> eS() {
  2045.         return ImmutableList.of(EntityPose.a, EntityPose.f, EntityPose.d);
  2046.     }
  2047.  
  2048.     protected boolean tryReadyArrow(ItemStack bow, ItemStack itemstack) {
  2049.         return !(this instanceof EntityPlayer) || (new PlayerReadyArrowEvent(((EntityPlayer)this).getBukkitEntity(), CraftItemStack.asCraftMirror(bow), CraftItemStack.asCraftMirror(itemstack))).callEvent();
  2050.     }
  2051.  
  2052.     public ItemStack h(ItemStack stack) {
  2053.         if (!(stack.getItem() instanceof ItemProjectileWeapon)) {
  2054.             return ItemStack.b;
  2055.         } else {
  2056.             Predicate<ItemStack> predicate = ((ItemProjectileWeapon)stack.getItem()).e();
  2057.             ItemStack itemstack1 = ItemProjectileWeapon.a(this, predicate);
  2058.             if (!itemstack1.isEmpty()) {
  2059.                 return itemstack1;
  2060.             } else {
  2061.                 predicate = ((ItemProjectileWeapon)stack.getItem()).b();
  2062.  
  2063.                 for(int i = 0; i < this.co.getSize(); ++i) {
  2064.                     ItemStack itemstack2 = this.co.getItem(i);
  2065.                     if (predicate.test(itemstack2) && this.tryReadyArrow(stack, itemstack2)) {
  2066.                         return itemstack2;
  2067.                     }
  2068.                 }
  2069.  
  2070.                 return this.cq.d ? new ItemStack(Items.mh) : ItemStack.b;
  2071.             }
  2072.         }
  2073.     }
  2074.  
  2075.     public ItemStack a(World world, ItemStack stack) {
  2076.         this.getFoodData().a(stack.getItem(), stack);
  2077.         this.b(StatisticList.c.b(stack.getItem()));
  2078.         world.playSound((EntityHuman)null, this.locX(), this.locY(), this.locZ(), SoundEffects.or, SoundCategory.h, 0.5F, world.w.nextFloat() * 0.1F + 0.9F);
  2079.         if (this instanceof EntityPlayer) {
  2080.             CriterionTriggers.z.a((EntityPlayer)this, stack);
  2081.         }
  2082.  
  2083.         return super.a(world, stack);
  2084.     }
  2085.  
  2086.     protected boolean b(IBlockData landingState) {
  2087.         return this.cq.b || super.b(landingState);
  2088.     }
  2089.  
  2090.     public Vec3D n(float f) {
  2091.         double d0 = 0.22D * (this.getMainHand() == EnumMainHand.b ? -1.0D : 1.0D);
  2092.         float f1 = MathHelper.h(f * 0.5F, this.getXRot(), super.y) * 0.017453292F;
  2093.         float f2 = MathHelper.h(f, super.aY, super.aX) * 0.017453292F;
  2094.         double d1;
  2095.         if (!this.isGliding() && !this.isRiptiding()) {
  2096.             if (this.bL()) {
  2097.                 return this.k(f).e((new Vec3D(d0, 0.2D, -0.15D)).a(-f1).b(-f2));
  2098.             } else {
  2099.                 double d2 = this.getBoundingBox().c() - 1.0D;
  2100.                 d1 = this.isCrouching() ? -0.2D : 0.07D;
  2101.                 return this.k(f).e((new Vec3D(d0, d2, d1)).b(-f2));
  2102.             }
  2103.         } else {
  2104.             Vec3D vec3d = this.e(f);
  2105.             Vec3D vec3d1 = this.getMot();
  2106.             d1 = vec3d1.i();
  2107.             double d3 = vec3d.i();
  2108.             float f3;
  2109.             if (d1 > 0.0D && d3 > 0.0D) {
  2110.                 double d4 = (vec3d1.b * vec3d.b + vec3d1.d * vec3d.d) / Math.sqrt(d1 * d3);
  2111.                 double d5 = vec3d1.b * vec3d.d - vec3d1.d * vec3d.b;
  2112.                 f3 = (float)(Math.signum(d5) * Math.acos(d4));
  2113.             } else {
  2114.                 f3 = 0.0F;
  2115.             }
  2116.  
  2117.             return this.k(f).e((new Vec3D(d0, -0.11D, 0.85D)).c(-f3).a(-f1).b(-f2));
  2118.         }
  2119.     }
  2120.  
  2121.     public boolean dn() {
  2122.         return true;
  2123.     }
  2124.  
  2125.     public boolean fH() {
  2126.         return this.isHandRaised() && this.getActiveItem().a(Items.ot);
  2127.     }
  2128.  
  2129.     public boolean dm() {
  2130.         return false;
  2131.     }
  2132.  
  2133.     static {
  2134.         b = ImmutableMap.builder().put(EntityPose.a, bO).put(EntityPose.c, EntityLiving.aD).put(EntityPose.b, EntitySize.b(0.6F, 0.6F)).put(EntityPose.d, EntitySize.b(0.6F, 0.6F)).put(EntityPose.e, EntitySize.b(0.6F, 0.6F)).put(EntityPose.f, EntitySize.b(0.6F, 1.5F)).put(EntityPose.h, EntitySize.c(0.2F, 0.2F)).build();
  2135.         d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
  2136.         e = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
  2137.         bP = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
  2138.         bQ = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
  2139.         bR = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
  2140.         bS = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
  2141.     }
  2142.  
  2143.     public static enum EnumBedResult {
  2144.         a,
  2145.         b(new ChatMessage("block.minecraft.bed.no_sleep")),
  2146.         c(new ChatMessage("block.minecraft.bed.too_far_away")),
  2147.         d(new ChatMessage("block.minecraft.bed.obstructed")),
  2148.         e,
  2149.         f(new ChatMessage("block.minecraft.bed.not_safe"));
  2150.  
  2151.         @Nullable
  2152.         private final IChatBaseComponent g;
  2153.  
  2154.         private EnumBedResult() {
  2155.             this.g = null;
  2156.         }
  2157.  
  2158.         private EnumBedResult(IChatBaseComponent ichatbasecomponent) {
  2159.             this.g = ichatbasecomponent;
  2160.         }
  2161.  
  2162.         @Nullable
  2163.         public IChatBaseComponent a() {
  2164.             return this.g;
  2165.         }
  2166.     }
  2167. }
  2168.  
Add Comment
Please, Sign In to add comment