mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-14 13:13:53 +00:00
Setup a legacy mapper system. The file does not exist yet.
This commit is contained in:
@ -61,80 +61,4 @@ public class BlockDataTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final TreeSet<Integer> datasTemplate = new TreeSet<Integer>();
|
||||
static {
|
||||
for (int data = 0; data < 16; ++data) {
|
||||
datasTemplate.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCycle() {
|
||||
// Test monotony and continuity
|
||||
for (int type = 0; type < 256; ++type) {
|
||||
// Cloth isn't monotonous, and thus excluded.
|
||||
if (type == BlockID.CLOTH
|
||||
|| type == BlockID.STAINED_CLAY
|
||||
|| type == BlockID.STAINED_GLASS
|
||||
|| type == BlockID.STAINED_GLASS_PANE
|
||||
|| type == BlockID.CARPET) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int data = 0; data < 16; ++data) {
|
||||
final String message = type + "/" + data;
|
||||
|
||||
final int cycled = BlockData.cycle(type, data, 1);
|
||||
|
||||
// If the cycle goes back (including -1), everything is ok.
|
||||
if (cycled <= data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there's a gap in the cycle, there's a problem.
|
||||
assertEquals(message, data + 1, cycled);
|
||||
}
|
||||
}
|
||||
|
||||
// Test cyclicity forwards
|
||||
testCycle(1);
|
||||
|
||||
// ...and backwards
|
||||
testCycle(-1);
|
||||
}
|
||||
|
||||
private static void testCycle(final int increment) {
|
||||
// Iterate each block type and data value that wasn't part of a cycle yet.
|
||||
for (int type = 0; type < 256; ++type) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final TreeSet<Integer> datas = (TreeSet<Integer>) datasTemplate.clone();
|
||||
while (!datas.isEmpty()) {
|
||||
final int start = datas.pollFirst();
|
||||
String message = type + "/" + start;
|
||||
int current = start;
|
||||
boolean first = true;
|
||||
while (true) {
|
||||
current = BlockData.cycle(type, current, increment);
|
||||
|
||||
// If the cycle immediately goes to -1, everything is ok.
|
||||
if (first && current == -1) break;
|
||||
|
||||
first = false;
|
||||
message += "->" + current;
|
||||
|
||||
// If the cycle goes off limits (including -1), there's a problem.
|
||||
assertTrue(message, current >= 0);
|
||||
assertTrue(message, current < 16);
|
||||
|
||||
// The cycle completes, everything is ok.
|
||||
if (current == start) break;
|
||||
|
||||
// Mark the current element as walked.
|
||||
assertTrue(message, datas.remove(current));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user