Search in sources :

Example 6 with JSONSource

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);
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockPos(net.minecraft.util.math.BlockPos) ParseBlockPos(de.modprog.blockmeter.util.parser.ParseBlockPos) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with JSONSource

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);
    }
}
Also used : ClientMeasureBox(win.baruna.blockmeter.measurebox.ClientMeasureBox) BlockMeterClient(win.baruna.blockmeter.BlockMeterClient) ModConfig(win.baruna.blockmeter.ModConfig) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with JSONSource

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);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) MeasureBox(win.baruna.blockmeter.measurebox.MeasureBox) JSONSource(de.modprog.blockmeter.util.JSONSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

JSONSource (de.modprog.blockmeter.util.JSONSource)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 ClientMeasureBox (win.baruna.blockmeter.measurebox.ClientMeasureBox)7 BlockMeterClient (win.baruna.blockmeter.BlockMeterClient)6 ParseBlockPos (de.modprog.blockmeter.util.parser.ParseBlockPos)2 PacketByteBuf (net.minecraft.network.PacketByteBuf)2 BlockPos (net.minecraft.util.math.BlockPos)2 ModConfig (win.baruna.blockmeter.ModConfig)1 MeasureBox (win.baruna.blockmeter.measurebox.MeasureBox)1