fixed utils
This commit is contained in:
@@ -3,10 +3,7 @@ package fun.ogre.ogredupealias.events;
|
||||
import fun.ogre.ogredupealias.data.PlacedStructures;
|
||||
import fun.ogre.ogredupealias.plugin.InventoryPresets;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.Cooldown;
|
||||
import fun.ogre.ogredupealias.utils.ItemUtils;
|
||||
import fun.ogre.ogredupealias.utils.RaycastUtils;
|
||||
import fun.ogre.ogredupealias.utils.SoundPlayer;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
@@ -101,6 +98,19 @@ public class InteractionListener implements Listener {
|
||||
});
|
||||
}
|
||||
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
|
||||
if (p.isSneaking()) {
|
||||
Location center = p.getLocation();
|
||||
|
||||
DisplayUtils.ring(center, 10, circlePoint -> {
|
||||
RaycastUtils.raycast(center, circlePoint, point -> {
|
||||
point.getWorld().spawnParticle(Particle.END_ROD, point, 1, 0, 0, 0, 0);
|
||||
return false;
|
||||
});
|
||||
}, (point, angle) -> {
|
||||
return angle % 9 == 0;
|
||||
});
|
||||
}
|
||||
else {
|
||||
Location start = p.getEyeLocation();
|
||||
Vector rotation = p.getLocation().getDirection().normalize();
|
||||
|
||||
@@ -113,4 +123,5 @@ public class InteractionListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,25 +4,28 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
|
||||
|
||||
public final class DisplayUtils {
|
||||
|
||||
public static void ring(Location center, double radius, Consumer<Location> onPoint) {
|
||||
public static void ring(Location center, double radius, Consumer<Location> onPoint, BiPredicate<Location, Integer> condition) {
|
||||
for (int i = 0; i <= 360; i ++) {
|
||||
Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i));
|
||||
if (condition.test(point, i)) {
|
||||
onPoint.accept(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void wave(Location center, double radius, double frequency, long interval, Consumer<Location> onPoint) {
|
||||
AtomicReference<Double> currentRadius = new AtomicReference<>(0.0);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, () -> {
|
||||
if (currentRadius.get() <= radius) {
|
||||
ring(center, currentRadius.get(), onPoint);
|
||||
ring(center, currentRadius.get(), onPoint, (point, angle) -> true);
|
||||
currentRadius.set(currentRadius.get() + frequency);
|
||||
}
|
||||
}, 0, interval);
|
||||
|
||||
Reference in New Issue
Block a user