use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testSetColorIndex.
@ParameterizedTest
@JSONSource(classes = { ParseDyeColor.class }, jsons = { "red", "blue", "white", "black" })
void testSetColorIndex(DyeColor color) {
try (MockedStatic<BlockMeterClient> client = getBMC()) {
ClientMeasureBox.setColorIndex(color.getId());
final ClientMeasureBox box = ClientMeasureBox.getBox(new BlockPos(0, 0, 0), OVERWORLD_ID);
assertThat(box.getColor()).isEqualTo(color);
}
}
use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class ClientMeasureBoxTest method testGetMeasureBox.
@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseIdentifier.class, ParseDyeColor.class, Boolean.class }, jsons = { "(1|2|3), overworld, blue, true", "(-10|200|3123), nether, black, false", "(-112312|100|33), end, red, true" })
void testGetMeasureBox(final BlockPos bp, final Identifier id, final DyeColor color, final boolean incrementColor) {
try (MockedStatic<BlockMeterClient> client = getBMC()) {
final ModConfig config = BlockMeterClient.getConfigManager().getConfig();
config.colorIndex = color.getId();
config.incrementColor = incrementColor;
final ClientMeasureBox box = ClientMeasureBox.getBox(bp, id);
assertThat(box.getBlockStart()).isEqualTo(bp);
assertThat(box.getBlockEnd()).isEqualTo(bp);
assertThat(box.getDimension()).isEqualTo(id);
assertThat(box.isFinished()).isFalse();
assertThat(box.getColor()).isEqualTo(color);
if (!incrementColor)
assertThat(DyeColor.byId(config.colorIndex)).isEqualTo(color);
else
assertThat(DyeColor.byId(config.colorIndex)).isNotEqualTo(color);
}
}
use of de.modprog.blockmeter.util.JSONSource in project BlockMeter by ModProg.
the class MeasureBoxTest method testPacketByteBuf.
@ParameterizedTest
@JSONSource(classes = { ParseBlockPos.class, ParseBlockPos.class, ParseIdentifier.class, ParseDyeColor.class, Boolean.class }, jsons = { "(11|2|-50), (0|0|0), overworld, red, true", "(10020|45|130), (10000|99|203), end, blue, false", "(17|0|40), (40|256|70), overworld, red, true", "(-1455|2|-6000), (-1455|32|-5000), overworld, red, true" })
void testPacketByteBuf(BlockPos bp1, BlockPos bp2, Identifier dimension, DyeColor color, boolean finished) {
final PacketByteBuf expectedBuf = new PacketByteBuf(Unpooled.buffer());
expectedBuf.writeBlockPos(bp1);
expectedBuf.writeBlockPos(bp2);
expectedBuf.writeIdentifier(dimension);
expectedBuf.writeInt(color.getId());
expectedBuf.writeBoolean(finished);
expectedBuf.writeInt(0);
expectedBuf.writeInt(0);
final MeasureBox mb = MeasureBox.fromPacketByteBuf(expectedBuf);
final PacketByteBuf actualBuf = new PacketByteBuf(Unpooled.buffer());
mb.writePacketBuf(actualBuf);
expectedBuf.resetReaderIndex();
assertThat(expectedBuf).isEqualTo(actualBuf);
}
Aggregations