Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by FernFlower decompiler)
- //
- package net.minecraft.world.entity.player;
- import com.google.common.collect.ImmutableList;
- import com.google.common.collect.ImmutableMap;
- import com.google.common.collect.Lists;
- import com.mojang.authlib.GameProfile;
- import com.mojang.datafixers.util.Either;
- import java.nio.charset.StandardCharsets;
- import java.util.Collection;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.Optional;
- import java.util.OptionalInt;
- import java.util.UUID;
- import java.util.function.Predicate;
- import javax.annotation.Nullable;
- import net.minecraft.SharedConstants;
- import net.minecraft.SystemUtils;
- import net.minecraft.advancements.CriterionTriggers;
- import net.minecraft.core.BlockPosition;
- import net.minecraft.core.EnumDirection;
- import net.minecraft.core.particles.ParticleParam;
- import net.minecraft.core.particles.Particles;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagList;
- import net.minecraft.network.chat.ChatClickable;
- import net.minecraft.network.chat.ChatComponentText;
- import net.minecraft.network.chat.ChatMessage;
- import net.minecraft.network.chat.IChatBaseComponent;
- import net.minecraft.network.chat.IChatMutableComponent;
- import net.minecraft.network.chat.ChatClickable.EnumClickAction;
- import net.minecraft.network.protocol.game.PacketPlayOutEntityVelocity;
- import net.minecraft.network.syncher.DataWatcher;
- import net.minecraft.network.syncher.DataWatcherObject;
- import net.minecraft.network.syncher.DataWatcherRegistry;
- import net.minecraft.resources.MinecraftKey;
- import net.minecraft.server.level.EntityPlayer;
- import net.minecraft.server.level.WorldServer;
- import net.minecraft.sounds.SoundCategory;
- import net.minecraft.sounds.SoundEffect;
- import net.minecraft.sounds.SoundEffects;
- import net.minecraft.stats.Statistic;
- import net.minecraft.stats.StatisticList;
- import net.minecraft.tags.Tag;
- import net.minecraft.tags.TagsFluid;
- import net.minecraft.util.MathHelper;
- import net.minecraft.util.Unit;
- import net.minecraft.world.EnumDifficulty;
- import net.minecraft.world.EnumHand;
- import net.minecraft.world.EnumInteractionResult;
- import net.minecraft.world.IInventory;
- import net.minecraft.world.ITileInventory;
- import net.minecraft.world.damagesource.DamageSource;
- import net.minecraft.world.effect.MobEffect;
- import net.minecraft.world.effect.MobEffectList;
- import net.minecraft.world.effect.MobEffectUtil;
- import net.minecraft.world.effect.MobEffects;
- import net.minecraft.world.entity.Entity;
- import net.minecraft.world.entity.EntityInsentient;
- import net.minecraft.world.entity.EntityLiving;
- import net.minecraft.world.entity.EntityPose;
- import net.minecraft.world.entity.EntitySize;
- import net.minecraft.world.entity.EntityTameableAnimal;
- import net.minecraft.world.entity.EntityTypes;
- import net.minecraft.world.entity.EnumItemSlot;
- import net.minecraft.world.entity.EnumMainHand;
- import net.minecraft.world.entity.EnumMonsterType;
- import net.minecraft.world.entity.EnumMoveType;
- import net.minecraft.world.entity.SlotAccess;
- import net.minecraft.world.entity.Entity.MovementEmission;
- import net.minecraft.world.entity.Entity.RemovalReason;
- import net.minecraft.world.entity.EntityLiving.a;
- import net.minecraft.world.entity.EnumItemSlot.Function;
- import net.minecraft.world.entity.ai.attributes.AttributeBase;
- import net.minecraft.world.entity.ai.attributes.GenericAttributes;
- import net.minecraft.world.entity.ai.attributes.AttributeProvider.Builder;
- import net.minecraft.world.entity.animal.EntityParrot;
- import net.minecraft.world.entity.animal.EntityPig;
- import net.minecraft.world.entity.animal.horse.EntityHorseAbstract;
- import net.minecraft.world.entity.boss.EntityComplexPart;
- import net.minecraft.world.entity.decoration.EntityArmorStand;
- import net.minecraft.world.entity.item.EntityItem;
- import net.minecraft.world.entity.monster.EntityStrider;
- import net.minecraft.world.entity.projectile.EntityFishingHook;
- import net.minecraft.world.entity.vehicle.EntityBoat;
- import net.minecraft.world.entity.vehicle.EntityMinecartAbstract;
- import net.minecraft.world.food.FoodMetaData;
- import net.minecraft.world.inventory.ClickAction;
- import net.minecraft.world.inventory.Container;
- import net.minecraft.world.inventory.ContainerPlayer;
- import net.minecraft.world.inventory.InventoryEnderChest;
- import net.minecraft.world.item.ItemAxe;
- import net.minecraft.world.item.ItemCooldown;
- import net.minecraft.world.item.ItemElytra;
- import net.minecraft.world.item.ItemProjectileWeapon;
- import net.minecraft.world.item.ItemStack;
- import net.minecraft.world.item.ItemSword;
- import net.minecraft.world.item.Items;
- import net.minecraft.world.item.crafting.IRecipe;
- import net.minecraft.world.item.enchantment.EnchantmentManager;
- import net.minecraft.world.item.trading.MerchantRecipeList;
- import net.minecraft.world.level.CommandBlockListenerAbstract;
- import net.minecraft.world.level.EnumGamemode;
- import net.minecraft.world.level.GameRules;
- import net.minecraft.world.level.World;
- import net.minecraft.world.level.block.Block;
- import net.minecraft.world.level.block.BlockBed;
- import net.minecraft.world.level.block.BlockRespawnAnchor;
- import net.minecraft.world.level.block.entity.TileEntityCommand;
- import net.minecraft.world.level.block.entity.TileEntityJigsaw;
- import net.minecraft.world.level.block.entity.TileEntitySign;
- import net.minecraft.world.level.block.entity.TileEntityStructure;
- import net.minecraft.world.level.block.state.IBlockData;
- import net.minecraft.world.level.block.state.pattern.ShapeDetectorBlock;
- import net.minecraft.world.phys.AxisAlignedBB;
- import net.minecraft.world.phys.Vec3D;
- import net.minecraft.world.scores.Scoreboard;
- import net.minecraft.world.scores.ScoreboardTeam;
- import org.bukkit.Bukkit;
- import org.bukkit.OfflinePlayer;
- import org.bukkit.craftbukkit.v1_18_R1.entity.CraftHumanEntity;
- import org.bukkit.craftbukkit.v1_18_R1.event.CraftEventFactory;
- import org.bukkit.craftbukkit.v1_18_R1.util.CraftVector;
- import org.bukkit.entity.Item;
- import org.bukkit.entity.Player;
- import org.bukkit.event.entity.EntityCombustByEntityEvent;
- import org.bukkit.event.entity.EntityExhaustionEvent;
- import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
- import org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason;
- import org.bukkit.event.entity.EntityPotionEffectEvent.Cause;
- import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
- import org.bukkit.event.player.PlayerDropItemEvent;
- import org.bukkit.event.player.PlayerVelocityEvent;
- import org.bukkit.scoreboard.Team;
- import org.bukkit.util.Vector;
- public abstract class EntityHuman extends EntityLiving {
- public static final String bF = "OfflinePlayer:";
- public static final int bG = 16;
- public static final int bH = 20;
- public static final int bI = 100;
- public static final int bJ = 10;
- public static final int bK = 200;
- public static final float bL = 1.5F;
- public static final float bM = 0.6F;
- public static final float bN = 0.6F;
- public static final float bO = 1.62F;
- public static final EntitySize bP = EntitySize.b(0.6F, 1.8F);
- private static final Map<EntityPose, EntitySize> b;
- private static final int c = 25;
- private static final DataWatcherObject<Float> d;
- private static final DataWatcherObject<Integer> e;
- protected static final DataWatcherObject<Byte> bQ;
- protected static final DataWatcherObject<Byte> bR;
- protected static final DataWatcherObject<NBTTagCompound> bS;
- protected static final DataWatcherObject<NBTTagCompound> bT;
- private long f;
- private final PlayerInventory cp = new PlayerInventory(this);
- protected InventoryEnderChest bU = new InventoryEnderChest(this);
- public final ContainerPlayer bV;
- public Container bW;
- protected FoodMetaData bX = new FoodMetaData(this);
- protected int bY;
- public float bZ;
- public float ca;
- public int cb;
- public double cc;
- public double cd;
- public double ce;
- public double cf;
- public double cg;
- public double ch;
- public int cq;
- protected boolean ci;
- private final PlayerAbilities cr = new PlayerAbilities();
- public int cj;
- public int ck;
- public float cl;
- protected int cm;
- protected final float cn = 0.02F;
- private int cs;
- private final GameProfile ct;
- private boolean cu;
- private ItemStack cv;
- private final ItemCooldown cw;
- @Nullable
- public EntityFishingHook co;
- public boolean fauxSleeping;
- public int oldLevel = -1;
- static {
- 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();
- d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
- e = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
- bQ = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
- bR = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
- bS = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
- bT = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
- }
- public CraftHumanEntity getBukkitEntity() {
- return (CraftHumanEntity)super.getBukkitEntity();
- }
- public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
- super(EntityTypes.bi, world);
- this.cv = ItemStack.b;
- this.cw = this.j();
- this.a_(a(gameprofile));
- this.ct = gameprofile;
- this.bV = new ContainerPlayer(this.cp, !world.y, this);
- this.bW = this.bV;
- this.b((double)blockposition.u() + 0.5D, (double)(blockposition.v() + 1), (double)blockposition.w() + 0.5D, f, 0.0F);
- this.bl = 180.0F;
- }
- public boolean a(World world, BlockPosition blockposition, EnumGamemode enumgamemode) {
- if (!enumgamemode.e()) {
- return false;
- } else if (enumgamemode == EnumGamemode.d) {
- return true;
- } else if (this.fB()) {
- return false;
- } else {
- ItemStack itemstack = this.er();
- return itemstack.b() || !itemstack.b(world.r(), new ShapeDetectorBlock(world, blockposition, false));
- }
- }
- public static Builder fe() {
- return EntityLiving.dv().a(GenericAttributes.f, 1.0D).a(GenericAttributes.d, 0.10000000149011612D).a(GenericAttributes.h).a(GenericAttributes.k);
- }
- protected void a_() {
- super.a_();
- this.Z.a(d, 0.0F);
- this.Z.a(e, 0);
- this.Z.a(bQ, (byte)0);
- this.Z.a(bR, (byte)1);
- this.Z.a(bS, new NBTTagCompound());
- this.Z.a(bT, new NBTTagCompound());
- }
- public void k() {
- this.Q = this.B_();
- if (this.B_()) {
- this.z = false;
- }
- if (this.cb > 0) {
- --this.cb;
- }
- if (this.fb()) {
- ++this.cq;
- if (this.cq > 100) {
- this.cq = 100;
- }
- if (!this.t.y && this.t.P()) {
- this.a(false, true);
- }
- } else if (this.cq > 0) {
- ++this.cq;
- if (this.cq >= 110) {
- this.cq = 0;
- }
- }
- this.fi();
- super.k();
- if (!this.t.y && this.bW != null && !this.bW.a(this)) {
- this.q();
- this.bW = this.bV;
- }
- this.r();
- if (!this.t.y) {
- this.bX.a(this);
- this.a(StatisticList.k);
- this.a(StatisticList.l);
- if (this.bl()) {
- this.a(StatisticList.m);
- }
- if (this.bL()) {
- this.a(StatisticList.o);
- }
- if (!this.fb()) {
- this.a(StatisticList.n);
- }
- }
- int i = 29999999;
- double d0 = MathHelper.a(this.dc(), -2.9999999E7D, 2.9999999E7D);
- double d1 = MathHelper.a(this.di(), -2.9999999E7D, 2.9999999E7D);
- if (d0 != this.dc() || d1 != this.di()) {
- this.e(d0, this.de(), d1);
- }
- ++this.aR;
- ItemStack itemstack = this.er();
- if (!ItemStack.b(this.cv, itemstack)) {
- if (!ItemStack.d(this.cv, itemstack)) {
- this.fJ();
- }
- this.cv = itemstack.m();
- }
- this.n();
- this.cw.a();
- this.fj();
- }
- public boolean ff() {
- return this.bI();
- }
- protected boolean fg() {
- return this.bI();
- }
- protected boolean fh() {
- return this.bI();
- }
- protected boolean fi() {
- this.ci = this.a((Tag)TagsFluid.b);
- return this.ci;
- }
- private void n() {
- ItemStack itemstack = this.b(EnumItemSlot.f);
- if (itemstack.a(Items.mc) && !this.a((Tag)TagsFluid.b)) {
- this.addEffect(new MobEffect(MobEffects.m, 200, 0, false, false, true), Cause.TURTLE_HELMET);
- }
- }
- protected ItemCooldown j() {
- return new ItemCooldown();
- }
- private void r() {
- this.cc = this.cf;
- this.cd = this.cg;
- this.ce = this.ch;
- double d0 = this.dc() - this.cf;
- double d1 = this.de() - this.cg;
- double d2 = this.di() - this.ch;
- double d3 = 10.0D;
- if (d0 > 10.0D) {
- this.cf = this.dc();
- this.cc = this.cf;
- }
- if (d2 > 10.0D) {
- this.ch = this.di();
- this.ce = this.ch;
- }
- if (d1 > 10.0D) {
- this.cg = this.de();
- this.cd = this.cg;
- }
- if (d0 < -10.0D) {
- this.cf = this.dc();
- this.cc = this.cf;
- }
- if (d2 < -10.0D) {
- this.ch = this.di();
- this.ce = this.ch;
- }
- if (d1 < -10.0D) {
- this.cg = this.de();
- this.cd = this.cg;
- }
- this.cf += d0 * 0.25D;
- this.ch += d2 * 0.25D;
- this.cg += d1 * 0.25D;
- }
- protected void fj() {
- if (this.c((EntityPose)EntityPose.d)) {
- EntityPose entitypose;
- if (this.eU()) {
- entitypose = EntityPose.b;
- } else if (this.fb()) {
- entitypose = EntityPose.c;
- } else if (this.bP()) {
- entitypose = EntityPose.d;
- } else if (this.eG()) {
- entitypose = EntityPose.e;
- } else if (this.bI() && !this.cr.b) {
- entitypose = EntityPose.f;
- } else {
- entitypose = EntityPose.a;
- }
- EntityPose entitypose1;
- if (!this.B_() && !this.bF() && !this.c((EntityPose)entitypose)) {
- if (this.c((EntityPose)EntityPose.f)) {
- entitypose1 = EntityPose.f;
- } else {
- entitypose1 = EntityPose.d;
- }
- } else {
- entitypose1 = entitypose;
- }
- this.b((EntityPose)entitypose1);
- }
- }
- public int ar() {
- return this.cr.a ? 1 : 80;
- }
- protected SoundEffect aF() {
- return SoundEffects.oP;
- }
- protected SoundEffect aG() {
- return SoundEffects.oN;
- }
- protected SoundEffect aH() {
- return SoundEffects.oO;
- }
- public int bz() {
- return 10;
- }
- public void a(SoundEffect soundeffect, float f, float f1) {
- this.t.a(this, this.dc(), this.de(), this.di(), soundeffect, this.cO(), f, f1);
- }
- public void a(SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
- }
- public SoundCategory cO() {
- return SoundCategory.h;
- }
- public int cP() {
- return 20;
- }
- public void a(byte b0) {
- if (b0 == 9) {
- this.v();
- } else if (b0 == 23) {
- this.cu = false;
- } else if (b0 == 22) {
- this.cu = true;
- } else if (b0 == 43) {
- this.a((ParticleParam)Particles.f);
- } else {
- super.a(b0);
- }
- }
- private void a(ParticleParam particleparam) {
- for(int i = 0; i < 5; ++i) {
- double d0 = this.R.nextGaussian() * 0.02D;
- double d1 = this.R.nextGaussian() * 0.02D;
- double d2 = this.R.nextGaussian() * 0.02D;
- this.t.a(particleparam, this.d(1.0D), this.df() + 1.0D, this.g(1.0D), d0, d1, d2);
- }
- }
- public void q() {
- this.bW = this.bV;
- }
- public void bo() {
- if (!this.t.y && this.fg() && this.bF()) {
- this.p();
- this.f(false);
- } else {
- double d0 = this.dc();
- double d1 = this.de();
- double d2 = this.di();
- super.bo();
- this.bZ = this.ca;
- this.ca = 0.0F;
- this.r(this.dc() - d0, this.de() - d1, this.di() - d2);
- }
- }
- protected void eE() {
- super.eE();
- this.eo();
- this.ba = this.dm();
- }
- public void w_() {
- if (this.bY > 0) {
- --this.bY;
- }
- if (this.t.af() == EnumDifficulty.a && this.t.X().b(GameRules.j)) {
- if (this.dZ() < this.el() && this.S % 20 == 0) {
- this.heal(1.0F, RegainReason.REGEN);
- }
- if (this.bX.c() && this.S % 10 == 0) {
- this.bX.a(this.bX.a() + 1);
- }
- }
- this.cp.j();
- this.bZ = this.ca;
- super.w_();
- this.bc = 0.02F;
- if (this.bO()) {
- this.bc = (float)((double)this.bc + 0.005999999865889549D);
- }
- this.r((float)this.b((AttributeBase)GenericAttributes.d));
- float f;
- if (this.z && !this.ea() && !this.bP()) {
- f = Math.min(0.1F, (float)this.da().h());
- } else {
- f = 0.0F;
- }
- this.ca += (f - this.ca) * 0.4F;
- if (this.dZ() > 0.0F && !this.B_()) {
- AxisAlignedBB axisalignedbb;
- if (this.bF() && !this.cN().do()) {
- axisalignedbb = this.cw().b(this.cN().cw()).c(1.0D, 0.0D, 1.0D);
- } else {
- axisalignedbb = this.cw().c(1.0D, 0.5D, 1.0D);
- }
- List<Entity> list = this.t.a_(this, axisalignedbb);
- List<Entity> list1 = Lists.newArrayList();
- for(int i = 0; i < list.size(); ++i) {
- Entity entity = (Entity)list.get(i);
- if (entity.ad() == EntityTypes.A) {
- list1.add(entity);
- } else if (!entity.do()) {
- this.c(entity);
- }
- }
- if (!list1.isEmpty()) {
- this.c((Entity)SystemUtils.a(list1, this.R));
- }
- }
- this.c(this.fG());
- this.c(this.fH());
- if (!this.t.y && (this.L > 0.5F || this.aQ()) || this.cr.b || this.fb() || this.am) {
- this.fD();
- }
- }
- private void c(@Nullable NBTTagCompound nbttagcompound) {
- if (nbttagcompound != null && (!nbttagcompound.e("Silent") || !nbttagcompound.q("Silent")) && this.t.w.nextInt(200) == 0) {
- String s = nbttagcompound.l("id");
- EntityTypes.a(s).filter((entitytypes) -> {
- return entitytypes == EntityTypes.al;
- }).ifPresent((entitytypes) -> {
- if (!EntityParrot.a(this.t, this)) {
- 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));
- }
- });
- }
- }
- private void c(Entity entity) {
- entity.b(this);
- }
- public int fk() {
- return (Integer)this.Z.a(e);
- }
- public void s(int i) {
- this.Z.b(e, i);
- }
- public void t(int i) {
- int j = this.fk();
- this.Z.b(e, j + i);
- }
- public void a(DamageSource damagesource) {
- super.a(damagesource);
- this.am();
- if (!this.B_()) {
- this.f(damagesource);
- }
- if (damagesource != null) {
- 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));
- } else {
- this.n(0.0D, 0.1D, 0.0D);
- }
- this.a(StatisticList.N);
- this.a(StatisticList.i.b(StatisticList.m));
- this.a(StatisticList.i.b(StatisticList.n));
- this.au();
- this.a_(false);
- }
- protected void ec() {
- super.ec();
- if (!this.t.X().b(GameRules.d)) {
- this.fl();
- this.cp.k();
- }
- }
- protected void fl() {
- for(int i = 0; i < this.cp.b(); ++i) {
- ItemStack itemstack = this.cp.a(i);
- if (!itemstack.b() && EnchantmentManager.e(itemstack)) {
- this.cp.b(i);
- }
- }
- }
- protected SoundEffect c(DamageSource damagesource) {
- return damagesource == DamageSource.c ? SoundEffects.oJ : (damagesource == DamageSource.h ? SoundEffects.oH : (damagesource == DamageSource.u ? SoundEffects.oK : (damagesource == DamageSource.v ? SoundEffects.oI : SoundEffects.oG)));
- }
- protected SoundEffect x_() {
- return SoundEffects.oF;
- }
- @Nullable
- public EntityItem a(ItemStack itemstack, boolean flag) {
- return this.a(itemstack, false, flag);
- }
- @Nullable
- public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) {
- if (itemstack.b()) {
- return null;
- } else {
- if (this.t.y) {
- this.a((EnumHand)EnumHand.a);
- }
- double d0 = this.dg() - 0.30000001192092896D;
- EntityItem entityitem = new EntityItem(this.t, this.dc(), d0, this.di(), itemstack);
- entityitem.a(40);
- if (flag1) {
- entityitem.c(this.cm());
- }
- float f;
- float f1;
- if (flag) {
- f = this.R.nextFloat() * 0.5F;
- f1 = this.R.nextFloat() * 6.2831855F;
- entityitem.n((double)(-MathHelper.a(f1) * f), 0.20000000298023224D, (double)(MathHelper.b(f1) * f));
- } else {
- f = 0.3F;
- f1 = MathHelper.a(this.dn() * 0.017453292F);
- float f2 = MathHelper.b(this.dn() * 0.017453292F);
- float f3 = MathHelper.a(this.dm() * 0.017453292F);
- float f4 = MathHelper.b(this.dm() * 0.017453292F);
- float f5 = this.R.nextFloat() * 6.2831855F;
- float f6 = 0.02F * this.R.nextFloat();
- 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);
- }
- Player player = (Player)this.getBukkitEntity();
- Item drop = (Item)entityitem.getBukkitEntity();
- PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
- this.t.getCraftServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- return entityitem;
- } else {
- org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
- if (flag1 && (cur == null || cur.getAmount() == 0)) {
- player.getInventory().setItemInHand(drop.getItemStack());
- } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
- cur.setAmount(cur.getAmount() + 1);
- player.getInventory().setItemInHand(cur);
- } else {
- player.getInventory().addItem(new org.bukkit.inventory.ItemStack[]{drop.getItemStack()});
- }
- return null;
- }
- }
- }
- public float c(IBlockData iblockdata) {
- float f = this.cp.a(iblockdata);
- if (f > 1.0F) {
- int i = EnchantmentManager.f(this);
- ItemStack itemstack = this.er();
- if (i > 0 && !itemstack.b()) {
- f += (float)(i * i + 1);
- }
- }
- if (MobEffectUtil.a(this)) {
- f *= 1.0F + (float)(MobEffectUtil.b(this) + 1) * 0.2F;
- }
- if (this.a((MobEffectList)MobEffects.d)) {
- float f1;
- switch(this.b((MobEffectList)MobEffects.d).c()) {
- case 0:
- f1 = 0.3F;
- break;
- case 1:
- f1 = 0.09F;
- break;
- case 2:
- f1 = 0.0027F;
- break;
- case 3:
- default:
- f1 = 8.1E-4F;
- }
- f *= f1;
- }
- if (this.a((Tag)TagsFluid.b) && !EnchantmentManager.h(this)) {
- f /= 5.0F;
- }
- if (!this.z) {
- f /= 5.0F;
- }
- return f;
- }
- public boolean d(IBlockData iblockdata) {
- return !iblockdata.r() || this.cp.f().b(iblockdata);
- }
- public void a(NBTTagCompound nbttagcompound) {
- super.a(nbttagcompound);
- this.a_(a(this.ct));
- NBTTagList nbttaglist = nbttagcompound.c("Inventory", 10);
- this.cp.b(nbttaglist);
- this.cp.k = nbttagcompound.h("SelectedItemSlot");
- this.cq = nbttagcompound.g("SleepTimer");
- this.cl = nbttagcompound.j("XpP");
- this.cj = nbttagcompound.h("XpLevel");
- this.ck = nbttagcompound.h("XpTotal");
- this.cm = nbttagcompound.h("XpSeed");
- if (this.cm == 0) {
- this.cm = this.R.nextInt();
- }
- this.s(nbttagcompound.h("Score"));
- this.bX.a(nbttagcompound);
- this.cr.b(nbttagcompound);
- this.a((AttributeBase)GenericAttributes.d).a((double)this.cr.b());
- if (nbttagcompound.b("EnderItems", 9)) {
- this.bU.a(nbttagcompound.c("EnderItems", 10));
- }
- if (nbttagcompound.b("ShoulderEntityLeft", 10)) {
- this.i(nbttagcompound.p("ShoulderEntityLeft"));
- }
- if (nbttagcompound.b("ShoulderEntityRight", 10)) {
- this.j(nbttagcompound.p("ShoulderEntityRight"));
- }
- }
- public void b(NBTTagCompound nbttagcompound) {
- super.b(nbttagcompound);
- nbttagcompound.a("DataVersion", SharedConstants.b().getWorldVersion());
- nbttagcompound.a("Inventory", this.cp.a(new NBTTagList()));
- nbttagcompound.a("SelectedItemSlot", this.cp.k);
- nbttagcompound.a("SleepTimer", (short)this.cq);
- nbttagcompound.a("XpP", this.cl);
- nbttagcompound.a("XpLevel", this.cj);
- nbttagcompound.a("XpTotal", this.ck);
- nbttagcompound.a("XpSeed", this.cm);
- nbttagcompound.a("Score", this.fk());
- this.bX.b(nbttagcompound);
- this.cr.a(nbttagcompound);
- nbttagcompound.a("EnderItems", this.bU.g());
- if (!this.fG().f()) {
- nbttagcompound.a("ShoulderEntityLeft", this.fG());
- }
- if (!this.fH().f()) {
- nbttagcompound.a("ShoulderEntityRight", this.fH());
- }
- }
- public boolean b(DamageSource damagesource) {
- 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))));
- }
- public boolean a(DamageSource damagesource, float f) {
- if (this.b(damagesource)) {
- return false;
- } else if (this.cr.a && !damagesource.i()) {
- this.forceExplosionKnockback = true;
- return false;
- } else {
- this.bg = 0;
- if (this.ea()) {
- return false;
- } else {
- if (damagesource.w()) {
- if (this.t.af() == EnumDifficulty.a) {
- return false;
- }
- if (this.t.af() == EnumDifficulty.b) {
- f = Math.min(f / 2.0F + 1.0F, f);
- }
- if (this.t.af() == EnumDifficulty.d) {
- f = f * 3.0F / 2.0F;
- }
- }
- boolean damaged = super.a(damagesource, f);
- if (damaged) {
- this.fD();
- }
- return damaged;
- }
- }
- }
- protected void d(EntityLiving entityliving) {
- super.d(entityliving);
- if (entityliving.er().c() instanceof ItemAxe) {
- this.r(true);
- }
- }
- public boolean dS() {
- return !this.fr().a && super.dS();
- }
- public boolean a(EntityHuman entityhuman) {
- Team team;
- if (entityhuman instanceof EntityPlayer) {
- EntityPlayer thatPlayer = (EntityPlayer)entityhuman;
- team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
- if (team == null || team.allowFriendlyFire()) {
- return true;
- }
- } else {
- OfflinePlayer thisPlayer = entityhuman.t.getCraftServer().getOfflinePlayer(entityhuman.co());
- team = entityhuman.t.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
- if (team == null || team.allowFriendlyFire()) {
- return true;
- }
- }
- if (this instanceof EntityPlayer) {
- return !team.hasPlayer(((EntityPlayer)this).getBukkitEntity());
- } else {
- return !team.hasPlayer(this.t.getCraftServer().getOfflinePlayer(this.co()));
- }
- }
- protected void b(DamageSource damagesource, float f) {
- this.cp.a(damagesource, f, PlayerInventory.f);
- }
- protected void c(DamageSource damagesource, float f) {
- this.cp.a(damagesource, f, PlayerInventory.g);
- }
- protected void q(float f) {
- if (this.bA.a(Items.sv)) {
- if (!this.t.y) {
- this.b(StatisticList.c.b(this.bA.c()));
- }
- if (f >= 3.0F) {
- int i = 1 + MathHelper.d(f);
- EnumHand enumhand = this.eM();
- this.bA.a(i, this, (entityhuman) -> {
- entityhuman.d((EnumHand)enumhand);
- });
- if (this.bA.b()) {
- if (enumhand == EnumHand.a) {
- this.a(EnumItemSlot.a, ItemStack.b);
- } else {
- this.a(EnumItemSlot.b, ItemStack.b);
- }
- this.bA = ItemStack.b;
- this.a(SoundEffects.qA, 0.8F, 0.8F + this.t.w.nextFloat() * 0.4F);
- }
- }
- }
- }
- protected boolean damageEntity0(DamageSource damagesource, float f) {
- return super.damageEntity0(damagesource, f);
- }
- protected boolean dz() {
- return !this.cr.b && super.dz();
- }
- public void a(TileEntitySign tileentitysign) {
- }
- public void a(CommandBlockListenerAbstract commandblocklistenerabstract) {
- }
- public void a(TileEntityCommand tileentitycommand) {
- }
- public void a(TileEntityStructure tileentitystructure) {
- }
- public void a(TileEntityJigsaw tileentityjigsaw) {
- }
- public void a(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
- }
- public OptionalInt a(@Nullable ITileInventory itileinventory) {
- return OptionalInt.empty();
- }
- public void a(int i, MerchantRecipeList merchantrecipelist, int j, int k, boolean flag, boolean flag1) {
- }
- public void a(ItemStack itemstack, EnumHand enumhand) {
- }
- public EnumInteractionResult a(Entity entity, EnumHand enumhand) {
- if (this.B_()) {
- if (entity instanceof ITileInventory) {
- this.a((ITileInventory)entity);
- }
- return EnumInteractionResult.d;
- } else {
- ItemStack itemstack = this.b((EnumHand)enumhand);
- ItemStack itemstack1 = itemstack.m();
- EnumInteractionResult enuminteractionresult = entity.a(this, enumhand);
- if (enuminteractionresult.a()) {
- if (this.cr.d && itemstack == this.b((EnumHand)enumhand) && itemstack.I() < itemstack1.I()) {
- itemstack.e(itemstack1.I());
- }
- return enuminteractionresult;
- } else {
- if (!itemstack.b() && entity instanceof EntityLiving) {
- if (this.cr.d) {
- itemstack = itemstack1;
- }
- EnumInteractionResult enuminteractionresult1 = itemstack.a(this, (EntityLiving)entity, enumhand);
- if (enuminteractionresult1.a()) {
- if (itemstack.b() && !this.cr.d) {
- this.a((EnumHand)enumhand, (ItemStack)ItemStack.b);
- }
- return enuminteractionresult1;
- }
- }
- return EnumInteractionResult.d;
- }
- }
- }
- public double bp() {
- return -0.35D;
- }
- public void bt() {
- super.bt();
- this.s = 0;
- }
- protected boolean ew() {
- return super.ew() || this.fb();
- }
- public boolean dF() {
- return !this.cr.b;
- }
- protected Vec3D a(Vec3D vec3d, EnumMoveType enummovetype) {
- if (!this.cr.b && (enummovetype == EnumMoveType.a || enummovetype == EnumMoveType.b) && this.fh() && this.t()) {
- double d0 = vec3d.b;
- double d1 = vec3d.d;
- double var7 = 0.05D;
- while(true) {
- while(d0 != 0.0D && this.t.a(this, this.cw().d(d0, (double)(-this.P), 0.0D))) {
- if (d0 < 0.05D && d0 >= -0.05D) {
- d0 = 0.0D;
- } else if (d0 > 0.0D) {
- d0 -= 0.05D;
- } else {
- d0 += 0.05D;
- }
- }
- while(true) {
- while(d1 != 0.0D && this.t.a(this, this.cw().d(0.0D, (double)(-this.P), d1))) {
- if (d1 < 0.05D && d1 >= -0.05D) {
- d1 = 0.0D;
- } else if (d1 > 0.0D) {
- d1 -= 0.05D;
- } else {
- d1 += 0.05D;
- }
- }
- while(true) {
- while(d0 != 0.0D && d1 != 0.0D && this.t.a(this, this.cw().d(d0, (double)(-this.P), d1))) {
- if (d0 < 0.05D && d0 >= -0.05D) {
- d0 = 0.0D;
- } else if (d0 > 0.0D) {
- d0 -= 0.05D;
- } else {
- d0 += 0.05D;
- }
- if (d1 < 0.05D && d1 >= -0.05D) {
- d1 = 0.0D;
- } else if (d1 > 0.0D) {
- d1 -= 0.05D;
- } else {
- d1 += 0.05D;
- }
- }
- vec3d = new Vec3D(d0, vec3d.c, d1);
- return vec3d;
- }
- }
- }
- } else {
- return vec3d;
- }
- }
- private boolean t() {
- return this.z || this.L < this.P && !this.t.a(this, this.cw().d(0.0D, (double)(this.L - this.P), 0.0D));
- }
- public void d(Entity entity) {
- if (entity.cf() && !entity.r(this)) {
- float f = (float)this.b((AttributeBase)GenericAttributes.f);
- float f1;
- if (entity instanceof EntityLiving) {
- f1 = EnchantmentManager.a(this.er(), ((EntityLiving)entity).eq());
- } else {
- f1 = EnchantmentManager.a(this.er(), EnumMonsterType.a);
- }
- float f2 = this.v(0.5F);
- f *= 0.2F + f2 * f2 * 0.8F;
- f1 *= f2;
- if (f > 0.0F || f1 > 0.0F) {
- boolean flag = f2 > 0.9F;
- boolean flag1 = false;
- byte b0 = 0;
- int i = b0 + EnchantmentManager.b(this);
- if (this.bO() && flag) {
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.ox, this.cO(), 1.0F, 1.0F);
- ++i;
- flag1 = true;
- }
- boolean flag2 = flag && this.L > 0.0F && !this.z && !this.b_() && !this.aQ() && !this.a((MobEffectList)MobEffects.o) && !this.bF() && entity instanceof EntityLiving;
- flag2 = flag2 && !this.bO();
- if (flag2) {
- f *= 1.5F;
- }
- f += f1;
- boolean flag3 = false;
- double d0 = (double)(this.I - this.H);
- if (flag && !flag2 && !flag1 && this.z && d0 < (double)this.eC()) {
- ItemStack itemstack = this.b((EnumHand)EnumHand.a);
- if (itemstack.c() instanceof ItemSword) {
- flag3 = true;
- }
- }
- float f3 = 0.0F;
- boolean flag4 = false;
- int j = EnchantmentManager.c(this);
- if (entity instanceof EntityLiving) {
- f3 = ((EntityLiving)entity).dZ();
- if (j > 0 && !entity.bE()) {
- EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1);
- Bukkit.getPluginManager().callEvent(combustEvent);
- if (!combustEvent.isCancelled()) {
- flag4 = true;
- entity.setSecondsOnFire(combustEvent.getDuration(), false);
- }
- }
- }
- Vec3D vec3d = entity.da();
- boolean flag5 = entity.a(DamageSource.a(this), f);
- if (flag5) {
- if (i > 0) {
- if (entity instanceof EntityLiving) {
- ((EntityLiving)entity).p((double)((float)i * 0.5F), (double)MathHelper.a(this.dm() * 0.017453292F), (double)(-MathHelper.b(this.dm() * 0.017453292F)));
- } else {
- 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));
- }
- this.g((Vec3D)this.da().d(0.6D, 1.0D, 0.6D));
- this.g(false);
- }
- if (flag3) {
- float f4 = 1.0F + EnchantmentManager.a(this) * f;
- List<EntityLiving> list = this.t.a(EntityLiving.class, entity.cw().c(1.0D, 0.25D, 1.0D));
- Iterator iterator = list.iterator();
- label179:
- while(true) {
- EntityLiving entityliving;
- do {
- do {
- do {
- do {
- if (!iterator.hasNext()) {
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.oA, this.cO(), 1.0F, 1.0F);
- this.fm();
- break label179;
- }
- entityliving = (EntityLiving)iterator.next();
- } while(entityliving == this);
- } while(entityliving == entity);
- } while(this.p(entityliving));
- } while(entityliving instanceof EntityArmorStand && ((EntityArmorStand)entityliving).t());
- if (this.f(entityliving) < 9.0D && entityliving.a(DamageSource.a(this).sweep(), f4)) {
- entityliving.p(0.4000000059604645D, (double)MathHelper.a(this.dm() * 0.017453292F), (double)(-MathHelper.b(this.dm() * 0.017453292F)));
- }
- }
- }
- if (entity instanceof EntityPlayer && entity.D) {
- boolean cancelled = false;
- Player player = (Player)entity.getBukkitEntity();
- Vector velocity = CraftVector.toBukkit(vec3d);
- PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
- this.t.getCraftServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- cancelled = true;
- } else if (!velocity.equals(event.getVelocity())) {
- player.setVelocity(event.getVelocity());
- }
- if (!cancelled) {
- ((EntityPlayer)entity).b.a(new PacketPlayOutEntityVelocity(entity));
- entity.D = false;
- entity.g(vec3d);
- }
- }
- if (flag2) {
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.ow, this.cO(), 1.0F, 1.0F);
- this.a(entity);
- }
- if (!flag2 && !flag3) {
- if (flag) {
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.oz, this.cO(), 1.0F, 1.0F);
- } else {
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.oB, this.cO(), 1.0F, 1.0F);
- }
- }
- if (f1 > 0.0F) {
- this.b(entity);
- }
- this.x(entity);
- if (entity instanceof EntityLiving) {
- EnchantmentManager.a((EntityLiving)entity, this);
- }
- EnchantmentManager.b(this, entity);
- ItemStack itemstack1 = this.er();
- Object object = entity;
- if (entity instanceof EntityComplexPart) {
- object = ((EntityComplexPart)entity).b;
- }
- if (!this.t.y && !itemstack1.b() && object instanceof EntityLiving) {
- itemstack1.a((EntityLiving)object, this);
- if (itemstack1.b()) {
- this.a((EnumHand)EnumHand.a, (ItemStack)ItemStack.b);
- }
- }
- if (entity instanceof EntityLiving) {
- float f5 = f3 - ((EntityLiving)entity).dZ();
- this.a(StatisticList.G, Math.round(f5 * 10.0F));
- if (j > 0) {
- EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4);
- Bukkit.getPluginManager().callEvent(combustEvent);
- if (!combustEvent.isCancelled()) {
- entity.setSecondsOnFire(combustEvent.getDuration(), false);
- }
- }
- if (this.t instanceof WorldServer && f5 > 2.0F) {
- int k = (int)((double)f5 * 0.5D);
- ((WorldServer)this.t).a(Particles.h, entity.dc(), entity.e(0.5D), entity.di(), k, 0.1D, 0.0D, 0.1D, 0.2D);
- }
- }
- this.causeFoodExhaustion(this.t.spigotConfig.combatExhaustion, ExhaustionReason.ATTACK);
- } else {
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.oy, this.cO(), 1.0F, 1.0F);
- if (flag4) {
- entity.au();
- }
- if (this instanceof EntityPlayer) {
- ((EntityPlayer)this).getBukkitEntity().updateInventory();
- }
- }
- }
- }
- }
- protected void g(EntityLiving entityliving) {
- this.d((Entity)entityliving);
- }
- public void r(boolean flag) {
- float f = 0.25F + (float)EnchantmentManager.f(this) * 0.05F;
- if (flag) {
- f += 0.75F;
- }
- if (this.R.nextFloat() < f) {
- this.fK().a(Items.sv, 100);
- this.eR();
- this.t.a(this, (byte)30);
- }
- }
- public void a(Entity entity) {
- }
- public void b(Entity entity) {
- }
- public void fm() {
- double d0 = (double)(-MathHelper.a(this.dm() * 0.017453292F));
- double d1 = (double)MathHelper.b(this.dm() * 0.017453292F);
- if (this.t instanceof WorldServer) {
- ((WorldServer)this.t).a(Particles.Y, this.dc() + d0, this.e(0.5D), this.di() + d1, 0, d0, 0.0D, d1, 0.0D);
- }
- }
- public void fn() {
- }
- public void a(RemovalReason entity_removalreason) {
- super.a(entity_removalreason);
- this.bV.b(this);
- if (this.bW != null) {
- this.bW.b(this);
- }
- }
- public boolean fo() {
- return false;
- }
- public GameProfile fp() {
- return this.ct;
- }
- public PlayerInventory fq() {
- return this.cp;
- }
- public PlayerAbilities fr() {
- return this.cr;
- }
- public void a(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {
- }
- public Either<EntityHuman.EnumBedResult, Unit> a(BlockPosition blockposition) {
- return this.startSleepInBed(blockposition, false);
- }
- public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition, boolean force) {
- this.b((BlockPosition)blockposition);
- this.cq = 0;
- return Either.right(Unit.a);
- }
- public void a(boolean flag, boolean flag1) {
- super.fc();
- if (this.t instanceof WorldServer && flag1) {
- ((WorldServer)this.t).e();
- }
- this.cq = flag ? 0 : 100;
- }
- public void fc() {
- this.a(true, true);
- }
- public static Optional<Vec3D> a(WorldServer worldserver, BlockPosition blockposition, float f, boolean flag, boolean flag1) {
- IBlockData iblockdata = worldserver.a_(blockposition);
- Block block = iblockdata.b();
- if (block instanceof BlockRespawnAnchor && (Integer)iblockdata.c(BlockRespawnAnchor.c) > 0 && BlockRespawnAnchor.a(worldserver)) {
- Optional<Vec3D> optional = BlockRespawnAnchor.a(EntityTypes.bi, worldserver, blockposition);
- if (!flag1 && optional.isPresent()) {
- worldserver.a(blockposition, (IBlockData)iblockdata.a(BlockRespawnAnchor.c, (Integer)iblockdata.c(BlockRespawnAnchor.c) - 1), 3);
- }
- return optional;
- } else if (block instanceof BlockBed && BlockBed.a(worldserver)) {
- return BlockBed.a(EntityTypes.bi, worldserver, blockposition, f);
- } else if (!flag) {
- return Optional.empty();
- } else {
- boolean flag2 = block.X_();
- boolean flag3 = worldserver.a_(blockposition.b()).b().X_();
- return flag2 && flag3 ? Optional.of(new Vec3D((double)blockposition.u() + 0.5D, (double)blockposition.v() + 0.1D, (double)blockposition.w() + 0.5D)) : Optional.empty();
- }
- }
- public boolean fs() {
- return this.fb() && this.cq >= 100;
- }
- public int ft() {
- return this.cq;
- }
- public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
- }
- public void a(MinecraftKey minecraftkey) {
- this.b(StatisticList.i.b(minecraftkey));
- }
- public void a(MinecraftKey minecraftkey, int i) {
- this.a(StatisticList.i.b(minecraftkey), i);
- }
- public void b(Statistic<?> statistic) {
- this.a((Statistic)statistic, 1);
- }
- public void a(Statistic<?> statistic, int i) {
- }
- public void a(Statistic<?> statistic) {
- }
- public int a(Collection<IRecipe<?>> collection) {
- return 0;
- }
- public void a(MinecraftKey[] aminecraftkey) {
- }
- public int b(Collection<IRecipe<?>> collection) {
- return 0;
- }
- public void ez() {
- super.ez();
- this.a(StatisticList.E);
- if (this.bO()) {
- this.causeFoodExhaustion(this.t.spigotConfig.jumpSprintExhaustion, ExhaustionReason.JUMP_SPRINT);
- } else {
- this.causeFoodExhaustion(this.t.spigotConfig.jumpWalkExhaustion, ExhaustionReason.JUMP);
- }
- }
- public void h(Vec3D vec3d) {
- double d0 = this.dc();
- double d1 = this.de();
- double d2 = this.di();
- double d3;
- if (this.bP() && !this.bF()) {
- d3 = this.bv().c;
- double d4 = d3 < -0.2D ? 0.085D : 0.06D;
- if (d3 <= 0.0D || this.bo || !this.t.a_(new BlockPosition(this.dc(), this.de() + 1.0D - 0.1D, this.di())).n().c()) {
- Vec3D vec3d1 = this.da();
- this.g((Vec3D)vec3d1.b(0.0D, (d3 - vec3d1.c) * d4, 0.0D));
- }
- }
- if (this.cr.b && !this.bF()) {
- d3 = this.da().c;
- float f = this.bc;
- this.bc = this.cr.a() * (float)(this.bO() ? 2 : 1);
- super.h(vec3d);
- Vec3D vec3d2 = this.da();
- this.n(vec3d2.b, d3 * 0.6D, vec3d2.d);
- this.bc = f;
- this.m();
- if (this.h(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
- this.b(7, false);
- }
- } else {
- super.h(vec3d);
- }
- this.q(this.dc() - d0, this.de() - d1, this.di() - d2);
- }
- public void aV() {
- if (this.cr.b) {
- this.h(false);
- } else {
- super.aV();
- }
- }
- protected boolean f(BlockPosition blockposition) {
- return !this.t.a_(blockposition).o(this.t, blockposition);
- }
- public float eC() {
- return (float)this.b((AttributeBase)GenericAttributes.d);
- }
- public void q(double d0, double d1, double d2) {
- if (!this.bF()) {
- int i;
- if (this.bP()) {
- i = Math.round((float)Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
- if (i > 0) {
- this.a(StatisticList.C, i);
- this.causeFoodExhaustion(this.t.spigotConfig.swimMultiplier * (float)i * 0.01F, ExhaustionReason.SWIM);
- }
- } else if (this.a((Tag)TagsFluid.b)) {
- i = Math.round((float)Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
- if (i > 0) {
- this.a(StatisticList.w, i);
- this.causeFoodExhaustion(this.t.spigotConfig.swimMultiplier * (float)i * 0.01F, ExhaustionReason.WALK_UNDERWATER);
- }
- } else if (this.aQ()) {
- i = Math.round((float)Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
- if (i > 0) {
- this.a(StatisticList.s, i);
- this.causeFoodExhaustion(this.t.spigotConfig.swimMultiplier * (float)i * 0.01F, ExhaustionReason.WALK_ON_WATER);
- }
- } else if (this.b_()) {
- if (d1 > 0.0D) {
- this.a(StatisticList.u, (int)Math.round(d1 * 100.0D));
- }
- } else if (this.z) {
- i = Math.round((float)Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
- if (i > 0) {
- if (this.bO()) {
- this.a(StatisticList.r, i);
- this.causeFoodExhaustion(this.t.spigotConfig.sprintMultiplier * (float)i * 0.01F, ExhaustionReason.SPRINT);
- } else if (this.bN()) {
- this.a(StatisticList.q, i);
- this.causeFoodExhaustion(this.t.spigotConfig.otherMultiplier * (float)i * 0.01F, ExhaustionReason.CROUCH);
- } else {
- this.a(StatisticList.p, i);
- this.causeFoodExhaustion(this.t.spigotConfig.otherMultiplier * (float)i * 0.01F, ExhaustionReason.WALK);
- }
- }
- } else if (this.eU()) {
- i = Math.round((float)Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
- this.a(StatisticList.B, i);
- } else {
- i = Math.round((float)Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
- if (i > 25) {
- this.a(StatisticList.v, i);
- }
- }
- }
- }
- private void r(double d0, double d1, double d2) {
- if (this.bF()) {
- int i = Math.round((float)Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
- if (i > 0) {
- Entity entity = this.cN();
- if (entity instanceof EntityMinecartAbstract) {
- this.a(StatisticList.x, i);
- } else if (entity instanceof EntityBoat) {
- this.a(StatisticList.y, i);
- } else if (entity instanceof EntityPig) {
- this.a(StatisticList.z, i);
- } else if (entity instanceof EntityHorseAbstract) {
- this.a(StatisticList.A, i);
- } else if (entity instanceof EntityStrider) {
- this.a(StatisticList.D, i);
- }
- }
- }
- }
- public boolean a(float f, float f1, DamageSource damagesource) {
- if (this.cr.c) {
- return false;
- } else {
- if (f >= 2.0F) {
- this.a(StatisticList.t, (int)Math.round((double)f * 100.0D));
- }
- return super.a(f, f1, damagesource);
- }
- }
- public boolean fu() {
- if (!this.z && !this.eU() && !this.aQ() && !this.a((MobEffectList)MobEffects.y)) {
- ItemStack itemstack = this.b(EnumItemSlot.e);
- if (itemstack.a(Items.lT) && ItemElytra.d(itemstack)) {
- this.fv();
- return true;
- }
- }
- return false;
- }
- public void fv() {
- if (!CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) {
- this.b(7, true);
- } else {
- this.b(7, true);
- this.b(7, false);
- }
- }
- public void fw() {
- if (!CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
- this.b(7, true);
- this.b(7, false);
- }
- }
- protected void aY() {
- if (!this.B_()) {
- super.aY();
- }
- }
- public a ef() {
- return new a(SoundEffects.oM, SoundEffects.oC);
- }
- public void a(WorldServer worldserver, EntityLiving entityliving) {
- this.b(StatisticList.g.b(entityliving.ad()));
- }
- public void a(IBlockData iblockdata, Vec3D vec3d) {
- if (!this.cr.b) {
- super.a(iblockdata, vec3d);
- }
- }
- public void d(int i) {
- this.t(i);
- this.cl += (float)i / (float)this.fy();
- this.ck = MathHelper.a(this.ck + i, 0, 2147483647);
- while(this.cl < 0.0F) {
- float f = this.cl * (float)this.fy();
- if (this.cj > 0) {
- this.c(-1);
- this.cl = 1.0F + f / (float)this.fy();
- } else {
- this.c(-1);
- this.cl = 0.0F;
- }
- }
- while(this.cl >= 1.0F) {
- this.cl = (this.cl - 1.0F) * (float)this.fy();
- this.c(1);
- this.cl /= (float)this.fy();
- }
- }
- public int fx() {
- return this.cm;
- }
- public void a(ItemStack itemstack, int i) {
- this.cj -= i;
- if (this.cj < 0) {
- this.cj = 0;
- this.cl = 0.0F;
- this.ck = 0;
- }
- this.cm = this.R.nextInt();
- }
- public void c(int i) {
- this.cj += i;
- if (this.cj < 0) {
- this.cj = 0;
- this.cl = 0.0F;
- this.ck = 0;
- }
- if (i > 0 && this.cj % 5 == 0 && (float)this.cs < (float)this.S - 100.0F) {
- float f = this.cj > 30 ? 1.0F : (float)this.cj / 30.0F;
- this.t.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.oL, this.cO(), f * 0.75F, 1.0F);
- this.cs = this.S;
- }
- }
- public int fy() {
- return this.cj >= 30 ? 112 + (this.cj - 30) * 9 : (this.cj >= 15 ? 37 + (this.cj - 15) * 5 : 7 + this.cj * 2);
- }
- public void u(float f) {
- this.causeFoodExhaustion(f, ExhaustionReason.UNKNOWN);
- }
- public void causeFoodExhaustion(float f, ExhaustionReason reason) {
- if (!this.cr.a && !this.t.y) {
- EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f);
- if (!event.isCancelled()) {
- this.bX.a(event.getExhaustion());
- }
- }
- }
- public FoodMetaData fz() {
- return this.bX;
- }
- public boolean s(boolean flag) {
- return this.cr.a || flag || this.bX.c();
- }
- public boolean fA() {
- return this.dZ() > 0.0F && this.dZ() < this.el();
- }
- public boolean fB() {
- return this.cr.e;
- }
- public boolean a(BlockPosition blockposition, EnumDirection enumdirection, ItemStack itemstack) {
- if (this.cr.e) {
- return true;
- } else {
- BlockPosition blockposition1 = blockposition.a(enumdirection.f());
- ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(this.t, blockposition1, false);
- return itemstack.a(this.t.r(), shapedetectorblock);
- }
- }
- protected int d(EntityHuman entityhuman) {
- if (!this.t.X().b(GameRules.d) && !this.B_()) {
- int i = this.cj * 7;
- return i > 100 ? 100 : i;
- } else {
- return 0;
- }
- }
- protected boolean dJ() {
- return true;
- }
- public boolean cs() {
- return true;
- }
- protected MovementEmission aN() {
- return this.cr.b || this.z && this.bL() ? MovementEmission.a : MovementEmission.d;
- }
- public void w() {
- }
- public IChatBaseComponent X() {
- return new ChatComponentText(this.ct.getName());
- }
- public InventoryEnderChest fC() {
- return this.bU;
- }
- public ItemStack b(EnumItemSlot enumitemslot) {
- 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));
- }
- public void a(EnumItemSlot enumitemslot, ItemStack itemstack) {
- this.setItemSlot(enumitemslot, itemstack, false);
- }
- public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
- this.f(itemstack);
- if (enumitemslot == EnumItemSlot.a) {
- this.equipEventAndSound(itemstack, silent);
- this.cp.h.set(this.cp.k, itemstack);
- } else if (enumitemslot == EnumItemSlot.b) {
- this.equipEventAndSound(itemstack, silent);
- this.cp.j.set(0, itemstack);
- } else if (enumitemslot.a() == Function.b) {
- this.equipEventAndSound(itemstack, silent);
- this.cp.i.set(enumitemslot.b(), itemstack);
- }
- }
- public boolean j(ItemStack itemstack) {
- this.c((ItemStack)itemstack);
- return this.cp.e(itemstack);
- }
- public Iterable<ItemStack> bB() {
- return Lists.newArrayList(new ItemStack[]{this.er(), this.es()});
- }
- public Iterable<ItemStack> bC() {
- return this.cp.i;
- }
- public boolean h(NBTTagCompound nbttagcompound) {
- if (!this.bF() && this.z && !this.aQ() && !this.am) {
- if (this.fG().f()) {
- this.i(nbttagcompound);
- this.f = this.t.V();
- return true;
- } else if (this.fH().f()) {
- this.j(nbttagcompound);
- this.f = this.t.V();
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- protected void fD() {
- if (this.f + 20L < this.t.V()) {
- if (this.spawnEntityFromShoulder(this.fG())) {
- this.i(new NBTTagCompound());
- }
- if (this.spawnEntityFromShoulder(this.fH())) {
- this.j(new NBTTagCompound());
- }
- }
- }
- private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) {
- return !this.t.y && !nbttagcompound.f() ? (Boolean)EntityTypes.a(nbttagcompound, this.t).map((entity) -> {
- if (entity instanceof EntityTameableAnimal) {
- ((EntityTameableAnimal)entity).b(this.ak);
- }
- entity.e(this.dc(), this.de() + 0.699999988079071D, this.di());
- return ((WorldServer)this.t).addWithUUID(entity, SpawnReason.SHOULDER_ENTITY);
- }).orElse(true) : true;
- }
- public abstract boolean B_();
- public boolean bP() {
- return !this.cr.b && !this.B_() && super.bP();
- }
- public abstract boolean f();
- public boolean cp() {
- return !this.cr.b;
- }
- public Scoreboard fE() {
- return this.t.K();
- }
- public IChatBaseComponent C_() {
- IChatMutableComponent ichatmutablecomponent = ScoreboardTeam.a(this.bW(), this.X());
- return this.a(ichatmutablecomponent);
- }
- private IChatMutableComponent a(IChatMutableComponent ichatmutablecomponent) {
- String s = this.fp().getName();
- return ichatmutablecomponent.a((chatmodifier) -> {
- return chatmodifier.a(new ChatClickable(EnumClickAction.d, "/tell " + s + " ")).a(this.cv()).a(s);
- });
- }
- public String co() {
- return this.fp().getName();
- }
- public float b(EntityPose entitypose, EntitySize entitysize) {
- switch($SWITCH_TABLE$net$minecraft$world$entity$EntityPose()[entitypose.ordinal()]) {
- case 2:
- case 4:
- case 5:
- return 0.4F;
- case 3:
- default:
- return 1.62F;
- case 6:
- return 1.27F;
- }
- }
- public void t(float f) {
- if (f < 0.0F) {
- f = 0.0F;
- }
- this.ai().b(d, f);
- }
- public float eI() {
- return (Float)this.ai().a(d);
- }
- public static UUID a(GameProfile gameprofile) {
- UUID uuid = gameprofile.getId();
- if (uuid == null) {
- uuid = c(gameprofile.getName());
- }
- return uuid;
- }
- public static UUID c(String s) {
- return UUID.nameUUIDFromBytes(("OfflinePlayer:" + s).getBytes(StandardCharsets.UTF_8));
- }
- public boolean a(PlayerModelPart playermodelpart) {
- return ((Byte)this.ai().a(bQ) & playermodelpart.a()) == playermodelpart.a();
- }
- public SlotAccess k(int i) {
- if (i >= 0 && i < this.cp.h.size()) {
- return SlotAccess.a(this.cp, i);
- } else {
- int j = i - 200;
- return j >= 0 && j < this.bU.b() ? SlotAccess.a(this.bU, j) : super.k(i);
- }
- }
- public boolean fF() {
- return this.cu;
- }
- public void t(boolean flag) {
- this.cu = flag;
- }
- public void g(int i) {
- super.g(this.cr.a ? Math.min(i, 1) : i);
- }
- public EnumMainHand eK() {
- return (Byte)this.Z.a(bR) == 0 ? EnumMainHand.a : EnumMainHand.b;
- }
- public void a(EnumMainHand enummainhand) {
- this.Z.b(bR, (byte)(enummainhand == EnumMainHand.a ? 0 : 1));
- }
- public NBTTagCompound fG() {
- return (NBTTagCompound)this.Z.a(bS);
- }
- public void i(NBTTagCompound nbttagcompound) {
- this.Z.b(bS, nbttagcompound);
- }
- public NBTTagCompound fH() {
- return (NBTTagCompound)this.Z.a(bT);
- }
- public void j(NBTTagCompound nbttagcompound) {
- this.Z.b(bT, nbttagcompound);
- }
- public float fI() {
- return (float)(1.0D / this.b((AttributeBase)GenericAttributes.h) * 20.0D);
- }
- public float v(float f) {
- return MathHelper.a(((float)this.aR + f) / this.fI(), 0.0F, 1.0F);
- }
- public void fJ() {
- this.aR = 0;
- }
- public ItemCooldown fK() {
- return this.cw;
- }
- protected float aC() {
- return !this.cr.b && !this.eU() ? super.aC() : 1.0F;
- }
- public float fL() {
- return (float)this.b((AttributeBase)GenericAttributes.k);
- }
- public boolean fM() {
- return this.cr.d && this.B() >= 2;
- }
- public boolean g(ItemStack itemstack) {
- EnumItemSlot enumitemslot = EntityInsentient.i(itemstack);
- return this.b(enumitemslot).b();
- }
- public EntitySize a(EntityPose entitypose) {
- return (EntitySize)b.getOrDefault(entitypose, bP);
- }
- public ImmutableList<EntityPose> eY() {
- return ImmutableList.of(EntityPose.a, EntityPose.f, EntityPose.d);
- }
- public ItemStack h(ItemStack itemstack) {
- if (!(itemstack.c() instanceof ItemProjectileWeapon)) {
- return ItemStack.b;
- } else {
- Predicate<ItemStack> predicate = ((ItemProjectileWeapon)itemstack.c()).e();
- ItemStack itemstack1 = ItemProjectileWeapon.a(this, predicate);
- if (!itemstack1.b()) {
- return itemstack1;
- } else {
- predicate = ((ItemProjectileWeapon)itemstack.c()).b();
- for(int i = 0; i < this.cp.b(); ++i) {
- ItemStack itemstack2 = this.cp.a(i);
- if (predicate.test(itemstack2)) {
- return itemstack2;
- }
- }
- return this.cr.d ? new ItemStack(Items.mh) : ItemStack.b;
- }
- }
- }
- public ItemStack a(World world, ItemStack itemstack) {
- this.fz().a(itemstack.c(), itemstack);
- this.b(StatisticList.c.b(itemstack.c()));
- world.a((EntityHuman)null, this.dc(), this.de(), this.di(), SoundEffects.oE, SoundCategory.h, 0.5F, world.w.nextFloat() * 0.1F + 0.9F);
- if (this instanceof EntityPlayer) {
- CriterionTriggers.z.a((EntityPlayer)this, itemstack);
- }
- return super.a(world, itemstack);
- }
- protected boolean b(IBlockData iblockdata) {
- return this.cr.b || super.b(iblockdata);
- }
- public Vec3D n(float f) {
- double d0 = 0.22D * (this.eK() == EnumMainHand.b ? -1.0D : 1.0D);
- float f1 = MathHelper.i(f * 0.5F, this.dn(), this.y) * 0.017453292F;
- float f2 = MathHelper.i(f, this.aZ, this.aY) * 0.017453292F;
- double d1;
- if (!this.eU() && !this.eG()) {
- if (this.bQ()) {
- return this.k(f).e((new Vec3D(d0, 0.2D, -0.15D)).a(-f1).b(-f2));
- } else {
- double d2 = this.cw().c() - 1.0D;
- d1 = this.bN() ? -0.2D : 0.07D;
- return this.k(f).e((new Vec3D(d0, d2, d1)).b(-f2));
- }
- } else {
- Vec3D vec3d = this.e(f);
- Vec3D vec3d1 = this.da();
- d1 = vec3d1.i();
- double d3 = vec3d.i();
- float f3;
- if (d1 > 0.0D && d3 > 0.0D) {
- double d4 = (vec3d1.b * vec3d.b + vec3d1.d * vec3d.d) / Math.sqrt(d1 * d3);
- double d5 = vec3d1.b * vec3d.d - vec3d1.d * vec3d.b;
- f3 = (float)(Math.signum(d5) * Math.acos(d4));
- } else {
- f3 = 0.0F;
- }
- return this.k(f).e((new Vec3D(d0, -0.11D, 0.85D)).c(-f3).a(-f1).b(-f2));
- }
- }
- public boolean ds() {
- return true;
- }
- public boolean fN() {
- return this.eL() && this.eN().a(Items.ot);
- }
- public boolean dr() {
- return false;
- }
- public static enum EnumBedResult {
- a,
- b(new ChatMessage("block.minecraft.bed.no_sleep")),
- c(new ChatMessage("block.minecraft.bed.too_far_away")),
- d(new ChatMessage("block.minecraft.bed.obstructed")),
- e,
- f(new ChatMessage("block.minecraft.bed.not_safe"));
- @Nullable
- private final IChatBaseComponent g;
- private EnumBedResult() {
- this.g = null;
- }
- private EnumBedResult(IChatBaseComponent ichatbasecomponent) {
- this.g = ichatbasecomponent;
- }
- @Nullable
- public IChatBaseComponent a() {
- return this.g;
- }
- }
- }
Add Comment
Please, Sign In to add comment