-
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Warp+Force lens behavior when hitting force relays
(fixes #4046)
- Loading branch information
1 parent
c4d5b26
commit 1a19a43
Showing
5 changed files
with
154 additions
and
1 deletion.
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
106 changes: 106 additions & 0 deletions
106
Xplat/src/main/java/vazkii/botania/test/item/lens/WarpForceTest.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,106 @@ | ||
package vazkii.botania.test.item.lens; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.ButtonBlock; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
|
||
import vazkii.botania.common.block.BotaniaBlocks; | ||
import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; | ||
import vazkii.botania.common.item.BotaniaItems; | ||
import vazkii.botania.common.item.lens.LensItem; | ||
import vazkii.botania.test.TestingUtil; | ||
|
||
public class WarpForceTest { | ||
private static final String TEMPLATE = "botania:item/lens/force_warp_relay_interaction"; | ||
|
||
private static final BlockPos SPREADER_POS = new BlockPos(1, 2, 1); | ||
private static final BlockPos SPREADER_TARGET_POS = new BlockPos(6, 2, 1); | ||
private static final BlockPos BUTTON_POS = new BlockPos(1, 2, 3); | ||
private static final BlockPos RELAY_POS = new BlockPos(3, 2, 1); | ||
private static final BlockPos BOUND_POS = new BlockPos(3, 2, 3); | ||
|
||
@GameTest(template = TEMPLATE, timeoutTicks = 50) | ||
public void testWarpForceLens(GameTestHelper helper) { | ||
setUpLensesAndBindings(helper, BotaniaItems.lensWarp, BotaniaItems.lensPiston); | ||
|
||
helper.startSequence() | ||
.thenExecute(() -> helper.pressButton(BUTTON_POS)) | ||
.thenWaitUntil(() -> helper.assertBlockProperty(BUTTON_POS, ButtonBlock.POWERED, false)) | ||
.thenExecute(() -> { | ||
helper.assertBlock(RELAY_POS, BotaniaBlocks.pistonRelay::equals, () -> "Force relay moved"); | ||
helper.assertBlockState(BOUND_POS, BlockState::isAir, () -> "Bound block did not move"); | ||
helper.assertBlock(BOUND_POS.east(), Blocks.POLISHED_ANDESITE::equals, | ||
() -> "Bound block did not move to expected position"); | ||
TestingUtil.assertEquals(TestingUtil.getBoundForceRelayTarget(helper, RELAY_POS), helper.absolutePos(BOUND_POS), | ||
() -> "Relay binding has changed"); | ||
}) | ||
// second shot to confirm binding still works | ||
.thenExecute(() -> helper.setBlock(BOUND_POS, Blocks.POLISHED_DIORITE)) | ||
.thenExecute(() -> helper.pressButton(BUTTON_POS)) | ||
.thenWaitUntil(() -> helper.assertBlockProperty(BUTTON_POS, ButtonBlock.POWERED, false)) | ||
.thenExecute(() -> { | ||
helper.assertBlockState(RELAY_POS, blockState -> blockState.is(BotaniaBlocks.pistonRelay), | ||
() -> "Force relay moved after second burst"); | ||
helper.assertBlockState(BOUND_POS, BlockState::isAir, () -> "Bound block did not move"); | ||
helper.assertBlock(BOUND_POS.east(), Blocks.POLISHED_DIORITE::equals, | ||
() -> "New block did not move to expected position after second burst"); | ||
helper.assertBlock(BOUND_POS.east(2), Blocks.POLISHED_ANDESITE::equals, | ||
() -> "Original block did not move to expected position after second burst"); | ||
TestingUtil.assertEquals(TestingUtil.getBoundForceRelayTarget(helper, RELAY_POS), helper.absolutePos(BOUND_POS), | ||
() -> "Relay binding has changed after second burst"); | ||
}) | ||
.thenSucceed(); | ||
} | ||
|
||
// TODO: Regression test for https://github.com/VazkiiMods/Botania/issues/4593 | ||
@GameTest(template = TEMPLATE, timeoutTicks = 50, required = false) | ||
public void testForceWarpLens(GameTestHelper helper) { | ||
setUpLensesAndBindings(helper, BotaniaItems.lensPiston, BotaniaItems.lensWarp); | ||
|
||
helper.startSequence() | ||
.thenExecute(() -> helper.pressButton(BUTTON_POS)) | ||
.thenWaitUntil(() -> helper.assertBlockProperty(BUTTON_POS, ButtonBlock.POWERED, false)) | ||
.thenExecute(() -> { | ||
helper.assertBlockState(RELAY_POS, BlockState::isAir, () -> "Force relay did not move"); | ||
helper.assertBlock(RELAY_POS.east(), BotaniaBlocks.pistonRelay::equals, | ||
() -> "Force relay did not move to expected position"); | ||
helper.assertBlockState(BOUND_POS, BlockState::isAir, () -> "Bound block did not move"); | ||
helper.assertBlock(BOUND_POS.east(), Blocks.POLISHED_ANDESITE::equals, | ||
() -> "Bound block did not move to expected position"); | ||
TestingUtil.assertEquals(TestingUtil.getBoundForceRelayTarget(helper, RELAY_POS.east()), BOUND_POS.east(), | ||
() -> "Relay binding was not updated"); | ||
}) | ||
// second shot to confirm binding still works | ||
.thenExecute(() -> helper.setBlock(BOUND_POS, Blocks.POLISHED_DIORITE)) | ||
.thenExecute(() -> helper.pressButton(BUTTON_POS)) | ||
.thenWaitUntil(() -> helper.assertBlockProperty(BUTTON_POS, ButtonBlock.POWERED, false)) | ||
.thenExecute(() -> { | ||
helper.assertBlock(BOUND_POS, Blocks.POLISHED_DIORITE::equals, () -> "New block at original bound position moved"); | ||
helper.assertBlockState(RELAY_POS.east(), BlockState::isAir, () -> "Force relay did not move after second burst"); | ||
helper.assertBlock(RELAY_POS.east(2), BotaniaBlocks.pistonRelay::equals, | ||
() -> "Force relay did not move to expected position after second burst"); | ||
helper.assertBlockState(BOUND_POS.east(), BlockState::isAir, () -> "Bound block did not move a second time"); | ||
helper.assertBlock(BOUND_POS.east(2), Blocks.POLISHED_ANDESITE::equals, | ||
() -> "Bound block did not move to expected position after second burst"); | ||
TestingUtil.assertEquals(TestingUtil.getBoundForceRelayTarget(helper, RELAY_POS.east(2)), BOUND_POS.east(2), | ||
() -> "Relay binding was not updated after second burst"); | ||
}) | ||
.thenSucceed(); | ||
} | ||
|
||
private static void setUpLensesAndBindings(GameTestHelper helper, Item firstLensType, Item secondLensType) { | ||
final var warpLensStack = new ItemStack(firstLensType); | ||
final var forceLensStack = new ItemStack(secondLensType); | ||
final var compositeLens = ((LensItem) warpLensStack.getItem()).setCompositeLens(warpLensStack, forceLensStack); | ||
final var spreaderEntity = TestingUtil.assertBlockEntity(helper, SPREADER_POS, BotaniaBlockEntities.SPREADER); | ||
spreaderEntity.getItemHandler().setItem(0, compositeLens); | ||
|
||
TestingUtil.bindWithWandOfTheForest(helper, SPREADER_POS, SPREADER_TARGET_POS); | ||
TestingUtil.bindForceRelayTarget(helper, RELAY_POS, BOUND_POS); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/resources/data/botania/gametest/structures/item/lens/force_warp_relay_interaction.snbt
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,23 @@ | ||
{ | ||
DataVersion: 3465, | ||
size: [7, 3, 5], | ||
data: [ | ||
{pos: [1, 1, 1], state: "botania:redstone_spreader{has_scaffolding:false,waterlogged:false}"}, | ||
{pos: [1, 1, 2], state: "minecraft:polished_andesite"}, | ||
{pos: [1, 1, 3], state: "minecraft:polished_blackstone_button{face:wall,facing:south,powered:false}"}, | ||
{pos: [3, 1, 1], state: "botania:piston_relay"}, | ||
{pos: [3, 1, 3], state: "minecraft:polished_andesite"}, | ||
{pos: [6, 1, 1], state: "minecraft:obsidian"}, | ||
{pos: [6, 1, 3], state: "minecraft:obsidian"}, | ||
{pos: [1, 2, 1], state: "botania:creative_pool{color:none,waterlogged:false}"} | ||
], | ||
entities: [], | ||
palette: [ | ||
"minecraft:polished_andesite", | ||
"botania:piston_relay", | ||
"minecraft:obsidian", | ||
"minecraft:polished_blackstone_button{face:wall,facing:south,powered:false}", | ||
"botania:redstone_spreader{has_scaffolding:false,waterlogged:false}", | ||
"botania:creative_pool{color:none,waterlogged:false}" | ||
] | ||
} |