Skip to content

Commit

Permalink
Add tests for dispensersPlaceBoatsOnIce
Browse files Browse the repository at this point in the history
  • Loading branch information
altrisi committed Jun 27, 2024
1 parent 34777b5 commit 16b3bf2
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/gametest/java/carpetextra/test/DispenserWithBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void before(ServerWorld world) {
CarpetExtraSettings.dispensersStripBlocks = true;
CarpetExtraSettings.dispensersTillSoil = true;
CarpetExtraSettings.dispensersUseCauldrons = true;
CarpetExtraSettings.dispensersPlaceBoatsOnIce = true;
}

@AfterBatch(batchId = BATCH)
Expand All @@ -53,6 +54,7 @@ public void after(ServerWorld world) {
CarpetExtraSettings.dispensersStripBlocks = false;
CarpetExtraSettings.dispensersTillSoil = false;
CarpetExtraSettings.dispensersUseCauldrons = false;
CarpetExtraSettings.dispensersPlaceBoatsOnIce = false;
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
Expand All @@ -65,6 +67,37 @@ public void shearPumpkinBreaks(TestContext ctx) {
blockConversionTest(ctx, Items.SHEARS, Blocks.PUMPKIN, Blocks.CARVED_PUMPKIN, 1, true, () -> ctx.expectItem(Items.PUMPKIN_SEEDS));
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void boatOnRegularIce(TestContext ctx) {
boatTest(ctx, Items.OAK_BOAT, Blocks.ICE, EntityType.BOAT);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void boatOnPackedIce(TestContext ctx) {
boatTest(ctx, Items.OAK_BOAT, Blocks.PACKED_ICE, EntityType.BOAT);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void boatOnBlueIce(TestContext ctx) {
boatTest(ctx, Items.OAK_BOAT, Blocks.BLUE_ICE, EntityType.BOAT);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void chestBoatOnIce(TestContext ctx) {
boatTest(ctx, Items.OAK_CHEST_BOAT, Blocks.ICE, EntityType.CHEST_BOAT);
}

private void boatTest(TestContext ctx, Item item, Block block, EntityType<?> expectedEntity) {
putInDispenser(ctx, item.getDefaultStack());
ctx.setBlockState(lapis, block);

ctx.pushButton(button);
ctx.addFinalTaskWithDuration(DISPENSER_DELAY, () -> {
ctx.expectEmptyContainer(dispenser);
ctx.expectEntityAt(expectedEntity, lapis.up());
});
}

@CustomTestProvider
public Collection<TestFunction> stripTests() {
List<TestFunction> fns = new ArrayList<>();
Expand Down Expand Up @@ -251,7 +284,7 @@ private void runAll(Runnable... actions) {

// Setup util
private TestFunction makeDispenserTest(String name, Consumer<TestContext> runner) {
name = name.replace("minecraft\\:", "");
name = name.replace("minecraft:", "");
return new TestFunction(BATCH, BATCH + '.' + name, STRUCTURE, 20, 0, true, runner);
}
}

0 comments on commit 16b3bf2

Please sign in to comment.