use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testPacketByteBuf.
@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseIdentifier.class, ParseDyeColor.class, Boolean.class }, jsons = { "(1|2|0), (0|0|0), overworld, red, true", "(-1020|30|10), (-1000|100|20), end, blue, false", "(1|2|0), (0|256|0), overworld, red, true", "(1400|2|-6000), (1200|32|-5000), nether, red, true" })
void testPacketByteBuf(final BlockPos bp0, final BlockPos bp1, final Identifier dimension, final DyeColor color, final boolean finished) {
final PacketByteBuf expectedBuf = new PacketByteBuf(Unpooled.buffer());
expectedBuf.writeBlockPos(bp0);
expectedBuf.writeBlockPos(bp1);
expectedBuf.writeIdentifier(dimension);
expectedBuf.writeInt(color.getId());
expectedBuf.writeBoolean(finished);
expectedBuf.writeInt(0);
expectedBuf.writeInt(0);
final ClientMeasureBox mb = ClientMeasureBox.fromPacketByteBuf(expectedBuf);
final PacketByteBuf actualBuf = new PacketByteBuf(Unpooled.buffer());
mb.writePacketBuf(actualBuf);
expectedBuf.resetReaderIndex();
assertThat(expectedBuf).isEqualTo(actualBuf);
}
use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testIsCorner.
@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class }, jsons = { "(0|0|0), (10|10|10), (0|0|10), (0|10|0), (0|10|10), (10|0|0), (10|0|10), (10|10|0)", "(-30|5|25), (-90|2|50), (-30|5|50), (-30|2|25), (-30|2|50), (-90|5|25), (-90|5|50), (-90|2|25)" })
void testIsCorner(BlockPos bp0, BlockPos bp1, BlockPos bp2, BlockPos bp3, BlockPos bp4, BlockPos bp5, BlockPos bp6, BlockPos bp7) {
try (MockedStatic<BlockMeterClient> client = getBMC()) {
final ClientMeasureBox box = ClientMeasureBox.getBox(bp0, OVERWORLD_ID);
box.setBlockEnd(bp1);
assertThat(box.isCorner(bp0));
assertThat(box.isCorner(bp1));
assertThat(box.isCorner(bp2));
assertThat(box.isCorner(bp3));
assertThat(box.isCorner(bp4));
assertThat(box.isCorner(bp5));
assertThat(box.isCorner(bp6));
assertThat(box.isCorner(bp7));
}
}
use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testSetBlockEnd.
@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class }, jsons = { "(0|0|0), (0|0|0)", "(-10|0|10000), (-500|0|10200)" })
void testSetBlockEnd(final BlockPos bp0, final BlockPos bp1) {
try (MockedStatic<BlockMeterClient> client = getBMC()) {
final ClientMeasureBox box = ClientMeasureBox.getBox(bp0, OVERWORLD_ID);
box.setBlockEnd(bp1);
assertThat(box.getBlockStart()).isEqualTo(bp0);
assertThat(box.getBlockEnd()).isEqualTo(bp1);
}
}
use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testSetColor.
@ParameterizedTest
@JSONSource(classes = { ParseDyeColor.class }, jsons = { "red", "black", "green", "blue" })
void testSetColor(final DyeColor color) {
try (MockedStatic<BlockMeterClient> client = getBMC()) {
final ClientMeasureBox box = ClientMeasureBox.getBox(new BlockPos(0, 0, 0), OVERWORLD_ID);
box.setColor(color);
assertThat(box.getColor()).isEqualTo(color);
}
}
use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testLoosenCorner.
@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseBlockPos.class }, jsons = { "(0|1|2), (3|4|5), (0|4|2)" })
void testLoosenCorner(BlockPos bp0, BlockPos bp1, BlockPos newBp0) {
try (MockedStatic<BlockMeterClient> client = getBMC()) {
final ClientMeasureBox box = ClientMeasureBox.getBox(bp0, OVERWORLD_ID);
box.setBlockEnd(bp1);
box.setFinished();
box.loosenCorner(newBp0);
assertThat(box.isCorner(bp0)).isTrue();
assertThat(box.isCorner(bp1)).isTrue();
assertThat(box.getBlockEnd()).isEqualTo(newBp0);
assertThat(box.isFinished()).isFalse();
}
}
Aggregations