Expand API (#80)

* PLAYER particles

When creating a custom particle effect its very limiting not having access to the player object, this PR adds a method that calls with the player object, allowing you to get player UUID for hash-map or checking nearby blocks etc.

* Remove metadata check

Bad for performance and not necessary (If a target is vanished player.canSee(target) will return false)

ParticleSpawner.canSee() 11.29% 577.34ms
CraftPlayer.getMetadata() 7.71% 394.13ms

* Add size param to PParticle

More customization

* Let actual vibration be used

Lets custom effects make cool skulk animations.

* Use eye location for spawning

Particles adjust when you sneak/crawl (player.getEyeLocation() exists in 1.8 also iirc)

* Remove unnecessary .clone

entity.getLocation returns a clone of their location.

* The changes esophose requested

* Changes

* Remove player from imports

* Where did this even come from

* and this
This commit is contained in:
basedAF 2021-07-14 20:16:51 +01:00 committed by GitHub
parent 45152fcfcb
commit 97cf24053c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 93 additions and 28 deletions

View file

@ -41,9 +41,10 @@ public abstract class ParticleSpawner {
* @param center Center location of the effect
* @param isLongRange If the particle can be viewed from long range
* @param owner The player that owns the particles
* @param size The size of the particle
* @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect
*/
public abstract void display(ParticleEffect particleEffect, ParticleColor color, Location center, boolean isLongRange, Player owner);
public abstract void display(ParticleEffect particleEffect, ParticleColor color, Location center, boolean isLongRange, Player owner, float size);
/**
* Displays a particle effect which requires additional data and is only
@ -80,7 +81,7 @@ public abstract class ParticleSpawner {
* @param owner The player that owns the particles
* @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect
*/
public abstract void display(ParticleEffect particleEffect, ColorTransition colorTransition, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner);
public abstract void display(ParticleEffect particleEffect, ColorTransition colorTransition, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner, float size);
/**
* Displays a particle effect which requires additional data and is only
@ -136,9 +137,9 @@ public abstract class ParticleSpawner {
if (player == null || target == null)
return true;
for (MetadataValue meta : target.getMetadata("vanished"))
/*for (MetadataValue meta : target.getMetadata("vanished"))
if (meta.asBoolean())
return false;
return false;*/
return player.canSee(target);
}