-
-
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.
Added test case for horizontal spreader aim hitting pool
- Loading branch information
1 parent
fd33456
commit 893d586
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Xplat/src/main/java/vazkii/botania/test/block/ManaSpreaderTest.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,49 @@ | ||
package vazkii.botania.test.block; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.gametest.framework.GameTest; | ||
import net.minecraft.gametest.framework.GameTestHelper; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; | ||
import vazkii.botania.common.item.BotaniaItems; | ||
import vazkii.botania.test.TestingUtil; | ||
|
||
public class ManaSpreaderTest { | ||
private static final String[] SPREADERS = { "Pulse Spreader", "Mana Spreader", "Elven Spreader", "Gaia Spreader" }; | ||
private static final int NUM_SPREADERS = 4; | ||
private static final BlockPos SPREADER_POS = new BlockPos(2, 1, 1); | ||
private static final BlockPos POOL_POS = new BlockPos(3, 1, 1); | ||
private static final BlockPos SINK_POS = new BlockPos(4, 1, 1); | ||
private static final BlockPos LEVER_POS = new BlockPos(1, 2, 2); | ||
|
||
@GameTest(template = "botania:block/spreader_pool_default_aim") | ||
public void testSpreaderDefaultAimHittingPool(GameTestHelper helper) { | ||
var player = helper.makeMockPlayer(); | ||
|
||
// point the spreaders at their corresponding sink block to aim them exactly horizontally | ||
for (int i = 0; i < NUM_SPREADERS; i++) { | ||
var spreaderName = SPREADERS[i]; | ||
var pool = TestingUtil.assertBlockEntity(helper, POOL_POS.south(i), BotaniaBlockEntities.POOL); | ||
TestingUtil.assertEquals(pool.getCurrentMana(), 0, () -> String.format("Pool for %s does not start empty", spreaderName)); | ||
var spreader = TestingUtil.assertBlockEntity(helper, SPREADER_POS.south(i), BotaniaBlockEntities.SPREADER); | ||
var bindPos = SINK_POS.south(i); | ||
TestingUtil.assertThat(spreader.bindTo(player, new ItemStack(BotaniaItems.twigWand), helper.absolutePos(bindPos), Direction.UP), | ||
() -> "Failed to bind spreader"); | ||
} | ||
|
||
helper.startSequence() | ||
.thenExecute(() -> helper.pullLever(LEVER_POS)) | ||
.thenExecuteAfter(10, () -> { | ||
for (int i = 0; i < NUM_SPREADERS; i++) { | ||
var spreaderName = SPREADERS[i]; | ||
var pool = TestingUtil.assertBlockEntity(helper, POOL_POS.south(i), BotaniaBlockEntities.POOL); | ||
var sink = TestingUtil.assertBlockEntity(helper, SINK_POS.south(i), BotaniaBlockEntities.FLUXFIELD); | ||
TestingUtil.assertThat(pool.getCurrentMana() > 0, () -> String.format("Pool for %s did not receive mana", spreaderName)); | ||
TestingUtil.assertEquals(sink.getCurrentMana(), 0, () -> String.format("Sink for %s should not have received", spreaderName)); | ||
} | ||
}) | ||
.thenSucceed(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
.../src/main/resources/data/botania/gametest/structures/block/spreader_pool_default_aim.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,46 @@ | ||
{ | ||
DataVersion: 3465, | ||
size: [6, 3, 6], | ||
data: [ | ||
{pos: [1, 0, 1], state: "botania:creative_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 1000000, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [1, 0, 2], state: "botania:creative_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 1000000, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [1, 0, 3], state: "botania:creative_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 1000000, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [1, 0, 4], state: "botania:creative_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 1000000, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [2, 0, 1], state: "botania:redstone_spreader{has_scaffolding:false,waterlogged:false}", nbt: {Items: [], canShootBurst: 1b, forceClientBindingX: 4, forceClientBindingY: -62, forceClientBindingZ: -3, id: "botania:mana_spreader", inputKey: "", lastPingbackX: 3.9000000059604645d, lastPingbackY: -61.5009765625d, lastPingbackZ: -2.5d, mana: 1000, mapmakerOverrideEnabled: 0b, mmForcedColor: 2162464, mmForcedGravity: 0.0f, mmForcedManaLossPerTick: 4.0f, mmForcedManaPayload: 160, mmForcedTicksBeforeManaLoss: 60, mmForcedVelocityMultiplier: 1.0f, outputKey: "", paddingColor: -1, pingbackTicks: 19, requestUpdate: 0b, rotationX: 180.0f, rotationY: 0.0f, uuid: [I; 1197996910, 37110511, -1332266059, 2023092097]}}, | ||
{pos: [2, 0, 2], state: "botania:mana_spreader{has_scaffolding:false,waterlogged:false}", nbt: {Items: [], canShootBurst: 1b, forceClientBindingX: 4, forceClientBindingY: -62, forceClientBindingZ: -2, id: "botania:mana_spreader", inputKey: "", lastPingbackX: 3.9000000059604645d, lastPingbackY: -61.5009765625d, lastPingbackZ: -1.5d, mana: 1000, mapmakerOverrideEnabled: 0b, mmForcedColor: 2162464, mmForcedGravity: 0.0f, mmForcedManaLossPerTick: 4.0f, mmForcedManaPayload: 160, mmForcedTicksBeforeManaLoss: 60, mmForcedVelocityMultiplier: 1.0f, outputKey: "", paddingColor: -1, pingbackTicks: 19, requestUpdate: 0b, rotationX: 180.0f, rotationY: 0.0f, uuid: [I; -709175232, -159036345, -1425230208, 1411459669]}}, | ||
{pos: [2, 0, 3], state: "botania:elven_spreader{has_scaffolding:false,waterlogged:false}", nbt: {Items: [], canShootBurst: 1b, forceClientBindingX: 4, forceClientBindingY: -62, forceClientBindingZ: -1, id: "botania:mana_spreader", inputKey: "", lastPingbackX: 4.000000007450581d, lastPingbackY: -61.5009765625d, lastPingbackZ: -0.5d, mana: 1000, mapmakerOverrideEnabled: 0b, mmForcedColor: 2162464, mmForcedGravity: 0.0f, mmForcedManaLossPerTick: 4.0f, mmForcedManaPayload: 160, mmForcedTicksBeforeManaLoss: 60, mmForcedVelocityMultiplier: 1.0f, outputKey: "", paddingColor: -1, pingbackTicks: 19, requestUpdate: 0b, rotationX: 180.0f, rotationY: 0.0f, uuid: [I; -1914231656, -1630650199, -1195737549, -742894024]}}, | ||
{pos: [2, 0, 4], state: "botania:gaia_spreader{has_scaffolding:false,waterlogged:false}", nbt: {Items: [], canShootBurst: 1b, forceClientBindingX: 4, forceClientBindingY: -62, forceClientBindingZ: 0, id: "botania:mana_spreader", inputKey: "", lastPingbackX: 3.9000000059604645d, lastPingbackY: -61.5009765625d, lastPingbackZ: 0.49999999999999994d, mana: 6400, mapmakerOverrideEnabled: 0b, mmForcedColor: 2162464, mmForcedGravity: 0.0f, mmForcedManaLossPerTick: 4.0f, mmForcedManaPayload: 160, mmForcedTicksBeforeManaLoss: 60, mmForcedVelocityMultiplier: 1.0f, outputKey: "", paddingColor: -1, pingbackTicks: 19, requestUpdate: 0b, rotationX: 180.0f, rotationY: 0.0f, uuid: [I; -2116016121, -309506703, -1242831366, -191133179]}}, | ||
{pos: [3, 0, 1], state: "botania:mana_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 0, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [3, 0, 2], state: "botania:mana_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 0, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [3, 0, 3], state: "botania:mana_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 0, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [3, 0, 4], state: "botania:mana_pool{color:none,waterlogged:false}", nbt: {canAccept: 1b, canSpare: 1b, id: "botania:mana_pool", inputKey: "", mana: 0, manaCap: 1000000, outputKey: "", outputting: 0b}}, | ||
{pos: [4, 0, 1], state: "botania:mana_fluxfield", nbt: {id: "botania:mana_fluxfield", mana: 0}}, | ||
{pos: [4, 0, 2], state: "botania:mana_fluxfield", nbt: {id: "botania:mana_fluxfield", mana: 0}}, | ||
{pos: [4, 0, 3], state: "botania:mana_fluxfield", nbt: {id: "botania:mana_fluxfield", mana: 0}}, | ||
{pos: [4, 0, 4], state: "botania:mana_fluxfield", nbt: {id: "botania:mana_fluxfield", mana: 0}}, | ||
{pos: [1, 1, 2], state: "minecraft:lever{face:wall,facing:west,powered:true}"}, | ||
{pos: [2, 1, 1], state: "minecraft:redstone_wall_torch{facing:north,lit:false}"}, | ||
{pos: [2, 1, 2], state: "minecraft:polished_andesite"}, | ||
{pos: [2, 1, 3], state: "minecraft:polished_andesite"}, | ||
{pos: [2, 1, 4], state: "minecraft:polished_andesite"}, | ||
{pos: [2, 2, 2], state: "minecraft:redstone_wire{east:none,north:side,power:15,south:side,west:none}"}, | ||
{pos: [2, 2, 3], state: "minecraft:redstone_wire{east:none,north:side,power:14,south:side,west:none}"}, | ||
{pos: [2, 2, 4], state: "minecraft:redstone_wire{east:none,north:side,power:13,south:side,west:none}"} | ||
], | ||
entities: [], | ||
palette: [ | ||
"minecraft:polished_andesite", | ||
"minecraft:lever{face:wall,facing:west,powered:true}", | ||
"minecraft:redstone_wall_torch{facing:north,lit:false}", | ||
"minecraft:redstone_wire{east:none,north:side,power:15,south:side,west:none}", | ||
"minecraft:redstone_wire{east:none,north:side,power:14,south:side,west:none}", | ||
"minecraft:redstone_wire{east:none,north:side,power:13,south:side,west:none}", | ||
"botania:creative_pool{color:none,waterlogged:false}", | ||
"botania:redstone_spreader{has_scaffolding:false,waterlogged:false}", | ||
"botania:mana_spreader{has_scaffolding:false,waterlogged:false}", | ||
"botania:elven_spreader{has_scaffolding:false,waterlogged:false}", | ||
"botania:gaia_spreader{has_scaffolding:false,waterlogged:false}", | ||
"botania:mana_pool{color:none,waterlogged:false}", | ||
"botania:mana_fluxfield" | ||
] | ||
} |