This commit is contained in:
Wizjany 2011-09-25 14:07:49 -04:00
parent c6c55c3b2a
commit 903abc80a4
2 changed files with 21 additions and 52 deletions

View File

@ -174,7 +174,7 @@ public final class BlockData {
case BlockID.VINE: case BlockID.VINE:
return ((data << 1) | (data >> 3)) & 0xf; return ((data << 1) | (data >> 3)) & 0xf;
case BlockID.FENCE_GATE: case BlockID.FENCE_GATE:
return ((data + 1) & 0x3) | (data & ~0x3); return ((data + 1) & 0x3) | (data & ~0x3);
@ -216,13 +216,14 @@ public final class BlockData {
case BlockID.POWERED_RAIL: case BlockID.POWERED_RAIL:
case BlockID.DETECTOR_RAIL: case BlockID.DETECTOR_RAIL:
int power = data & ~0x7;
switch (data & 0x7) { switch (data & 0x7) {
case 1: return 0 | (data & ~0x7); case 1: return 0 | power;
case 0: return 1 | (data & ~0x7); case 0: return 1 | power;
case 5: return 2 | (data & ~0x7); case 5: return 2 | power;
case 4: return 3 | (data & ~0x7); case 4: return 3 | power;
case 2: return 4 | (data & ~0x7); case 2: return 4 | power;
case 3: return 5 | (data & ~0x7); case 3: return 5 | power;
} }
break; break;
@ -380,8 +381,7 @@ public final class BlockData {
case BlockID.TORCH: case BlockID.TORCH:
case BlockID.REDSTONE_TORCH_OFF: case BlockID.REDSTONE_TORCH_OFF:
case BlockID.REDSTONE_TORCH_ON: case BlockID.REDSTONE_TORCH_ON:
if (data > 4) if (data > 4) break;
break;
/* FALL-THROUGH */ /* FALL-THROUGH */
case BlockID.LEVER: case BlockID.LEVER:
@ -409,11 +409,9 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data; return data;
case 2: case 2:
case 3: case 3:
return data ^ flipX; return data ^ flipX;
case 4: case 4:
case 5: case 5:
return data ^ flipZ; return data ^ flipZ;
@ -428,7 +426,6 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data ^ flipX; return data ^ flipX;
case 2: case 2:
case 3: case 3:
return data ^ flipZ; return data ^ flipZ;
@ -450,7 +447,6 @@ public final class BlockData {
switch (direction) { switch (direction) {
case NORTH_SOUTH: case NORTH_SOUTH:
return (16 - data) & 0xf; return (16 - data) & 0xf;
case WEST_EAST: case WEST_EAST:
return (8 - data) & 0xf; return (8 - data) & 0xf;
} }
@ -465,7 +461,6 @@ public final class BlockData {
case 2: case 2:
case 3: case 3:
return data ^ flipZ; return data ^ flipZ;
case 4: case 4:
case 5: case 5:
return data ^ flipX; return data ^ flipX;
@ -474,8 +469,7 @@ public final class BlockData {
case BlockID.PUMPKIN: case BlockID.PUMPKIN:
case BlockID.JACKOLANTERN: case BlockID.JACKOLANTERN:
if (data > 3) if (data > 3) break;
break;
/* FALL-THROUGH */ /* FALL-THROUGH */
case BlockID.REDSTONE_REPEATER_OFF: case BlockID.REDSTONE_REPEATER_OFF:
@ -484,7 +478,6 @@ public final class BlockData {
case 0: case 0:
case 2: case 2:
return data ^ (flipZ << 1); return data ^ (flipZ << 1);
case 1: case 1:
case 3: case 3:
return data ^ (flipX << 1); return data ^ (flipX << 1);
@ -496,7 +489,6 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data ^ flipZ; return data ^ flipZ;
case 2: case 2:
case 3: case 3:
return data ^ flipX; return data ^ flipX;
@ -510,11 +502,9 @@ public final class BlockData {
case 0: case 0:
case 1: case 1:
return data ^ flipY; return data ^ flipY;
case 2: case 2:
case 3: case 3:
return data ^ flipZ; return data ^ flipZ;
case 4: case 4:
case 5: case 5:
return data ^ flipX; return data ^ flipX;
@ -554,19 +544,16 @@ public final class BlockData {
bit1 = 0x2; bit1 = 0x2;
bit2 = 0x8; bit2 = 0x8;
break; break;
case WEST_EAST: case WEST_EAST:
bit1 = 0x1; bit1 = 0x1;
bit2 = 0x4; bit2 = 0x4;
break; break;
default: default:
return data; return data;
} }
int newData = data & ~(bit1 | bit2); int newData = data & ~(bit1 | bit2);
if ((data & bit1) != 0) newData |= bit2; if ((data & bit1) != 0) newData |= bit2;
if ((data & bit2) != 0) newData |= bit1; if ((data & bit2) != 0) newData |= bit1;
return newData; return newData;
case BlockID.FENCE_GATE: case BlockID.FENCE_GATE:
@ -574,12 +561,12 @@ public final class BlockData {
case 0: case 0:
case 2: case 2:
return data ^ flipZ * 2; return data ^ flipZ * 2;
case 1: case 1:
case 3: case 3:
return data ^ flipX * 2; return data ^ flipX * 2;
} }
break; break;
} }
return data; return data;
@ -596,12 +583,12 @@ public final class BlockData {
* @return the new data value for the block * @return the new data value for the block
*/ */
public static int cycle(int type, int data, int increment) { public static int cycle(int type, int data, int increment) {
int store;
switch (type) { switch (type) {
case BlockID.LOG: case BlockID.LOG:
case BlockID.LONG_GRASS: case BlockID.LONG_GRASS:
case BlockID.STONE_BRICK: case BlockID.STONE_BRICK:
case BlockID.SILVERFISH_BLOCK: case BlockID.SILVERFISH_BLOCK:
if (data > 2) return -1;
return (data + increment) % 3; return (data + increment) % 3;
case BlockID.TORCH: case BlockID.TORCH:
@ -616,30 +603,24 @@ public final class BlockData {
case BlockID.STONE_BRICK_STAIRS: case BlockID.STONE_BRICK_STAIRS:
case BlockID.PUMPKIN: case BlockID.PUMPKIN:
case BlockID.JACKOLANTERN: case BlockID.JACKOLANTERN:
case BlockID.TRAP_DOOR:
if (data > 3) return -1;
return (data + increment) % 4; return (data + increment) % 4;
case BlockID.STEP: case BlockID.STEP:
case BlockID.DOUBLE_STEP: case BlockID.DOUBLE_STEP:
case BlockID.CAKE_BLOCK: case BlockID.CAKE_BLOCK:
if (data > 5) return -1;
return (data + increment) % 6; return (data + increment) % 6;
case BlockID.CROPS: case BlockID.CROPS:
case BlockID.PUMPKIN_STEM: case BlockID.PUMPKIN_STEM:
case BlockID.MELON_STEM: case BlockID.MELON_STEM:
if (data > 6) return -1;
return (data + increment) % 7; return (data + increment) % 7;
case BlockID.SOIL: case BlockID.SOIL:
case BlockID.SNOW: case BlockID.SNOW:
if (data > 8) return -1;
return (data + increment) % 9; return (data + increment) % 9;
case BlockID.RED_MUSHROOM_CAP: case BlockID.RED_MUSHROOM_CAP:
case BlockID.BROWN_MUSHROOM_CAP: case BlockID.BROWN_MUSHROOM_CAP:
if (data > 10) return -1;
return (data + increment) % 11; return (data + increment) % 11;
case BlockID.CACTUS: case BlockID.CACTUS:
@ -654,29 +635,23 @@ public final class BlockData {
case BlockID.WALL_SIGN: case BlockID.WALL_SIGN:
case BlockID.LADDER: case BlockID.LADDER:
case BlockID.CHEST: case BlockID.CHEST:
if (data < 2 || data > 5) return -1;
return (data - 2 + increment) % 4 + 2; return (data - 2 + increment) % 4 + 2;
case BlockID.REDSTONE_REPEATER_OFF: case BlockID.REDSTONE_REPEATER_OFF:
case BlockID.REDSTONE_REPEATER_ON: { case BlockID.REDSTONE_REPEATER_ON:
int orientation = data & 0x3; case BlockID.TRAP_DOOR:
int withoutOrientation = data & ~0x3; case BlockID.FENCE_GATE:
return (orientation + increment) % 4 | withoutOrientation; case BlockID.LEAVES:
} store = data & ~0x3;
return ((data & 0x3) + increment) % 4 | store;
case BlockID.MINECART_TRACKS: case BlockID.MINECART_TRACKS:
if (data < 6 || data > 9) return -1; if (data < 6 || data > 9) return -1;
return (data - 6 + increment) % 4 + 6; return (data - 6 + increment) % 4 + 6;
case BlockID.SAPLING: case BlockID.SAPLING:
int saplingType = data & 0x3; store = data & ~0x3;
int withoutType = data & ~0x3; return ((data & 0x3) + increment) % 3 | store;
return (saplingType + increment) % 3 | withoutType;
case BlockID.LEAVES:
int tree = data & 0x3;
int withoutTree = data & ~0x3;
return (tree + increment) % 4 | withoutTree;
case BlockID.CLOTH: case BlockID.CLOTH:
if (increment > 0) { if (increment > 0) {
@ -688,12 +663,6 @@ public final class BlockData {
} }
return data; return data;
case BlockID.FENCE_GATE: {
int orientation = data & 0x3;
int withoutOrientation = data & ~0x3;
return (orientation + increment) % 4 | withoutOrientation;
}
default: default:
return -1; return -1;
} }

View File

@ -237,7 +237,7 @@ commands:
description: Block information tool description: Block information tool
usage: /<command> usage: /<command>
none: none:
description: Turn off all superpickaxe alternate modes description: Unbind all bound tools
usage: /<command> usage: /<command>
tree: tree:
description: Tree generator tool description: Tree generator tool