2019-03-20 00:28:15 +00:00
|
|
|
From a854a7b5588062bada57d6f473da1caafcaf14f2 Mon Sep 17 00:00:00 2001
|
2018-10-18 20:53:10 +00:00
|
|
|
From: Caleb Bassham <caleb.bassham@gmail.com>
|
|
|
|
Date: Fri, 28 Sep 2018 02:32:19 -0500
|
|
|
|
Subject: [PATCH] Call player spectator target events
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
2019-03-20 00:28:15 +00:00
|
|
|
index 62feadc8a..f1b7353cf 100644
|
2018-10-18 20:53:10 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
2019-01-01 03:15:55 +00:00
|
|
|
@@ -59,7 +59,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2018-10-18 20:53:10 +00:00
|
|
|
private EntityHuman.EnumChatVisibility cs;
|
|
|
|
private boolean ct = true;
|
2018-12-17 05:18:06 +00:00
|
|
|
private long cu = SystemUtils.getMonotonicMillis();
|
|
|
|
- private Entity spectatedEntity;
|
|
|
|
+ private Entity spectatedEntity; private void setSpectatorTargetField(Entity e) { this.spectatedEntity = e; } // Paper - OBFHELPER
|
2018-10-18 20:53:10 +00:00
|
|
|
public boolean worldChangeInvuln;
|
|
|
|
private boolean cx; private void setHasSeenCredits(boolean has) { this.cx = has; } // Paper - OBFHELPER
|
2018-12-17 05:18:06 +00:00
|
|
|
private final RecipeBookServer recipeBook;
|
2019-03-20 00:28:15 +00:00
|
|
|
@@ -1390,15 +1390,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2018-12-17 05:18:06 +00:00
|
|
|
return (Entity) (this.spectatedEntity == null ? this : this.spectatedEntity);
|
2018-10-18 20:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- public void setSpectatorTarget(Entity entity) {
|
|
|
|
+ public void setSpectatorTarget(Entity newSpectatorTarget) {
|
2018-10-21 19:27:53 +00:00
|
|
|
+ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event
|
2018-10-18 20:53:10 +00:00
|
|
|
Entity entity1 = this.getSpecatorTarget();
|
|
|
|
|
2018-12-17 05:18:06 +00:00
|
|
|
- this.spectatedEntity = (Entity) (entity == null ? this : entity);
|
|
|
|
- if (entity1 != this.spectatedEntity) {
|
|
|
|
- this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
|
|
|
|
- this.playerConnection.a(this.spectatedEntity.locX, this.spectatedEntity.locY, this.spectatedEntity.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
|
2018-10-18 20:53:10 +00:00
|
|
|
+ if (newSpectatorTarget == null) {
|
|
|
|
+ newSpectatorTarget = this;
|
2018-10-21 19:27:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ if (entity1 == newSpectatorTarget) return; // new spec target is the current spec target
|
2018-10-18 20:53:10 +00:00
|
|
|
+
|
2018-10-21 19:27:53 +00:00
|
|
|
+ if (newSpectatorTarget == this) {
|
|
|
|
+ com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity());
|
2018-10-18 20:53:10 +00:00
|
|
|
+
|
2018-10-21 19:27:53 +00:00
|
|
|
+ if (!playerStopSpectatingEntityEvent.callEvent()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent playerStartSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStartSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity(), newSpectatorTarget.getBukkitEntity());
|
2018-10-18 20:53:10 +00:00
|
|
|
+
|
2018-10-21 19:27:53 +00:00
|
|
|
+ if (!playerStartSpectatingEntityEvent.callEvent()) {
|
|
|
|
+ return;
|
2018-10-18 20:53:10 +00:00
|
|
|
+ }
|
2018-10-21 19:27:53 +00:00
|
|
|
+ }
|
2018-10-18 20:53:10 +00:00
|
|
|
+
|
|
|
|
+ setSpectatorTargetField(newSpectatorTarget);
|
2018-10-21 19:27:53 +00:00
|
|
|
+
|
|
|
|
+ this.playerConnection.sendPacket(new PacketPlayOutCamera(newSpectatorTarget));
|
2018-12-17 05:18:06 +00:00
|
|
|
+ this.playerConnection.a(this.spectatedEntity.locX, this.spectatedEntity.locY, this.spectatedEntity.locZ, this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
|
2018-10-21 19:27:53 +00:00
|
|
|
+ // Paper end
|
2018-10-18 20:53:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void E() {
|
|
|
|
--
|
2019-03-20 00:28:15 +00:00
|
|
|
2.21.0
|
2018-10-18 20:53:10 +00:00
|
|
|
|