Skip to content

Instantly share code, notes, and snippets.

@Minikloon
Created March 10, 2022 06:02
Show Gist options
  • Save Minikloon/38d6c6fd875a7556516e2a8e6cbe82c0 to your computer and use it in GitHub Desktop.
Save Minikloon/38d6c6fd875a7556516e2a8e6cbe82c0 to your computer and use it in GitHub Desktop.
For NoOneBoss
package com.minikloon.particlestest;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import java.awt.Color;
import java.util.concurrent.ThreadLocalRandom;
import java.util.logging.Level;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
getLogger().log(Level.INFO, "Registered this gabagool");
Bukkit.getPluginManager().registerEvents(new Listener() {
@EventHandler
public void onSlash(PlayerInteractEvent e) {
ItemStack inHand = e.getItem();
if (inHand == null || inHand.getType() != Material.STICK) {
return;
}
if (e.getAction() == Action.PHYSICAL) {
return;
}
Player player = e.getPlayer();
player.sendMessage(ChatColor.of(new Color(237, 81, 255)) + "Slash!");
World world = player.getWorld();
Location playerLoc = player.getLocation();
double lookRad = Math.toRadians(playerLoc.getYaw());
double lookPitch = Math.toRadians(playerLoc.getPitch());
Matrix4f mat = new Matrix4f()
.translate(0, 1.6f, 0)
.rotate((float) lookRad, 0, -1, 0)
.rotate((float) lookPitch, 1, 0, 0)
.rotate((float) Math.PI * 0.25f, 0, 0, 1);
Particle.DustOptions dustOptions = new Particle.DustOptions(org.bukkit.Color.fromRGB(181, 0, 9), 1f);
for (double t = 0; t < 210; t++) {
double tRad = Math.toRadians(t);
double length = 1.25;
double dx = Math.cos(tRad) * length;
double dz = Math.sin(tRad) * length;
Vector3f p = mat.transformPosition(new Vector3f((float) dx, 0, (float) dz));
Location particleLoc = playerLoc.clone().add(p.x, p.y, p.z);
if (ThreadLocalRandom.current().nextInt(2) == 0) {
if (t % 2 == 0) {
world.spawnParticle(Particle.FLAME, particleLoc, 1, 0f, 0f, 0f, 0f);
world.spawnParticle(Particle.REDSTONE, particleLoc, 1, dustOptions);
}
}
}
}
}, this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment