diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/AbstractArrow.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/AbstractArrow.java.patch | 784 |
1 files changed, 784 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/AbstractArrow.java.patch new file mode 100644 index 0000000000..d546fcc7e3 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -0,0 +1,784 @@ +--- a/net/minecraft/world/entity/projectile/AbstractArrow.java ++++ b/net/minecraft/world/entity/projectile/AbstractArrow.java +@@ -3,6 +3,8 @@ + import com.google.common.collect.Lists; + import it.unimi.dsi.fastutil.ints.IntOpenHashSet; + import java.util.Arrays; ++import java.util.Collection; ++import java.util.Iterator; + import java.util.List; + import javax.annotation.Nullable; + import net.minecraft.advancements.CriteriaTriggers; +@@ -25,11 +27,12 @@ + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityDimensions; ++import net.minecraft.world.entity.EntityPose; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMoveType; + import net.minecraft.world.entity.LivingEntity; +-import net.minecraft.world.entity.MoverType; +-import net.minecraft.world.entity.Pose; + import net.minecraft.world.entity.ai.attributes.Attributes; ++import net.minecraft.world.entity.item.ItemEntity; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.enchantment.EnchantmentHelper; +@@ -37,56 +40,65 @@ + import net.minecraft.world.level.ClipContext; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.block.Blocks; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.phys.AABB; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.EntityHitResult; + import net.minecraft.world.phys.HitResult; + import net.minecraft.world.phys.Vec3; + import net.minecraft.world.phys.shapes.VoxelShape; ++import org.bukkit.event.entity.EntityCombustByEntityEvent; ++import org.bukkit.event.player.PlayerPickupArrowEvent; ++// CraftBukkit end + + public abstract class AbstractArrow extends Projectile { +- private static final double ARROW_BASE_DAMAGE = 2.0; ++ ++ private static final double ARROW_BASE_DAMAGE = 2.0D; + private static final EntityDataAccessor<Byte> ID_FLAGS = SynchedEntityData.defineId(AbstractArrow.class, EntityDataSerializers.BYTE); + private static final EntityDataAccessor<Byte> PIERCE_LEVEL = SynchedEntityData.defineId(AbstractArrow.class, EntityDataSerializers.BYTE); + private static final int FLAG_CRIT = 1; + private static final int FLAG_NOPHYSICS = 2; + private static final int FLAG_CROSSBOW = 4; + @Nullable +- private BlockState lastState; +- protected boolean inGround; ++ private IBlockData lastState; ++ public boolean inGround; + protected int inGroundTime; +- public AbstractArrow.Pickup pickup = AbstractArrow.Pickup.DISALLOWED; ++ public AbstractArrow.Pickup pickup; + public int shakeTime; +- private int life; +- private double baseDamage = 2.0; +- private int knockback; +- private SoundEvent soundEvent = this.getDefaultHitGroundSoundEvent(); ++ public int life; ++ private double baseDamage; ++ public int knockback; ++ private SoundEvent soundEvent; + @Nullable + private IntOpenHashSet piercingIgnoreEntityIds; + @Nullable + private List<Entity> piercedAndKilledEntities; +- private ItemStack pickupItemStack; ++ public ItemStack pickupItemStack; + +- protected AbstractArrow(EntityType<? extends AbstractArrow> entityType, Level level, ItemStack itemStack) { +- super(entityType, level); +- this.pickupItemStack = itemStack.copy(); +- if (itemStack.hasCustomHoverName()) { +- this.setCustomName(itemStack.getHoverName()); ++ protected AbstractArrow(EntityType<? extends AbstractArrow> entitytypes, Level world, ItemStack itemstack) { ++ super(entitytypes, world); ++ this.pickup = AbstractArrow.Pickup.DISALLOWED; ++ this.baseDamage = 2.0D; ++ this.soundEvent = this.getDefaultHitGroundSoundEvent(); ++ this.pickupItemStack = itemstack.copy(); ++ if (itemstack.hasCustomHoverName()) { ++ this.setCustomName(itemstack.getHoverName()); + } ++ + } + +- protected AbstractArrow(EntityType<? extends AbstractArrow> entityType, double d, double d1, double d2, Level level, ItemStack itemStack) { +- this(entityType, level, itemStack); +- this.setPos(d, d1, d2); ++ protected AbstractArrow(EntityType<? extends AbstractArrow> entitytypes, double d0, double d1, double d2, Level world, ItemStack itemstack) { ++ this(entitytypes, world, itemstack); ++ this.setPos(d0, d1, d2); + } + +- protected AbstractArrow(EntityType<? extends AbstractArrow> entityType, LivingEntity livingEntity, Level level, ItemStack itemStack) { +- this(entityType, livingEntity.getX(), livingEntity.getEyeY() - 0.1F, livingEntity.getZ(), level, itemStack); +- this.setOwner(livingEntity); +- if (livingEntity instanceof Player) { ++ protected AbstractArrow(EntityType<? extends AbstractArrow> entitytypes, LivingEntity entityliving, Level world, ItemStack itemstack) { ++ this(entitytypes, entityliving.getX(), entityliving.getEyeY() - 0.10000000149011612D, entityliving.getZ(), world, itemstack); ++ this.setOwner(entityliving); ++ if (entityliving instanceof Player) { + this.pickup = AbstractArrow.Pickup.ALLOWED; + } ++ + } + + public void setSoundEvent(SoundEvent soundEvent) { +@@ -95,61 +107,70 @@ + + @Override + public boolean shouldRenderAtSqrDistance(double distance) { +- double d = this.getBoundingBox().getSize() * 10.0; +- if (Double.isNaN(d)) { +- d = 1.0; ++ double d1 = this.getBoundingBox().getSize() * 10.0D; ++ ++ if (Double.isNaN(d1)) { ++ d1 = 1.0D; + } + +- d *= 64.0 * getViewScale(); +- return distance < d * d; ++ d1 *= 64.0D * getViewScale(); ++ return distance < d1 * d1; + } + + @Override + protected void defineSynchedData() { +- this.entityData.define(ID_FLAGS, (byte)0); +- this.entityData.define(PIERCE_LEVEL, (byte)0); ++ this.entityData.define(AbstractArrow.ID_FLAGS, (byte) 0); ++ this.entityData.define(AbstractArrow.PIERCE_LEVEL, (byte) 0); + } + + @Override +- public void shoot(double x, double y, double z, float velocity, float inaccuracy) { +- super.shoot(x, y, z, velocity, inaccuracy); ++ public void shoot(double x, double d1, double y, float f, float z) { ++ super.shoot(x, d1, y, f, z); + this.life = 0; + } + + @Override +- public void lerpTo(double d, double d1, double d2, float f, float f1, int i) { +- this.setPos(d, d1, d2); ++ public void lerpTo(double d0, double d1, double d2, float f, float f1, int i) { ++ this.setPos(d0, d1, d2); + this.setRot(f, f1); + } + + @Override +- public void lerpMotion(double x, double y, double z) { +- super.lerpMotion(x, y, z); ++ public void lerpMotion(double x, double d1, double y) { ++ super.lerpMotion(x, d1, y); + this.life = 0; + } + + @Override + public void tick() { + super.tick(); +- boolean isNoPhysics = this.isNoPhysics(); +- Vec3 deltaMovement = this.getDeltaMovement(); ++ boolean flag = this.isNoPhysics(); ++ Vec3 vec3d = this.getDeltaMovement(); ++ + if (this.xRotO == 0.0F && this.yRotO == 0.0F) { +- double d = deltaMovement.horizontalDistance(); +- this.setYRot((float)(Mth.atan2(deltaMovement.x, deltaMovement.z) * 180.0F / (float)Math.PI)); +- this.setXRot((float)(Mth.atan2(deltaMovement.y, d) * 180.0F / (float)Math.PI)); ++ double d0 = vec3d.horizontalDistance(); ++ ++ this.setYRot((float) (Mth.atan2(vec3d.x, vec3d.z) * 57.2957763671875D)); ++ this.setXRot((float) (Mth.atan2(vec3d.y, d0) * 57.2957763671875D)); + this.yRotO = this.getYRot(); + this.xRotO = this.getXRot(); + } + +- BlockPos blockPos = this.blockPosition(); +- BlockState blockState = this.level().getBlockState(blockPos); +- if (!blockState.isAir() && !isNoPhysics) { +- VoxelShape collisionShape = blockState.getCollisionShape(this.level(), blockPos); +- if (!collisionShape.isEmpty()) { +- Vec3 vec3 = this.position(); ++ BlockPos blockposition = this.blockPosition(); ++ IBlockData iblockdata = this.level().getBlockState(blockposition); ++ Vec3 vec3d1; + +- for (AABB aABB : collisionShape.toAabbs()) { +- if (aABB.move(blockPos).contains(vec3)) { ++ if (!iblockdata.isAir() && !flag) { ++ VoxelShape voxelshape = iblockdata.getCollisionShape(this.level(), blockposition); ++ ++ if (!voxelshape.isEmpty()) { ++ vec3d1 = this.position(); ++ Iterator iterator = voxelshape.toAabbs().iterator(); ++ ++ while (iterator.hasNext()) { ++ AABB axisalignedbb = (AABB) iterator.next(); ++ ++ if (axisalignedbb.move(blockposition).contains(vec3d1)) { + this.inGround = true; + break; + } +@@ -158,104 +179,104 @@ + } + + if (this.shakeTime > 0) { +- this.shakeTime--; ++ --this.shakeTime; + } + +- if (this.isInWaterOrRain() || blockState.is(Blocks.POWDER_SNOW)) { ++ if (this.isInWaterOrRain() || iblockdata.is(Blocks.POWDER_SNOW)) { + this.clearFire(); + } + +- if (this.inGround && !isNoPhysics) { +- if (this.lastState != blockState && this.shouldFall()) { ++ if (this.inGround && !flag) { ++ if (this.lastState != iblockdata && this.shouldFall()) { + this.startFalling(); + } else if (!this.level().isClientSide) { + this.tickDespawn(); + } + +- this.inGroundTime++; ++ ++this.inGroundTime; + } else { + this.inGroundTime = 0; +- Vec3 vec31 = this.position(); +- Vec3 vec3 = vec31.add(deltaMovement); +- HitResult hitResult = this.level().clip(new ClipContext(vec31, vec3, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)); +- if (hitResult.getType() != HitResult.Type.MISS) { +- vec3 = hitResult.getLocation(); ++ Vec3 vec3d2 = this.position(); ++ ++ vec3d1 = vec3d2.add(vec3d); ++ Object object = this.level().clip(new ClipContext(vec3d2, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)); ++ ++ if (((HitResult) object).getType() != HitResult.EnumMovingObjectType.MISS) { ++ vec3d1 = ((HitResult) object).getLocation(); + } + + while (!this.isRemoved()) { +- EntityHitResult entityHitResult = this.findHitEntity(vec31, vec3); +- if (entityHitResult != null) { +- hitResult = entityHitResult; ++ EntityHitResult movingobjectpositionentity = this.findHitEntity(vec3d2, vec3d1); ++ ++ if (movingobjectpositionentity != null) { ++ object = movingobjectpositionentity; + } + +- if (hitResult != null && hitResult.getType() == HitResult.Type.ENTITY) { +- Entity entity = ((EntityHitResult)hitResult).getEntity(); +- Entity owner = this.getOwner(); +- if (entity instanceof Player && owner instanceof Player && !((Player)owner).canHarmPlayer((Player)entity)) { +- hitResult = null; +- entityHitResult = null; ++ if (object != null && ((HitResult) object).getType() == HitResult.EnumMovingObjectType.ENTITY) { ++ Entity entity = ((EntityHitResult) object).getEntity(); ++ Entity entity1 = this.getOwner(); ++ ++ if (entity instanceof Player && entity1 instanceof Player && !((Player) entity1).canHarmPlayer((Player) entity)) { ++ object = null; ++ movingobjectpositionentity = null; + } + } + +- if (hitResult != null && !isNoPhysics) { +- this.onHit(hitResult); ++ if (object != null && !flag) { ++ this.preOnHit((HitResult) object); // CraftBukkit - projectile hit event + this.hasImpulse = true; + } + +- if (entityHitResult == null || this.getPierceLevel() <= 0) { ++ if (movingobjectpositionentity == null || this.getPierceLevel() <= 0) { + break; + } + +- hitResult = null; ++ object = null; + } + +- deltaMovement = this.getDeltaMovement(); +- double d1 = deltaMovement.x; +- double d2 = deltaMovement.y; +- double d3 = deltaMovement.z; ++ vec3d = this.getDeltaMovement(); ++ double d1 = vec3d.x; ++ double d2 = vec3d.y; ++ double d3 = vec3d.z; ++ + if (this.isCritArrow()) { +- for (int i = 0; i < 4; i++) { +- this.level() +- .addParticle( +- ParticleTypes.CRIT, +- this.getX() + d1 * (double)i / 4.0, +- this.getY() + d2 * (double)i / 4.0, +- this.getZ() + d3 * (double)i / 4.0, +- -d1, +- -d2 + 0.2, +- -d3 +- ); ++ for (int i = 0; i < 4; ++i) { ++ this.level().addParticle(ParticleTypes.CRIT, this.getX() + d1 * (double) i / 4.0D, this.getY() + d2 * (double) i / 4.0D, this.getZ() + d3 * (double) i / 4.0D, -d1, -d2 + 0.2D, -d3); + } + } + + double d4 = this.getX() + d1; + double d5 = this.getY() + d2; + double d6 = this.getZ() + d3; +- double d7 = deltaMovement.horizontalDistance(); +- if (isNoPhysics) { +- this.setYRot((float)(Mth.atan2(-d1, -d3) * 180.0F / (float)Math.PI)); ++ double d7 = vec3d.horizontalDistance(); ++ ++ if (flag) { ++ this.setYRot((float) (Mth.atan2(-d1, -d3) * 57.2957763671875D)); + } else { +- this.setYRot((float)(Mth.atan2(d1, d3) * 180.0F / (float)Math.PI)); ++ this.setYRot((float) (Mth.atan2(d1, d3) * 57.2957763671875D)); + } + +- this.setXRot((float)(Mth.atan2(d2, d7) * 180.0F / (float)Math.PI)); ++ this.setXRot((float) (Mth.atan2(d2, d7) * 57.2957763671875D)); + this.setXRot(lerpRotation(this.xRotO, this.getXRot())); + this.setYRot(lerpRotation(this.yRotO, this.getYRot())); + float f = 0.99F; + float f1 = 0.05F; ++ + if (this.isInWater()) { +- for (int i1 = 0; i1 < 4; i1++) { ++ for (int j = 0; j < 4; ++j) { + float f2 = 0.25F; +- this.level().addParticle(ParticleTypes.BUBBLE, d4 - d1 * 0.25, d5 - d2 * 0.25, d6 - d3 * 0.25, d1, d2, d3); ++ ++ this.level().addParticle(ParticleTypes.BUBBLE, d4 - d1 * 0.25D, d5 - d2 * 0.25D, d6 - d3 * 0.25D, d1, d2, d3); + } + + f = this.getWaterInertia(); + } + +- this.setDeltaMovement(deltaMovement.scale((double)f)); +- if (!this.isNoGravity() && !isNoPhysics) { +- Vec3 deltaMovement1 = this.getDeltaMovement(); +- this.setDeltaMovement(deltaMovement1.x, deltaMovement1.y - 0.05F, deltaMovement1.z); ++ this.setDeltaMovement(vec3d.scale((double) f)); ++ if (!this.isNoGravity() && !flag) { ++ Vec3 vec3d3 = this.getDeltaMovement(); ++ ++ this.setDeltaMovement(vec3d3.x, vec3d3.y - 0.05000000074505806D, vec3d3.z); + } + + this.setPos(d4, d5, d6); +@@ -264,31 +285,32 @@ + } + + private boolean shouldFall() { +- return this.inGround && this.level().noCollision(new AABB(this.position(), this.position()).inflate(0.06)); ++ return this.inGround && this.level().noCollision((new AABB(this.position(), this.position())).inflate(0.06D)); + } + + private void startFalling() { + this.inGround = false; +- Vec3 deltaMovement = this.getDeltaMovement(); +- this.setDeltaMovement( +- deltaMovement.multiply((double)(this.random.nextFloat() * 0.2F), (double)(this.random.nextFloat() * 0.2F), (double)(this.random.nextFloat() * 0.2F)) +- ); ++ Vec3 vec3d = this.getDeltaMovement(); ++ ++ this.setDeltaMovement(vec3d.multiply((double) (this.random.nextFloat() * 0.2F), (double) (this.random.nextFloat() * 0.2F), (double) (this.random.nextFloat() * 0.2F))); + this.life = 0; + } + + @Override +- public void move(MoverType type, Vec3 pos) { ++ public void move(EnumMoveType type, Vec3 pos) { + super.move(type, pos); +- if (type != MoverType.SELF && this.shouldFall()) { ++ if (type != EnumMoveType.SELF && this.shouldFall()) { + this.startFalling(); + } ++ + } + + protected void tickDespawn() { +- this.life++; ++ ++this.life; + if (this.life >= 1200) { + this.discard(); + } ++ + } + + private void resetPiercedEntities() { +@@ -299,14 +321,16 @@ + if (this.piercingIgnoreEntityIds != null) { + this.piercingIgnoreEntityIds.clear(); + } ++ + } + + @Override + protected void onHitEntity(EntityHitResult result) { + super.onHitEntity(result); + Entity entity = result.getEntity(); +- float f = (float)this.getDeltaMovement().length(); +- int ceil = Mth.ceil(Mth.clamp((double)f * this.baseDamage, 0.0, 2.147483647E9)); ++ float f = (float) this.getDeltaMovement().length(); ++ int i = Mth.ceil(Mth.clamp((double) f * this.baseDamage, 0.0D, 2.147483647E9D)); ++ + if (this.getPierceLevel() > 0) { + if (this.piercingIgnoreEntityIds == null) { + this.piercingIgnoreEntityIds = new IntOpenHashSet(5); +@@ -325,65 +349,79 @@ + } + + if (this.isCritArrow()) { +- long l = (long)this.random.nextInt(ceil / 2 + 2); +- ceil = (int)Math.min(l + (long)ceil, 2147483647L); ++ long j = (long) this.random.nextInt(i / 2 + 2); ++ ++ i = (int) Math.min(j + (long) i, 2147483647L); + } + +- Entity owner = this.getOwner(); +- DamageSource damageSource; +- if (owner == null) { +- damageSource = this.damageSources().arrow(this, this); ++ Entity entity1 = this.getOwner(); ++ DamageSource damagesource; ++ ++ if (entity1 == null) { ++ damagesource = this.damageSources().arrow(this, this); + } else { +- damageSource = this.damageSources().arrow(this, owner); +- if (owner instanceof LivingEntity) { +- ((LivingEntity)owner).setLastHurtMob(entity); ++ damagesource = this.damageSources().arrow(this, entity1); ++ if (entity1 instanceof LivingEntity) { ++ ((LivingEntity) entity1).setLastHurtMob(entity); + } + } + + boolean flag = entity.getType() == EntityType.ENDERMAN; +- int remainingFireTicks = entity.getRemainingFireTicks(); +- boolean isDeflectsArrows = entity.getType().is(EntityTypeTags.DEFLECTS_ARROWS); +- if (this.isOnFire() && !flag && !isDeflectsArrows) { +- entity.setSecondsOnFire(5); ++ int k = entity.getRemainingFireTicks(); ++ boolean flag1 = entity.getType().is(EntityTypeTags.DEFLECTS_ARROWS); ++ ++ if (this.isOnFire() && !flag && !flag1) { ++ // CraftBukkit start ++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5); ++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); ++ if (!combustEvent.isCancelled()) { ++ entity.setSecondsOnFire(combustEvent.getDuration(), false); ++ } ++ // CraftBukkit end + } + +- if (entity.hurt(damageSource, (float)ceil)) { ++ if (entity.hurt(damagesource, (float) i)) { + if (flag) { + return; + } + +- if (entity instanceof LivingEntity livingEntity) { ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving = (LivingEntity) entity; ++ + if (!this.level().isClientSide && this.getPierceLevel() <= 0) { +- livingEntity.setArrowCount(livingEntity.getArrowCount() + 1); ++ entityliving.setArrowCount(entityliving.getArrowCount() + 1); + } + + if (this.knockback > 0) { +- double max = Math.max(0.0, 1.0 - livingEntity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); +- Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale((double)this.knockback * 0.6 * max); +- if (vec3.lengthSqr() > 0.0) { +- livingEntity.push(vec3.x, 0.1, vec3.z); ++ double d0 = Math.max(0.0D, 1.0D - entityliving.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); ++ Vec3 vec3d = this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D).normalize().scale((double) this.knockback * 0.6D * d0); ++ ++ if (vec3d.lengthSqr() > 0.0D) { ++ entityliving.push(vec3d.x, 0.1D, vec3d.z); + } + } + +- if (!this.level().isClientSide && owner instanceof LivingEntity) { +- EnchantmentHelper.doPostHurtEffects(livingEntity, owner); +- EnchantmentHelper.doPostDamageEffects((LivingEntity)owner, livingEntity); ++ if (!this.level().isClientSide && entity1 instanceof LivingEntity) { ++ EnchantmentHelper.doPostHurtEffects(entityliving, entity1); ++ EnchantmentHelper.doPostDamageEffects((LivingEntity) entity1, entityliving); + } + +- this.doPostHurtEffects(livingEntity); +- if (owner != null && livingEntity != owner && livingEntity instanceof Player && owner instanceof ServerPlayer && !this.isSilent()) { +- ((ServerPlayer)owner).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.ARROW_HIT_PLAYER, 0.0F)); ++ this.doPostHurtEffects(entityliving); ++ if (entity1 != null && entityliving != entity1 && entityliving instanceof Player && entity1 instanceof ServerPlayer && !this.isSilent()) { ++ ((ServerPlayer) entity1).connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.ARROW_HIT_PLAYER, 0.0F)); + } + + if (!entity.isAlive() && this.piercedAndKilledEntities != null) { +- this.piercedAndKilledEntities.add(livingEntity); ++ this.piercedAndKilledEntities.add(entityliving); + } + +- if (!this.level().isClientSide && owner instanceof ServerPlayer serverPlayer) { ++ if (!this.level().isClientSide && entity1 instanceof ServerPlayer) { ++ ServerPlayer entityplayer = (ServerPlayer) entity1; ++ + if (this.piercedAndKilledEntities != null && this.shotFromCrossbow()) { +- CriteriaTriggers.KILLED_BY_CROSSBOW.trigger(serverPlayer, this.piercedAndKilledEntities); ++ CriteriaTriggers.KILLED_BY_CROSSBOW.trigger(entityplayer, (Collection) this.piercedAndKilledEntities); + } else if (!entity.isAlive() && this.shotFromCrossbow()) { +- CriteriaTriggers.KILLED_BY_CROSSBOW.trigger(serverPlayer, Arrays.asList(entity)); ++ CriteriaTriggers.KILLED_BY_CROSSBOW.trigger(entityplayer, (Collection) Arrays.asList(entity)); + } + } + } +@@ -392,14 +430,14 @@ + if (this.getPierceLevel() <= 0) { + this.discard(); + } +- } else if (isDeflectsArrows) { ++ } else if (flag1) { + this.deflect(); + } else { +- entity.setRemainingFireTicks(remainingFireTicks); +- this.setDeltaMovement(this.getDeltaMovement().scale(-0.1)); ++ entity.setRemainingFireTicks(k); ++ this.setDeltaMovement(this.getDeltaMovement().scale(-0.1D)); + this.setYRot(this.getYRot() + 180.0F); + this.yRotO += 180.0F; +- if (!this.level().isClientSide && this.getDeltaMovement().lengthSqr() < 1.0E-7) { ++ if (!this.level().isClientSide && this.getDeltaMovement().lengthSqr() < 1.0E-7D) { + if (this.pickup == AbstractArrow.Pickup.ALLOWED) { + this.spawnAtLocation(this.getPickupItem(), 0.1F); + } +@@ -407,11 +445,13 @@ + this.discard(); + } + } ++ + } + + public void deflect() { + float f = this.random.nextFloat() * 360.0F; +- this.setDeltaMovement(this.getDeltaMovement().yRot(f * (float) (Math.PI / 180.0)).scale(0.5)); ++ ++ this.setDeltaMovement(this.getDeltaMovement().yRot(f * 0.017453292F).scale(0.5D)); + this.setYRot(this.getYRot() + f); + this.yRotO += f; + } +@@ -420,15 +460,17 @@ + protected void onHitBlock(BlockHitResult result) { + this.lastState = this.level().getBlockState(result.getBlockPos()); + super.onHitBlock(result); +- Vec3 vec3 = result.getLocation().subtract(this.getX(), this.getY(), this.getZ()); +- this.setDeltaMovement(vec3); +- Vec3 vec31 = vec3.normalize().scale(0.05F); +- this.setPosRaw(this.getX() - vec31.x, this.getY() - vec31.y, this.getZ() - vec31.z); ++ Vec3 vec3d = result.getLocation().subtract(this.getX(), this.getY(), this.getZ()); ++ ++ this.setDeltaMovement(vec3d); ++ Vec3 vec3d1 = vec3d.normalize().scale(0.05000000074505806D); ++ ++ this.setPosRaw(this.getX() - vec3d1.x, this.getY() - vec3d1.y, this.getZ() - vec3d1.z); + this.playSound(this.getHitGroundSoundEvent(), 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.shakeTime = 7; + this.setCritArrow(false); +- this.setPierceLevel((byte)0); ++ this.setPierceLevel((byte) 0); + this.setSoundEvent(SoundEvents.ARROW_HIT); + this.setShotFromCrossbow(false); + this.resetPiercedEntities(); +@@ -442,14 +484,11 @@ + return this.soundEvent; + } + +- protected void doPostHurtEffects(LivingEntity target) { +- } ++ protected void doPostHurtEffects(LivingEntity target) {} + + @Nullable + protected EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { +- return ProjectileUtil.getEntityHitResult( +- this.level(), this, startVec, endVec, this.getBoundingBox().expandTowards(this.getDeltaMovement()).inflate(1.0), this::canHitEntity +- ); ++ return ProjectileUtil.getEntityHitResult(this.level(), this, startVec, endVec, this.getBoundingBox().expandTowards(this.getDeltaMovement()).inflate(1.0D), this::canHitEntity); + } + + @Override +@@ -460,14 +499,14 @@ + @Override + public void addAdditionalSaveData(CompoundTag compound) { + super.addAdditionalSaveData(compound); +- compound.putShort("life", (short)this.life); ++ compound.putShort("life", (short) this.life); + if (this.lastState != null) { + compound.put("inBlockState", NbtUtils.writeBlockState(this.lastState)); + } + +- compound.putByte("shake", (byte)this.shakeTime); ++ compound.putByte("shake", (byte) this.shakeTime); + compound.putBoolean("inGround", this.inGround); +- compound.putByte("pickup", (byte)this.pickup.ordinal()); ++ compound.putByte("pickup", (byte) this.pickup.ordinal()); + compound.putDouble("damage", this.baseDamage); + compound.putBoolean("crit", this.isCritArrow()); + compound.putByte("PierceLevel", this.getPierceLevel()); +@@ -494,32 +533,48 @@ + this.setCritArrow(compound.getBoolean("crit")); + this.setPierceLevel(compound.getByte("PierceLevel")); + if (compound.contains("SoundEvent", 8)) { +- this.soundEvent = BuiltInRegistries.SOUND_EVENT +- .getOptional(new ResourceLocation(compound.getString("SoundEvent"))) +- .orElse(this.getDefaultHitGroundSoundEvent()); ++ this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(new ResourceLocation(compound.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); + } + + this.setShotFromCrossbow(compound.getBoolean("ShotFromCrossbow")); + if (compound.contains("item", 10)) { + this.pickupItemStack = ItemStack.of(compound.getCompound("item")); + } ++ + } + + @Override + public void setOwner(@Nullable Entity entity) { + super.setOwner(entity); + if (entity instanceof Player) { +- this.pickup = ((Player)entity).getAbilities().instabuild ? AbstractArrow.Pickup.CREATIVE_ONLY : AbstractArrow.Pickup.ALLOWED; ++ this.pickup = ((Player) entity).getAbilities().instabuild ? AbstractArrow.Pickup.CREATIVE_ONLY : AbstractArrow.Pickup.ALLOWED; + } ++ + } + + @Override + public void playerTouch(Player entity) { + if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) { +- if (this.tryPickup(entity)) { ++ // CraftBukkit start ++ ItemStack itemstack = this.getPickupItem(); ++ if (this.pickup == Pickup.ALLOWED && !itemstack.isEmpty() && entity.getInventory().canHold(itemstack) > 0) { ++ ItemEntity item = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); ++ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level().getCraftServer(), item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); ++ // event.setCancelled(!entityhuman.canPickUpLoot); TODO ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ return; ++ } ++ itemstack = item.getItem(); ++ } ++ ++ if ((this.pickup == AbstractArrow.Pickup.ALLOWED && entity.getInventory().add(itemstack)) || (this.pickup == AbstractArrow.Pickup.CREATIVE_ONLY && entity.getAbilities().instabuild)) { ++ // CraftBukkit end + entity.take(this, 1); + this.discard(); + } ++ + } + } + +@@ -569,7 +624,7 @@ + } + + @Override +- protected float getEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getEyeHeight(EntityPose pose, EntityDimensions size) { + return 0.13F; + } + +@@ -578,47 +633,53 @@ + } + + public void setPierceLevel(byte pierceLevel) { +- this.entityData.set(PIERCE_LEVEL, pierceLevel); ++ this.entityData.set(AbstractArrow.PIERCE_LEVEL, pierceLevel); + } + + private void setFlag(int id, boolean value) { +- byte b = this.entityData.get(ID_FLAGS); ++ byte b0 = (Byte) this.entityData.get(AbstractArrow.ID_FLAGS); ++ + if (value) { +- this.entityData.set(ID_FLAGS, (byte)(b | id)); ++ this.entityData.set(AbstractArrow.ID_FLAGS, (byte) (b0 | id)); + } else { +- this.entityData.set(ID_FLAGS, (byte)(b & ~id)); ++ this.entityData.set(AbstractArrow.ID_FLAGS, (byte) (b0 & ~id)); + } ++ + } + + public boolean isCritArrow() { +- byte b = this.entityData.get(ID_FLAGS); +- return (b & 1) != 0; ++ byte b0 = (Byte) this.entityData.get(AbstractArrow.ID_FLAGS); ++ ++ return (b0 & 1) != 0; + } + + public boolean shotFromCrossbow() { +- byte b = this.entityData.get(ID_FLAGS); +- return (b & 4) != 0; ++ byte b0 = (Byte) this.entityData.get(AbstractArrow.ID_FLAGS); ++ ++ return (b0 & 4) != 0; + } + + public byte getPierceLevel() { +- return this.entityData.get(PIERCE_LEVEL); ++ return (Byte) this.entityData.get(AbstractArrow.PIERCE_LEVEL); + } + + public void setEnchantmentEffectsFromEntity(LivingEntity shooter, float velocity) { +- int enchantmentLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER_ARROWS, shooter); +- int enchantmentLevel1 = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH_ARROWS, shooter); +- this.setBaseDamage((double)(velocity * 2.0F) + this.random.triangle((double)this.level().getDifficulty().getId() * 0.11, 0.57425)); +- if (enchantmentLevel > 0) { +- this.setBaseDamage(this.getBaseDamage() + (double)enchantmentLevel * 0.5 + 0.5); ++ int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER_ARROWS, shooter); ++ int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH_ARROWS, shooter); ++ ++ this.setBaseDamage((double) (velocity * 2.0F) + this.random.triangle((double) this.level().getDifficulty().getId() * 0.11D, 0.57425D)); ++ if (i > 0) { ++ this.setBaseDamage(this.getBaseDamage() + (double) i * 0.5D + 0.5D); + } + +- if (enchantmentLevel1 > 0) { +- this.setKnockback(enchantmentLevel1); ++ if (j > 0) { ++ this.setKnockback(j); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAMING_ARROWS, shooter) > 0) { + this.setSecondsOnFire(100); + } ++ + } + + protected float getWaterInertia() { +@@ -631,7 +692,7 @@ + } + + public boolean isNoPhysics() { +- return !this.level().isClientSide ? this.noPhysics : (this.entityData.get(ID_FLAGS) & 2) != 0; ++ return !this.level().isClientSide ? this.noPhysics : ((Byte) this.entityData.get(AbstractArrow.ID_FLAGS) & 2) != 0; + } + + public void setShotFromCrossbow(boolean shotFromCrossbow) { +@@ -639,10 +700,11 @@ + } + + public static enum Pickup { +- DISALLOWED, +- ALLOWED, +- CREATIVE_ONLY; + ++ DISALLOWED, ALLOWED, CREATIVE_ONLY; ++ ++ private Pickup() {} ++ + public static AbstractArrow.Pickup byOrdinal(int ordinal) { + if (ordinal < 0 || ordinal > values().length) { + ordinal = 0; |