Archived
0

добавлен BlockLocationSerializer

This commit is contained in:
2018-09-08 17:04:58 +03:00
parent ad31a90455
commit debb75a080
3 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package mc.core.network.proto_1_12_2.serializers;
import mc.core.world.block.BlockLocation;
import org.junit.Before;
import org.junit.Test;
import java.util.concurrent.ThreadLocalRandom;
import static org.junit.Assert.*;
public class TestBlockLocationSerializer {
private static final ThreadLocalRandom rnd = ThreadLocalRandom.current();
private static final int minI = 0, maxI = 10;
private int x, y, z;
@Before
public void before() {
x = rnd.nextInt(minI, maxI);
y = rnd.nextInt(minI, maxI);
z = rnd.nextInt(minI, maxI);
}
@Test
public void test() {
BlockLocation location = new BlockLocation(x, y, z);
final long serializedCoords = BlockLocationSerializer.toLong(location);
BlockLocation deserLoc = BlockLocationSerializer.fromLong(serializedCoords);
assertEquals(location, deserLoc);
}
}