diff --git a/src/gametest/java/carpetextra/test/DispenserWithBlock.java b/src/gametest/java/carpetextra/test/DispenserWithBlock.java index 1f227f46..5e271878 100644 --- a/src/gametest/java/carpetextra/test/DispenserWithBlock.java +++ b/src/gametest/java/carpetextra/test/DispenserWithBlock.java @@ -49,6 +49,7 @@ public void before(ServerWorld world) { CarpetExtraSettings.blazeMeal = true; CarpetExtraSettings.renewableEndstone = true; CarpetExtraSettings.renewableNetherrack = true; + CarpetExtraSettings.autoCraftingDropper = true; // TODO separate, further testing for this feature } @AfterBatch(batchId = BATCH) @@ -62,6 +63,7 @@ public void after(ServerWorld world) { CarpetExtraSettings.blazeMeal = false; CarpetExtraSettings.renewableEndstone = false; CarpetExtraSettings.renewableNetherrack = false; + CarpetExtraSettings.autoCraftingDropper = false; } @GameTest(templateName = STRUCTURE, batchId = BATCH) @@ -299,7 +301,7 @@ private void cartTest(TestContext ctx, Item item, EntityType entity, Runnable ctx.spawnEntity(EntityType.MINECART, lapis.up()); ctx.pushButton(button); - ctx.addFinalTaskWithDuration(4, () -> { + ctx.addFinalTaskWithDuration(DISPENSER_DELAY, () -> { ctx.expectEntityAt(entity, lapis.up()); ctx.dontExpectEntity(EntityType.MINECART); ctx.dontExpectEntity(EntityType.ITEM); @@ -307,6 +309,39 @@ private void cartTest(TestContext ctx, Item item, EntityType entity, Runnable }); } + // very basic autocrafting test, for now just to catch simple crashes or malfunctioning stuff + @GameTest(templateName = STRUCTURE, batchId = BATCH) + public void craftCake(TestContext ctx) { + Item[] recipe = new Item[] { + Items.MILK_BUCKET, Items.MILK_BUCKET, Items.MILK_BUCKET, + Items.SUGAR, Items.EGG, Items.SUGAR, + Items.WHEAT, Items.WHEAT, Items.WHEAT + }; + ctx.setBlockState(dispenser, Blocks.DROPPER.getStateWithProperties(ctx.getBlockState(dispenser))); + ctx.setBlockState(lapis.up(), Blocks.CRAFTING_TABLE); + for (int i = 0; i < 9; i++) { + ctx.getBlockEntity(dispenser).setStack(i, recipe[i].getDefaultStack()); + } + ctx.pushButton(button); + + ctx.addFinalTaskWithDuration(DISPENSER_DELAY, () -> { + ctx.expectItem(Items.CAKE); + for (Item item : recipe) ctx.dontExpectItem(item); + for (int i = 0; i < 3; i++) { + int finalI = i; + ctx.checkBlockEntity(dispenser, + disp -> disp.getStack(finalI).getItem() == Items.BUCKET, + () -> "Must have buckets remaining in dispenser"); + } + for (int i = 3; i < 9; i++) { + int finalI = i; + ctx.checkBlockEntity(dispenser, + disp -> disp.getStack(finalI).isEmpty(), + () -> "Must not have anything but the first 3 buckets in dispenser"); + } + }); + } + // Util private void putInDispenser(TestContext ctx, ItemStack item) { ctx.getBlockEntity(dispenser).addToFirstFreeSlot(item);