Search in sources :

Example 1 with MapResourcePack

use of com.bergerkiller.bukkit.common.map.MapResourcePack in project BKCommonLib by bergerhealer.

the class MapCanvasFunctionsTest method testDepthBuffer.

@Ignore
@Test
public void testDepthBuffer() {
    MapTexture map = MapTexture.createEmpty(64, 64);
    // Load the source textures
    MapResourcePack texturePack = MapResourcePack.VANILLA;
    // Test brush masks with depth buffer
    // map.setBrushMask(texturePack.getTexture("blocks/vine"));
    map.setDrawDepth(0);
    map.draw(texturePack.getTexture("blocks/brick"), 5, 5);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(1);
    map.draw(texturePack.getTexture("blocks/coal_ore"), 12, 12);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(0);
    map.clearRectangle(5, 5, 16, 16);
    assertTrue(map.hasMoreDepth());
    map.setDrawDepth(1);
    map.draw(texturePack.getTexture("blocks/coal_ore"), 12, 12);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(3);
    map.draw(texturePack.getTexture("blocks/bookshelf"), 23, 23);
    assertFalse(map.hasMoreDepth());
    map.setDrawDepth(2);
    map.draw(texturePack.getTexture("blocks/grass_side"), 15, 18);
    assertFalse(map.hasMoreDepth());
    MapDebugWindow.showMapForever(map, 10);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) MapResourcePack(com.bergerkiller.bukkit.common.map.MapResourcePack) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with MapResourcePack

use of com.bergerkiller.bukkit.common.map.MapResourcePack in project BKCommonLib by bergerhealer.

the class MapCanvasFunctionsTest method testBrushMask.

// @Test
public void testBrushMask() {
    MapTexture map = MapTexture.createEmpty(64, 64);
    // Load the source textures
    MapResourcePack texturePack = MapResourcePack.VANILLA;
    map.setBrushMask(texturePack.getTexture("blocks/ladder"));
    map.fill(MapColorPalette.COLOR_RED);
    map.draw(texturePack.getTexture("blocks/stone"), 30, 5);
    MapDebugWindow.showMapForever(map, 10);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) MapResourcePack(com.bergerkiller.bukkit.common.map.MapResourcePack)

Example 3 with MapResourcePack

use of com.bergerkiller.bukkit.common.map.MapResourcePack in project BKCommonLib by bergerhealer.

the class MapIsometricTest method testIsometric.

@Ignore
@Test
public void testIsometric() {
    // Load the source textures
    MapResourcePack texturePack = MapResourcePack.VANILLA;
    MapTexture sprite1 = renderSprite(texturePack.getBlockModel(Material.DIRT));
    MapTexture sprite2 = renderSprite(texturePack.getBlockModel(Material.GRASS));
    MapTexture sprite3 = renderSprite(texturePack.getBlockModel(Material.RAILS));
    MapTexture tile = MapTexture.createEmpty(128, 128);
    // tile.fill(MapColorPalette.COLOR_RED);
    renderTile(tile, sprite1, 0, 18);
    renderTile(tile, sprite2, 0, 0);
    renderTile(tile, sprite3, 0, -18);
    // Show a 2x2 map display
    MapTexture tile2x2 = MapTexture.createEmpty(256, 256);
    for (int x = 0; x < 2; x++) {
        for (int y = 0; y < 2; y++) {
            tile2x2.draw(tile, x * 128, y * 128);
        }
    }
    MapDebugWindow.showMapForever(tile2x2, 4);
}
Also used : MapTexture(com.bergerkiller.bukkit.common.map.MapTexture) MapResourcePack(com.bergerkiller.bukkit.common.map.MapResourcePack) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with MapResourcePack

use of com.bergerkiller.bukkit.common.map.MapResourcePack in project BKCommonLib by bergerhealer.

the class MapResourcePackTest method testBlockModels.

@Ignore
@Test
public void testBlockModels() {
    MapResourcePack resourcePack = MapResourcePack.VANILLA;
    // All of these have animations or a complicated model
    // We need to define a simplified placeholder model to make it work
    // This acts as a TODO list for models to fix
    HashSet<String> ignore = new HashSet<String>();
    ignore.add("bed");
    ignore.add("skull");
    ignore.add("barrier");
    ignore.add("standing_banner");
    ignore.add("wall_banner");
    ignore.add("piston_extension");
    // this is the black void-looking surface
    ignore.add("end_portal");
    // I could not find what this was
    ignore.add("structure_void");
    // Shulker boxes come in many colors. How will we deal?
    ignore.add("brown_shulker_box");
    ignore.add("white_shulker_box");
    ignore.add("red_shulker_box");
    ignore.add("magenta_shulker_box");
    ignore.add("pink_shulker_box");
    ignore.add("yellow_shulker_box");
    ignore.add("black_shulker_box");
    ignore.add("cyan_shulker_box");
    ignore.add("orange_shulker_box");
    ignore.add("lime_shulker_box");
    ignore.add("light_blue_shulker_box");
    ignore.add("green_shulker_box");
    ignore.add("purple_shulker_box");
    ignore.add("gray_shulker_box");
    ignore.add("blue_shulker_box");
    ignore.add("silver_shulker_box");
    boolean hasLoadErrors = false;
    for (BlockData block : BlockData.values()) {
        Model model = resourcePack.getBlockModel(block);
        String name = block.getBlockName();
        if (model.placeholder && !ignore.contains(name)) {
            hasLoadErrors = true;
            System.err.println("Failed to load model of block " + block.toString());
        }
    }
    if (hasLoadErrors) {
        fail("Some block models could not be loaded!");
    }
}
Also used : MapResourcePack(com.bergerkiller.bukkit.common.map.MapResourcePack) Model(com.bergerkiller.bukkit.common.map.util.Model) BlockData(com.bergerkiller.bukkit.common.wrappers.BlockData) HashSet(java.util.HashSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with MapResourcePack

use of com.bergerkiller.bukkit.common.map.MapResourcePack in project BKCommonLib by bergerhealer.

the class MapResourcePackTest method testItemModels.

@Ignore
@Test
public void testItemModels() {
    MapResourcePack resourcePack = MapResourcePack.VANILLA;
    // All of these have animations or a complicated model
    // We need to define a simplified placeholder model to make it work
    // This acts as a TODO list for models to fix
    HashSet<String> ignore = new HashSet<String>();
    ignore.add("bed");
    ignore.add("chest");
    ignore.add("trapped_chest");
    ignore.add("ender_chest");
    ignore.add("anvil");
    ignore.add("skull");
    ignore.add("banner");
    ignore.add("shield");
    // Shulker boxes come in many colors. How will we deal?
    ignore.add("brown_shulker_box");
    ignore.add("white_shulker_box");
    ignore.add("red_shulker_box");
    ignore.add("magenta_shulker_box");
    ignore.add("pink_shulker_box");
    ignore.add("yellow_shulker_box");
    ignore.add("black_shulker_box");
    ignore.add("cyan_shulker_box");
    ignore.add("orange_shulker_box");
    ignore.add("lime_shulker_box");
    ignore.add("light_blue_shulker_box");
    ignore.add("green_shulker_box");
    ignore.add("purple_shulker_box");
    ignore.add("gray_shulker_box");
    ignore.add("blue_shulker_box");
    ignore.add("silver_shulker_box");
    boolean hasLoadErrors = false;
    for (Material type : ItemUtil.getItemTypes()) {
        for (ItemStack variant : ItemUtil.getItemVariants(type)) {
            Model model = resourcePack.getItemModel(variant);
            if (model.placeholder && !ignore.contains(model.name)) {
                hasLoadErrors = true;
                System.err.println("Failed to load model of item " + variant.getType() + ":" + variant.getDurability() + " " + model.name);
            }
        }
    }
    if (hasLoadErrors) {
        fail("Some block models could not be loaded!");
    }
}
Also used : MapResourcePack(com.bergerkiller.bukkit.common.map.MapResourcePack) Model(com.bergerkiller.bukkit.common.map.util.Model) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) HashSet(java.util.HashSet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

MapResourcePack (com.bergerkiller.bukkit.common.map.MapResourcePack)6 Ignore (org.junit.Ignore)5 Test (org.junit.Test)5 MapTexture (com.bergerkiller.bukkit.common.map.MapTexture)4 Model (com.bergerkiller.bukkit.common.map.util.Model)2 HashSet (java.util.HashSet)2 ItemStack (org.bukkit.inventory.ItemStack)2 BlockData (com.bergerkiller.bukkit.common.wrappers.BlockData)1 Random (java.util.Random)1 Material (org.bukkit.Material)1