Merge branch 'master' into pre/1.13

This commit is contained in:
Shane Freeder
2018-08-14 16:26:01 +01:00
2 changed files with 56 additions and 14 deletions

View File

@@ -5,11 +5,12 @@ Subject: [PATCH] Expand World.spawnParticle API and add Builder
Adds ability to control who receives it and who is the source/sender (vanish API)
the standard API is to send the packet to everyone in the world, which is ineffecient.
Adds an option to control the force mode of the particle.
This adds a new Builder API which is much friendlier to use.
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 5d5f6f6328..d506503e93 100644
index 5d5f6f6328..544f789bda 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler {
@@ -18,15 +19,15 @@ index 5d5f6f6328..d506503e93 100644
}
-
+ // Paper start - Particle API Expansion
+ // TODO: rework this, "flag" should probably be exposed as it was before
public <T extends ParticleParam> int sendParticles(EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
+ return sendParticles(this.players, sender, t0, d0, d1, d2, i, d3, d5, d5, d6);
+ return sendParticles(this.players, sender, t0, false, d0, d1, d2, i, d3, d5, d5, d6);
+ }
+
+ public <T extends ParticleParam> int sendParticles(List<EntityHuman> receivers, EntityPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
+ // Paper end
+ public <T extends ParticleParam> int sendParticles(List<EntityHuman> receivers, EntityPlayer sender, T t0, boolean force, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
// CraftBukkit end
PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
- PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, false, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
+ PacketPlayOutWorldParticles packetplayoutworldparticles = new PacketPlayOutWorldParticles(t0, force, (float) d0, (float) d1, (float) d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
+ // Paper end
int j = 0;
- for (int k = 0; k < this.players.size(); ++k) {
@@ -37,7 +38,7 @@ index 5d5f6f6328..d506503e93 100644
if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 5cadee4ae0..aa8b237faf 100644
index 5cadee4ae0..92fadd7f78 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
@@ -45,10 +46,9 @@ index 5cadee4ae0..aa8b237faf 100644
}
+ // Paper start - Particle API Expansion
+ // TODO: Add back extended?
@Override
- public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
+ public <T> void spawnParticle(Particle particle, List<Player> receivers, Player sender, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
+ public <T> void spawnParticle(Particle particle, List<Player> receivers, Player sender, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
+ // Paper end
if (data != null && !particle.getDataType().isInstance(data)) {
throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
@@ -58,6 +58,8 @@ index 5cadee4ae0..aa8b237faf 100644
+ receivers == null ? getHandle().players : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API Expansion
+ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API Expansion
CraftParticle.toNMS(particle, data), // Particle
+ force , // Extended range // Paper - Particle API Expansion
x, y, z, // Position
count, // Count
offsetX, offsetY, offsetZ, // Random offset
--