- if (entity.damage(damageSource2, (float) i)) {
- if (bl) {
- return;
- }
- if (entity instanceof LivingEntity) {
- LivingEntity livingEntity = (LivingEntity) entity;
- if (!this.world.isClient && this.getPierceLevel() <= 0) {
- livingEntity.setStuckArrowCount(livingEntity.getStuckArrowCount() + 1);
- }
- if (this.punch > 0) {
- Vec3d vec3d = this.getVelocity().multiply(1.0D, 0.0D, 1.0D).normalize().multiply((double) this.punch * 0.6D);
- if (vec3d.lengthSquared() > 0.0D) {
- livingEntity.addVelocity(vec3d.x, 0.1D, vec3d.z);
- }
- }
- if (!this.world.isClient && entity2 instanceof LivingEntity) {
- EnchantmentHelper.onUserDamaged(livingEntity, entity2);
- EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
- }
- this.onHit(livingEntity);
- if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
- ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, GameStateChangeS2CPacket.DEMO_OPEN_SCREEN));
- }
- if (!entity.isAlive() && this.piercingKilledEntities != null) {
- this.piercingKilledEntities.add(livingEntity);
- }
- if (!this.world.isClient && entity2 instanceof ServerPlayerEntity) {
- ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) entity2;
- if (this.piercingKilledEntities != null && this.isShotFromCrossbow()) {
- Criteria.KILLED_BY_CROSSBOW.trigger(serverPlayerEntity, this.piercingKilledEntities);
- } else if (!entity.isAlive() && this.isShotFromCrossbow()) {
- Criteria.KILLED_BY_CROSSBOW.trigger(serverPlayerEntity, Arrays.asList(entity));
- }
- }
- }
- this.playSound(this.sound, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
- if (this.getPierceLevel() <= 0) {
- this.discard();
- }
- } else {
- entity.setFireTicks(j);
- this.setVelocity(this.getVelocity().multiply(-0.1D));
- this.setYaw(this.getYaw() + 180.0F);
- this.prevYaw += 180.0F;
- if (!this.world.isClient && this.getVelocity().lengthSquared() < 1.0E-7D) {
- if (this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED) {
- this.dropStack(this.asItemStack(), 0.1F);
- }
- this.discard();
- }
- }
复制代码 |