diff --git a/Movecraft/src/main/java/net/countercraft/movecraft/mapUpdater/update/CraftRotateCommand.java b/Movecraft/src/main/java/net/countercraft/movecraft/mapUpdater/update/CraftRotateCommand.java index 4a94d7974..d5b4e6fda 100644 --- a/Movecraft/src/main/java/net/countercraft/movecraft/mapUpdater/update/CraftRotateCommand.java +++ b/Movecraft/src/main/java/net/countercraft/movecraft/mapUpdater/update/CraftRotateCommand.java @@ -93,7 +93,7 @@ public void doUpdate() { } } //The subtraction of the set of coordinates in the HitBox cube and the HitBox itself - final SetHitBox invertedHitBox = new SetHitBox(Sets.difference(craft.getHitBox().boundingHitBox().asSet(), craft.getHitBox().asSet())); + final Set invertedHitBox = Sets.difference(craft.getHitBox().boundingHitBox().asSet(), craft.getHitBox().asSet()); //A set of locations that are confirmed to be "exterior" locations final SetHitBox exterior = new SetHitBox(); final SetHitBox interior = new SetHitBox(); @@ -139,10 +139,10 @@ public void doUpdate() { } } exterior.addAll(visited); - interior.addAll(Sets.difference(invertedHitBox.asSet(), exterior.asSet())); + interior.addAll(Sets.difference(invertedHitBox, exterior.asSet())); final WorldHandler handler = Movecraft.getInstance().getWorldHandler(); - for (MovecraftLocation location : Sets.difference(invertedHitBox.asSet(), exterior.asSet())) { + for (MovecraftLocation location : Sets.difference(invertedHitBox, exterior.asSet())) { var data = location.toBukkit(craft.getWorld()).getBlock().getBlockData(); if (!passthroughBlocks.contains(data.getMaterial())) { continue; diff --git a/api/src/main/java/net/countercraft/movecraft/util/CollectionUtils.java b/api/src/main/java/net/countercraft/movecraft/util/CollectionUtils.java index 45edac278..021ff172f 100644 --- a/api/src/main/java/net/countercraft/movecraft/util/CollectionUtils.java +++ b/api/src/main/java/net/countercraft/movecraft/util/CollectionUtils.java @@ -6,11 +6,7 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; +import java.util.*; public class CollectionUtils { /** @@ -90,6 +86,18 @@ public static BitmapHitBox filter(@NotNull final HitBox collection, @NotNull fin @NotNull @Contract(pure = true) public static Iterable neighbors(@NotNull HitBox hitbox, @NotNull MovecraftLocation location){ + return neighbors(hitbox.asSet(), location); + } + + /** + * finds the axial neighbors to a location. Neighbors are defined as locations that exist within one meter of a given + * location + * @param location the location to search for neighbors + * @return an iterable set of neighbors to the given location + */ + @NotNull + @Contract(pure = true) + public static Iterable neighbors(@NotNull Set hitbox, @NotNull MovecraftLocation location){ if(hitbox.isEmpty()){ return Collections.emptyList(); }