Search in sources :

Example 16 with SetHitBox

use of net.countercraft.movecraft.util.hitboxes.SetHitBox in project Movecraft by APDevTeam.

the class TreeHitBoxTest method testContains.

@Test
public void testContains() {
    SetHitBox box = new SetHitBox();
    box.add(new MovecraftLocation(0, 1, 0));
    assertTrue(box.contains(new MovecraftLocation(0, 1, 0)));
}
Also used : SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) Test(org.junit.Test)

Example 17 with SetHitBox

use of net.countercraft.movecraft.util.hitboxes.SetHitBox in project Movecraft by APDevTeam.

the class TreeHitBoxTest method testIncrementalIterator.

@Test
public void testIncrementalIterator() {
    Set<MovecraftLocation> visited = new HashSet<>();
    SetHitBox box = new SetHitBox();
    for (var location : new SolidHitBox(new MovecraftLocation(-3, -3, -3), new MovecraftLocation(3, 3, 3))) {
        box.add(location);
        visited.add(location);
        Set<MovecraftLocation> verified = new HashSet<>();
        for (var probe : box) {
            assertTrue(visited.contains(probe), String.format("Location %s is not contained in %s, however %s are", probe, visited, verified));
            verified.add(probe);
        }
    }
}
Also used : SolidHitBox(net.countercraft.movecraft.util.hitboxes.SolidHitBox) SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with SetHitBox

use of net.countercraft.movecraft.util.hitboxes.SetHitBox in project Movecraft by APDevTeam.

the class TreeHitBoxTest method testCloneBounds.

@Test
public void testCloneBounds() {
    SolidHitBox solid = new SolidHitBox(new MovecraftLocation(-3, -3, -3), new MovecraftLocation(3, 3, 3));
    SetHitBox box = new SetHitBox(solid);
    assertEquals(-3, box.getMinX(), "X");
    assertEquals(-3, box.getMinY(), "Y");
    assertEquals(-3, box.getMinZ(), "Z");
    assertEquals(3, box.getMaxX());
    assertEquals(3, box.getMaxY());
    assertEquals(3, box.getMaxZ());
}
Also used : SolidHitBox(net.countercraft.movecraft.util.hitboxes.SolidHitBox) SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) Test(org.junit.Test)

Aggregations

SetHitBox (net.countercraft.movecraft.util.hitboxes.SetHitBox)18 SolidHitBox (net.countercraft.movecraft.util.hitboxes.SolidHitBox)10 MovecraftLocation (net.countercraft.movecraft.MovecraftLocation)9 Test (org.junit.Test)9 Material (org.bukkit.Material)6 HashSet (java.util.HashSet)4 HitBox (net.countercraft.movecraft.util.hitboxes.HitBox)4 ArrayList (java.util.ArrayList)3 Logger (java.util.logging.Logger)3 SinkingCraft (net.countercraft.movecraft.craft.SinkingCraft)3 Location (org.bukkit.Location)3 LinkedList (java.util.LinkedList)2 Movecraft (net.countercraft.movecraft.Movecraft)2 WorldHandler (net.countercraft.movecraft.WorldHandler)2 CraftType (net.countercraft.movecraft.craft.type.CraftType)2 CraftPreTranslateEvent (net.countercraft.movecraft.events.CraftPreTranslateEvent)2 MutableHitBox (net.countercraft.movecraft.util.hitboxes.MutableHitBox)2 Waterlogged (org.bukkit.block.data.Waterlogged)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1