From 4641a0936fa785c7898f04ca46f70aabaf835c18 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 8 Apr 2023 00:43:58 +0200 Subject: [PATCH] Add HearthBeat --- src/de/steamwar/lobby/LobbySystem.properties | 1 + .../steamwar/lobby/LobbySystem_de.properties | 2 + .../lobby/particle/elements/Wing.java | 2 +- .../particle/elements/custom/HearthBeat.java | 44 +++++++++++++++++++ .../custom/CustomEasterParticle.java | 6 +-- .../particles/custom/CustomTeamParticle.java | 3 ++ 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/elements/custom/HearthBeat.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 86ee7ef..5fdfe48 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -96,6 +96,7 @@ PARTICLE_TEAM_PULSE_AURA_1 = §fPulse Aura §cFlame PARTICLE_TEAM_PULSE_AURA_2 = §fPulse Aura §7End Rod PARTICLE_TEAM_PULSE_AURA_3 = §fPulse Aura §fEnchanted PARTICLE_TEAM_PULSE_LOGO = §fPulse Logo +PARTICLE_TEAM_PULSE_HEART_BEAT = §cHeart Beat PARTICLE_RAINCLOUD_NORMAL = §fRaincloud PARTICLE_RAINCLOUD_RED = §fLava cloud diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index b451a73..450779d 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -90,6 +90,8 @@ PARTICLE_WINGS_EVIL = §5Lila Flügel PARTICLE_PLAYER_RONGAMER99091_AURA = §7Rauchgranate +PARTICLE_TEAM_PULSE_HEART_BEAT = §cHerzschlag + PARTICLE_RAINCLOUD_NORMAL = §fRegenwolke PARTICLE_RAINCLOUD_RED = §fLavawolke PARTICLE_RAINCLOUD_YELLOW = §fNektarwolke diff --git a/src/de/steamwar/lobby/particle/elements/Wing.java b/src/de/steamwar/lobby/particle/elements/Wing.java index 6163382..bb43da5 100644 --- a/src/de/steamwar/lobby/particle/elements/Wing.java +++ b/src/de/steamwar/lobby/particle/elements/Wing.java @@ -25,7 +25,7 @@ public class Wing extends DelegatingParticleElement { @Override public void tick(ParticleTickData particleTickData) { for (Vector dVector : wingDesign.getVectors()) { - Vector vector = new Vector(dVector.getX() * size, 0.6 + dVector.getY() * size - (particleTickData.getPlayer().isSneaking() ? 0.5 : 0) , 0.5); + Vector vector = new Vector(dVector.getX() * size, 0.6 + dVector.getY() * size - (particleTickData.getPlayer().isSneaking() ? 0.5 : 0), 0.5); vector.rotateAroundY(Math.toRadians(particleTickData.getPlayer().getLocation().getYaw() * -1)); vector.setX(-vector.getX()); vector.setZ(-vector.getZ()); diff --git a/src/de/steamwar/lobby/particle/elements/custom/HearthBeat.java b/src/de/steamwar/lobby/particle/elements/custom/HearthBeat.java new file mode 100644 index 0000000..0e974e6 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/custom/HearthBeat.java @@ -0,0 +1,44 @@ +package de.steamwar.lobby.particle.elements.custom; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.elements.DelegatingParticleElement; +import org.bukkit.Location; +import org.bukkit.util.Vector; + +public class HearthBeat extends DelegatingParticleElement { + + private double speed; + + private double y(double time) { + double d1 = Math.pow(2, -Math.pow(time * 17 - 7.5, 2)); + double d2 = Math.pow(2, -Math.pow(time * 20 - 11, 2)) * 0.5; + double d3 = Math.pow(2, -Math.pow(time * 25 - 17, 2)) * 0.1; + return (d1 - d2 + d3) * 0.5; + } + + public HearthBeat(ParticleElement particleElement, double speed) { + super(particleElement); + this.speed = speed; + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + double time = ((particleTickData.getDeg() * speed) % 360) / 360.0; + double y = y(time) * 2; + double x = (time - 0.5) * 2; + + Vector vector = new Vector(x, 1.1 + y - (particleTickData.getPlayer().isSneaking() ? 0.5 : 0), 0.7); + vector.rotateAroundY(Math.toRadians(particleTickData.getPlayer().getLocation().getYaw() * -1)); + vector.setX(-vector.getX()); + vector.setZ(-vector.getZ()); + Location location = particleTickData.getPlayer().getLocation().clone().add(vector); + ParticleTickData current = particleTickData.withLocation(location); + particleElement.tick(current); + } +} diff --git a/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java index 7ba9466..eba7415 100644 --- a/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java @@ -3,8 +3,8 @@ package de.steamwar.lobby.particle.particles.custom; import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleEnum; import de.steamwar.lobby.particle.ParticleRequirement; -import de.steamwar.lobby.particle.WingDesign; import de.steamwar.lobby.particle.elements.*; +import de.steamwar.lobby.particle.elements.custom.HearthBeat; import de.steamwar.lobby.particle.elements.custom.NonMoving; import de.steamwar.lobby.particle.elements.custom.PulseShimmer; import lombok.AllArgsConstructor; @@ -33,8 +33,8 @@ public enum CustomEasterParticle implements ParticleEnum { Pulse_EASTER_1(new ParticleData(Material.RED_CANDLE, "PARTICLE_TEAM_PULSE_AURA_1", ParticleRequirement.easterEventSpecificTeam(210), new Always(new NonMoving(new PulseShimmer(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0, 1), 80, 2)))) ), - Pulse_Logo(new ParticleData(Material.ENDER_CHEST, "PARTICLE_TEAM_PULSE_LOGO", ParticleRequirement.easterEventSpecificTeam(210), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.END_ROD, 0, 0, 0, 0, 1), 0.15, WingDesign.PL)), 80))) + Pulse_EASTER_3(new ParticleData(Material.APPLE, "PARTICLE_TEAM_PULSE_HEART_BEAT", ParticleRequirement.easterEventSpecificTeam(210), + new Always(new NonFlying(new HearthBeat(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0, 1), 80)))) ), ; public static ParticleEnum[] particles = values(); diff --git a/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java index 9af8c58..35b6afa 100644 --- a/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java @@ -24,6 +24,9 @@ public enum CustomTeamParticle implements ParticleEnum { Pulse_2(new ParticleData(Material.WHITE_CANDLE, "PARTICLE_TEAM_PULSE_AURA_3", ParticleRequirement.specificTeam(210), new Always(new NonMoving(new PulseShimmer(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0, 5), 80, 2)))) ), + Pulse_Logo(new ParticleData(Material.ENDER_CHEST, "PARTICLE_TEAM_PULSE_LOGO", ParticleRequirement.easterEventSpecificTeam(210), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.END_ROD, 0, 0, 0, 0, 1), 0.15, WingDesign.PL)), 80))) + ), ; public static ParticleEnum[] particles = values();