broken-arrow

Untitled

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