mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-25 15:18:24 +07:00
"fixes"
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package power;
|
||||
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
@ -7,6 +8,8 @@ import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.power.ItemLiquidGenerator;
|
||||
import io.anuke.mindustry.world.consumers.Consume;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeItemFilter;
|
||||
import org.junit.jupiter.api.DynamicTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestFactory;
|
||||
@ -36,7 +39,6 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
||||
generator = new ItemLiquidGenerator(inputType != InputType.liquids, inputType != InputType.items, "fakegen"){
|
||||
{
|
||||
powerProduction = 0.1f;
|
||||
itemDuration = 60f;
|
||||
itemDuration = fakeItemDuration;
|
||||
maxLiquidGenerate = maximumLiquidUsage;
|
||||
}
|
||||
@ -135,6 +137,13 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
||||
entity.items.add(item, amount);
|
||||
}
|
||||
entity.cons.update();
|
||||
if(!entity.cons.valid()){
|
||||
Log.info("not valid: ");
|
||||
for(Consume cons : entity.block.consumes.all()){
|
||||
if(cons instanceof ConsumeItemFilter)
|
||||
Log.info("--" + cons.getClass().getSimpleName() + ": " + cons.valid(entity) + " " + ((ConsumeItemFilter)cons).filter.test(item) + " update: " + cons.isUpdate() + " optional: " + cons.isOptional());
|
||||
}
|
||||
}
|
||||
assertTrue(entity.cons.valid());
|
||||
|
||||
// Perform an update on the generator once - This should use up one or zero items - dependent on if the item is accepted and available or not.
|
||||
|
@ -2,6 +2,7 @@ package power;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Log;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
@ -34,6 +35,7 @@ public class PowerTestFixture{
|
||||
Core.graphics = new FakeGraphics();
|
||||
Vars.content = new ContentLoader();
|
||||
Vars.content.load();
|
||||
Log.setUseColors(false);
|
||||
Time.setDeltaProvider(() -> 0.5f);
|
||||
}
|
||||
|
||||
@ -71,6 +73,11 @@ public class PowerTestFixture{
|
||||
try{
|
||||
Tile tile = new Tile(x, y);
|
||||
|
||||
//workaround since init() is not called for custom blocks
|
||||
if(block.consumes.all() == null){
|
||||
block.consumes.init();
|
||||
}
|
||||
|
||||
// Using the Tile(int, int, byte, byte) constructor would require us to register any fake block or tile we create
|
||||
// Since this part shall not be part of the test and would require more work anyway, we manually set the block and floor
|
||||
// through reflections and then simulate part of what the changed() method does.
|
||||
|
Reference in New Issue
Block a user