mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
Revert some no longer needed changes from earlier Material changes
This commit is contained in:
parent
2ee3cca8b6
commit
4d26fc9aa6
4 changed files with 165 additions and 108 deletions
|
@ -5573,7 +5573,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_WOOL:
|
case YELLOW_WOOL:
|
||||||
case ZOMBIE_HEAD:
|
case ZOMBIE_HEAD:
|
||||||
case ZOMBIE_WALL_HEAD:
|
case ZOMBIE_WALL_HEAD:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return 0 <= id && id < 256;
|
return 0 <= id && id < 256;
|
||||||
|
@ -5628,7 +5628,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case SUSPICIOUS_STEW:
|
case SUSPICIOUS_STEW:
|
||||||
case SWEET_BERRIES:
|
case SWEET_BERRIES:
|
||||||
case TROPICAL_FISH:
|
case TROPICAL_FISH:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_BREAD:
|
case LEGACY_BREAD:
|
||||||
case LEGACY_CARROT_ITEM:
|
case LEGACY_CARROT_ITEM:
|
||||||
case LEGACY_BAKED_POTATO:
|
case LEGACY_BAKED_POTATO:
|
||||||
|
@ -5659,7 +5659,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_BEETROOT:
|
case LEGACY_BEETROOT:
|
||||||
case LEGACY_CHORUS_FRUIT:
|
case LEGACY_CHORUS_FRUIT:
|
||||||
case LEGACY_BEETROOT_SOUP:
|
case LEGACY_BEETROOT_SOUP:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -5779,7 +5779,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case MUSIC_DISC_STRAD:
|
case MUSIC_DISC_STRAD:
|
||||||
case MUSIC_DISC_WAIT:
|
case MUSIC_DISC_WAIT:
|
||||||
case MUSIC_DISC_WARD:
|
case MUSIC_DISC_WARD:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return id >= LEGACY_GOLD_RECORD.id && id <= LEGACY_RECORD_12.id;
|
return id >= LEGACY_GOLD_RECORD.id && id <= LEGACY_RECORD_12.id;
|
||||||
|
@ -6575,7 +6575,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_TERRACOTTA:
|
case YELLOW_TERRACOTTA:
|
||||||
case YELLOW_WALL_BANNER:
|
case YELLOW_WALL_BANNER:
|
||||||
case YELLOW_WOOL:
|
case YELLOW_WOOL:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_STONE:
|
case LEGACY_STONE:
|
||||||
case LEGACY_GRASS:
|
case LEGACY_GRASS:
|
||||||
case LEGACY_DIRT:
|
case LEGACY_DIRT:
|
||||||
|
@ -6775,7 +6775,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_BLACK_GLAZED_TERRACOTTA:
|
case LEGACY_BLACK_GLAZED_TERRACOTTA:
|
||||||
case LEGACY_CONCRETE:
|
case LEGACY_CONCRETE:
|
||||||
case LEGACY_CONCRETE_POWDER:
|
case LEGACY_CONCRETE_POWDER:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -6793,7 +6793,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case AIR:
|
case AIR:
|
||||||
case CAVE_AIR:
|
case CAVE_AIR:
|
||||||
case VOID_AIR:
|
case VOID_AIR:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_AIR:
|
case LEGACY_AIR:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
|
@ -6943,7 +6943,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_CARPET:
|
case YELLOW_CARPET:
|
||||||
case ZOMBIE_HEAD:
|
case ZOMBIE_HEAD:
|
||||||
case ZOMBIE_WALL_HEAD:
|
case ZOMBIE_WALL_HEAD:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_AIR:
|
case LEGACY_AIR:
|
||||||
case LEGACY_SAPLING:
|
case LEGACY_SAPLING:
|
||||||
case LEGACY_POWERED_RAIL:
|
case LEGACY_POWERED_RAIL:
|
||||||
|
@ -6994,7 +6994,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_BEETROOT_BLOCK:
|
case LEGACY_BEETROOT_BLOCK:
|
||||||
case LEGACY_END_GATEWAY:
|
case LEGACY_END_GATEWAY:
|
||||||
case LEGACY_STRUCTURE_VOID:
|
case LEGACY_STRUCTURE_VOID:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -7286,7 +7286,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_CARPET:
|
case YELLOW_CARPET:
|
||||||
case YELLOW_WALL_BANNER:
|
case YELLOW_WALL_BANNER:
|
||||||
case YELLOW_WOOL:
|
case YELLOW_WOOL:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_WOOD:
|
case LEGACY_WOOD:
|
||||||
case LEGACY_LOG:
|
case LEGACY_LOG:
|
||||||
case LEGACY_LEAVES:
|
case LEGACY_LEAVES:
|
||||||
|
@ -7342,7 +7342,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_JUNGLE_DOOR:
|
case LEGACY_JUNGLE_DOOR:
|
||||||
case LEGACY_ACACIA_DOOR:
|
case LEGACY_ACACIA_DOOR:
|
||||||
case LEGACY_DARK_OAK_DOOR:
|
case LEGACY_DARK_OAK_DOOR:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -7534,7 +7534,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case WITHER_ROSE:
|
case WITHER_ROSE:
|
||||||
case YELLOW_CARPET:
|
case YELLOW_CARPET:
|
||||||
case YELLOW_WOOL:
|
case YELLOW_WOOL:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_WOOD:
|
case LEGACY_WOOD:
|
||||||
case LEGACY_LOG:
|
case LEGACY_LOG:
|
||||||
case LEGACY_LEAVES:
|
case LEGACY_LEAVES:
|
||||||
|
@ -7572,7 +7572,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_ACACIA_FENCE:
|
case LEGACY_ACACIA_FENCE:
|
||||||
case LEGACY_ACACIA_STAIRS:
|
case LEGACY_ACACIA_STAIRS:
|
||||||
case LEGACY_DARK_OAK_STAIRS:
|
case LEGACY_DARK_OAK_STAIRS:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -7835,7 +7835,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_BANNER:
|
case YELLOW_BANNER:
|
||||||
case YELLOW_CARPET:
|
case YELLOW_CARPET:
|
||||||
case YELLOW_WOOL:
|
case YELLOW_WOOL:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_LAVA_BUCKET:
|
case LEGACY_LAVA_BUCKET:
|
||||||
case LEGACY_COAL_BLOCK:
|
case LEGACY_COAL_BLOCK:
|
||||||
case LEGACY_BLAZE_ROD:
|
case LEGACY_BLAZE_ROD:
|
||||||
|
@ -7899,7 +7899,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_WOOL:
|
case LEGACY_WOOL:
|
||||||
case LEGACY_CARPET:
|
case LEGACY_CARPET:
|
||||||
case LEGACY_BOWL:
|
case LEGACY_BOWL:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -8286,7 +8286,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_SHULKER_BOX:
|
case YELLOW_SHULKER_BOX:
|
||||||
case YELLOW_TERRACOTTA:
|
case YELLOW_TERRACOTTA:
|
||||||
case YELLOW_WOOL:
|
case YELLOW_WOOL:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_STONE:
|
case LEGACY_STONE:
|
||||||
case LEGACY_GRASS:
|
case LEGACY_GRASS:
|
||||||
case LEGACY_DIRT:
|
case LEGACY_DIRT:
|
||||||
|
@ -8385,7 +8385,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_BLACK_GLAZED_TERRACOTTA:
|
case LEGACY_BLACK_GLAZED_TERRACOTTA:
|
||||||
case LEGACY_CONCRETE:
|
case LEGACY_CONCRETE:
|
||||||
case LEGACY_CONCRETE_POWDER:
|
case LEGACY_CONCRETE_POWDER:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -8424,12 +8424,12 @@ public enum Material implements Keyed, Translatable {
|
||||||
case SAND:
|
case SAND:
|
||||||
case WHITE_CONCRETE_POWDER:
|
case WHITE_CONCRETE_POWDER:
|
||||||
case YELLOW_CONCRETE_POWDER:
|
case YELLOW_CONCRETE_POWDER:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_SAND:
|
case LEGACY_SAND:
|
||||||
case LEGACY_GRAVEL:
|
case LEGACY_GRAVEL:
|
||||||
case LEGACY_ANVIL:
|
case LEGACY_ANVIL:
|
||||||
case LEGACY_CONCRETE_POWDER:
|
case LEGACY_CONCRETE_POWDER:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -8591,7 +8591,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case YELLOW_CANDLE_CAKE:
|
case YELLOW_CANDLE_CAKE:
|
||||||
case YELLOW_WALL_BANNER:
|
case YELLOW_WALL_BANNER:
|
||||||
case ZOMBIE_WALL_HEAD:
|
case ZOMBIE_WALL_HEAD:
|
||||||
// ----- Legacy Separator -----
|
// ----- Legacy Separator -----
|
||||||
case LEGACY_ACACIA_DOOR:
|
case LEGACY_ACACIA_DOOR:
|
||||||
case LEGACY_BED_BLOCK:
|
case LEGACY_BED_BLOCK:
|
||||||
case LEGACY_BEETROOT_BLOCK:
|
case LEGACY_BEETROOT_BLOCK:
|
||||||
|
@ -8644,7 +8644,7 @@ public enum Material implements Keyed, Translatable {
|
||||||
case LEGACY_WATER:
|
case LEGACY_WATER:
|
||||||
case LEGACY_WOODEN_DOOR:
|
case LEGACY_WOODEN_DOOR:
|
||||||
case LEGACY_WOOD_DOUBLE_STEP:
|
case LEGACY_WOOD_DOUBLE_STEP:
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -76,17 +76,20 @@ public class Crops extends MaterialData {
|
||||||
* @return CropState of this crop
|
* @return CropState of this crop
|
||||||
*/
|
*/
|
||||||
public CropState getState() {
|
public CropState getState() {
|
||||||
if (getItemType() == Material.LEGACY_CROPS || getItemType() == Material.LEGACY_CARROT || getItemType() == Material.LEGACY_POTATO) {
|
switch (getItemType()) {
|
||||||
// Mask the data just in case top bit set
|
case LEGACY_CROPS:
|
||||||
return CropState.getByData((byte) (getData() & 0x7));
|
case LEGACY_CARROT:
|
||||||
|
case LEGACY_POTATO:
|
||||||
|
// Mask the data just in case top bit set
|
||||||
|
return CropState.getByData((byte) (getData() & 0x7));
|
||||||
|
case LEGACY_BEETROOT_BLOCK:
|
||||||
|
case LEGACY_NETHER_WARTS:
|
||||||
|
// Mask the data just in case top bits are set
|
||||||
|
// Will return SEEDED, SMALL, TALL, RIPE for the three growth data values
|
||||||
|
return CropState.getByData((byte) (((getData() & 0x3) * 7 + 2) / 3));
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Block type is not a crop");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_BEETROOT_BLOCK || getItemType() == Material.LEGACY_NETHER_WARTS) {
|
|
||||||
// Mask the data just in case top bits are set
|
|
||||||
// Will return SEEDED, SMALL, TALL, RIPE for the three growth data values
|
|
||||||
return CropState.getByData((byte) (((getData() & 0x3) * 7 + 2) / 3));
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Block type is not a crop");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,19 +107,21 @@ public class Crops extends MaterialData {
|
||||||
* @param state New growth state of this crop
|
* @param state New growth state of this crop
|
||||||
*/
|
*/
|
||||||
public void setState(CropState state) {
|
public void setState(CropState state) {
|
||||||
if (getItemType() == Material.LEGACY_CROPS || getItemType() == Material.LEGACY_CARROT || getItemType() == Material.LEGACY_POTATO) {
|
switch (getItemType()) {
|
||||||
// Preserve the top bit in case it is set
|
case LEGACY_CROPS:
|
||||||
setData((byte) ((getData() & 0x8) | state.getData()));
|
case LEGACY_CARROT:
|
||||||
return;
|
case LEGACY_POTATO:
|
||||||
|
// Preserve the top bit in case it is set
|
||||||
|
setData((byte) ((getData() & 0x8) | state.getData()));
|
||||||
|
break;
|
||||||
|
case LEGACY_NETHER_WARTS:
|
||||||
|
case LEGACY_BEETROOT_BLOCK:
|
||||||
|
// Preserve the top bits in case they are set
|
||||||
|
setData((byte) ((getData() & 0xC) | (state.getData() >> 1)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Block type is not a crop");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_NETHER_WARTS || getItemType() == Material.LEGACY_BEETROOT_BLOCK) {
|
|
||||||
// Preserve the top bits in case they are set
|
|
||||||
setData((byte) ((getData() & 0xC) | (state.getData() >> 1)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Block type is not a crop");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -71,23 +71,22 @@ public class Wood extends MaterialData {
|
||||||
* @return TreeSpecies of this wood block
|
* @return TreeSpecies of this wood block
|
||||||
*/
|
*/
|
||||||
public TreeSpecies getSpecies() {
|
public TreeSpecies getSpecies() {
|
||||||
if (getItemType() == Material.LEGACY_WOOD || getItemType() == Material.LEGACY_WOOD_DOUBLE_STEP) {
|
switch (getItemType()) {
|
||||||
return TreeSpecies.getByData((byte) getData());
|
case LEGACY_WOOD:
|
||||||
|
case LEGACY_WOOD_DOUBLE_STEP:
|
||||||
|
return TreeSpecies.getByData((byte) getData());
|
||||||
|
case LEGACY_LOG:
|
||||||
|
case LEGACY_LEAVES:
|
||||||
|
return TreeSpecies.getByData((byte) (getData() & 0x3));
|
||||||
|
case LEGACY_LOG_2:
|
||||||
|
case LEGACY_LEAVES_2:
|
||||||
|
return TreeSpecies.getByData((byte) ((getData() & 0x3) | 0x4));
|
||||||
|
case LEGACY_SAPLING:
|
||||||
|
case LEGACY_WOOD_STEP:
|
||||||
|
return TreeSpecies.getByData((byte) (getData() & 0x7));
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid block type for tree species");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_LOG || getItemType() == Material.LEGACY_LEAVES) {
|
|
||||||
return TreeSpecies.getByData((byte) (getData() & 0x3));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_LOG_2 || getItemType() == Material.LEGACY_LEAVES_2) {
|
|
||||||
return TreeSpecies.getByData((byte) ((getData() & 0x3) | 0x4));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_SAPLING || getItemType() == Material.LEGACY_WOOD_STEP) {
|
|
||||||
return TreeSpecies.getByData((byte) (getData() & 0x7));
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Invalid block type for tree species");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,20 +102,22 @@ public class Wood extends MaterialData {
|
||||||
case REDWOOD:
|
case REDWOOD:
|
||||||
case BIRCH:
|
case BIRCH:
|
||||||
case JUNGLE:
|
case JUNGLE:
|
||||||
if (type == Material.LEGACY_LOG_2) {
|
switch (type) {
|
||||||
return Material.LEGACY_LOG;
|
case LEGACY_LOG_2:
|
||||||
}
|
return Material.LEGACY_LOG;
|
||||||
if (type == Material.LEGACY_LEAVES_2) {
|
case LEGACY_LEAVES_2:
|
||||||
return Material.LEGACY_LEAVES;
|
return Material.LEGACY_LEAVES;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACACIA:
|
case ACACIA:
|
||||||
case DARK_OAK:
|
case DARK_OAK:
|
||||||
if (type == Material.LEGACY_LOG) {
|
switch (type) {
|
||||||
return Material.LEGACY_LOG_2;
|
case LEGACY_LOG:
|
||||||
}
|
return Material.LEGACY_LOG_2;
|
||||||
if (type == Material.LEGACY_LEAVES) {
|
case LEGACY_LEAVES:
|
||||||
return Material.LEGACY_LEAVES_2;
|
return Material.LEGACY_LEAVES_2;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -130,44 +131,42 @@ public class Wood extends MaterialData {
|
||||||
*/
|
*/
|
||||||
public void setSpecies(final TreeSpecies species) {
|
public void setSpecies(final TreeSpecies species) {
|
||||||
boolean firstType = false;
|
boolean firstType = false;
|
||||||
|
switch (getItemType()) {
|
||||||
if (getItemType() == Material.LEGACY_WOOD || getItemType() == Material.LEGACY_WOOD_DOUBLE_STEP) {
|
case LEGACY_WOOD:
|
||||||
setData(species.getData());
|
case LEGACY_WOOD_DOUBLE_STEP:
|
||||||
return;
|
setData(species.getData());
|
||||||
|
break;
|
||||||
|
case LEGACY_LOG:
|
||||||
|
case LEGACY_LEAVES:
|
||||||
|
firstType = true;
|
||||||
|
// fall through to next switch statement below
|
||||||
|
case LEGACY_LOG_2:
|
||||||
|
case LEGACY_LEAVES_2:
|
||||||
|
switch (species) {
|
||||||
|
case GENERIC:
|
||||||
|
case REDWOOD:
|
||||||
|
case BIRCH:
|
||||||
|
case JUNGLE:
|
||||||
|
if (!firstType) {
|
||||||
|
throw new IllegalArgumentException("Invalid tree species for block type, use block type 2 instead");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ACACIA:
|
||||||
|
case DARK_OAK:
|
||||||
|
if (firstType) {
|
||||||
|
throw new IllegalArgumentException("Invalid tree species for block type 2, use block type instead");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setData((byte) ((getData() & 0xC) | (species.getData() & 0x3)));
|
||||||
|
break;
|
||||||
|
case LEGACY_SAPLING:
|
||||||
|
case LEGACY_WOOD_STEP:
|
||||||
|
setData((byte) ((getData() & 0x8) | species.getData()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid block type for tree species");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_LOG || getItemType() == Material.LEGACY_LEAVES) {
|
|
||||||
firstType = true;
|
|
||||||
// fall through to next switch statement below
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_LOG || getItemType() == Material.LEGACY_LEAVES || getItemType() == Material.LEGACY_LOG_2 || getItemType() == Material.LEGACY_LEAVES_2) {
|
|
||||||
switch (species) {
|
|
||||||
case GENERIC:
|
|
||||||
case REDWOOD:
|
|
||||||
case BIRCH:
|
|
||||||
case JUNGLE:
|
|
||||||
if (!firstType) {
|
|
||||||
throw new IllegalArgumentException("Invalid tree species for block type, use block type 2 instead");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ACACIA:
|
|
||||||
case DARK_OAK:
|
|
||||||
if (firstType) {
|
|
||||||
throw new IllegalArgumentException("Invalid tree species for block type 2, use block type instead");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
setData((byte) ((getData() & 0xC) | (species.getData() & 0x3)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getItemType() == Material.LEGACY_SAPLING || getItemType() == Material.LEGACY_WOOD_STEP) {
|
|
||||||
setData((byte) ((getData() & 0x8) | species.getData()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new IllegalArgumentException("Invalid block type for tree species");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,18 +2,71 @@ package org.bukkit;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.bukkit.support.AbstractTestingBase;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class MaterialTest extends AbstractTestingBase {
|
public class MaterialTest {
|
||||||
|
@Test
|
||||||
|
public void getByName() {
|
||||||
|
for (Material material : Material.values()) {
|
||||||
|
assertThat(Material.getMaterial(material.toString()), is(material));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getByNameNull() {
|
public void getByNameNull() {
|
||||||
assertThat(Material.getMaterial(null), is(nullValue()));
|
assertThat(Material.getMaterial(null), is(nullValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getData() {
|
||||||
|
for (Material material : Material.values()) {
|
||||||
|
if (!material.isLegacy()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Class<? extends MaterialData> clazz = material.getData();
|
||||||
|
|
||||||
|
assertThat(material.getNewData((byte) 0), is(instanceOf(clazz)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void matchMaterialByNull() {
|
public void matchMaterialByNull() {
|
||||||
Material.matchMaterial(null);
|
Material.matchMaterial(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void matchMaterialByName() {
|
||||||
|
for (Material material : Material.values()) {
|
||||||
|
assertThat(Material.matchMaterial(material.toString()), is(material));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void matchMaterialByKey() {
|
||||||
|
for (Material material : Material.values()) {
|
||||||
|
if (material.isLegacy()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assertThat(Material.matchMaterial(material.getKey().toString()), is(material));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void matchMaterialByWrongNamespace() {
|
||||||
|
for (Material material : Material.values()) {
|
||||||
|
if (material.isLegacy()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assertNull(Material.matchMaterial("bogus:" + material.getKey().getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void matchMaterialByLowerCaseAndSpaces() {
|
||||||
|
for (Material material : Material.values()) {
|
||||||
|
String name = material.toString().replaceAll("_", " ").toLowerCase(java.util.Locale.ENGLISH);
|
||||||
|
assertThat(Material.matchMaterial(name), is(material));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue