geforkt von Mirrors/Paper
0c4a1c4496
Add to gradle build so that this is automatically done throughout the update
53 Zeilen
2.5 KiB
Diff
53 Zeilen
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Caleb Bassham <caleb.bassham@gmail.com>
|
|
Date: Fri, 28 Sep 2018 02:32:19 -0500
|
|
Subject: [PATCH] Call player spectator target events and improve
|
|
implementation
|
|
|
|
Use a proper teleport for teleporting to entities in different
|
|
worlds.
|
|
|
|
Implementation improvements authored by Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Validate that the target entity is valid and deny spectate
|
|
requests from frozen players.
|
|
|
|
Also, make sure the entity is spawned to the client before
|
|
sending the camera packet. If the entity isn't spawned clientside
|
|
when it receives the camera packet, then the client will not
|
|
spectate the target entity.
|
|
|
|
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 35bf922f7995074dd875474cc3d5577dbdb72dad..47a7b3171917b520eead0932eec821f1eff788c3 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -1936,6 +1936,19 @@ public class ServerPlayer extends Player {
|
|
|
|
this.camera = (Entity) (entity == null ? this : entity);
|
|
if (entity1 != this.camera) {
|
|
+ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event
|
|
+ if (this.camera == this) {
|
|
+ com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity());
|
|
+ if (!playerStopSpectatingEntityEvent.callEvent()) {
|
|
+ return;
|
|
+ }
|
|
+ } else {
|
|
+ com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent playerStartSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity(), entity.getBukkitEntity());
|
|
+ if (!playerStartSpectatingEntityEvent.callEvent()) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
Level world = this.camera.level();
|
|
|
|
if (world instanceof ServerLevel) {
|
|
@@ -1951,7 +1964,6 @@ public class ServerPlayer extends Player {
|
|
this.connection.send(new ClientboundSetCameraPacket(this.camera));
|
|
this.connection.resetPosition();
|
|
}
|
|
-
|
|
}
|
|
|
|
@Override
|