Commits
Doc authored and md_5 committed 300e7448f5f
60 60 | this.chatVisibility = EnumChatVisibility.FULL; |
61 61 | |
62 62 | this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this); |
63 63 | this.maxUpStep = 1.0F; |
64 64 | this.fudgeSpawnLocation(worldserver); |
65 65 | + |
66 66 | + // CraftBukkit start |
67 67 | + this.displayName = this.getScoreboardName(); |
68 68 | + this.bukkitPickUpLoot = true; |
69 69 | + this.maxHealthCache = this.getMaxHealth(); |
70 - | } |
71 - | |
70 + | + } |
71 + | + |
72 72 | + // Yes, this doesn't match Vanilla, but it's the best we can do for now. |
73 73 | + // If this is an issue, PRs are welcome |
74 74 | + public final BlockPosition getSpawnPoint(WorldServer worldserver) { |
75 75 | + BlockPosition blockposition = worldserver.getSharedSpawnPos(); |
76 76 | + |
77 77 | + if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { |
78 78 | + int i = Math.max(0, this.server.getSpawnRadius(worldserver)); |
79 79 | + int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); |
80 80 | + |
81 81 | + if (j < i) { |
98 98 | + int k2 = i2 / (i * 2 + 1); |
99 99 | + BlockPosition blockposition1 = WorldProviderNormal.getOverworldRespawnPos(worldserver, blockposition.getX() + j2 - i, blockposition.getZ() + k2 - i); |
100 100 | + |
101 101 | + if (blockposition1 != null) { |
102 102 | + return blockposition1; |
103 103 | + } |
104 104 | + } |
105 105 | + } |
106 106 | + |
107 107 | + return blockposition; |
108 - | + } |
108 + | } |
109 109 | + // CraftBukkit end |
110 - | + |
110 + | |
111 111 | private void fudgeSpawnLocation(WorldServer worldserver) { |
112 112 | BlockPosition blockposition = worldserver.getSharedSpawnPos(); |
113 113 | |
114 114 | - if (worldserver.dimensionType().hasSkyLight() && worldserver.getServer().getWorldData().getGameType() != EnumGamemode.ADVENTURE) { |
115 115 | + if (worldserver.dimensionType().hasSkyLight() && worldserver.serverLevelData.getGameType() != EnumGamemode.ADVENTURE) { // CraftBukkit |
116 116 | int i = Math.max(0, this.server.getSpawnRadius(worldserver)); |
117 117 | int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ())); |
118 118 | |
119 119 | |
120 120 | if (nbttagcompound.contains("recipeBook", 10)) { |
168 168 | |
169 169 | |
170 170 | nbttagcompound.putInt("SpawnZ", this.respawnPosition.getZ()); |
171 171 | nbttagcompound.putBoolean("SpawnForced", this.respawnForced); |
172 172 | nbttagcompound.putFloat("SpawnAngle", this.respawnAngle); |
173 173 | - DataResult dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.location()); |
174 174 | + DataResult<NBTBase> dataresult = MinecraftKey.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.respawnDimension.location()); // CraftBukkit - decompile error |
175 175 | Logger logger = EntityPlayer.LOGGER; |
176 176 | |
177 177 | Objects.requireNonNull(logger); |
178 - | |
178 + | |
179 179 | nbttagcompound.put("SpawnDimension", nbtbase); |
180 180 | }); |
181 181 | } |
182 182 | + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit |
183 - | + |
184 - | + } |
183 + | |
184 + | } |
185 185 | |
186 186 | + // CraftBukkit start - World fallback code, either respawn location or global spawn |
187 187 | + public void spawnIn(World world) { |
188 188 | + this.level = world; |
189 189 | + if (world == null) { |
190 190 | + this.unsetRemoved(); |
191 191 | + Vec3D position = null; |
192 192 | + if (this.respawnDimension != null) { |
193 193 | + world = this.getLevel().getCraftServer().getHandle().getServer().getLevel(this.respawnDimension); |
194 194 | + if (world != null && this.getRespawnPosition() != null) { |
195 195 | + position = EntityHuman.findRespawnPositionAndUseSpawnBlock((WorldServer) world, this.getRespawnPosition(), this.getRespawnAngle(), false, false).orElse(null); |
196 196 | + } |
197 197 | + } |
198 198 | + if (world == null || position == null) { |
199 199 | + world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle(); |
200 200 | + position = Vec3D.atCenterOf(((WorldServer) world).getSharedSpawnPos()); |
201 201 | + } |
202 202 | + this.level = world; |
203 203 | + this.setPos(position.x(), position.y(), position.z()); |
204 204 | + } |
205 205 | + this.gameMode.setLevel((WorldServer) world); |
206 - | } |
206 + | + } |
207 207 | + // CraftBukkit end |
208 - | |
208 + | + |
209 209 | public void setExperiencePoints(int i) { |
210 210 | float f = (float) this.getXpNeededForNextLevel(); |
211 + | float f1 = (f - 1.0F) / f; |
211 212 | |
212 213 | |
213 214 | @Override |
214 215 | public void tick() { |
215 216 | + // CraftBukkit start |
216 217 | + if (this.joining) { |
217 218 | + this.joining = false; |
218 219 | + } |
219 220 | + // CraftBukkit end |
220 221 | this.gameMode.tick(); |
480 481 | + // CraftBukkit end |
481 482 | this.setLevel(worldserver); |
482 483 | worldserver.addDuringPortalTeleport(this); |
483 484 | - this.setRot(shapedetectorshape.yRot, shapedetectorshape.xRot); |
484 485 | - this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z); |
485 486 | + this.connection.teleport(exit); // CraftBukkit - use internal teleport without event |
486 487 | + this.connection.resetPosition(); // CraftBukkit - sync position after changing it (from PortalTravelAgent#findAndteleport) |
487 488 | worldserver1.getProfiler().pop(); |
488 489 | this.triggerDimensionChangeTriggers(worldserver1); |
489 490 | this.connection.send(new PacketPlayOutAbilities(this.getAbilities())); |
490 - | |
491 + | |
491 492 | this.lastSentExp = -1; |
492 493 | this.lastSentHealth = -1.0F; |
493 494 | this.lastSentFood = -1; |
494 495 | + |
495 496 | + // CraftBukkit start |
496 497 | + PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld()); |
497 498 | + this.level.getCraftServer().getPluginManager().callEvent(changeEvent); |
498 499 | + // CraftBukkit end |
499 500 | } |
500 501 | |
511 512 | + Bukkit.getServer().getPluginManager().callEvent(event); |
512 513 | + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) { |
513 514 | + return null; |
514 515 | + } |
515 516 | + return new CraftPortalEvent(event); |
516 517 | + } |
517 518 | + // CraftBukkit end |
518 519 | + |
519 520 | private void createEndPlatform(WorldServer worldserver, BlockPosition blockposition) { |
520 521 | BlockPosition.MutableBlockPosition blockposition_mutableblockposition = blockposition.mutable(); |
522 + | + org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(worldserver); // CraftBukkit |
523 + | |
524 + | for (int i = -2; i <= 2; ++i) { |
525 + | for (int j = -2; j <= 2; ++j) { |
526 + | for (int k = -1; k < 3; ++k) { |
527 + | IBlockData iblockdata = k == -1 ? Blocks.OBSIDIAN.defaultBlockState() : Blocks.AIR.defaultBlockState(); |
528 + | |
529 + | - worldserver.setBlockAndUpdate(blockposition_mutableblockposition.set(blockposition).move(j, k, i), iblockdata); |
530 + | + blockList.setBlock(blockposition_mutableblockposition.set(blockposition).move(j, k, i), iblockdata, 3); // CraftBukkit |
531 + | } |
532 + | } |
533 + | } |
534 + | + // CraftBukkit start - call portal event |
535 + | + org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((List<org.bukkit.block.BlockState>) (List) blockList.getList(), worldserver.getWorld(), this.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); |
536 + | + worldserver.getCraftServer().getPluginManager().callEvent(portalEvent); |
537 + | + if (!portalEvent.isCancelled()) { |
538 + | + blockList.updateList(); |
539 + | + } |
540 + | + // CraftBukkit end |
521 541 | |
522 - | |
523 542 | } |
524 543 | |
525 544 | @Override |
526 545 | - protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder) { |
527 546 | - Optional<BlockUtil.Rectangle> optional = super.getExitPortal(worldserver, blockposition, flag, worldborder); |
528 547 | + protected Optional<BlockUtil.Rectangle> getExitPortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, WorldBorder worldborder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit |
529 548 | + Optional<BlockUtil.Rectangle> optional = super.getExitPortal(worldserver, blockposition, flag, worldborder, searchRadius, canCreatePortal, createRadius); // CraftBukkit |
530 549 | |
531 550 | - if (optional.isPresent()) { |
532 551 | + if (optional.isPresent() || !canCreatePortal) { // CraftBukkit |
535 554 | EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level.getBlockState(this.portalEntrancePos).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X); |
536 555 | - Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis); |
537 556 | + Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit |
538 557 | |
539 558 | if (!optional1.isPresent()) { |
540 559 | - EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); |
541 560 | + // EntityPlayer.LOGGER.error("Unable to create a portal, likely target out of worldborder"); // CraftBukkit |
542 561 | } |
543 562 | |
544 563 | return optional1; |
545 - | |
564 + | |
546 565 | public void triggerDimensionChangeTriggers(WorldServer worldserver) { |
547 566 | ResourceKey<World> resourcekey = worldserver.dimension(); |
548 567 | ResourceKey<World> resourcekey1 = this.level.dimension(); |
549 568 | + // CraftBukkit start |
550 569 | + ResourceKey<World> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(worldserver); |
551 570 | + ResourceKey<World> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level); |
552 571 | |
553 572 | - CriterionTriggers.CHANGED_DIMENSION.trigger(this, resourcekey, resourcekey1); |
554 573 | - if (resourcekey == World.NETHER && resourcekey1 == World.OVERWORLD && this.enteredNetherPosition != null) { |
555 574 | + CriterionTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1); |
560 579 | + if (maindimensionkey == World.NETHER && maindimensionkey1 == World.OVERWORLD && this.enteredNetherPosition != null) { |
561 580 | + // CraftBukkit end |
562 581 | CriterionTriggers.NETHER_TRAVEL.trigger(this, this.enteredNetherPosition); |
563 582 | } |
564 583 | |
565 584 | - if (resourcekey1 != World.NETHER) { |
566 585 | + if (maindimensionkey1 != World.NETHER) { // CraftBukkit |
567 586 | this.enteredNetherPosition = null; |
568 587 | } |
569 588 | |
570 - | |
589 + | |
571 590 | this.containerMenu.broadcastChanges(); |
572 591 | } |
573 592 | |
574 593 | - @Override |
575 594 | - public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) { |
576 595 | - EnumDirection enumdirection = (EnumDirection) this.level.getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING); |
577 596 | - |
578 597 | + // CraftBukkit start - moved bed result checks from below into separate method |
579 598 | + private Either<EntityHuman.EnumBedResult, Unit> getBedResult(BlockPosition blockposition, EnumDirection enumdirection) { |
580 599 | if (!this.isSleeping() && this.isAlive()) { |
581 600 | - if (!this.level.dimensionType().natural()) { |
582 601 | + if (!this.level.dimensionType().natural() || !this.level.dimensionType().bedWorks()) { |
583 602 | return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE); |
584 603 | } else if (!this.bedInRange(blockposition, enumdirection)) { |
585 604 | return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY); |
586 - | |
605 + | |
587 606 | } |
588 607 | } |
589 608 | |
590 609 | - Either<EntityHuman.EnumBedResult, Unit> either = super.startSleepInBed(blockposition).ifRight((unit) -> { |
591 610 | + return Either.right(Unit.INSTANCE); |
592 611 | + } |
593 612 | + } |
594 613 | + } else { |
595 614 | + return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); |
596 615 | + } |
614 633 | + return bedResult; |
615 634 | + } |
616 635 | + |
617 636 | + { |
618 637 | + { |
619 638 | + { |
620 639 | + Either<EntityHuman.EnumBedResult, Unit> either = super.startSleepInBed(blockposition, force).ifRight((unit) -> { |
621 640 | this.awardStat(StatisticList.SLEEP_IN_BED); |
622 641 | CriterionTriggers.SLEPT_IN_BED.trigger(this); |
623 642 | }); |
624 - | |
643 + | |
625 644 | return either; |
626 645 | } |
627 646 | } |
628 647 | - } else { |
629 648 | - return Either.left(EntityHuman.EnumBedResult.OTHER_PROBLEM); |
630 649 | } |
631 650 | + // CraftBukkit end |
632 651 | } |
633 652 | |
634 653 | @Override |
635 - | |
654 + | |
636 655 | |
637 656 | @Override |
638 657 | public void stopSleepInBed(boolean flag, boolean flag1) { |
639 658 | + if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one! |
640 659 | + // CraftBukkit start - fire PlayerBedLeaveEvent |
641 660 | + CraftPlayer player = this.getBukkitEntity(); |
642 661 | + BlockPosition bedPosition = this.getSleepingPos().orElse(null); |
643 662 | + |
644 663 | + org.bukkit.block.Block bed; |
645 664 | + if (bedPosition != null) { |
650 669 | + |
651 670 | + PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true); |
652 671 | + this.level.getCraftServer().getPluginManager().callEvent(event); |
653 672 | + if (event.isCancelled()) { |
654 673 | + return; |
655 674 | + } |
656 675 | + // CraftBukkit end |
657 676 | if (this.isSleeping()) { |
658 677 | this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2)); |
659 678 | } |
660 - | |
679 + | |
661 680 | this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos())); |
662 681 | } |
663 682 | |
664 683 | - public void nextContainerCounter() { |
665 684 | + public int nextContainerCounter() { // CraftBukkit - void -> int |
666 685 | this.containerCounter = this.containerCounter % 100 + 1; |
667 686 | + return containerCounter; // CraftBukkit |
668 687 | } |
669 688 | |
670 689 | @Override |
671 - | |
690 + | |
672 691 | if (itileinventory == null) { |
673 692 | return OptionalInt.empty(); |
674 693 | } else { |
675 694 | + // CraftBukkit start - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEvent(...) |
676 695 | + /* |
677 696 | if (this.containerMenu != this.inventoryMenu) { |
678 697 | this.closeContainer(); |
679 698 | } |
680 699 | + */ |
681 700 | + // CraftBukkit end |
697 716 | + // SPIGOT-5355 - double chests too :( |
698 717 | + ((BlockChest.DoubleInventory) itileinventory).inventorylargechest.stopOpen(this); |
699 718 | + } |
700 719 | + return OptionalInt.empty(); |
701 720 | + } |
702 721 | + } |
703 722 | + // CraftBukkit end |
704 723 | if (container == null) { |
705 724 | if (this.isSpectator()) { |
706 725 | this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true); |
707 - | |
726 + | |
708 727 | |
709 728 | return OptionalInt.empty(); |
710 729 | } else { |
711 730 | - this.connection.send(new PacketPlayOutOpenWindow(container.containerId, container.getType(), itileinventory.getDisplayName())); |
712 731 | - this.initMenu(container); |
713 732 | + // CraftBukkit start |
714 733 | this.containerMenu = container; |
715 734 | + this.connection.send(new PacketPlayOutOpenWindow(container.containerId, container.getType(), container.getTitle())); |
716 735 | + // CraftBukkit end |
717 736 | + this.initMenu(container); |
718 737 | return OptionalInt.of(this.containerCounter); |
719 738 | } |
720 739 | } |
721 - | |
740 + | |
722 741 | |
723 742 | @Override |
724 743 | public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { |
725 744 | + // CraftBukkit start - Inventory open hook |
726 745 | + this.nextContainerCounter(); |
727 746 | + Container container = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); |
728 747 | + container.setTitle(entityhorseabstract.getDisplayName()); |
729 748 | + container = CraftEventFactory.callInventoryOpenEvent(this, container); |
730 749 | + |
731 750 | + if (container == null) { |
738 757 | } |
739 758 | |
740 759 | - this.nextContainerCounter(); |
741 760 | + // this.nextContainerCounter(); // CraftBukkit - moved up |
742 761 | this.connection.send(new PacketPlayOutOpenWindowHorse(this.containerCounter, iinventory.getContainerSize(), entityhorseabstract.getId())); |
743 762 | - this.containerMenu = new ContainerHorse(this.containerCounter, this.getInventory(), iinventory, entityhorseabstract); |
744 763 | + this.containerMenu = container; // CraftBukkit |
745 764 | this.initMenu(this.containerMenu); |
746 765 | } |
747 766 | |
748 - | |
767 + | |
749 768 | |
750 769 | @Override |
751 770 | public void closeContainer() { |
752 771 | + CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit |
753 772 | this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); |
754 773 | this.doCloseContainer(); |
755 774 | } |
756 - | |
775 + | |
757 776 | @Override |
758 777 | public void awardStat(Statistic<?> statistic, int i) { |
759 778 | this.stats.increment(this, statistic, i); |
760 779 | - this.getScoreboard().forAllObjectives(statistic, this.getScoreboardName(), (scoreboardscore) -> { |
761 780 | + this.level.getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead |
762 781 | scoreboardscore.add(i); |
763 782 | }); |
764 783 | } |
765 - | |
784 + | |
766 785 | @Override |
767 786 | public void resetStat(Statistic<?> statistic) { |
768 787 | this.stats.setValue(this, statistic, 0); |
769 788 | - this.getScoreboard().forAllObjectives(statistic, this.getScoreboardName(), ScoreboardScore::reset); |
770 789 | + this.level.getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), ScoreboardScore::reset); // CraftBukkit - Get our scores instead |
771 790 | } |
772 791 | |
773 792 | @Override |
774 - | |
793 + | |
775 794 | |
776 795 | for (int j = 0; j < i; ++j) { |
777 796 | MinecraftKey minecraftkey = aminecraftkey1[j]; |
778 797 | - Optional optional = this.server.getRecipeManager().byKey(minecraftkey); |
779 798 | + Optional<? extends IRecipe<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error |
780 799 | |
781 800 | Objects.requireNonNull(list); |
782 801 | optional.ifPresent(list::add); |
783 - | |
802 + | |
784 803 | |
785 804 | public void resetSentInfo() { |
786 805 | this.lastSentHealth = -1.0E8F; |
787 806 | + this.lastSentExp = -1; // CraftBukkit - Added to reset |
788 807 | } |
789 808 | |
790 809 | @Override |
791 - | |
810 + | |
792 811 | this.lastSentExp = -1; |
793 812 | this.lastSentHealth = -1.0F; |
794 813 | this.lastSentFood = -1; |
795 814 | - this.recipeBook.copyOverData(entityplayer.recipeBook); |
796 815 | + // this.recipeBook.copyOverData(entityplayer.recipeBook); // CraftBukkit |
797 816 | this.seenCredits = entityplayer.seenCredits; |
798 817 | this.enteredNetherPosition = entityplayer.enteredNetherPosition; |
799 818 | this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft()); |
800 - | |
819 + | |
801 820 | return s; |
802 821 | } |
803 822 | |
804 823 | + public String locale = "en_us"; // CraftBukkit - add, lowercase |
805 824 | public void updateOptions(PacketPlayInSettings packetplayinsettings) { |
806 825 | + // CraftBukkit start |
807 826 | + if (getMainArm() != packetplayinsettings.mainHand()) { |
808 827 | + PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainArm() == EnumMainHand.LEFT ? MainHand.LEFT : MainHand.RIGHT); |
809 828 | + this.server.server.getPluginManager().callEvent(event); |
810 829 | + } |
811 830 | + if (!this.locale.equals(packetplayinsettings.language)) { |
812 831 | + PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packetplayinsettings.language); |
813 832 | + this.server.server.getPluginManager().callEvent(event); |
814 833 | + } |
815 834 | + this.locale = packetplayinsettings.language; |
816 835 | + this.clientViewDistance = packetplayinsettings.viewDistance; |
817 836 | + // CraftBukkit end |
818 837 | this.chatVisibility = packetplayinsettings.chatVisibility(); |
819 838 | this.canChatColor = packetplayinsettings.chatColors(); |
820 839 | this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled(); |
821 - | |
840 + | |
822 841 | this.camera = (Entity) (entity == null ? this : entity); |
823 842 | if (entity1 != this.camera) { |
824 843 | this.connection.send(new PacketPlayOutCamera(this.camera)); |
825 844 | - this.teleportTo(this.camera.getX(), this.camera.getY(), this.camera.getZ()); |
826 845 | + this.connection.teleport(this.camera.getX(), this.camera.getY(), this.camera.getZ(), this.getYRot(), this.getXRot(), TeleportCause.SPECTATE); // CraftBukkit |
827 846 | } |
828 847 | |
829 848 | } |
830 - | |
849 + | |
831 850 | |
832 851 | @Nullable |
833 852 | public IChatBaseComponent getTabListDisplayName() { |
834 853 | - return null; |
835 854 | + return listName; // CraftBukkit |
836 855 | } |
837 856 | |
838 857 | @Override |
839 - | |
858 + | |
840 859 | return this.advancements; |
841 860 | } |
842 861 | |
843 862 | + // CraftBukkit start |
844 863 | public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1) { |
845 864 | + this.teleportTo(worldserver, d0, d1, d2, f, f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); |
846 865 | + } |
847 866 | + |
848 867 | + public void teleportTo(WorldServer worldserver, double d0, double d1, double d2, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { |
849 868 | + // CraftBukkit end |
850 869 | this.setCamera(this); |
851 870 | this.stopRiding(); |
852 871 | + /* CraftBukkit start - replace with bukkit handling for multi-world |
853 872 | if (worldserver == this.level) { |
854 873 | this.connection.teleport(d0, d1, d2, f, f1); |
855 874 | } else { |
856 - | |
875 + | |
857 876 | this.server.getPlayerList().sendLevelInfo(this, worldserver); |
858 877 | this.server.getPlayerList().sendAllPlayerInfo(this); |
859 878 | } |
860 879 | + */ |
861 880 | + this.getBukkitEntity().teleport(new Location(worldserver.getWorld(), d0, d1, d2, f, f1), cause); |
862 881 | + // CraftBukkit end |
863 882 | |
864 883 | } |
865 884 | |
866 - | |
885 + | |
867 886 | } |
868 887 | |
869 888 | } |
870 889 | + |
871 890 | + // CraftBukkit start - Add per-player time and weather. |
872 891 | + public long timeOffset = 0; |
873 892 | + public boolean relativeTime = true; |
874 893 | + |
875 894 | + public long getPlayerTime() { |
876 895 | + if (this.relativeTime) { |