mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Fixed not flipping the center plane blocks.
Added regression test so we'll never have to deal with it again.
This commit is contained in:
parent
54dca39b07
commit
73bf2bd215
@ -206,16 +206,16 @@ public void flip(FlipDirection dir, boolean aroundPlayer) {
|
|||||||
for (int xs = 0; xs < wid; ++xs) {
|
for (int xs = 0; xs < wid; ++xs) {
|
||||||
for (int z = 0; z < length; ++z) {
|
for (int z = 0; z < length; ++z) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
// Skip the center plane
|
|
||||||
if (xs == width - xs - 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final BaseBlock block1 = data[xs][y][z];
|
final BaseBlock block1 = data[xs][y][z];
|
||||||
if (block1 != null) {
|
if (block1 != null) {
|
||||||
block1.flip(dir);
|
block1.flip(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip the center plane
|
||||||
|
if (xs == width - xs - 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final BaseBlock block2 = data[width - xs - 1][y][z];
|
final BaseBlock block2 = data[width - xs - 1][y][z];
|
||||||
if (block2 != null) {
|
if (block2 != null) {
|
||||||
block2.flip(dir);
|
block2.flip(dir);
|
||||||
@ -238,16 +238,16 @@ public void flip(FlipDirection dir, boolean aroundPlayer) {
|
|||||||
for (int zs = 0; zs < len; ++zs) {
|
for (int zs = 0; zs < len; ++zs) {
|
||||||
for (int x = 0; x < width; ++x) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
// Skip the center plane
|
|
||||||
if (zs == length - zs - 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final BaseBlock block1 = data[x][y][zs];
|
final BaseBlock block1 = data[x][y][zs];
|
||||||
if (block1 != null) {
|
if (block1 != null) {
|
||||||
block1.flip(dir);
|
block1.flip(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip the center plane
|
||||||
|
if (zs == length - zs - 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final BaseBlock block2 = data[x][y][length - zs - 1];
|
final BaseBlock block2 = data[x][y][length - zs - 1];
|
||||||
if (block2 != null) {
|
if (block2 != null) {
|
||||||
block2.flip(dir);
|
block2.flip(dir);
|
||||||
@ -270,16 +270,16 @@ public void flip(FlipDirection dir, boolean aroundPlayer) {
|
|||||||
for (int ys = 0; ys < hei; ++ys) {
|
for (int ys = 0; ys < hei; ++ys) {
|
||||||
for (int x = 0; x < width; ++x) {
|
for (int x = 0; x < width; ++x) {
|
||||||
for (int z = 0; z < length; ++z) {
|
for (int z = 0; z < length; ++z) {
|
||||||
// Skip the center plane
|
|
||||||
if (ys == height - ys - 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final BaseBlock block1 = data[x][ys][z];
|
final BaseBlock block1 = data[x][ys][z];
|
||||||
if (block1 != null) {
|
if (block1 != null) {
|
||||||
block1.flip(dir);
|
block1.flip(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip the center plane
|
||||||
|
if (ys == height - ys - 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final BaseBlock block2 = data[x][height - ys - 1][z];
|
final BaseBlock block2 = data[x][height - ys - 1][z];
|
||||||
if (block2 != null) {
|
if (block2 != null) {
|
||||||
block2.flip(dir);
|
block2.flip(dir);
|
||||||
|
23
src/test/java/com/sk89q/worldedit/CuboidClipboardTest.java
Normal file
23
src/test/java/com/sk89q/worldedit/CuboidClipboardTest.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
final CuboidClipboard clipboard = new CuboidClipboard(new Vector(1, 1, 1));
|
||||||
|
clipboard.setBlock(Vector.ZERO, new BaseBlock(BlockID.PISTON_BASE, data));
|
||||||
|
clipboard.flip(flipDirection);
|
||||||
|
assertEquals(expectedDataAfterFlip, clipboard.getBlock(Vector.ZERO).getData());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user