Skip to content

Commit

Permalink
Merge pull request #638 from starforcraft/feat/GH-248/silktouchtests
Browse files Browse the repository at this point in the history
Silk Touch upgrade gametest
  • Loading branch information
raoulvdberge authored Jul 31, 2024
2 parents 112ec9f + 052637c commit 6334023
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
import net.neoforged.neoforge.gametest.GameTestHolder;
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;

import static com.refinedmods.refinedstorage.common.GameTestUtil.RSITEMS;
import static com.refinedmods.refinedstorage.common.GameTestUtil.asResource;
import static com.refinedmods.refinedstorage.common.GameTestUtil.insert;
import static com.refinedmods.refinedstorage.common.GameTestUtil.networkIsAvailable;
import static com.refinedmods.refinedstorage.common.GameTestUtil.storageContainsExactly;
import static net.minecraft.world.item.Items.DIAMOND;
import static net.minecraft.world.item.Items.DIAMOND_ORE;
import static net.minecraft.world.item.Items.DIRT;
import static net.minecraft.world.item.Items.STONE;
import static net.minecraft.world.level.material.Fluids.LAVA;
Expand Down Expand Up @@ -50,6 +53,15 @@ public static void shouldBreakBlock(final GameTestHelper helper) {
new ResourceAmount(asResource(DIRT), 11),
new ResourceAmount(asResource(STONE), 15)
))
.thenExecute(() -> helper.setBlock(pos.east(), Blocks.DIAMOND_ORE))
.thenWaitUntil(() -> helper.assertBlockNotPresent(Blocks.DIAMOND_ORE, pos.east()))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 11),
new ResourceAmount(asResource(STONE), 15),
new ResourceAmount(asResource(DIAMOND), 1)
))
.thenSucceed();
});
}
Expand Down Expand Up @@ -116,6 +128,33 @@ public static void shouldBreakBlockBlocklist(final GameTestHelper helper) {
});
}

@GameTest(template = "empty_15x15")
public static void shouldBreakBlockWithSilkTouchUpgrade(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
// Arrange
sequence.thenWaitUntil(networkIsAvailable(helper, pos, network -> {
insert(helper, network, DIRT, 10);
insert(helper, network, STONE, 15);
}));

// Act
helper.setBlock(pos.east(), Blocks.DIAMOND_ORE);
destructor.addUpgradeItem(RSITEMS.getSilkTouchUpgrade());

// Assert
sequence
.thenWaitUntil(() -> helper.assertBlockNotPresent(Blocks.DIAMOND_ORE, pos.east()))
.thenWaitUntil(storageContainsExactly(
helper,
pos,
new ResourceAmount(asResource(DIRT), 10),
new ResourceAmount(asResource(STONE), 15),
new ResourceAmount(asResource(DIAMOND_ORE), 1)
))
.thenSucceed();
});
}

@GameTest(template = "empty_15x15")
public static void shouldPickupItemAllowlist(final GameTestHelper helper) {
DestructorTestPlots.preparePlot(helper, Direction.EAST, (destructor, pos, sequence) -> {
Expand Down

0 comments on commit 6334023

Please sign in to comment.