Add whirl/whirlwind styles

This commit is contained in:
Esophose 2019-01-27 00:45:24 -07:00
parent 429bee472a
commit a0826ae06c
5 changed files with 182 additions and 2 deletions

View file

@ -1,7 +1,8 @@
== UPDATING WILL DELETE YOUR CONFIG.YML ==
* Create a backup of your config.yml if you wish to import all your old settings!
=== v6.3 (Implemented so far) ===
=== v6.3 ===
+ Added the ability to remove particles by id/effect/style using '/pp remove <id>|<effect>|<style>'
+ Added new styles 'pulse', 'whirl', and 'whirlwind'
+ The "Save New Group" button in the GUI now actually saves a new group and prompts for a name in chat (15 second timeout)
+ Added a click sound to the GUI for button clicks (Can be disabled in the config.yml)
* Reduced the number of particles that spawn for the styles 'blockbreak', 'blockplace', and 'swords'

View file

@ -41,6 +41,8 @@ public class DefaultStyles {
public static final ParticleStyle SWORDS = new ParticleStyleSwords();
public static final ParticleStyle THICK = new ParticleStyleThick();
public static final ParticleStyle VORTEX = new ParticleStyleVortex();
public static final ParticleStyle WHIRL = new ParticleStyleWhirl();
public static final ParticleStyle WHIRLWIND = new ParticleStyleWhirlwind();
public static final ParticleStyle WINGS = new ParticleStyleWings();
/**
@ -75,6 +77,8 @@ public class DefaultStyles {
ParticleStyleManager.registerCustomHandledStyle(SWORDS);
ParticleStyleManager.registerStyle(THICK);
ParticleStyleManager.registerStyle(VORTEX);
ParticleStyleManager.registerStyle(WHIRL);
ParticleStyleManager.registerStyle(WHIRLWIND);
ParticleStyleManager.registerStyle(WINGS);
// Register their events

View file

@ -0,0 +1,85 @@
package com.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.styles.api.PParticle;
import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleWhirl implements ParticleStyle {
private int points = 2;
private double step = 0;
private int numSteps = 40;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
double speed = getSpeedByEffect(particle.getEffect());
for (int i = 0; i < points; i++) {
double dx = Math.cos(step + (Math.PI * 2 * ((double)i / points)));
double dy = -0.9;
double dz = Math.sin(step + (Math.PI * 2 * ((double)i / points)));
double angle = Math.atan2(dz, dx);
double xAng = Math.cos(angle);
double zAng = Math.sin(angle);
particles.add(new PParticle(location.clone().add(0, dy, 0), xAng, 0, zAng, speed, true));
}
return particles;
}
private double getSpeedByEffect(ParticleEffect effect) {
switch (effect) {
case CRIT:
case DAMAGE_INDICATOR:
case ENCHANTED_HIT:
return 1;
case DRAGON_BREATH:
return 0.01;
case ENCHANT:
case NAUTILUS:
case PORTAL:
return 1;
case END_ROD:
case SMOKE:
case SQUID_INK:
return 0.15;
case FIREWORK:
case SPIT:
case SPLASH:
return 0.25;
case POOF:
return 0.2;
case TOTEM_OF_UNDYING:
return 0.75;
default:
return 0.1; // Flame
}
}
public void updateTimers() {
step = (step + Math.PI * 2 / numSteps) % numSteps;
}
public String getName() {
return "whirl";
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
}
}

View file

@ -0,0 +1,86 @@
package com.esophose.playerparticles.styles;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticlePair;
import com.esophose.playerparticles.styles.api.PParticle;
import com.esophose.playerparticles.styles.api.ParticleStyle;
public class ParticleStyleWhirlwind implements ParticleStyle {
private int points = 3;
private double step = 0;
private int numSteps = 40;
public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>();
double speed = getSpeedByEffect(particle.getEffect()) * 2.5;
// Orbit going clockwise
for (int i = 0; i < points; i++) {
double dx = Math.cos(step + (Math.PI * 2 * ((double)i / points)));
double dy = -0.9;
double dz = Math.sin(step + (Math.PI * 2 * ((double)i / points)));
double angle = Math.atan2(dz, dx);
double xAng = Math.cos(angle);
double zAng = Math.sin(angle);
particles.add(new PParticle(location.clone().add(0, dy, 0), xAng, 0, zAng, speed, true));
}
return particles;
}
private double getSpeedByEffect(ParticleEffect effect) {
switch (effect) {
case CRIT:
case DAMAGE_INDICATOR:
case ENCHANTED_HIT:
return 1;
case DRAGON_BREATH:
return 0.01;
case ENCHANT:
case NAUTILUS:
case PORTAL:
return 1;
case END_ROD:
case SMOKE:
case SQUID_INK:
return 0.15;
case FIREWORK:
case SPIT:
case SPLASH:
return 0.25;
case POOF:
return 0.2;
case TOTEM_OF_UNDYING:
return 0.75;
default:
return 0.1; // Flame
}
}
public void updateTimers() {
step = (step + Math.PI * 2 / numSteps) % numSteps;
}
public String getName() {
return "whirlwind";
}
public boolean canBeFixed() {
return true;
}
public boolean canToggleWithMovement() {
return true;
}
public double getFixedEffectOffset() {
return 0.5;
}
}

View file

@ -345,7 +345,7 @@ gui-icon:
- NAUTILUS_SHELL
- ACTIVATOR_RAIL
rings:
- STRING
- LEAD
sphere:
- HEART_OF_THE_SEA
- SNOWBALL
@ -360,6 +360,10 @@ gui-icon:
- WEB
vortex:
- GLOWSTONE_DUST
whirl:
- FEATHER
whirlwind:
- STRING
wings:
- ELYTRA