Commits

md_5 authored 4b67fed7f60
Better handling of custom end/nether teleports
No tags

nms-patches/Entity.patch

Modified
595 595 + if (worldserver == null){
596 596 + return null;
597 597 + }
598 598 + // CraftBukkit end
599 599 this.world.getMethodProfiler().enter("reposition");
600 600 Vec3D vec3d = this.getMot();
601 601 float f = 0.0F;
602 602 - BlockPosition blockposition;
603 603 + BlockPosition blockposition = location; // CraftBukkit
604 604
605 -+ if (blockposition == null) { // CraftBukkit
606 - if (this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) {
605 +- if (this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD) {
607 606 - blockposition = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn());
607 +- } else if (worldserver.getDimensionKey() == World.THE_END) {
608 +- blockposition = WorldServer.a;
609 ++ if (blockposition == null) { // CraftBukkit
610 ++ if (this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD) { // CraftBukkit
608 611 + // CraftBukkit start
609 612 + EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn()), 0);
610 613 + if (event == null) {
611 614 + return null;
612 615 + }
613 616 + worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
614 617 + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
615 618 + // CraftBukkit end
616 - } else if (worldserver.getDimensionKey() == World.THE_END) {
617 -- blockposition = WorldServer.a;
619 ++ } else if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
618 620 + // CraftBukkit start
619 621 + EntityPortalEvent event = CraftEventFactory.callEntityPortalEvent(this, worldserver, WorldServer.a, 0);
620 622 + if (event == null) {
621 623 + return null;
622 624 + }
623 625 + worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
624 626 + blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
625 627 + // CraftBukkit end
626 628 } else {
627 629 double d0 = this.locX();
649 651 f = (float) shapedetector_shape.yaw;
650 652 }
651 653 + } // CraftBukkit
652 654 +
653 655 + // CraftBukkit start
654 656 + this.decouple();
655 657 + // CraftBukkit end
656 658
657 659 this.world.getMethodProfiler().exitEnter("reloading");
658 660 Entity entity = this.getEntityType().a((World) worldserver);
659 -@@ -2043,8 +2423,16 @@
661 +@@ -2042,9 +2422,17 @@
662 + entity.setPositionRotation(blockposition, entity.yaw + f, entity.pitch);
660 663 entity.setMot(vec3d);
661 664 worldserver.addEntityTeleport(entity);
662 - if (worldserver.getDimensionKey() == World.THE_END) {
665 +- if (worldserver.getDimensionKey() == World.THE_END) {
663 666 - WorldServer.a(worldserver);
667 ++ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
664 668 + WorldServer.a(worldserver, this); // CraftBukkit
665 669 + }
666 670 + // CraftBukkit start - Forward the CraftEntity to the new entity
667 671 + this.getBukkitEntity().setHandle(entity);
668 672 + entity.bukkitEntity = this.getBukkitEntity();
669 673 +
670 674 + if (this instanceof EntityInsentient) {
671 675 + ((EntityInsentient)this).unleash(true, false); // Unleash to prevent duping of leads.
672 676 }
673 677 + // CraftBukkit end

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut