Fix button rotation, add support for up/down flipping and restore unit test functionality.

Dieser Commit ist enthalten in:
wizjany 2015-01-23 00:28:05 -05:00
Ursprung ec9c77c31b
Commit ddc741147e
4 geänderte Dateien mit 59 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -95,12 +95,22 @@ public final class BlockData {
}
break;
case BlockID.LEVER:
case BlockID.STONE_BUTTON:
case BlockID.WOODEN_BUTTON:
case BlockID.WOODEN_BUTTON: {
int thrown = data & 0x8;
int withoutThrown = data & ~0x8;
switch (withoutThrown) {
switch (data & ~0x8) {
case 1: return 3 | thrown;
case 2: return 4 | thrown;
case 3: return 2 | thrown;
case 4: return 1 | thrown;
// 0 and 5 are vertical
}
break;
}
case BlockID.LEVER: {
int thrown = data & 0x8;
switch (data & ~0x8) {
case 1: return 3 | thrown;
case 2: return 4 | thrown;
case 3: return 2 | thrown;
@ -111,6 +121,7 @@ public final class BlockData {
case 0: return 7 | thrown;
}
break;
}
case BlockID.WOODEN_DOOR:
case BlockID.IRON_DOOR:
@ -316,12 +327,22 @@ public final class BlockData {
}
break;
case BlockID.LEVER:
case BlockID.STONE_BUTTON:
case BlockID.WOODEN_BUTTON:
case BlockID.WOODEN_BUTTON: {
int thrown = data & 0x8;
int withoutThrown = data & ~0x8;
switch (withoutThrown) {
switch (data & ~0x8) {
case 3: return 1 | thrown;
case 4: return 2 | thrown;
case 2: return 3 | thrown;
case 1: return 4 | thrown;
// 0 and 5 are vertical
}
break;
}
case BlockID.LEVER: {
int thrown = data & 0x8;
switch (data & ~0x8) {
case 3: return 1 | thrown;
case 4: return 2 | thrown;
case 2: return 3 | thrown;
@ -332,6 +353,7 @@ public final class BlockData {
case 7: return 0 | thrown;
}
break;
}
case BlockID.WOODEN_DOOR:
case BlockID.IRON_DOOR:
@ -509,11 +531,29 @@ public final class BlockData {
case BlockID.REDSTONE_TORCH_OFF:
case BlockID.REDSTONE_TORCH_ON:
if (data < 1 || data > 4) break;
/* FALL-THROUGH */
switch (data) {
case 1: return data + flipX;
case 2: return data - flipX;
case 3: return data + flipZ;
case 4: return data - flipZ;
}
break;
case BlockID.STONE_BUTTON:
case BlockID.WOODEN_BUTTON: {
switch (data & ~0x8) {
case 1: return data + flipX;
case 2: return data - flipX;
case 3: return data + flipZ;
case 4: return data - flipZ;
case 0:
case 5:
return data ^ (flipY * 5);
}
break;
}
case BlockID.LEVER:
case BlockID.STONE_BUTTON:
case BlockID.WOODEN_BUTTON:
switch (data & ~0x8) {
case 1: return data + flipX;
case 2: return data - flipX;

Datei anzeigen

@ -1842,6 +1842,10 @@ public enum BlockType {
addCardinals(BlockID.STONE_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2);
addCardinals(BlockID.WOODEN_BUTTON, offset + 4, offset + 1, offset + 3, offset + 2);
}
dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 0), PlayerDirection.UP);
dataAttachments.put(typeDataKey(BlockID.STONE_BUTTON, 5), PlayerDirection.DOWN);
dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 0), PlayerDirection.UP);
dataAttachments.put(typeDataKey(BlockID.WOODEN_BUTTON, 5), PlayerDirection.DOWN);
nonDataAttachments.put(BlockID.CACTUS, PlayerDirection.DOWN);
nonDataAttachments.put(BlockID.REED, PlayerDirection.DOWN);
nonDataAttachments.put(BlockID.CAKE_BLOCK, PlayerDirection.DOWN);

Datei anzeigen

@ -2755,8 +2755,8 @@
"values": {
"down": { "data": 0, "direction": [0, -1, 0] },
"east": { "data": 1, "direction": [1, 0, 0] },
"south": { "data": 2, "direction": [0, 0, 1] },
"west": { "data": 3, "direction": [-1, 0, 0] },
"west": { "data": 2, "direction": [-1, 0, 0] },
"south": { "data": 3, "direction": [0, 0, 1] },
"north": { "data": 4, "direction": [0, 0, -1] },
"up": { "data": 5, "direction": [0, 1, 0] }
}
@ -4943,8 +4943,8 @@
"values": {
"down": { "data": 0, "direction": [0, -1, 0] },
"east": { "data": 1, "direction": [1, 0, 0] },
"south": { "data": 2, "direction": [0, 0, 1] },
"west": { "data": 3, "direction": [-1, 0, 0] },
"west": { "data": 2, "direction": [-1, 0, 0] },
"south": { "data": 3, "direction": [0, 0, 1] },
"north": { "data": 4, "direction": [0, 0, -1] },
"up": { "data": 5, "direction": [0, 1, 0] }
}

Datei anzeigen

@ -46,8 +46,6 @@ public class BlockTransformExtentTest {
ignored.add(BlockType.BED); // Broken in existing rotation code?
ignored.add(BlockType.WOODEN_DOOR); // Complicated
ignored.add(BlockType.IRON_DOOR); // Complicated
ignored.add(BlockType.STONE_BUTTON); // Existing rotation code doesn't handle down/up directions
ignored.add(BlockType.WOODEN_BUTTON); // Existing rotation code doesn't handle down/up directions
ignored.add(BlockType.END_PORTAL); // Not supported in existing rotation code
}