Commits
md_5 authored dc043d91a08
513 513 | + // CraftBukkit start |
514 514 | + if (this instanceof EntityPlayer) { |
515 515 | + ((EntityPlayer) this).b(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL); |
516 516 | + } else { |
517 517 | + this.b(worldserver1); |
518 518 | + } |
519 519 | + // CraftBukkit end |
520 520 | this.world.getMethodProfiler().exit(); |
521 521 | } |
522 522 | |
523 - | |
524 - | |
525 - | public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {} |
526 - | |
527 - | + public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {} // CraftBukkit |
528 - | + |
529 - | public boolean isBurning() { |
530 - | boolean flag = this.world != null && this.world.isClientSide; |
531 - | |
532 - | |
523 + | |
533 524 | } |
534 525 | |
535 526 | public void setSwimming(boolean flag) { |
536 527 | + // CraftBukkit start |
537 528 | + if (this.isSwimming() != flag && this instanceof EntityLiving) { |
538 529 | + if (CraftEventFactory.callToggleSwimEvent((EntityLiving) this, flag).isCancelled()) { |
539 530 | + return; |
540 531 | + } |
541 532 | + } |
542 533 | + // CraftBukkit end |
543 534 | this.setFlag(4, flag); |
544 535 | } |
545 536 | |
546 - | |
537 + | |
547 538 | return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false; |
548 539 | } |
549 540 | |
550 541 | + // CraftBukkit - start |
551 542 | public void setInvisible(boolean flag) { |
552 543 | - this.setFlag(5, flag); |
553 544 | + if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag |
554 545 | + this.setFlag(5, flag); |
555 546 | + } |
556 547 | + // CraftBukkit - end |
557 548 | } |
558 549 | |
559 550 | public boolean getFlag(int i) { |
560 - | |
551 + | |
561 552 | } |
562 553 | |
563 554 | public void setAirTicks(int i) { |
564 555 | - this.datawatcher.set(Entity.AIR_TICKS, i); |
565 556 | + // CraftBukkit start |
566 557 | + EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i); |
567 558 | + // Suppress during worldgen |
568 559 | + if (this.valid) { |
569 560 | + event.getEntity().getServer().getPluginManager().callEvent(event); |
570 561 | + } |
610 601 | + } |
611 602 | + CraftEventFactory.entityDamage = entitylightning; |
612 603 | + if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) { |
613 604 | + CraftEventFactory.entityDamage = null; |
614 605 | + return; |
615 606 | + } |
616 607 | + // CraftBukkit end |
617 608 | } |
618 609 | |
619 610 | public void k(boolean flag) { |
620 - | |
611 + | |
621 612 | |
622 613 | @Nullable |
623 614 | public Entity b(WorldServer worldserver) { |
624 615 | + // CraftBukkit start |
625 616 | + return teleportTo(worldserver, null); |
626 617 | + } |
627 618 | + |
628 619 | + @Nullable |
629 620 | + public Entity teleportTo(WorldServer worldserver, BlockPosition location) { |
630 621 | + // CraftBukkit end |
645 636 | return null; |
646 637 | } else { |
647 638 | + // CraftBukkit start |
648 639 | + worldserver = shapedetectorshape.world; |
649 640 | + this.decouple(); |
650 641 | + // CraftBukkit end |
651 642 | + |
652 643 | this.world.getMethodProfiler().exitEnter("reloading"); |
653 644 | Entity entity = this.getEntityType().a((World) worldserver); |
654 645 | |
655 - | |
646 + | |
656 647 | entity.setPositionRotation(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, entity.pitch); |
657 648 | entity.setMot(shapedetectorshape.velocity); |
658 649 | worldserver.addEntityTeleport(entity); |
659 650 | - if (worldserver.getDimensionKey() == World.THE_END) { |
660 651 | - WorldServer.a(worldserver); |
661 652 | + if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit |
662 653 | + WorldServer.a(worldserver, this); // CraftBukkit |
663 654 | } |
664 655 | + // CraftBukkit start - Forward the CraftEntity to the new entity |
665 656 | + this.getBukkitEntity().setHandle(entity); |
666 657 | + entity.bukkitEntity = this.getBukkitEntity(); |
667 658 | + |
668 659 | + if (this instanceof EntityInsentient) { |
669 660 | + ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads. |
670 661 | + } |
671 662 | + // CraftBukkit end |
672 663 | } |
673 664 | |
674 665 | this.bN(); |
675 - | |
666 + | |
676 667 | |
677 668 | @Nullable |
678 669 | protected ShapeDetectorShape a(WorldServer worldserver) { |
679 670 | - boolean flag = this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD; |
680 671 | - boolean flag1 = worldserver.getDimensionKey() == World.THE_END; |
681 672 | + // CraftBukkit start |
682 673 | + if (worldserver == null) { |
683 674 | + return null; |
684 675 | + } |
685 676 | + boolean flag = this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD; // fromEndToOverworld |
688 679 | |
689 680 | if (!flag && !flag1) { |
690 681 | - boolean flag2 = worldserver.getDimensionKey() == World.THE_NETHER; |
691 682 | + boolean flag2 = worldserver.getTypeKey() == DimensionManager.THE_NETHER; // CraftBukkit |
692 683 | |
693 684 | - if (this.world.getDimensionKey() != World.THE_NETHER && !flag2) { |
694 685 | + if (this.world.getTypeKey() != DimensionManager.THE_NETHER && !flag2) { |
695 686 | return null; |
696 687 | } else { |
697 688 | WorldBorder worldborder = worldserver.getWorldBorder(); |
698 - | |
689 + | |
699 690 | double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D); |
700 691 | double d4 = DimensionManager.a(this.world.getDimensionManager(), worldserver.getDimensionManager()); |
701 692 | BlockPosition blockposition = new BlockPosition(MathHelper.a(this.locX() * d4, d0, d2), this.locY(), MathHelper.a(this.locZ() * d4, d1, d3)); |
702 693 | + // CraftBukkit start |
703 694 | + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16); |
704 695 | + if (event == null) { |
705 696 | + return null; |
706 697 | + } |
707 698 | + final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle(); |
708 699 | + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); |
709 700 | |
710 701 | - return (ShapeDetectorShape) this.a(worldserver, blockposition, flag2).map((blockutil_rectangle) -> { |
711 702 | + return (ShapeDetectorShape) this.a(worldserver, blockposition, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> { |
712 703 | + // CraftBukkit end |
713 704 | IBlockData iblockdata = this.world.getType(this.ac); |
714 705 | EnumDirection.EnumAxis enumdirection_enumaxis; |
715 706 | Vec3D vec3d; |
716 - | |
707 + | |
717 708 | vec3d = new Vec3D(0.5D, 0.0D, 0.0D); |
718 709 | } |
719 710 | |
720 711 | - return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch); |
721 712 | - }).orElse((Object) null); |
722 713 | + return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch, event); // CraftBukkit |
723 714 | + }).orElse(null); // CraftBuukkit - decompile error |
724 715 | } |
725 716 | } else { |
726 717 | BlockPosition blockposition1; |
727 - | |
718 + | |
728 719 | } else { |
729 720 | blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()); |
730 721 | } |
731 722 | + // CraftBukkit start |
732 723 | + CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1, PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0); |
733 724 | + if (event == null) { |
734 725 | + return null; |
735 726 | + } |
736 727 | + blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ()); |
737 728 | |
738 729 | - return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch); |
739 730 | + return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch, ((CraftWorld) event.getTo().getWorld()).getHandle(), event); |
740 731 | + // CraftBukkit end |
741 732 | } |
742 733 | } |
743 734 | |
744 - | |
735 + | |
745 736 | return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose())); |
746 737 | } |
747 738 | |
748 739 | - protected Optional<BlockUtil.Rectangle> a(WorldServer worldserver, BlockPosition blockposition, boolean flag) { |
749 740 | - return worldserver.getTravelAgent().findPortal(blockposition, flag); |
750 741 | + // CraftBukkit start |
751 742 | + protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { |
752 743 | + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); |
753 744 | + Location enter = bukkitEntity.getLocation(); |
754 745 | + Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()); |
760 751 | + } |
761 752 | + return new CraftPortalEvent(event); |
762 753 | + } |
763 754 | + |
764 755 | + protected Optional<BlockUtil.Rectangle> a(WorldServer worldserver, BlockPosition blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) { // PAIL rename findOrCreatePortal |
765 756 | + return worldserver.getTravelAgent().findPortal(blockposition, searchRadius); |
766 757 | + // CraftBukkit end |
767 758 | } |
768 759 | |
769 760 | public boolean canPortal() { |
770 - | |
761 + | |
771 762 | } |
772 763 | |
773 764 | public void a(AxisAlignedBB axisalignedbb) { |
774 765 | - this.boundingBox = axisalignedbb; |
775 766 | + // CraftBukkit start - block invalid bounding boxes |
776 767 | + double minX = axisalignedbb.minX, |
777 768 | + minY = axisalignedbb.minY, |
778 769 | + minZ = axisalignedbb.minZ, |
779 770 | + maxX = axisalignedbb.maxX, |
780 771 | + maxY = axisalignedbb.maxY, |