mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Add block transform test that tests against older rotation code.
Also fixes the rotations for some blocks.
This commit is contained in:
parent
9c205e0e00
commit
8508055ddc
@ -106,7 +106,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
||||
* @param registry the registry
|
||||
* @return the same block
|
||||
*/
|
||||
private static BaseBlock transform(BaseBlock block, Transform transform, BlockRegistry registry) {
|
||||
public static BaseBlock transform(BaseBlock block, Transform transform, BlockRegistry registry) {
|
||||
return transform(block, transform, registry, block);
|
||||
}
|
||||
|
||||
|
@ -919,7 +919,7 @@
|
||||
"facing": {
|
||||
"values": {
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"south": { "data": 1, "direction": [0, 0, 1] },
|
||||
"south": { "data": 0, "direction": [0, 0, 1] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"west": { "data": 1, "direction": [-1, 0, 0] },
|
||||
"east_ascending": { "data": 2, "direction": [1, 1, 0] },
|
||||
@ -929,6 +929,7 @@
|
||||
"north_ascending": { "data": 4, "direction": [0, 1, -1] },
|
||||
"north_descending": { "data": 4, "direction": [0, -1, 1] },
|
||||
"south_ascending": { "data": 5, "direction": [0, 1, 1] },
|
||||
"south_descending": { "data": 5, "direction": [0, -1, -1] },
|
||||
"southeast": { "data": 6, "direction": [1, 0, 1] },
|
||||
"southwest": { "data": 7, "direction": [-1, 0, 1] },
|
||||
"northwest": { "data": 8, "direction": [-1, 0, -1] },
|
||||
@ -969,7 +970,7 @@
|
||||
"facing": {
|
||||
"values": {
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"south": { "data": 1, "direction": [0, 0, 1] },
|
||||
"south": { "data": 0, "direction": [0, 0, 1] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"west": { "data": 1, "direction": [-1, 0, 0] },
|
||||
"east_ascending": { "data": 2, "direction": [1, 1, 0] },
|
||||
@ -979,6 +980,7 @@
|
||||
"north_ascending": { "data": 4, "direction": [0, 1, -1] },
|
||||
"north_descending": { "data": 4, "direction": [0, -1, 1] },
|
||||
"south_ascending": { "data": 5, "direction": [0, 1, 1] },
|
||||
"south_descending": { "data": 5, "direction": [0, -1, -1] },
|
||||
"southeast": { "data": 6, "direction": [1, 0, 1] },
|
||||
"southwest": { "data": 7, "direction": [-1, 0, 1] },
|
||||
"northwest": { "data": 8, "direction": [-1, 0, -1] },
|
||||
@ -2320,7 +2322,7 @@
|
||||
"facing": {
|
||||
"values": {
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"south": { "data": 1, "direction": [0, 0, 1] },
|
||||
"south": { "data": 0, "direction": [0, 0, 1] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"west": { "data": 1, "direction": [-1, 0, 0] },
|
||||
"east_ascending": { "data": 2, "direction": [1, 1, 0] },
|
||||
@ -2330,6 +2332,7 @@
|
||||
"north_ascending": { "data": 4, "direction": [0, 1, -1] },
|
||||
"north_descending": { "data": 4, "direction": [0, -1, 1] },
|
||||
"south_ascending": { "data": 5, "direction": [0, 1, 1] },
|
||||
"south_descending": { "data": 5, "direction": [0, -1, -1] },
|
||||
"southeast": { "data": 6, "direction": [1, 0, 1] },
|
||||
"southwest": { "data": 7, "direction": [-1, 0, 1] },
|
||||
"northwest": { "data": 8, "direction": [-1, 0, -1] },
|
||||
@ -2457,7 +2460,15 @@
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"south": { "data": 3, "direction": [0, 0, 1] },
|
||||
"west": { "data": 2, "direction": [-1, 0, 0] },
|
||||
"north": { "data": 4, "direction": [0, 0, -1] }
|
||||
"north": { "data": 4, "direction": [0, 0, -1] },
|
||||
"ground_south": { "data": 5, "direction": [0, 1, 1] },
|
||||
"ground_north": { "data": 5, "direction": [0, 1, -1] },
|
||||
"ground_east": { "data": 6, "direction": [1, 1, 0] },
|
||||
"ground_west": { "data": 6, "direction": [-1, 1, 0] },
|
||||
"ceiling_south": { "data": 7, "direction": [0, -1, -1] },
|
||||
"ceiling_north": { "data": 7, "direction": [0, -1, 1] },
|
||||
"ceiling_east": { "data": 0, "direction": [1, -1, 0] },
|
||||
"ceiling_west": { "data": 0, "direction": [-1, -1, 0] }
|
||||
}
|
||||
},
|
||||
"powered": {
|
||||
@ -3286,6 +3297,17 @@
|
||||
"legacyId": 94,
|
||||
"id": "minecraft:powered_repeater",
|
||||
"unlocalizedName": "tile.diode",
|
||||
"states": {
|
||||
"facing": {
|
||||
"dataMask": 3,
|
||||
"values": {
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"south": { "data": 2, "direction": [0, 0, 1] },
|
||||
"west": { "data": 3, "direction": [-1, 0, 0] }
|
||||
}
|
||||
}
|
||||
},
|
||||
"material": {
|
||||
"renderedAsNormalBlock": false,
|
||||
"fullCube": false,
|
||||
@ -5006,6 +5028,17 @@
|
||||
"legacyId": 145,
|
||||
"id": "minecraft:anvil",
|
||||
"unlocalizedName": "tile.anvil",
|
||||
"states": {
|
||||
"facing": {
|
||||
"dataMask": 3,
|
||||
"values": {
|
||||
"south": { "data": 0, "direction": [0, 0, 1] },
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"west": { "data": 1, "direction": [-1, 0, 0] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] }
|
||||
}
|
||||
}
|
||||
},
|
||||
"material": {
|
||||
"renderedAsNormalBlock": false,
|
||||
"fullCube": false,
|
||||
@ -5191,6 +5224,17 @@
|
||||
"legacyId": 150,
|
||||
"id": "minecraft:powered_comparator",
|
||||
"unlocalizedName": "tile.comparator",
|
||||
"states": {
|
||||
"facing": {
|
||||
"dataMask": 3,
|
||||
"values": {
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"south": { "data": 2, "direction": [0, 0, 1] },
|
||||
"west": { "data": 3, "direction": [-1, 0, 0] }
|
||||
}
|
||||
}
|
||||
},
|
||||
"material": {
|
||||
"renderedAsNormalBlock": false,
|
||||
"fullCube": false,
|
||||
@ -5433,7 +5477,7 @@
|
||||
"facing": {
|
||||
"values": {
|
||||
"north": { "data": 0, "direction": [0, 0, -1] },
|
||||
"south": { "data": 1, "direction": [0, 0, 1] },
|
||||
"south": { "data": 0, "direction": [0, 0, 1] },
|
||||
"east": { "data": 1, "direction": [1, 0, 0] },
|
||||
"west": { "data": 1, "direction": [-1, 0, 0] },
|
||||
"east_ascending": { "data": 2, "direction": [1, 1, 0] },
|
||||
@ -5443,6 +5487,7 @@
|
||||
"north_ascending": { "data": 4, "direction": [0, 1, -1] },
|
||||
"north_descending": { "data": 4, "direction": [0, -1, 1] },
|
||||
"south_ascending": { "data": 5, "direction": [0, 1, 1] },
|
||||
"south_descending": { "data": 5, "direction": [0, -1, -1] },
|
||||
"southeast": { "data": 6, "direction": [1, 0, 1] },
|
||||
"southwest": { "data": 7, "direction": [-1, 0, 1] },
|
||||
"northwest": { "data": 8, "direction": [-1, 0, -1] },
|
||||
|
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser 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 Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extent.transform;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockData;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.LegacyBlockRegistry;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class BlockTransformExtentTest {
|
||||
|
||||
private final Transform ROTATE_90 = new AffineTransform().rotateY(-90);
|
||||
private final Transform ROTATE_NEG_90 = new AffineTransform().rotateY(90);
|
||||
private final Set<BlockType> ignored = new HashSet<BlockType>();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
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
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransform() throws Exception {
|
||||
BlockRegistry blockRegistry = new LegacyBlockRegistry();
|
||||
for (BlockType type : BlockType.values()) {
|
||||
if (ignored.contains(type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BaseBlock orig = new BaseBlock(type.getID());
|
||||
for (int i = 1; i < 4; i++) {
|
||||
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_90, blockRegistry);
|
||||
BaseBlock reference = new BaseBlock(orig.getType(), BlockData.rotate90(orig.getType(), orig.getData()));
|
||||
assertThat(type + "#" + type.getID() + " rotated " + (90 * i) + " degrees did not match BlockData.rotate90()'s expected result", rotated, equalTo(reference));
|
||||
orig = rotated;
|
||||
}
|
||||
|
||||
orig = new BaseBlock(type.getID());
|
||||
for (int i = 0; i < 4; i++) {
|
||||
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_NEG_90, blockRegistry);
|
||||
BaseBlock reference = new BaseBlock(orig.getType(), BlockData.rotate90Reverse(orig.getType(), orig.getData()));
|
||||
assertThat(type + "#" + type.getID() + " rotated " + (-90 * i) + " degrees did not match BlockData.rotate90Reverse()'s expected result", rotated, equalTo(reference));
|
||||
orig = rotated;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user