Block update unit tests

This commit is contained in:
Anuken 2019-04-01 11:57:43 -04:00
parent 41b08f38c5
commit 0a8f2edb05
2 changed files with 41 additions and 0 deletions

View File

@ -407,6 +407,7 @@ public class Blocks implements ContentList{
outputItem = new ItemStack(Items.silicon, 1);
craftTime = 40f;
size = 2;
hasPower = true;
hasLiquids = false;
flameColor = Color.valueOf("ffef99");
@ -462,6 +463,7 @@ public class Blocks implements ContentList{
outputItem = new ItemStack(Items.phasefabric, 1);
craftTime = 120f;
size = 2;
hasPower = true;
consumes.items(new ItemStack(Items.thorium, 4), new ItemStack(Items.sand, 10));
consumes.power(5f);
@ -507,6 +509,7 @@ public class Blocks implements ContentList{
outputItem = new ItemStack(Items.surgealloy, 1);
craftTime = 75f;
size = 3;
hasPower = true;
consumes.power(4f);
consumes.items(new ItemStack(Items.titanium, 2), new ItemStack(Items.lead, 4), new ItemStack(Items.silicon, 3), new ItemStack(Items.copper, 3));
@ -625,6 +628,7 @@ public class Blocks implements ContentList{
size = 2;
health = 320;
hasLiquids = true;
hasPower = true;
consumes.item(Items.sporePod, 1);
consumes.power(0.60f);

View File

@ -334,6 +334,43 @@ public class ApplicationTests{
assertEquals(Blocks.air, world.tile(1, 1).block());
}
@Test
void allBlockTest(){
Tile[][] tiles = world.createTiles(256 + 20, 10);
world.beginMapLoad();
for(int x = 0; x < tiles.length; x++){
for(int y = 0; y < tiles[0].length; y++){
tiles[x][y] = new Tile(x, y, Blocks.stone.id, (byte)0);
}
}
int i = 0;
for(int x = 5; x < tiles.length && i < content.blocks().size;){
Block block = content.block(i++);
if(block.buildVisibility.get()){
tiles[x][5].setBlock(block);
x += block.size;
}
}
world.endMapLoad();
for(int x = 0; x < tiles.length; x++){
for(int y = 0; y < tiles[0].length; y++){
Tile tile = world.tile(x, y);
if(tile.entity != null){
try{
tile.entity.update();
}catch(Throwable t){
fail("Failed to update block '" + tile.block() + "'.", t);
}
assertEquals(tile.block(), tile.entity.block);
assertEquals(tile.block().health, tile.entity.health);
}
}
}
}
void initBuilding(){
createMap();