summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2015-06-07 21:04:28 +0100
committerThinkofdeath <thinkofdeath@spigotmc.org>2015-06-07 21:04:28 +0100
commit53433de98d7e83dca4ff77d83447e7fca57d3639 (patch)
tree7e6c0a7a0aa4ed915c41d0a3350563e74de296d7 /nms-patches
parent845336b511bdd3d3d9b8a67346503acc4ad3396a (diff)
downloadcraftbukkit-53433de98d7e83dca4ff77d83447e7fca57d3639.tar
craftbukkit-53433de98d7e83dca4ff77d83447e7fca57d3639.tar.gz
craftbukkit-53433de98d7e83dca4ff77d83447e7fca57d3639.tar.lz
craftbukkit-53433de98d7e83dca4ff77d83447e7fca57d3639.tar.xz
craftbukkit-53433de98d7e83dca4ff77d83447e7fca57d3639.zip
SPIGOT-954: Don't send block animations or gamemode updates to players can't see the player
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/PlayerInteractManager.patch9
-rw-r--r--nms-patches/PlayerList.patch52
-rw-r--r--nms-patches/WorldManager.patch26
3 files changed, 66 insertions, 21 deletions
diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch
index 0214d109..c4b0f192 100644
--- a/nms-patches/PlayerInteractManager.patch
+++ b/nms-patches/PlayerInteractManager.patch
@@ -14,6 +14,15 @@
public class PlayerInteractManager {
public World world;
+@@ -26,7 +34,7 @@
+ this.gamemode = worldsettings_enumgamemode;
+ worldsettings_enumgamemode.a(this.player.abilities);
+ this.player.updateAbilities();
+- this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[] { this.player}));
++ this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[] { this.player}), this.player); // CraftBukkit
+ }
+
+ public WorldSettings.EnumGamemode getGameMode() {
@@ -50,7 +58,7 @@
}
diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch
index 28ca82c0..e12cf832 100644
--- a/nms-patches/PlayerList.patch
+++ b/nms-patches/PlayerList.patch
@@ -579,12 +579,12 @@
+ double d1 = enter.getZ();
+ double d2 = 8.0D;
+ /*
-+ double d0 = entity.locX;
-+ double d1 = entity.locZ;
-+ double d2 = 8.0D;
-+ float f = entity.yaw;
-+
-+ worldserver.methodProfiler.a("moving");
+ double d0 = entity.locX;
+ double d1 = entity.locZ;
+ double d2 = 8.0D;
+ float f = entity.yaw;
+
+ worldserver.methodProfiler.a("moving");
+ */
+ if (worldserver1.dimension == -1) {
+ d0 = MathHelper.a(d0 / d2, worldserver1.getWorldBorder().b()+ 16.0D, worldserver1.getWorldBorder().d() - 16.0D);
@@ -654,12 +654,12 @@
+ int i = worldserver.dimension;
+
+ /*
- double d0 = entity.locX;
- double d1 = entity.locZ;
- double d2 = 8.0D;
- float f = entity.yaw;
-
- worldserver.methodProfiler.a("moving");
++ double d0 = entity.locX;
++ double d1 = entity.locZ;
++ double d2 = 8.0D;
++ float f = entity.yaw;
++
++ worldserver.methodProfiler.a("moving");
+ */
+ entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch());
+ if (entity.isAlive()) {
@@ -715,11 +715,21 @@
}
public void tick() {
-@@ -494,6 +858,15 @@
+@@ -494,6 +858,25 @@
}
-+ // CraftBukkit start - add a world limited version
++ // CraftBukkit start - add a world/entity limited version
++ public void sendAll(Packet packet, EntityHuman entityhuman) {
++ for (int i = 0; i < this.players.size(); ++i) {
++ EntityPlayer entityplayer = this.players.get(i);
++ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
++ continue;
++ }
++ ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet);
++ }
++ }
++
+ public void sendAll(Packet packet, World world) {
+ for (int i = 0; i < world.players.size(); ++i) {
+ ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet);
@@ -731,7 +741,7 @@
public void a(Packet packet, int i) {
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
-@@ -589,10 +962,24 @@
+@@ -589,10 +972,24 @@
public void addOp(GameProfile gameprofile) {
this.operators.add(new OpListEntry(gameprofile, this.server.p(), this.operators.b(gameprofile)));
@@ -756,7 +766,7 @@
}
public boolean isWhitelisted(GameProfile gameprofile) {
-@@ -600,7 +987,7 @@
+@@ -600,7 +997,7 @@
}
public boolean isOp(GameProfile gameprofile) {
@@ -765,7 +775,7 @@
}
public EntityPlayer getPlayer(String s) {
-@@ -627,6 +1014,12 @@
+@@ -627,6 +1024,12 @@
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
@@ -778,7 +788,7 @@
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
-@@ -674,21 +1067,26 @@
+@@ -674,21 +1077,26 @@
public void reloadWhitelist() {}
public void b(EntityPlayer entityplayer, WorldServer worldserver) {
@@ -810,7 +820,7 @@
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
}
-@@ -701,7 +1099,7 @@
+@@ -701,7 +1109,7 @@
}
public String[] getSeenPlayers() {
@@ -819,7 +829,7 @@
}
public boolean getHasWhitelist() {
-@@ -751,16 +1149,26 @@
+@@ -751,16 +1159,26 @@
public void u() {
for (int i = 0; i < this.players.size(); ++i) {
@@ -848,7 +858,7 @@
}
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
-@@ -797,8 +1205,10 @@
+@@ -797,8 +1215,10 @@
WorldServer[] aworldserver = this.server.worldServer;
int j = aworldserver.length;
diff --git a/nms-patches/WorldManager.patch b/nms-patches/WorldManager.patch
index cbf37c13..4a9fa5b4 100644
--- a/nms-patches/WorldManager.patch
+++ b/nms-patches/WorldManager.patch
@@ -26,3 +26,29 @@
}
public void a(int i, BlockPosition blockposition, int j) {
+@@ -52,6 +55,12 @@
+ public void b(int i, BlockPosition blockposition, int j) {
+ Iterator iterator = this.a.getPlayerList().v().iterator();
+
++ // CraftBukkit start
++ EntityHuman entityhuman = null;
++ Entity entity = world.a(i); // PAIL Rename getEntity
++ if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
++ // CraftBukkit end
++
+ while (iterator.hasNext()) {
+ EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+
+@@ -60,6 +69,12 @@
+ double d1 = (double) blockposition.getY() - entityplayer.locY;
+ double d2 = (double) blockposition.getZ() - entityplayer.locZ;
+
++ // CraftBukkit start
++ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
++ continue;
++ }
++ // CraftBukkit end
++
+ if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
+ }