Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
Send nearby packets from world list instead of server list (#1196)
Dieser Commit ist enthalten in:
Ursprung
af57a5fed5
Commit
51e29fb2a1
@ -0,0 +1,134 @@
|
||||
From aee707c111aa24b4a9036acb37b6e226efc81a44 Mon Sep 17 00:00:00 2001
|
||||
From: Mystiflow <mystiflow@gmail.com>
|
||||
Date: Fri, 6 Jul 2018 13:21:30 +0100
|
||||
Subject: [PATCH] Send nearby packets from world player list not server list
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index eaaa54ac..44ced604 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -1239,8 +1239,25 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, Packet<?> packet) {
|
||||
- for (int j = 0; j < this.players.size(); ++j) {
|
||||
- EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
|
||||
+ // Paper start - Use world list instead of server list where preferable
|
||||
+ sendPacketNearby(entityhuman, d0, d1, d2, d3, i, null, packet); // Retained for compatibility
|
||||
+ }
|
||||
+
|
||||
+ public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, WorldServer world, Packet<?> packet) {
|
||||
+ sendPacketNearby(entityhuman, d0, d1, d2, d3, world.dimension, world, packet);
|
||||
+ }
|
||||
+
|
||||
+ public void sendPacketNearby(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, @Nullable WorldServer world, Packet<?> packet) {
|
||||
+ if (world == null && entityhuman != null && entityhuman.world instanceof WorldServer) {
|
||||
+ world = (WorldServer) entityhuman.world;
|
||||
+ }
|
||||
+
|
||||
+ List<? extends EntityHuman> players1 = world == null ? players : world.players;
|
||||
+ for (int j = 0; j < players1.size(); ++j) {
|
||||
+ EntityHuman entity = players1.get(j);
|
||||
+ if (!(entity instanceof EntityPlayer)) continue;
|
||||
+ EntityPlayer entityplayer = (EntityPlayer) players1.get(j);
|
||||
+ // Paper end
|
||||
|
||||
// CraftBukkit start - Test if player receiving packet can see the source of the packet
|
||||
if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
|
||||
@@ -1248,7 +1265,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
- if (entityplayer != entityhuman && entityplayer.dimension == i) {
|
||||
+ if (entityplayer != entityhuman && (world != null || entityplayer.dimension == i)) { // Paper
|
||||
double d4 = d0 - entityplayer.locX;
|
||||
double d5 = d1 - entityplayer.locY;
|
||||
double d6 = d2 - entityplayer.locZ;
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldManager.java b/src/main/java/net/minecraft/server/WorldManager.java
|
||||
index 2c8fb705..a986e947 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldManager.java
|
||||
@@ -35,8 +35,8 @@ public class WorldManager implements IWorldAccess {
|
||||
}
|
||||
|
||||
public void a(@Nullable EntityHuman entityhuman, SoundEffect soundeffect, SoundCategory soundcategory, double d0, double d1, double d2, float f, float f1) {
|
||||
- // CraftBukkit - this.world.dimension
|
||||
- this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world.dimension, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
|
||||
+ // CraftBukkit - this.world.dimension, // Paper - this.world.dimension -> this.world
|
||||
+ this.a.getPlayerList().sendPacketNearby(entityhuman, d0, d1, d2, f > 1.0F ? (double) (16.0F * f) : 16.0D, this.world, new PacketPlayOutNamedSoundEffect(soundeffect, soundcategory, d0, d1, d2, f, f1));
|
||||
}
|
||||
|
||||
public void a(int i, int j, int k, int l, int i1, int j1) {}
|
||||
@@ -51,7 +51,7 @@ public class WorldManager implements IWorldAccess {
|
||||
|
||||
public void a(EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
|
||||
// CraftBukkit - this.world.dimension
|
||||
- this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world.dimension, new PacketPlayOutWorldEvent(i, blockposition, j, false));
|
||||
+ this.a.getPlayerList().sendPacketNearby(entityhuman, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 64.0D, this.world, new PacketPlayOutWorldEvent(i, blockposition, j, false));
|
||||
}
|
||||
|
||||
public void a(int i, BlockPosition blockposition, int j) {
|
||||
@@ -59,7 +59,7 @@ public class WorldManager implements IWorldAccess {
|
||||
}
|
||||
|
||||
public void b(int i, BlockPosition blockposition, int j) {
|
||||
- Iterator iterator = this.a.getPlayerList().v().iterator();
|
||||
+ // Iterator iterator = this.a.getPlayerList().v().iterator(); // Paper
|
||||
|
||||
// CraftBukkit start
|
||||
EntityHuman entityhuman = null;
|
||||
@@ -67,7 +67,13 @@ public class WorldManager implements IWorldAccess {
|
||||
if (entity instanceof EntityHuman) entityhuman = (EntityHuman) entity;
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start
|
||||
+ java.util.List<? extends EntityHuman> list = entity != null ? entity.world.players : this.a.getPlayerList().v();
|
||||
+ Iterator<? extends EntityHuman> iterator = list.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
+ EntityHuman human = iterator.next();
|
||||
+ if (!(human instanceof EntityPlayer)) continue;
|
||||
+ // Paper end
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
if (entityplayer != null && entityplayer.world == this.world && entityplayer.getId() != i) {
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 9fe5c440..8768b0b8 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -1234,7 +1234,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (super.strikeLightning(entity)) {
|
||||
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension
|
||||
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, this, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension, // Paper - use world instead of dimension
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -1309,8 +1309,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
BlockActionData blockactiondata = (BlockActionData) iterator.next();
|
||||
|
||||
if (this.a(blockactiondata)) {
|
||||
- // CraftBukkit - this.worldProvider.dimension -> this.dimension
|
||||
- this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, dimension, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c()));
|
||||
+ // CraftBukkit - this.worldProvider.dimension -> this.dimension, // Paper - dimension -> world
|
||||
+ this.server.getPlayerList().sendPacketNearby((EntityHuman) null, (double) blockactiondata.a().getX(), (double) blockactiondata.a().getY(), (double) blockactiondata.a().getZ(), 64.0D, this, new PacketPlayOutBlockAction(blockactiondata.a(), blockactiondata.d(), blockactiondata.b(), blockactiondata.c()));
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 210e3bc4..170c937a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -1496,7 +1496,7 @@ public class CraftWorld implements World {
|
||||
double z = loc.getZ();
|
||||
|
||||
PacketPlayOutCustomSoundEffect packet = new PacketPlayOutCustomSoundEffect(sound, SoundCategory.valueOf(category.name()), x, y, z, volume, pitch);
|
||||
- world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world.dimension, packet);
|
||||
+ world.getMinecraftServer().getPlayerList().sendPacketNearby(null, x, y, z, volume > 1.0F ? 16.0F * volume : 16.0D, this.world, packet); // Paper - this.world.dimension -> this.world
|
||||
}
|
||||
|
||||
public String getGameRuleValue(String rule) {
|
||||
--
|
||||
2.18.0.rc2.windows.1
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren