2020-04-27 09:34:45 +02:00
|
|
|
From 8b8ec3a2fefaceaeb38dacfe5251360b15ac388e Mon Sep 17 00:00:00 2001
|
2018-10-18 22:53:10 +02: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
|
2020-04-27 09:34:45 +02:00
|
|
|
index f43584f0e3..bc62a9f08e 100644
|
2018-10-18 22:53:10 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
2020-03-01 00:39:00 +01:00
|
|
|
@@ -61,7 +61,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2019-12-12 17:20:43 +01:00
|
|
|
private EnumChatVisibility ch;
|
|
|
|
private boolean ci = true;
|
|
|
|
private long cj = SystemUtils.getMonotonicMillis();
|
2018-12-17 06:18:06 +01:00
|
|
|
- private Entity spectatedEntity;
|
|
|
|
+ private Entity spectatedEntity; private void setSpectatorTargetField(Entity e) { this.spectatedEntity = e; } // Paper - OBFHELPER
|
2018-10-18 22:53:10 +02:00
|
|
|
public boolean worldChangeInvuln;
|
2019-12-12 17:20:43 +01:00
|
|
|
private boolean cm; private void setHasSeenCredits(boolean has) { this.cm = has; } // Paper - OBFHELPER
|
2018-12-17 06:18:06 +01:00
|
|
|
private final RecipeBookServer recipeBook;
|
2020-04-27 09:34:45 +02:00
|
|
|
@@ -1586,15 +1586,35 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2018-12-17 06:18:06 +01:00
|
|
|
return (Entity) (this.spectatedEntity == null ? this : this.spectatedEntity);
|
2018-10-18 22:53:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- public void setSpectatorTarget(Entity entity) {
|
|
|
|
+ public void setSpectatorTarget(Entity newSpectatorTarget) {
|
2018-10-21 21:27:53 +02:00
|
|
|
+ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event
|
2018-10-18 22:53:10 +02:00
|
|
|
Entity entity1 = this.getSpecatorTarget();
|
|
|
|
|
2018-12-17 06:18:06 +01:00
|
|
|
- this.spectatedEntity = (Entity) (entity == null ? this : entity);
|
|
|
|
- if (entity1 != this.spectatedEntity) {
|
|
|
|
- this.playerConnection.sendPacket(new PacketPlayOutCamera(this.spectatedEntity));
|
2019-12-12 17:20:43 +01:00
|
|
|
- this.playerConnection.a(this.spectatedEntity.locX(), this.spectatedEntity.locY(), this.spectatedEntity.locZ(), this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
|
2018-10-18 22:53:10 +02:00
|
|
|
+ if (newSpectatorTarget == null) {
|
|
|
|
+ newSpectatorTarget = this;
|
2018-10-21 21:27:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ if (entity1 == newSpectatorTarget) return; // new spec target is the current spec target
|
2018-10-18 22:53:10 +02:00
|
|
|
+
|
2018-10-21 21:27:53 +02: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 22:53:10 +02:00
|
|
|
+
|
2018-10-21 21:27:53 +02: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 22:53:10 +02:00
|
|
|
+
|
2018-10-21 21:27:53 +02:00
|
|
|
+ if (!playerStartSpectatingEntityEvent.callEvent()) {
|
|
|
|
+ return;
|
2018-10-18 22:53:10 +02:00
|
|
|
+ }
|
2018-10-21 21:27:53 +02:00
|
|
|
+ }
|
2018-10-18 22:53:10 +02:00
|
|
|
+
|
|
|
|
+ setSpectatorTargetField(newSpectatorTarget);
|
2018-10-21 21:27:53 +02:00
|
|
|
+
|
|
|
|
+ this.playerConnection.sendPacket(new PacketPlayOutCamera(newSpectatorTarget));
|
2019-12-15 21:19:52 +01:00
|
|
|
+ this.playerConnection.a(this.spectatedEntity.locX(), this.spectatedEntity.locY(), this.spectatedEntity.locZ(), this.yaw, this.pitch, TeleportCause.SPECTATE); // CraftBukkit
|
2018-10-21 21:27:53 +02:00
|
|
|
+ // Paper end
|
2018-10-18 22:53:10 +02:00
|
|
|
}
|
|
|
|
|
2019-12-12 17:20:43 +01:00
|
|
|
@Override
|
2020-04-27 09:34:45 +02:00
|
|
|
@@ -1602,7 +1622,6 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
2019-12-12 17:20:43 +01:00
|
|
|
if (this.portalCooldown > 0 && !this.worldChangeInvuln) {
|
|
|
|
--this.portalCooldown;
|
|
|
|
}
|
|
|
|
-
|
|
|
|
}
|
|
|
|
|
2019-05-05 10:33:44 +02:00
|
|
|
@Override
|
2018-10-18 22:53:10 +02:00
|
|
|
--
|
2020-04-27 09:34:45 +02:00
|
|
|
2.26.2
|
2018-10-18 22:53:10 +02:00
|
|
|
|