This commit is contained in:
Anuken
2020-06-26 14:27:26 -04:00
parent eabc5c15c7
commit fdf7c88083
228 changed files with 1219 additions and 1163 deletions

View File

@@ -28,8 +28,8 @@ public class DirectConsumerTests extends PowerTestFixture{
consumes.power(requestedPower);
consumes.items(new ItemStack(Items.silicon, 30), new ItemStack(Items.lead, 30));
}});
consumerTile.entity.items().add(Items.silicon, siliconAmount);
consumerTile.entity.items().add(Items.lead, leadAmount);
consumerTile.entity.items.add(Items.silicon, siliconAmount);
consumerTile.entity.items.add(Items.lead, leadAmount);
Tile producerTile = createFakeTile(2, 0, createFakeProducerBlock(producedPower));
producerTile.<PowerGenerator.GeneratorEntity>ent().productionEfficiency = 1f;
@@ -41,6 +41,6 @@ public class DirectConsumerTests extends PowerTestFixture{
consumerTile.entity.update();
graph.update();
assertEquals(expectedSatisfaction, consumerTile.entity.power().status);
assertEquals(expectedSatisfaction, consumerTile.entity.power.status);
}*/
}

View File

@@ -88,13 +88,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
createGenerator(inputType);
assertTrue(entity.acceptLiquid(null, liquid, availableLiquidAmount), inputType + " | " + parameterDescription + ": Liquids which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
entity.liquids().add(liquid, availableLiquidAmount);
entity.liquids.add(liquid, availableLiquidAmount);
entity.cons().update();
// Perform an update on the generator once - This should use up any resource up to the maximum liquid usage
entity.updateTile();
assertEquals(expectedRemainingLiquidAmount, entity.liquids().get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
assertEquals(expectedRemainingLiquidAmount, entity.liquids.get(liquid), inputType + " | " + parameterDescription + ": Remaining liquid amount mismatch.");
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
}
@@ -131,7 +131,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
assertTrue(entity.acceptItem(null, item), inputType + " | " + parameterDescription + ": Items which will be declined by the generator don't need to be tested - The code won't be called for those cases.");
if(amount > 0){
entity.items().add(item, amount);
entity.items.add(item, amount);
}
entity.cons().update();
@@ -139,7 +139,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
try{
entity.updateTile();
assertEquals(expectedRemainingItemAmount, entity.items().get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
assertEquals(expectedRemainingItemAmount, entity.items.get(item), inputType + " | " + parameterDescription + ": Remaining item amount mismatch.");
assertEquals(expectedEfficiency, entity.productionEfficiency, inputType + " | " + parameterDescription + ": Efficiency mismatch.");
}catch(NullPointerException e){
e.printStackTrace();
@@ -163,7 +163,7 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
createGenerator(inputType);
// Burn a single coal and test for the duration
entity.items().add(Items.coal, 1);
entity.items.add(Items.coal, 1);
entity.cons().update();
entity.updateTile();

View File

@@ -58,7 +58,7 @@ public class PowerTestFixture{
protected static Block createFakeDirectConsumer(float powerPerTick){
return new PowerBlock("fakedirectconsumer"){{
entityType = TileEntity::create;
entityType = Building::create;
consumes.power(powerPerTick);
}};
}
@@ -89,14 +89,14 @@ public class PowerTestFixture{
// Simulate the "changed" method. Calling it through reflections would require half the game to be initialized.
tile.entity = block.newEntity().init(tile, Team.sharded, false);
if(block.hasPower){
tile.entity.power().graph = new PowerGraph(){
tile.entity.power.graph = new PowerGraph(){
//assume there's always something consuming power
@Override
public float getUsageFraction(){
return 1f;
}
};
tile.entity.power().graph.add(tile.entity);
tile.entity.power.graph.add(tile.entity);
}
// Assign incredibly high health so the block does not get destroyed on e.g. burning Blast Compound

View File

@@ -66,7 +66,7 @@ public class PowerTests extends PowerTestFixture{
// Update and check for the expected power status of the consumer
powerGraph.update();
assertEquals(expectedSatisfaction, directConsumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
assertEquals(expectedSatisfaction, directConsumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
}
/**
@@ -104,14 +104,14 @@ public class PowerTests extends PowerTestFixture{
}
float maxCapacity = 100f;
Tile batteryTile = createFakeTile(0, 2, createFakeBattery(maxCapacity));
batteryTile.entity.power().status = initialBatteryCapacity / maxCapacity;
batteryTile.entity.power.status = initialBatteryCapacity / maxCapacity;
powerGraph.add(batteryTile.entity);
powerGraph.update();
assertEquals(expectedBatteryCapacity / maxCapacity, batteryTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Expected battery status did not match");
assertEquals(expectedBatteryCapacity / maxCapacity, batteryTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Expected battery status did not match");
if(directConsumerTile != null){
assertEquals(expectedSatisfaction, directConsumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
assertEquals(expectedSatisfaction, directConsumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR, parameterDescription + ": Satisfaction of direct consumer did not match");
}
}
@@ -127,13 +127,13 @@ public class PowerTests extends PowerTestFixture{
powerGraph.add(consumerTile.entity);
powerGraph.update();
assertEquals(1.0f, consumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR);
assertEquals(1.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR);
powerGraph.remove(producerTile.entity);
powerGraph.add(consumerTile.entity);
powerGraph.update();
assertEquals(0.0f, consumerTile.entity.power().status, Mathf.FLOAT_ROUNDING_ERROR);
assertEquals(0.0f, consumerTile.entity.power.status, Mathf.FLOAT_ROUNDING_ERROR);
if(consumerTile.block().consumes.hasPower()){
ConsumePower consumePower = consumerTile.block().consumes.getPower();
assertFalse(consumePower.valid(consumerTile.ent()));