Search in sources :

Example 1 with SetHitBox

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

the class TreeHitBoxTest method testDoubleAdd.

@Test
public void testDoubleAdd() {
    SetHitBox box = new SetHitBox();
    assertTrue(box.add(new MovecraftLocation(0, 1, 0)), "first");
    assertFalse(box.add(new MovecraftLocation(0, 1, 0)), "second");
    assertEquals(1, box.size());
}
Also used : SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) Test(org.junit.Test)

Example 2 with SetHitBox

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

the class TreeHitBoxTest method testSinglePointIterator.

@Test
public void testSinglePointIterator() {
    for (var location : new SolidHitBox(new MovecraftLocation(-3, -3, -3), new MovecraftLocation(3, 3, 3))) {
        SetHitBox box = new SetHitBox();
        box.add(location);
        assertEquals(location, box.iterator().next());
    }
}
Also used : SolidHitBox(net.countercraft.movecraft.util.hitboxes.SolidHitBox) SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) Test(org.junit.Test)

Example 3 with SetHitBox

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

the class TreeHitBoxTest method testRemoveThanIterate.

@Test
public void testRemoveThanIterate() {
    SetHitBox hitBox = createTestHitbox();
    SetHitBox other = createTestHitbox();
    int size = other.size();
    for (var location : hitBox) {
        other.remove(location);
        size -= 1;
        assertEquals(size, Iterators.size(other.iterator()));
    }
    assertTrue(other.isEmpty());
}
Also used : SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) Test(org.junit.Test)

Example 4 with SetHitBox

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

the class TreeHitBoxTest method testIteratorBitPosition.

@Test
public void testIteratorBitPosition() {
    long l = 1;
    for (int i = 0; i < 64; i++) {
        long shifted = l << i;
        MovecraftLocation unpacked = MovecraftLocation.unpack(shifted);
        SetHitBox box = new SetHitBox();
        box.add(unpacked);
        for (var iterLoc : box) {
            assertEquals(unpacked, iterLoc);
        }
    }
}
Also used : SetHitBox(net.countercraft.movecraft.util.hitboxes.SetHitBox) Test(org.junit.Test)

Example 5 with SetHitBox

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

the class TreeHitBoxTest method testRemove.

@Test
public void testRemove() {
    SetHitBox hitBox = createTestHitbox();
    SetHitBox other = createTestHitbox();
    for (var location : hitBox) {
        other.remove(location);
    }
    assertTrue(other.isEmpty());
}
Also used : 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