Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 19:10:07 +01:00
Added a test case for BlockData.
Fixed some non-breaking inaccuracies to make the test case work.
Dieser Commit ist enthalten in:
Ursprung
63fa72af5e
Commit
93f36955ca
@ -145,13 +145,13 @@ public final class BlockData {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BlockID.TRAP_DOOR:
|
case BlockID.TRAP_DOOR:
|
||||||
int open = data & 0x4;
|
int withoutOrientation = data & ~0x3;
|
||||||
int withoutOpen = data & ~0x4;
|
int orientation = data & 0x3;
|
||||||
switch (withoutOpen) {
|
switch (orientation) {
|
||||||
case 0: return 3 | open;
|
case 0: return 3 | withoutOrientation;
|
||||||
case 1: return 2 | open;
|
case 1: return 2 | withoutOrientation;
|
||||||
case 2: return 0 | open;
|
case 2: return 0 | withoutOrientation;
|
||||||
case 3: return 1 | open;
|
case 3: return 1 | withoutOrientation;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -302,13 +302,13 @@ public final class BlockData {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BlockID.TRAP_DOOR:
|
case BlockID.TRAP_DOOR:
|
||||||
int open = data & 0x4;
|
int withoutOrientation = data & ~0x3;
|
||||||
int withoutOpen = data & ~0x4;
|
int orientation = data & 0x3;
|
||||||
switch (withoutOpen) {
|
switch (orientation) {
|
||||||
case 3: return 0 | open;
|
case 3: return 0 | withoutOrientation;
|
||||||
case 2: return 1 | open;
|
case 2: return 1 | withoutOrientation;
|
||||||
case 0: return 2 | open;
|
case 0: return 2 | withoutOrientation;
|
||||||
case 1: return 3 | open;
|
case 1: return 3 | withoutOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BlockID.PISTON_BASE:
|
case BlockID.PISTON_BASE:
|
||||||
@ -380,6 +380,10 @@ 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)
|
||||||
|
break;
|
||||||
|
/* FALL-THROUGH */
|
||||||
|
|
||||||
case BlockID.LEVER:
|
case BlockID.LEVER:
|
||||||
case BlockID.STONE_BUTTON:
|
case BlockID.STONE_BUTTON:
|
||||||
switch (data & ~0x8) {
|
switch (data & ~0x8) {
|
||||||
@ -470,6 +474,10 @@ public final class BlockData {
|
|||||||
|
|
||||||
case BlockID.PUMPKIN:
|
case BlockID.PUMPKIN:
|
||||||
case BlockID.JACKOLANTERN:
|
case BlockID.JACKOLANTERN:
|
||||||
|
if (data > 3)
|
||||||
|
break;
|
||||||
|
/* FALL-THROUGH */
|
||||||
|
|
||||||
case BlockID.REDSTONE_REPEATER_OFF:
|
case BlockID.REDSTONE_REPEATER_OFF:
|
||||||
case BlockID.REDSTONE_REPEATER_ON:
|
case BlockID.REDSTONE_REPEATER_ON:
|
||||||
switch (data & 0x3) {
|
switch (data & 0x3) {
|
||||||
|
49
src/test/java/com/sk89q/worldedit/data/BlockDataTest.java
Normale Datei
49
src/test/java/com/sk89q/worldedit/data/BlockDataTest.java
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.data;
|
||||||
|
|
||||||
|
import org.junit.*;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
public class BlockDataTest {
|
||||||
|
@Test
|
||||||
|
public void testSlice() {
|
||||||
|
for (int type = 0; type < 256; ++type) {
|
||||||
|
for (int data = 0; data < 16; ++data) {
|
||||||
|
final String message = type+"/"+data;
|
||||||
|
|
||||||
|
assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90Reverse(type, data)));
|
||||||
|
assertEquals(message, data, BlockData.rotate90Reverse(type, BlockData.rotate90(type, data)));
|
||||||
|
|
||||||
|
int flipped = BlockData.flip(type, BlockData.flip(type, data, FlipDirection.WEST_EAST), FlipDirection.NORTH_SOUTH);
|
||||||
|
|
||||||
|
assertEquals(message, flipped, BlockData.rotate90(type, BlockData.rotate90(type, data)));
|
||||||
|
assertEquals(message, flipped, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, data)));
|
||||||
|
|
||||||
|
assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.NORTH_SOUTH), FlipDirection.NORTH_SOUTH));
|
||||||
|
assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.WEST_EAST), FlipDirection.WEST_EAST));
|
||||||
|
assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.UP_DOWN), FlipDirection.UP_DOWN));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren