Update configs, and remove unused BlockData methods.

This commit is contained in:
Matthew Miller
2018-07-05 23:22:33 +10:00
parent d33e2e98aa
commit e1c2ea3a3b
13 changed files with 83 additions and 1298 deletions

View File

@ -1,38 +0,0 @@
/*
* 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;
// TODO FIX
public class CuboidClipboardTest {
// @Test
// public void testFlipCenterPlane() throws Exception {
// testFlip(0, 1, CuboidClipboard.FlipDirection.UP_DOWN);
// testFlip(2, 3, CuboidClipboard.FlipDirection.NORTH_SOUTH);
// testFlip(4, 5, CuboidClipboard.FlipDirection.WEST_EAST);
// }
//
// private void testFlip(int data, int expectedDataAfterFlip, CuboidClipboard.FlipDirection flipDirection) {
// BlockType blockType = new BlockType("minecraft:piston_base");
// final CuboidClipboard clipboard = new CuboidClipboard(new Vector(1, 1, 1));
// clipboard.setBlock(Vector.ZERO, new BaseBlock(blockType, data));
// clipboard.flip(flipDirection);
// assertEquals(expectedDataAfterFlip, clipboard.getBlock(Vector.ZERO).getData());
// }
}

View File

@ -1,64 +0,0 @@
/*
* 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.blocks;
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
import org.junit.Test;
import java.util.TreeSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class BlockDataTest {
@Test
public void testRotateFlip() {
for (int type = 0; type < 256; ++type) {
for (int data = 0; data < 16; ++data) {
final String message = type + "/" + data;
//Test r90(r-90(x))==x
assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90Reverse(type, data)));
//Test r-90(r90(x))==x
assertEquals(message, data, BlockData.rotate90Reverse(type, BlockData.rotate90(type, data)));
final int flipped = BlockData.flip(type, BlockData.flip(type, data, FlipDirection.WEST_EAST), FlipDirection.NORTH_SOUTH);
//Test r90(r90(x))==flipNS(flipWE(x))
assertEquals(message, flipped, BlockData.rotate90(type, BlockData.rotate90(type, data)));
//Test r-90(r-90(x))==flipNS(flipWE(x))
assertEquals(message, flipped, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, data)));
//Test flipNS(flipNS(x))==x
assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.NORTH_SOUTH), FlipDirection.NORTH_SOUTH));
//Test flipWE(flipWE(x))==x
assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.WEST_EAST), FlipDirection.WEST_EAST));
//Test flipUD(flipUD(x))==x
assertEquals(message, data, BlockData.flip(type, BlockData.flip(type, data, FlipDirection.UP_DOWN), FlipDirection.UP_DOWN));
//Test r90(r90(r90(r90(x))))==x
assertEquals(message, data, BlockData.rotate90(type, BlockData.rotate90(type, BlockData.rotate90(type, BlockData.rotate90(type, data)))));
//Test r-90(r-90(r-90(r-90(x))))==x
assertEquals(message, data, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, BlockData.rotate90Reverse(type, data)))));
}
}
}
}

View File

@ -1,90 +0,0 @@
/*
* 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.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
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.BundledBlockRegistry;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
@Ignore("Old BlockData class needs to be updated manually. Current block definitions are in blocks.json, " +
"which is automatically generated and generally accurate.")
public class BlockTransformExtentTest {
private static final Transform ROTATE_90 = new AffineTransform().rotateY(-90);
private static final Transform ROTATE_NEG_90 = new AffineTransform().rotateY(90);
private final Set<BlockType> ignored = new HashSet<>();
@Before
public void setUp() throws Exception {
ignored.add(BlockTypes.BLACK_BED); // Broken in existing rotation code?
ignored.add(BlockTypes.BLUE_BED); // Complicated
ignored.add(BlockTypes.BROWN_BED); // Complicated
ignored.add(BlockTypes.CYAN_BED); // Complicated
ignored.add(BlockTypes.GRAY_BED); // Complicated
ignored.add(BlockTypes.GREEN_BED); // Complicated
ignored.add(BlockTypes.LIGHT_BLUE_BED); // Complicated
ignored.add(BlockTypes.LIGHT_GRAY_BED); // Complicated
ignored.add(BlockTypes.LIME_BED); // Complicated
ignored.add(BlockTypes.OAK_DOOR); // Complicated
ignored.add(BlockTypes.IRON_DOOR); // Complicated
ignored.add(BlockTypes.END_PORTAL); // Not supported in existing rotation code
}
@Test
public void testTransform() throws Exception {
BlockRegistry blockRegistry = new BundledBlockRegistry();
for (BlockType type : BlockTypes.values()) {
if (ignored.contains(type)) {
continue;
}
BaseBlock orig = new BaseBlock(type);
for (int i = 1; i < 4; i++) {
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_90);
BaseBlock reference = new BaseBlock(orig.getBlockType().getLegacyId(), BlockData.rotate90(orig.getBlockType().getLegacyId(), 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);
for (int i = 0; i < 4; i++) {
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_NEG_90);
BaseBlock reference = new BaseBlock(orig.getBlockType().getLegacyId(), BlockData.rotate90Reverse(orig.getBlockType().getLegacyId(), orig.getData()));
assertThat(type + "#" + type.getId() + " rotated " + (-90 * i) + " degrees did not match BlockData.rotate90Reverse()'s expected result", rotated, equalTo(reference));
orig = rotated;
}
}
}
}