-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
More constructor tests
- Loading branch information
Showing
8 changed files
with
246 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
...om/refinedmods/refinedstorage2/platform/common/constructordestructor/ConstructorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package com.refinedmods.refinedstorage2.platform.common.constructordestructor; | ||
|
||
import com.refinedmods.refinedstorage2.api.resource.ResourceAmount; | ||
import com.refinedmods.refinedstorage2.platform.common.Platform; | ||
import com.refinedmods.refinedstorage2.platform.common.util.IdentifierUtil; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.core.Direction; | ||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.material.FluidState; | ||
import net.neoforged.neoforge.gametest.GameTestHolder; | ||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate; | ||
|
||
import static com.refinedmods.refinedstorage2.platform.common.constructordestructor.ConstructorTestPlots.preparePlot; | ||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.asResource; | ||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.assertFluidPresent; | ||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.insert; | ||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.networkIsAvailable; | ||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.storageContainsExactly; | ||
import static net.minecraft.world.item.Items.DIRT; | ||
import static net.minecraft.world.item.Items.FIREWORK_ROCKET; | ||
import static net.minecraft.world.item.Items.STONE; | ||
import static net.minecraft.world.level.material.Fluids.WATER; | ||
|
||
@GameTestHolder(IdentifierUtil.MOD_ID) | ||
@PrefixGameTestTemplate(false) | ||
public final class ConstructorTest { | ||
private ConstructorTest() { | ||
} | ||
|
||
@GameTest(template = "empty_15x15") | ||
public static void shouldPlaceBlock(final GameTestHelper helper) { | ||
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> { | ||
// Arrange | ||
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> { | ||
insert(helper, network, DIRT, 10); | ||
insert(helper, network, STONE, 15); | ||
})); | ||
|
||
// Act | ||
constructor.setFilters(List.of(asResource(DIRT))); | ||
|
||
// Assert | ||
sequence | ||
.thenWaitUntil(() -> helper.assertBlockPresent(Blocks.DIRT, pos.east())) | ||
.thenWaitUntil(storageContainsExactly( | ||
helper, | ||
pos, | ||
new ResourceAmount(asResource(DIRT), 9), | ||
new ResourceAmount(asResource(STONE), 15) | ||
)) | ||
.thenSucceed(); | ||
}); | ||
} | ||
|
||
@GameTest(template = "empty_15x15") | ||
public static void shouldPlaceWater(final GameTestHelper helper) { | ||
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> { | ||
// Arrange | ||
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> { | ||
insert(helper, network, DIRT, 10); | ||
insert(helper, network, STONE, 15); | ||
insert(helper, network, WATER, Platform.INSTANCE.getBucketAmount() * 2); | ||
})); | ||
|
||
// Act | ||
constructor.setFilters(List.of(asResource(WATER))); | ||
|
||
// Assert | ||
sequence | ||
.thenWaitUntil(() -> assertFluidPresent(helper, pos.east(), WATER, FluidState.AMOUNT_FULL)) | ||
.thenWaitUntil(storageContainsExactly( | ||
helper, | ||
pos, | ||
new ResourceAmount(asResource(DIRT), 10), | ||
new ResourceAmount(asResource(STONE), 15), | ||
new ResourceAmount(asResource(WATER), Platform.INSTANCE.getBucketAmount()) | ||
)) | ||
.thenSucceed(); | ||
}); | ||
} | ||
|
||
@GameTest(template = "empty_15x15") | ||
public static void shouldDropItem(final GameTestHelper helper) { | ||
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> { | ||
// Arrange | ||
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> { | ||
insert(helper, network, DIRT, 10); | ||
insert(helper, network, STONE, 15); | ||
})); | ||
|
||
// Act | ||
constructor.setDropItems(true); | ||
constructor.setFilters(List.of(asResource(DIRT))); | ||
|
||
// Assert | ||
sequence | ||
.thenWaitUntil(() -> helper.assertBlockNotPresent(Blocks.DIRT, pos.east())) | ||
.thenWaitUntil(() -> helper.assertItemEntityPresent(DIRT, pos.east(), 1)) | ||
.thenWaitUntil(storageContainsExactly( | ||
helper, | ||
pos, | ||
new ResourceAmount(asResource(DIRT), 9), | ||
new ResourceAmount(asResource(STONE), 15) | ||
)) | ||
.thenSucceed(); | ||
}); | ||
} | ||
|
||
@GameTest(template = "empty_15x15") | ||
public static void shouldPlaceFireworks(final GameTestHelper helper) { | ||
preparePlot(helper, Direction.EAST, (constructor, pos, sequence) -> { | ||
// Arrange | ||
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> { | ||
insert(helper, network, DIRT, 10); | ||
insert(helper, network, FIREWORK_ROCKET, 15); | ||
})); | ||
|
||
// Act | ||
constructor.setFilters(List.of(asResource(FIREWORK_ROCKET))); | ||
|
||
// Assert | ||
sequence | ||
.thenWaitUntil(() -> helper.assertBlockPresent(Blocks.AIR, pos.east())) | ||
.thenWaitUntil(() -> helper.assertEntityPresent(EntityType.FIREWORK_ROCKET, pos.east())) | ||
.thenWaitUntil(storageContainsExactly( | ||
helper, | ||
pos, | ||
new ResourceAmount(asResource(DIRT), 10), | ||
new ResourceAmount(asResource(FIREWORK_ROCKET), 14) | ||
)) | ||
.thenSucceed(); | ||
}); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...finedmods/refinedstorage2/platform/common/constructordestructor/ConstructorTestPlots.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.refinedmods.refinedstorage2.platform.common.constructordestructor; | ||
|
||
import com.refinedmods.refinedstorage2.platform.common.storage.FluidStorageType; | ||
import com.refinedmods.refinedstorage2.platform.common.storage.ItemStorageType; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import net.minecraft.gametest.framework.GameTestSequence; | ||
import org.apache.commons.lang3.function.TriConsumer; | ||
|
||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.RSBLOCKS; | ||
import static com.refinedmods.refinedstorage2.platform.forge.GameTestUtil.requireBlockEntity; | ||
import static net.minecraft.core.BlockPos.ZERO; | ||
|
||
final class ConstructorTestPlots { | ||
private ConstructorTestPlots() { | ||
} | ||
|
||
static void preparePlot(final GameTestHelper helper, | ||
final Direction direction, | ||
final TriConsumer<ConstructorBlockEntity, BlockPos, GameTestSequence> consumer) { | ||
helper.setBlock(ZERO.above(), RSBLOCKS.getCreativeController().getDefault()); | ||
helper.setBlock(ZERO.above().above(), RSBLOCKS.getItemStorageBlock(ItemStorageType.Variant.ONE_K)); | ||
helper.setBlock( | ||
ZERO.above().above().north(), | ||
RSBLOCKS.getFluidStorageBlock(FluidStorageType.Variant.SIXTY_FOUR_B) | ||
); | ||
final BlockPos constructorPos = ZERO.above().above().above(); | ||
helper.setBlock(constructorPos, RSBLOCKS.getConstructor().getDefault().rotated(direction)); | ||
consumer.accept( | ||
requireBlockEntity(helper, constructorPos, ConstructorBlockEntity.class), | ||
constructorPos, | ||
helper.startSequence() | ||
); | ||
} | ||
} |
51 changes: 0 additions & 51 deletions
51
...m-forge/src/test/java/com/refinedmods/refinedstorage2/platform/forge/ConstructorTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.