SPIGOT-1464: Fixed setting Mushroom faces

By: ryanbennitt <ryanbennitt@googlemail.com>
This commit is contained in:
Bukkit/Spigot
2016-03-20 14:20:46 +00:00
parent b93b212047
commit 3e1845033a
3 changed files with 266 additions and 12 deletions

View File

@@ -8,10 +8,12 @@ import org.bukkit.TreeSpecies;
import org.bukkit.block.BlockFace;
import org.bukkit.material.Door;
import org.bukkit.material.Leaves;
import org.bukkit.material.Mushroom;
import org.bukkit.material.Sapling;
import org.bukkit.material.Tree;
import org.bukkit.material.Wood;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.types.MushroomBlockTexture;
import org.junit.Test;
public class MaterialDataTest {
@@ -231,4 +233,30 @@ public class MaterialDataTest {
}
}
}
@Test
public void testMushroom() {
Material[] mushroomTypes = new Material[] { Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2 };
BlockFace[] setFaces = new BlockFace[] { BlockFace.SELF, BlockFace.UP, BlockFace.NORTH,
BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST };
MushroomBlockTexture[] textures = MushroomBlockTexture.values();
for (Material type : mushroomTypes) {
Mushroom mushroom = new Mushroom(type);
assertThat("Constructed with correct mushroom type", mushroom.getItemType(), equalTo(type));
assertThat("Constructed with default pores face", mushroom.getBlockTexture(), equalTo(MushroomBlockTexture.ALL_PORES));
for (int f = 0; f < setFaces.length; f++) {
mushroom = new Mushroom(type, setFaces[f]);
assertThat("Constructed with correct mushroom type", mushroom.getItemType(), equalTo(type));
assertThat("Constructed with correct texture", mushroom.getBlockTexture(), equalTo(MushroomBlockTexture.getCapByFace(setFaces[f])));
}
for (MushroomBlockTexture texture : textures) {
mushroom = new Mushroom(type, texture);
assertThat("Constructed with correct mushroom type", mushroom.getItemType(), equalTo(type));
assertThat("Constructed with correct texture", mushroom.getBlockTexture(), equalTo(texture));
}
}
}
}