Commits
md_5 authored 38f204d8cb2
560 560 | public boolean getSharedFlag(int i) { |
561 561 | |
562 562 | } |
563 563 | |
564 564 | public int getMaxAirSupply() { |
565 565 | - return 300; |
566 566 | + return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() |
567 567 | } |
568 568 | |
569 569 | public int getAirSupply() { |
570 - | |
570 + | |
571 571 | } |
572 572 | |
573 573 | public void setAirSupply(int i) { |
574 574 | - this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, i); |
575 575 | + // CraftBukkit start |
576 576 | + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); |
577 577 | + // Suppress during worldgen |
578 578 | + if (this.valid) { |
579 579 | + event.getEntity().getServer().getPluginManager().callEvent(event); |
580 580 | + } |
581 - | + if (event.isCancelled()) { |
581 + | + if (event.isCancelled() && this.getAirSupply() != i) { |
582 + | + this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); |
582 583 | + return; |
583 584 | + } |
584 585 | + this.entityData.set(Entity.DATA_AIR_SUPPLY_ID, event.getAmount()); |
585 586 | + // CraftBukkit end |
586 587 | } |
587 588 | |
588 589 | public int getTicksFrozen() { |
589 - | |
590 + | |
590 591 | |
591 592 | public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { |
592 593 | this.setRemainingFireTicks(this.remainingFireTicks + 1); |
593 594 | + // CraftBukkit start |
594 595 | + final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity(); |
595 596 | + final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity(); |
596 597 | + final PluginManager pluginManager = Bukkit.getPluginManager(); |
597 598 | + // CraftBukkit end |
598 599 | + |
599 600 | if (this.remainingFireTicks == 0) { |
623 624 | + } |
624 625 | + CraftEventFactory.entityDamage = entitylightning; |
625 626 | + if (!this.hurt(DamageSource.LIGHTNING_BOLT, 5.0F)) { |
626 627 | + CraftEventFactory.entityDamage = null; |
627 628 | + return; |
628 629 | + } |
629 630 | + // CraftBukkit end |
630 631 | } |
631 632 | |
632 633 | public void onAboveBubbleCol(boolean flag) { |
633 - | |
634 + | |
634 635 | |
635 636 | @Nullable |
636 637 | public Entity changeDimension(WorldServer worldserver) { |
637 638 | + // CraftBukkit start |
638 639 | + return teleportTo(worldserver, null); |
639 640 | + } |
640 641 | + |
641 642 | + @Nullable |
642 643 | + public Entity teleportTo(WorldServer worldserver, BlockPosition location) { |
643 644 | + // CraftBukkit end |
664 665 | + moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot); |
665 666 | + setDeltaMovement(shapedetectorshape.speed); |
666 667 | + return this; |
667 668 | + } |
668 669 | + this.unRide(); |
669 670 | + // CraftBukkit end |
670 671 | + |
671 672 | this.level.getProfiler().popPush("reloading"); |
672 673 | Entity entity = this.getType().create(worldserver); |
673 674 | |
674 - | |
675 + | |
675 676 | entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); |
676 677 | entity.setDeltaMovement(shapedetectorshape.speed); |
677 678 | worldserver.addDuringTeleport(entity); |
678 679 | - if (worldserver.dimension() == World.END) { |
679 680 | - WorldServer.makeObsidianPlatform(worldserver); |
680 681 | + if (worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit |
681 682 | + WorldServer.makeObsidianPlatform(worldserver, this); // CraftBukkit |
682 - | } |
683 + | + } |
683 684 | + // CraftBukkit start - Forward the CraftEntity to the new entity |
684 685 | + this.getBukkitEntity().setHandle(entity); |
685 686 | + entity.bukkitEntity = this.getBukkitEntity(); |
686 687 | + |
687 688 | + if (this instanceof EntityInsentient) { |
688 689 | + ((EntityInsentient) this).dropLeash(true, false); // Unleash to prevent duping of leads. |
689 - | + } |
690 + | } |
690 691 | + // CraftBukkit end |
691 692 | } |
692 693 | |
693 694 | this.removeAfterChangingDimensions(); |
694 - | |
695 + | |
695 696 | |
696 697 | @Nullable |
697 698 | protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { |
698 699 | - boolean flag = this.level.dimension() == World.END && worldserver.dimension() == World.OVERWORLD; |
699 700 | - boolean flag1 = worldserver.dimension() == World.END; |
700 701 | + // CraftBukkit start |
701 702 | + if (worldserver == null) { |
702 703 | + return null; |
703 704 | + } |
704 705 | + boolean flag = this.level.getTypeKey() == WorldDimension.END && worldserver.getTypeKey() == WorldDimension.OVERWORLD; // fromEndToOverworld |
724 725 | + final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); |
725 726 | + worldborder = worldserverFinal.getWorldBorder(); |
726 727 | + blockposition = worldborder.clampToBounds(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); |
727 728 | |
728 729 | - return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder).map((blockutil_rectangle) -> { |
729 730 | + return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> { |
730 731 | + // CraftBukkit end |
731 732 | IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos); |
732 733 | EnumDirection.EnumAxis enumdirection_enumaxis; |
733 734 | Vec3D vec3d; |
734 - | |
735 + | |
735 736 | vec3d = new Vec3D(0.5D, 0.0D, 0.0D); |
736 737 | } |
737 738 | |
738 739 | - return BlockPortalShape.createPortalInfo(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot()); |
739 740 | - }).orElse((Object) null); |
740 741 | + return BlockPortalShape.createPortalInfo(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.getDimensions(this.getPose()), this.getDeltaMovement(), this.getYRot(), this.getXRot(), event); // CraftBukkit |
741 742 | + }).orElse(null); // CraftBuukkit - decompile error |
742 743 | } |
743 744 | } else { |
744 745 | BlockPosition blockposition1; |
745 - | |
746 + | |
746 747 | } else { |
747 748 | blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); |
748 749 | } |
749 750 | + // CraftBukkit start |
750 751 | + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1, PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0); |
751 752 | + if (event == null) { |
752 753 | + return null; |
753 754 | + } |
754 755 | + blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); |
755 756 | |
756 757 | - return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot()); |
757 758 | + return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getDeltaMovement(), this.getYRot(), this.getXRot(), ((CraftWorld) event.getTo().getWorld()).getHandle(), event); |
758 759 | + // CraftBukkit end |
759 760 | } |
760 761 | } |
761 762 | |
762 - | |
763 + | |
763 764 | return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); |
764 765 | } |
765 766 | |
766 767 | - protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) { |
767 768 | - return worldserver.getPortalForcer().findPortalAround(blockposition, flag, worldborder); |
768 769 | + // CraftBukkit start |
769 770 | + protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { |
770 771 | + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); |
771 772 | + Location enter = bukkitEntity.getLocation(); |
772 773 | + Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()); |
778 779 | + } |
779 780 | + return new CraftPortalEvent(event); |
780 781 | + } |
781 782 | + |
782 783 | + protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { |
783 784 | + return worldserver.getPortalForcer().findPortalAround(blockposition, worldborder, searchRadius); |
784 785 | + // CraftBukkit end |
785 786 | } |
786 787 | |
787 788 | public boolean canChangeDimensions() { |
788 - | |
789 + | |
789 790 | } |
790 791 | |
791 792 | public final void setBoundingBox(AxisAlignedBB axisalignedbb) { |
792 793 | - this.bb = axisalignedbb; |
793 794 | + // CraftBukkit start - block invalid bounding boxes |
794 795 | + double minX = axisalignedbb.minX, |
795 796 | + minY = axisalignedbb.minY, |
796 797 | + minZ = axisalignedbb.minZ, |
797 798 | + maxX = axisalignedbb.maxX, |
798 799 | + maxY = axisalignedbb.maxY, |
806 807 | + if (len > 64) maxY = minY + 64.0; |
807 808 | + |
808 809 | + len = axisalignedbb.maxZ - axisalignedbb.minZ; |
809 810 | + if (len < 0) maxZ = minZ; |
810 811 | + if (len > 64) maxZ = minZ + 64.0; |
811 812 | + this.bb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); |
812 813 | + // CraftBukkit end |
813 814 | } |
814 815 | |
815 816 | protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { |
816 - | |
817 + | |
817 818 | vec3d = vec3d.add(vec3d1); |
818 819 | ++k1; |
819 820 | } |
820 821 | + // CraftBukkit start - store last lava contact location |
821 822 | + if (tag == TagsFluid.LAVA) { |
822 823 | + this.lastLavaContact = blockposition_mutableblockposition.immutable(); |
823 824 | + } |
824 825 | + // CraftBukkit end |
825 826 | } |
826 827 | } |
827 828 | } |