Add rainbow halo by NotAlexNoyle
This commit is contained in:
1 parent
ba438fe96d
commit
c9ffe75123
4 files changed
+185
-4
No files matched your search
@@ -348,9 +348,10 @@ public enum Message {
|
||||
* Types
|
||||
*/
|
||||
TYPE_NONE_NAME("&cNone"), TYPE_NONE_DESCRIPTION("&8Does absolutely nothing"), TYPE_HALO_NAME("&bHalo"),
|
||||
TYPE_HALO_DESCRIPTION("&8A ring of particles for the/n&8players head"), TYPE_TRAIL_NAME("&bTrail"),
|
||||
TYPE_TRAIL_DESCRIPTION("&8Displays a small cloud of particles/n&8with random offsets"), TYPE_CAPE_NAME("&bCape"),
|
||||
TYPE_CAPE_DESCRIPTION("&8A Cape worn on the players back"), TYPE_WINGS_NAME("&bWings"),
|
||||
TYPE_HALO_DESCRIPTION("&8A ring of particles for the/n&8players head"), TYPE_RAINBOW_HALO_NAME("&dRainbow Halo"),
|
||||
TYPE_RAINBOW_HALO_DESCRIPTION("&8A spinning rainbow ring of/n&8particles above the players head"),
|
||||
TYPE_TRAIL_NAME("&bTrail"), TYPE_TRAIL_DESCRIPTION("&8Displays a small cloud of particles/n&8with random offsets"),
|
||||
TYPE_CAPE_NAME("&bCape"), TYPE_CAPE_DESCRIPTION("&8A Cape worn on the players back"), TYPE_WINGS_NAME("&bWings"),
|
||||
TYPE_WINGS_DESCRIPTION("&8Default Wings"), TYPE_VORTEX_NAME("&bVortex"),
|
||||
TYPE_VORTEX_DESCRIPTION("&8A Swirling cone that gets/n&8larger at the bottom"), TYPE_ARCH_NAME("&bArch"),
|
||||
TYPE_ARCH_DESCRIPTION("&8A half circle that sits/n&8above the players head"), TYPE_ATOM_NAME("&bAtom"),
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
package cosmeticsOG.particles.effects;
|
||||
|
||||
import cosmeticsOG.locale.Message;
|
||||
import cosmeticsOG.particles.Effect;
|
||||
import cosmeticsOG.particles.Hat;
|
||||
import cosmeticsOG.particles.ParticleEffect;
|
||||
import cosmeticsOG.particles.properties.ParticleLocation;
|
||||
import cosmeticsOG.particles.properties.ParticleTracking;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RainbowHaloEffect extends Effect {
|
||||
|
||||
private static final Color[] RAINBOW_COLORS = { Color.fromRGB(255, 82, 82), Color.fromRGB(255, 171, 64),
|
||||
Color.fromRGB(255, 238, 88), Color.fromRGB(105, 240, 174), Color.fromRGB(64, 196, 255),
|
||||
Color.fromRGB(124, 77, 255), Color.fromRGB(255, 64, 129) };
|
||||
private static final int POINT_COUNT = 18;
|
||||
private static final double RADIUS = 0.8D;
|
||||
private static final float DUST_SCALE = 0.7F;
|
||||
|
||||
private final List<Vector> ringPoints = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return "rainbow_halo";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
|
||||
return Message.TYPE_RAINBOW_HALO_NAME.getValue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
return Message.TYPE_RAINBOW_HALO_DESCRIPTION.getValue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getParticlesSupported() {
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleLocation getDefaultLocation() {
|
||||
|
||||
return ParticleLocation.HEAD;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ParticleTracking> getSupportedTrackingMethods() {
|
||||
|
||||
return Arrays.asList(ParticleTracking.values());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleTracking getDefaultTrackingMethod() {
|
||||
|
||||
return ParticleTracking.TRACK_NOTHING;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAnimation() {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCustom() {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
|
||||
ringPoints.clear();
|
||||
for (int i = 0; i < POINT_COUNT; i++) {
|
||||
|
||||
final double angle = i * Math.PI * 2.0D / POINT_COUNT;
|
||||
ringPoints.add(new Vector(Math.cos(angle) * RADIUS, 0.0D, Math.sin(angle) * RADIUS));
|
||||
|
||||
}
|
||||
|
||||
final List<List<Vector>> frames = createEmptyFrames();
|
||||
frames.add(new ArrayList<>(ringPoints));
|
||||
setFrames(frames);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(int ticks, Entity entity, Hat hat) {
|
||||
|
||||
if (ticks % hat.getUpdateFrequency() != 0) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Location location = entity.getLocation();
|
||||
if (hat.getTrackingMethod() == ParticleTracking.TRACK_HEAD_MOVEMENT && entity instanceof Player) {
|
||||
|
||||
location = ((Player) entity).getEyeLocation();
|
||||
|
||||
}
|
||||
|
||||
final double yaw = Math.toRadians(location.getYaw());
|
||||
final double cos = Math.cos(yaw);
|
||||
final double sin = Math.sin(yaw);
|
||||
|
||||
final Vector offset = hat.getOffset();
|
||||
final double offsetX = ((offset.getX() * cos) - (offset.getZ() * sin));
|
||||
final double offsetZ = ((offset.getX() * sin) + (offset.getZ() * cos));
|
||||
|
||||
final Vector angle = hat.getAngle();
|
||||
final double angleX = Math.toRadians(angle.getX());
|
||||
final double angleY = Math.toRadians(angle.getY());
|
||||
final double angleZ = Math.toRadians(angle.getZ());
|
||||
|
||||
final World world = location.getWorld();
|
||||
final int colorStep = ticks / 4;
|
||||
final double spin = ticks * 0.05D;
|
||||
final double spinCos = Math.cos(spin);
|
||||
final double spinSin = Math.sin(spin);
|
||||
|
||||
for (int i = 0; i < ringPoints.size(); i++) {
|
||||
|
||||
final Vector base = ringPoints.get(i).clone();
|
||||
final double rx = (base.getX() * spinCos) - (base.getZ() * spinSin);
|
||||
final double rz = (base.getX() * spinSin) + (base.getZ() * spinCos);
|
||||
Vector v = new Vector(rx, 0.0D, rz);
|
||||
v.multiply(hat.getScale());
|
||||
v = getAngleVector(angleX, angleY, angleZ, v);
|
||||
|
||||
final Location target = location.clone().add(offsetX, 0.0D, offsetZ);
|
||||
target.add(getTrackingPosition(hat, v, location, cos, sin));
|
||||
|
||||
final Color color = RAINBOW_COLORS[Math.floorMod(colorStep + i, RAINBOW_COLORS.length)];
|
||||
renderer.spawnParticleColor(world, ParticleEffect.REDSTONE, target, 1, 0.0D, 0.0D, 0.0D, 0.0D, color,
|
||||
DUST_SCALE, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import cosmeticsOG.particles.effects.CrystalEffect;
|
||||
import cosmeticsOG.particles.effects.Debug5x5Effect;
|
||||
import cosmeticsOG.particles.effects.Debug6x6Effect;
|
||||
import cosmeticsOG.particles.effects.HaloEffect;
|
||||
import cosmeticsOG.particles.effects.RainbowHaloEffect;
|
||||
import cosmeticsOG.particles.effects.HelixEffect;
|
||||
import cosmeticsOG.particles.effects.HoopEffect;
|
||||
import cosmeticsOG.particles.effects.InverseVortexEffect;
|
||||
@@ -40,7 +41,8 @@ public enum ParticleType {
|
||||
ANGEL_WINGS(14, new AngelWingsEffect()), CREEPER_HAT(15, new CreeperEffect()),
|
||||
CLEAN_TRAIL(16, new CleanTrailEffect()), TORNADO(17, new TornadoEffect()), CUSTOM(18, new PixelEffect()),
|
||||
PARTICLEHATS(19, new ParticleHatsEffect()), ANIMATED(20, new AnimatedEffect(), true),
|
||||
DEBUG_5X5(-1, new Debug5x5Effect(), true), DEBUG_6X6(-2, new Debug6x6Effect(), true);
|
||||
RAINBOW_HALO(21, new RainbowHaloEffect()), DEBUG_5X5(-1, new Debug5x5Effect(), true),
|
||||
DEBUG_6X6(-2, new Debug6x6Effect(), true);
|
||||
|
||||
private final int id;
|
||||
private final Effect effect;
|
||||
|
||||
@@ -198,3 +198,16 @@ items:
|
||||
particles:
|
||||
'1':
|
||||
particle: NOTE
|
||||
'34':
|
||||
name: '&dRainbow Halo'
|
||||
id: NETHER_STAR
|
||||
action:
|
||||
left-click:
|
||||
id: override
|
||||
type: rainbow_halo
|
||||
location: head
|
||||
update-frequency: 1
|
||||
particles:
|
||||
'1':
|
||||
particle: REDSTONE
|
||||
color: random
|
||||
Reference in new issue
Block a user