Merge branch 'master' into pre/1.13

This commit is contained in:
Shane Freeder 2018-08-14 16:26:01 +01:00
commit 466e43b16d
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
2 changed files with 62 additions and 20 deletions

View File

@ -1,19 +1,20 @@
From 883ac3334bba303050fbf07799feee0d56cea5c7 Mon Sep 17 00:00:00 2001 From f07a9db92dd5b0017c2cbd316a15fe3ee338057b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Tue, 29 Aug 2017 23:58:48 -0400 Date: Tue, 29 Aug 2017 23:58:48 -0400
Subject: [PATCH] Expand World.spawnParticle API and add Builder Subject: [PATCH] Expand World.spawnParticle API and add Builder
Adds ability to control who receives it and who is the source/sender (vanish API) 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. 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. This adds a new Builder API which is much friendlier to use.
diff --git a/src/main/java/com/destroystokyo/paper/ParticleBuilder.java b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java diff --git a/src/main/java/com/destroystokyo/paper/ParticleBuilder.java b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
new file mode 100644 new file mode 100644
index 000000000..2bccc4098 index 000000000..f7aa162fb
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java +++ b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
@@ -0,0 +1,365 @@ @@ -0,0 +1,378 @@
+package com.destroystokyo.paper; +package com.destroystokyo.paper;
+ +
+import com.google.common.collect.Lists; +import com.google.common.collect.Lists;
@ -42,6 +43,7 @@ index 000000000..2bccc4098
+ private double offsetX = 0, offsetY = 0, offsetZ = 0; + private double offsetX = 0, offsetY = 0, offsetZ = 0;
+ private double extra = 1; + private double extra = 1;
+ private Object data; + private Object data;
+ private boolean force = true;
+ +
+ public ParticleBuilder(Particle particle) { + public ParticleBuilder(Particle particle) {
+ this.particle = particle; + this.particle = particle;
@ -57,7 +59,7 @@ index 000000000..2bccc4098
+ } + }
+ location.getWorld().spawnParticle(particle, receivers, source, + location.getWorld().spawnParticle(particle, receivers, source,
+ location.getX(), location.getY(), location.getZ(), + location.getX(), location.getY(), location.getZ(),
+ count, offsetX, offsetY, offsetZ, extra, data + count, offsetX, offsetY, offsetZ, extra, data, force
+ ); + );
+ return this; + return this;
+ } + }
@ -350,6 +352,18 @@ index 000000000..2bccc4098
+ } + }
+ +
+ /** + /**
+ * Sets whether the particle is forcefully shown to the player.
+ * If forced, the particle will show faraway, as far as the player's view distance allows.
+ * If false, the particle will show according to the client's particle settings.
+ *
+ * @param force true to force, false for normal
+ */
+ public ParticleBuilder force(boolean force) {
+ this.force = force;
+ return this;
+ }
+
+ /**
+ * Sets the particle Color. + * Sets the particle Color.
+ * Only valid for REDSTONE, SPELL_MOB and SPELL_MOB_AMBIENT. + * Only valid for REDSTONE, SPELL_MOB and SPELL_MOB_AMBIENT.
+ */ + */
@ -410,15 +424,15 @@ index 4d0acaf5b..0ae85d855 100644
* Options which can be applied to redstone dust particles - a particle * Options which can be applied to redstone dust particles - a particle
* color and size. * color and size.
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index cf5bd1540..a7964fb1e 100644 index cf5bd1540..ef1494dee 100644
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -1709,7 +1709,31 @@ public interface World extends PluginMessageRecipient, Metadatable { @@ -1709,7 +1709,57 @@ public interface World extends PluginMessageRecipient, Metadatable {
* the type of this depends on {@link Particle#getDataType()} * the type of this depends on {@link Particle#getDataType()}
* @param <T> Type * @param <T> Type
*/ */
- 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, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data);
+ public default <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { spawnParticle(particle, null, null, x, y, z, count, offsetX, offsetY, offsetZ, extra, data); }// Paper start - Expand Particle API + public default <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { spawnParticle(particle, null, null, x, y, z, count, offsetX, offsetY, offsetZ, extra, data, true); }// Paper start - Expand Particle API
+ /** + /**
+ * Spawns the particle (the number of times specified by count) + * Spawns the particle (the number of times specified by count)
+ * at the target location. The position of each particle will be + * at the target location. The position of each particle will be
@ -441,8 +455,34 @@ index cf5bd1540..a7964fb1e 100644
+ * the type of this depends on {@link Particle#getDataType()} + * the type of this depends on {@link Particle#getDataType()}
+ * @param <T> Type + * @param <T> Type
+ */ + */
+ public <T> void spawnParticle(Particle particle, List<Player> receivers, Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data); + public default <T> void spawnParticle(Particle particle, List<Player> receivers, Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { spawnParticle(particle, receivers, source, x, y, z, count, offsetX, offsetY, offsetZ, extra, data, true); }
+ /**
+ * Spawns the particle (the number of times specified by count)
+ * at the target location. The position of each particle will be
+ * randomized positively and negatively by the offset parameters
+ * on each axis.
+ *
+ * @param particle the particle to spawn
+ * @param receivers List of players to receive the particles, or null for all in world
+ * @param source Source of the particles to be used in visibility checks, or null if no player source
+ * @param x the position on the x axis to spawn at
+ * @param y the position on the y axis to spawn at
+ * @param z the position on the z axis to spawn at
+ * @param count the number of particles
+ * @param offsetX the maximum random offset on the X axis
+ * @param offsetY the maximum random offset on the Y axis
+ * @param offsetZ the maximum random offset on the Z axis
+ * @param extra the extra data for this particle, depends on the
+ * particle used (normally speed)
+ * @param data the data to use for the particle or null,
+ * the type of this depends on {@link Particle#getDataType()}
+ * @param <T> Type
+ * @param force allows the particle to be seen further away from the player
+ * and shows to players using any vanilla client particle settings
+ */
+ public <T> void spawnParticle(Particle particle, List<Player> receivers, Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force);
+ // Paper end + // Paper end
+
// Spigot start // Spigot start
public class Spigot public class Spigot

View File

@ -1,32 +1,33 @@
From f40dfd47e9dbb7f53a4f297fb8aa39e285a17d71 Mon Sep 17 00:00:00 2001 From 4efa9bc44f6b6249bea85669ddc94d746343ef1e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Tue, 15 Aug 2017 22:29:12 -0400 Date: Tue, 15 Aug 2017 22:29:12 -0400
Subject: [PATCH] Expand World.spawnParticle API and add Builder Subject: [PATCH] Expand World.spawnParticle API and add Builder
Adds ability to control who receives it and who is the source/sender (vanish API) 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. 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. 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 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 --- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1205,14 +1205,20 @@ public class WorldServer extends World implements IAsyncTaskHandler { @@ -1205,14 +1205,19 @@ public class WorldServer extends World implements IAsyncTaskHandler {
// CraftBukkit - visibility api support // CraftBukkit - visibility api support
return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6); return sendParticles(null, t0, d0, d1, d2, i, d3, d4, d5, d6);
} }
- -
+ // Paper start - Particle API Expansion + // 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) { 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) { + 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) {
+ // Paper end
// CraftBukkit end // 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; int j = 0;
- for (int k = 0; k < this.players.size(); ++k) { - for (int k = 0; k < this.players.size(); ++k) {
@ -37,18 +38,17 @@ index 5d5f6f6328..d506503e93 100644
if (this.a(entityplayer, false, d0, d1, d2, packetplayoutworldparticles)) { 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 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 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1611,13 +1611,17 @@ public class CraftWorld implements World { @@ -1611,14 +1611,18 @@ public class CraftWorld implements World {
spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra, data); spawnParticle(particle, location.getX(), location.getY(), location.getZ(), count, offsetX, offsetY, offsetZ, extra, data);
} }
+ // Paper start - Particle API Expansion + // Paper start - Particle API Expansion
+ // TODO: Add back extended?
@Override @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, 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 + // Paper end
if (data != null && !particle.getDataType().isInstance(data)) { if (data != null && !particle.getDataType().isInstance(data)) {
throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass()); throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
@ -58,8 +58,10 @@ 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 + 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 + sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API Expansion
CraftParticle.toNMS(particle, data), // Particle CraftParticle.toNMS(particle, data), // Particle
+ force , // Extended range // Paper - Particle API Expansion
x, y, z, // Position x, y, z, // Position
count, // Count count, // Count
offsetX, offsetY, offsetZ, // Random offset
-- --
2.18.0 2.18.0