Commits
md_5 authored d492e363b8d
461 461 | + this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM); |
462 462 | + // CraftBukkit end |
463 463 | this.world.broadcastEntityEffect(this, (byte) 35); |
464 464 | } |
465 465 | |
466 466 | - return itemstack != null; |
467 467 | + return !event.isCancelled(); |
468 468 | } |
469 469 | } |
470 470 | |
471 - | |
471 + | |
472 472 | |
473 473 | boolean flag = this.lastDamageByPlayerTime > 0; |
474 474 | |
475 475 | + this.dropInventory(); // CraftBukkit - from below |
476 476 | if (this.cV() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) { |
477 477 | this.a(damagesource, flag); |
478 478 | this.dropDeathLoot(damagesource, i, flag); |
479 - | + // CraftBukkit start - Call death event |
480 - | + CraftEventFactory.callEntityDeathEvent(this, this.drops); |
481 - | + this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); |
482 - | + } else { |
483 - | + CraftEventFactory.callEntityDeathEvent(this); |
484 - | + // CraftBukkit end |
485 479 | } |
480 + | + // CraftBukkit start - Call death event |
481 + | + CraftEventFactory.callEntityDeathEvent(this, this.drops); |
482 + | + this.drops = new ArrayList<>(); |
483 + | + // CraftBukkit end |
486 484 | |
487 485 | - this.dropInventory(); |
488 486 | + // this.dropInventory();// CraftBukkit - moved up |
489 487 | this.dropExperience(); |
490 488 | } |
491 489 | |
492 490 | protected void dropInventory() {} |
493 491 | |
494 492 | - protected void dropExperience() { |
495 493 | + // CraftBukkit start |
512 510 | |
513 511 | i -= j; |
514 512 | this.world.addEntity(new EntityExperienceOrb(this.world, this.locX(), this.locY(), this.locZ(), j)); |
515 513 | } |
516 514 | + this.expToDrop = 0; |
517 515 | } |
518 516 | + // CraftBukkit end |
519 517 | |
520 518 | } |
521 519 | |
522 - | |
520 + | |
523 521 | int i = this.e(f, f1); |
524 522 | |
525 523 | if (i > 0) { |
526 524 | + // CraftBukkit start |
527 525 | + if (!this.damageEntity(DamageSource.FALL, (float) i)) { |
528 526 | + return true; |
529 527 | + } |
530 528 | + // CraftBukkit end |
531 529 | this.playSound(this.getSoundFall(i), 1.0F, 1.0F); |
532 530 | this.playBlockStepSound(); |
533 531 | - this.damageEntity(DamageSource.FALL, (float) i); |
534 532 | + // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up |
535 533 | return true; |
536 534 | } else { |
537 535 | return flag; |
538 - | |
536 + | |
539 537 | |
540 538 | protected float applyArmorModifier(DamageSource damagesource, float f) { |
541 539 | if (!damagesource.ignoresArmor()) { |
542 540 | - this.damageArmor(damagesource, f); |
543 541 | + // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) |
544 542 | f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS)); |
545 543 | } |
546 544 | |
547 - | |
545 + | |
548 546 | } else { |
549 547 | int i; |
550 548 | |
551 549 | - if (this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { |
552 550 | + // CraftBukkit - Moved to damageEntity0(DamageSource, float) |
553 551 | + if (false && this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) { |
554 552 | i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; |
555 553 | int j = 25 - i; |
556 554 | float f1 = f * (float) j; |
557 - | |
555 + | |
558 556 | } |
559 557 | } |
560 558 | |
561 559 | - protected void damageEntity0(DamageSource damagesource, float f) { |
562 560 | - if (!this.isInvulnerable(damagesource)) { |
563 561 | - f = this.applyArmorModifier(damagesource, f); |
564 562 | - f = this.applyMagicModifier(damagesource, f); |
565 563 | - float f1 = f; |
566 564 | + // CraftBukkit start |
567 565 | + protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final |
731 729 | + } else { |
732 730 | + return originalDamage > 0; |
733 731 | + } |
734 732 | + // CraftBukkit end |
735 733 | } |
736 734 | } |
737 735 | + return false; // CraftBukkit |
738 736 | } |
739 737 | |
740 738 | public CombatTracker getCombatTracker() { |
741 - | |
739 + | |
742 740 | } |
743 741 | |
744 742 | if (this.onGround && !this.world.isClientSide) { |
745 743 | + if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit |
746 744 | this.setFlag(7, false); |
747 745 | } |
748 746 | } else { |
749 - | |
747 + | |
750 748 | } |
751 749 | |
752 750 | if (!this.world.isClientSide) { |
753 751 | + if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit |
754 752 | this.setFlag(7, flag); |
755 753 | } |
756 754 | |
757 - | |
755 + | |
758 756 | } |
759 757 | |
760 758 | public boolean hasLineOfSight(Entity entity) { |
761 759 | + if (this.world != entity.world) return false; // CraftBukkit - SPIGOT-5675, SPIGOT-5798, MC-149563 |
762 760 | Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ()); |
763 761 | Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ()); |
764 762 | |
765 - | |
763 + | |
766 764 | |
767 765 | @Override |
768 766 | public boolean isInteractable() { |
769 767 | - return !this.dead; |
770 768 | + return !this.dead && this.collides; // CraftBukkit |
771 769 | } |
772 770 | |
773 771 | @Override |
774 772 | public boolean isCollidable() { |
775 773 | - return this.isAlive() && !this.isClimbing(); |
778 776 | + |
779 777 | + // CraftBukkit start - collidable API |
780 778 | + @Override |
781 779 | + public boolean canCollideWith(Entity entity) { |
782 780 | + return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID()); |
783 781 | } |
784 782 | + // CraftBukkit end |
785 783 | |
786 784 | @Override |
787 785 | protected void velocityChanged() { |
788 - | |
786 + | |
789 787 | } else { |
790 788 | if (!this.activeItem.isEmpty() && this.isHandRaised()) { |
791 789 | this.b(this.activeItem, 16); |
792 790 | - this.a(this.getRaisedHand(), this.activeItem.a(this.world, this)); |
793 791 | + // CraftBukkit start - fire PlayerItemConsumeEvent |
794 792 | + ItemStack itemstack; |
795 793 | + if (this instanceof EntityPlayer) { |
796 794 | + org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem); |
797 795 | + PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem); |
798 796 | + world.getServer().getPluginManager().callEvent(event); |
807 805 | + itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this); |
808 806 | + } else { |
809 807 | + itemstack = this.activeItem.a(this.world, this); |
810 808 | + } |
811 809 | + |
812 810 | + this.a(this.getRaisedHand(), itemstack); |
813 811 | + // CraftBukkit end |
814 812 | this.clearActiveItem(); |
815 813 | } |
816 814 | |
817 - | |
815 + | |
818 816 | } |
819 817 | |
820 818 | if (flag2) { |
821 819 | - this.enderTeleportTo(d0, d6, d2); |
822 820 | - if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) { |
823 821 | - flag1 = true; |
824 822 | + // CraftBukkit start - Teleport event |
825 823 | + // this.enderTeleportTo(d0, d6, d2); |
826 824 | + EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), d0, d6, d2)); |
827 825 | + this.world.getServer().getPluginManager().callEvent(teleport); |
828 826 | + if (!teleport.isCancelled()) { |
829 827 | + Location to = teleport.getTo(); |
830 828 | + this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); |
831 829 | + if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) { |
832 830 | + flag1 = true; |
833 831 | + } |
834 832 | } |
835 833 | + // CraftBukkit end |
836 834 | } |
837 835 | } |
838 836 | |
839 - | |
837 + | |
840 838 | } |
841 839 | |
842 840 | public void entityWakeup() { |
843 841 | - Optional optional = this.getBedPosition(); |
844 842 | + Optional<BlockPosition> optional = this.getBedPosition(); // CraftBukkit - decompile error |
845 843 | World world = this.world; |
846 844 | |
847 845 | this.world.getClass(); |
848 - | |
846 + | |
849 847 | Pair<MobEffect, Float> pair = (Pair) iterator.next(); |
850 848 | |
851 849 | if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) { |
852 850 | - entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst())); |
853 851 | + entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit |
854 852 | } |
855 853 | } |
856 854 | } |