forked from SteamWar/SteamWar
64 lines
2.3 KiB
Java
64 lines
2.3 KiB
Java
/*
|
|
* This file is a part of the SteamWar software.
|
|
*
|
|
* Copyright (C) 2025 SteamWar.de-Serverteam
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
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);
|
|
}
|
|
}
|