Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gnembon:master #63

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion src/gametest/java/carpetextra/test/DispenserWithBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeveledCauldronBlock;
import net.minecraft.block.NetherWartBlock;
import net.minecraft.block.entity.DispenserBlockEntity;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.entity.EntityType;
Expand Down Expand Up @@ -44,6 +45,10 @@ public void before(ServerWorld world) {
CarpetExtraSettings.dispensersStripBlocks = true;
CarpetExtraSettings.dispensersTillSoil = true;
CarpetExtraSettings.dispensersUseCauldrons = true;
CarpetExtraSettings.dispensersPlaceBoatsOnIce = true;
CarpetExtraSettings.blazeMeal = true;
CarpetExtraSettings.renewableEndstone = true;
CarpetExtraSettings.renewableNetherrack = true;
}

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

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void renewableNetherrack(TestContext ctx) {
blockConversionTest(ctx, Items.FIRE_CHARGE, Blocks.COBBLESTONE, Blocks.NETHERRACK, 1, true);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void renewableEndstone(TestContext ctx) {
blockConversionTest(ctx, Items.DRAGON_BREATH, Blocks.COBBLESTONE, Blocks.END_STONE, 1, true);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void blazeMeal(TestContext ctx) {
putInDispenser(ctx, Items.BLAZE_POWDER.getDefaultStack());
ctx.setBlockState(lapis, Blocks.SOUL_SAND);
ctx.setBlockState(lapis.up(), Blocks.NETHER_WART);

ctx.pushButton(button);

ctx.addFinalTaskWithDuration(DISPENSER_DELAY, () -> {
ctx.expectEmptyContainer(dispenser);
ctx.expectBlockProperty(lapis.up(), NetherWartBlock.AGE, 1);
});
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void blazeMealMaxed(TestContext ctx) {
putInDispenser(ctx, Items.BLAZE_POWDER.getDefaultStack());
ctx.setBlockState(lapis, Blocks.SOUL_SAND);
ctx.setBlockState(lapis.up(), Blocks.NETHER_WART.getDefaultState().with(NetherWartBlock.AGE, NetherWartBlock.MAX_AGE));

ctx.pushButton(button);

ctx.runAtTick(DISPENSER_DELAY, () -> {
checkFirstSlotHas(ctx, Items.BLAZE_POWDER, false);
ctx.expectBlockProperty(lapis.up(), NetherWartBlock.AGE, NetherWartBlock.MAX_AGE);
ctx.complete();
});
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
Expand All @@ -65,6 +113,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 +330,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);
}
}