fixed utils

This commit is contained in:
ImproperIssues
2023-06-03 19:09:53 -07:00
parent d1a4c9f8f0
commit 4349a5abea
2 changed files with 28 additions and 14 deletions

View File

@@ -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();
@@ -114,3 +124,4 @@ public class InteractionListener implements Listener {
}
}
}
}

View File

@@ -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);