mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-31 03:50:36 +01:00
Merge branch 'master' into pre/1.13
This commit is contained in:
commit
b1f15b91ad
2 changed files with 56 additions and 14 deletions
Spigot-API-Patches
Spigot-Server-Patches
|
@ -5,12 +5,13 @@ 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/com/destroystokyo/paper/ParticleBuilder.java b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
|
||||
new file mode 100644
|
||||
index 000000000..2bccc4098
|
||||
index 000000000..f7aa162fb
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/ParticleBuilder.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
@ -42,6 +43,7 @@ index 000000000..2bccc4098
|
|||
+ private double offsetX = 0, offsetY = 0, offsetZ = 0;
|
||||
+ private double extra = 1;
|
||||
+ private Object data;
|
||||
+ private boolean force = true;
|
||||
+
|
||||
+ public ParticleBuilder(Particle particle) {
|
||||
+ this.particle = particle;
|
||||
|
@ -57,7 +59,7 @@ index 000000000..2bccc4098
|
|||
+ }
|
||||
+ location.getWorld().spawnParticle(particle, receivers, source,
|
||||
+ location.getX(), location.getY(), location.getZ(),
|
||||
+ count, offsetX, offsetY, offsetZ, extra, data
|
||||
+ count, offsetX, offsetY, offsetZ, extra, data, force
|
||||
+ );
|
||||
+ 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.
|
||||
+ * Only valid for REDSTONE, SPELL_MOB and SPELL_MOB_AMBIENT.
|
||||
+ */
|
||||
|
@ -410,7 +424,7 @@ index 4d0acaf5b..0ae85d855 100644
|
|||
* Options which can be applied to redstone dust particles - a particle
|
||||
* color and size.
|
||||
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
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -0,0 +0,0 @@ public interface World extends PluginMessageRecipient, Metadatable {
|
||||
|
@ -418,7 +432,7 @@ index cf5bd1540..a7964fb1e 100644
|
|||
* @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 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)
|
||||
+ * 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()}
|
||||
+ * @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
|
||||
+
|
||||
|
||||
// Spigot start
|
||||
public class Spigot
|
||||
|
|
|
@ -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
|
||||
--
|
Loading…
Add table
Reference in a new issue