Search in sources :

Example 1 with BlockFaceSet

use of com.bergerkiller.bukkit.common.collections.BlockFaceSet in project BKCommonLib by bergerhealer.

the class BlockDataOpacityTest method assertOpaqueFaces.

private void assertOpaqueFaces(BlockFaceSet expected, BlockData blockdata) {
    BlockFaceSet actual = blockdata.getOpaqueFaces(null);
    if (expected != actual) {
        System.err.println("Incorrect opaque faces for " + blockdata);
        System.err.println("  Actual: " + actual);
        System.err.println("Expected: " + expected);
        fail("Incorrect opaque faces for " + blockdata);
    }
}
Also used : BlockFaceSet(com.bergerkiller.bukkit.common.collections.BlockFaceSet)

Example 2 with BlockFaceSet

use of com.bergerkiller.bukkit.common.collections.BlockFaceSet in project BKCommonLib by bergerhealer.

the class BlockFaceSetTest method testFacePropertiesSetClear.

private void testFacePropertiesSetClear(BlockFaceSet initial, boolean north, boolean east, boolean south, boolean west, boolean up, boolean down) {
    // Set them all
    BlockFaceSet set = initial;
    set = set.setNorth(north);
    set = set.setEast(east);
    set = set.setSouth(south);
    set = set.setWest(west);
    set = set.setUp(up);
    set = set.setDown(down);
    // Check get() equals
    assertEquals(north, set.get(BlockFace.NORTH));
    assertEquals(east, set.get(BlockFace.EAST));
    assertEquals(south, set.get(BlockFace.SOUTH));
    assertEquals(west, set.get(BlockFace.WEST));
    assertEquals(up, set.get(BlockFace.UP));
    assertEquals(down, set.get(BlockFace.DOWN));
    // Check face properties equals
    assertEquals(north, set.north());
    assertEquals(east, set.east());
    assertEquals(south, set.south());
    assertEquals(west, set.west());
    assertEquals(up, set.up());
    assertEquals(down, set.down());
}
Also used : BlockFaceSet(com.bergerkiller.bukkit.common.collections.BlockFaceSet)

Example 3 with BlockFaceSet

use of com.bergerkiller.bukkit.common.collections.BlockFaceSet in project BKCommonLib by bergerhealer.

the class BlockDataOpacityTest method testOpaqueFaces.

@Test
public void testOpaqueFaces() {
    assertOpaqueFaces(BlockFaceSet.NONE, BlockData.fromMaterial(Material.GLASS));
    assertOpaqueFaces(BlockFaceSet.NONE, BlockData.fromMaterial(Material.AIR));
    assertOpaqueFaces(BlockFaceSet.NONE, BlockData.fromMaterial(Material.ACACIA_FENCE));
    assertOpaqueFaces(BlockFaceSet.ALL, BlockData.fromMaterial(Material.OAK_WOOD));
    assertOpaqueFaces(BlockFaceSet.ALL, BlockData.fromMaterial(Material.OBSIDIAN));
    // Weird. Says all faces are opaque? Still works since opacity is 0
    // assertOpaqueFaces(BlockFaceSet.NONE, BlockData.fromMaterial(Material.GLASS));
    // Slabs top/bottom half should be opaque
    assertOpaqueFaces(BlockFaceSet.of(BlockFace.UP), BlockData.fromMaterial(Material.OAK_SLAB).setState("type", "top"));
    assertOpaqueFaces(BlockFaceSet.of(BlockFace.DOWN), BlockData.fromMaterial(Material.OAK_SLAB).setState("type", "bottom"));
    // We should see the bottom and the backside be opaque
    for (BlockFace facing : FaceUtil.AXIS) {
        BlockFaceSet expected = BlockFaceSet.of(BlockFace.DOWN, facing);
        assertOpaqueFaces(expected, BlockData.fromMaterial(Material.OAK_STAIRS).setState("facing", facing).setState("half", "bottom").setState("shape", "straight"));
    }
    // We should see the top and the backside be opaque
    for (BlockFace facing : FaceUtil.AXIS) {
        BlockFaceSet expected = BlockFaceSet.of(BlockFace.UP, facing);
        assertOpaqueFaces(expected, BlockData.fromMaterial(Material.OAK_STAIRS).setState("facing", facing).setState("half", "top").setState("shape", "straight"));
    }
    // Stairs using inner_left should see two faces be opaque
    {
        BlockFaceSet expected = BlockFaceSet.of(BlockFace.UP, BlockFace.NORTH, BlockFace.WEST);
        assertOpaqueFaces(expected, BlockData.fromMaterial(Material.OAK_STAIRS).setState("facing", BlockFace.NORTH).setState("half", "top").setState("shape", "inner_left"));
    }
}
Also used : BlockFace(org.bukkit.block.BlockFace) BlockFaceSet(com.bergerkiller.bukkit.common.collections.BlockFaceSet) Test(org.junit.Test)

Example 4 with BlockFaceSet

use of com.bergerkiller.bukkit.common.collections.BlockFaceSet in project BKCommonLib by bergerhealer.

the class BlockFaceSetTest method testFaceGettersSetClear.

private void testFaceGettersSetClear(BlockFaceSet initial, boolean north, boolean east, boolean south, boolean west, boolean up, boolean down) {
    // Set them all
    BlockFaceSet set = initial;
    set = north ? set.set(BlockFace.NORTH) : set.clear(BlockFace.NORTH);
    set = east ? set.set(BlockFace.EAST) : set.clear(BlockFace.EAST);
    set = south ? set.set(BlockFace.SOUTH) : set.clear(BlockFace.SOUTH);
    set = west ? set.set(BlockFace.WEST) : set.clear(BlockFace.WEST);
    set = up ? set.set(BlockFace.UP) : set.clear(BlockFace.UP);
    set = down ? set.set(BlockFace.DOWN) : set.clear(BlockFace.DOWN);
    // Check get() equals
    assertEquals(north, set.get(BlockFace.NORTH));
    assertEquals(east, set.get(BlockFace.EAST));
    assertEquals(south, set.get(BlockFace.SOUTH));
    assertEquals(west, set.get(BlockFace.WEST));
    assertEquals(up, set.get(BlockFace.UP));
    assertEquals(down, set.get(BlockFace.DOWN));
    // Check face properties equals
    assertEquals(north, set.north());
    assertEquals(east, set.east());
    assertEquals(south, set.south());
    assertEquals(west, set.west());
    assertEquals(up, set.up());
    assertEquals(down, set.down());
}
Also used : BlockFaceSet(com.bergerkiller.bukkit.common.collections.BlockFaceSet)

Example 5 with BlockFaceSet

use of com.bergerkiller.bukkit.common.collections.BlockFaceSet in project BKCommonLib by bergerhealer.

the class BlockFaceSetTest method testByBlockFace.

@Test
public void testByBlockFace() {
    for (BlockFace face : FaceUtil.BLOCK_SIDES) {
        BlockFaceSet set = BlockFaceSet.of(face);
        assertTrue(set.get(face));
        for (BlockFace face2 : FaceUtil.BLOCK_SIDES) {
            if (face2 != face) {
                assertFalse(set.get(face2));
            }
        }
    }
    assertEquals(BlockFaceSet.ALL, BlockFaceSet.of(FaceUtil.BLOCK_SIDES));
    assertEquals(BlockFaceSet.NONE, BlockFaceSet.of());
}
Also used : BlockFace(org.bukkit.block.BlockFace) BlockFaceSet(com.bergerkiller.bukkit.common.collections.BlockFaceSet) Test(org.junit.Test)

Aggregations

BlockFaceSet (com.bergerkiller.bukkit.common.collections.BlockFaceSet)7 Test (org.junit.Test)3 BlockFace (org.bukkit.block.BlockFace)2