Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
Material.java
1 package org.bukkit;
2 
3 import java.lang.reflect.Constructor;
4 import java.util.Map;
5 
6 import org.apache.commons.lang.Validate;
7 import org.bukkit.map.MapView;
8 import org.bukkit.material.Bed;
10 import org.bukkit.material.Cake;
12 import org.bukkit.material.Chest;
13 import org.bukkit.material.Coal;
15 import org.bukkit.material.Command;
16 import org.bukkit.material.Crops;
18 import org.bukkit.material.Diode;
20 import org.bukkit.material.Door;
21 import org.bukkit.material.Dye;
24 import org.bukkit.material.Furnace;
25 import org.bukkit.material.Gate;
26 import org.bukkit.material.Ladder;
27 import org.bukkit.material.Lever;
37 import org.bukkit.material.Pumpkin;
38 import org.bukkit.material.Rails;
42 import org.bukkit.material.Sign;
43 import org.bukkit.material.Skull;
46 import org.bukkit.material.Stairs;
47 import org.bukkit.material.Step;
48 import org.bukkit.material.Torch;
50 import org.bukkit.material.Tree;
53 import org.bukkit.material.Vine;
55 import org.bukkit.material.Wool;
56 import org.bukkit.potion.Potion;
58 
59 import com.google.common.collect.Maps;
60 
61 /**
62  * An enum of all material IDs accepted by the official server and client
63  */
64 public enum Material {
65  AIR(0, 0),
66  STONE(1),
67  GRASS(2),
68  DIRT(3),
69  COBBLESTONE(4),
70  WOOD(5, Tree.class),
71  SAPLING(6, Tree.class),
72  BEDROCK(7),
73  WATER(8, MaterialData.class),
74  STATIONARY_WATER(9, MaterialData.class),
75  LAVA(10, MaterialData.class),
76  STATIONARY_LAVA(11, MaterialData.class),
77  SAND(12),
78  GRAVEL(13),
79  GOLD_ORE(14),
80  IRON_ORE(15),
81  COAL_ORE(16),
82  LOG(17, Tree.class),
83  LEAVES(18, Tree.class),
84  SPONGE(19),
85  GLASS(20),
86  LAPIS_ORE(21),
87  LAPIS_BLOCK(22),
88  DISPENSER(23, Dispenser.class),
89  SANDSTONE(24, Sandstone.class),
90  NOTE_BLOCK(25),
91  BED_BLOCK(26, Bed.class),
92  POWERED_RAIL(27, PoweredRail.class),
93  DETECTOR_RAIL(28, DetectorRail.class),
94  PISTON_STICKY_BASE(29, PistonBaseMaterial.class),
95  WEB(30),
96  LONG_GRASS(31, LongGrass.class),
97  DEAD_BUSH(32),
98  PISTON_BASE(33, PistonBaseMaterial.class),
99  PISTON_EXTENSION(34, PistonExtensionMaterial.class),
100  WOOL(35, Wool.class),
101  PISTON_MOVING_PIECE(36),
102  YELLOW_FLOWER(37),
103  RED_ROSE(38),
104  BROWN_MUSHROOM(39),
105  RED_MUSHROOM(40),
106  GOLD_BLOCK(41),
107  IRON_BLOCK(42),
108  DOUBLE_STEP(43, Step.class),
109  STEP(44, Step.class),
110  BRICK(45),
111  TNT(46),
112  BOOKSHELF(47),
113  MOSSY_COBBLESTONE(48),
114  OBSIDIAN(49),
115  TORCH(50, Torch.class),
116  FIRE(51),
117  MOB_SPAWNER(52),
118  WOOD_STAIRS(53, Stairs.class),
119  CHEST(54, Chest.class),
120  REDSTONE_WIRE(55, RedstoneWire.class),
121  DIAMOND_ORE(56),
122  DIAMOND_BLOCK(57),
123  WORKBENCH(58),
124  CROPS(59, Crops.class),
125  SOIL(60, MaterialData.class),
126  FURNACE(61, Furnace.class),
127  BURNING_FURNACE(62, Furnace.class),
128  SIGN_POST(63, 64, Sign.class),
129  WOODEN_DOOR(64, Door.class),
130  LADDER(65, Ladder.class),
131  RAILS(66, Rails.class),
132  COBBLESTONE_STAIRS(67, Stairs.class),
133  WALL_SIGN(68, 64, Sign.class),
134  LEVER(69, Lever.class),
135  STONE_PLATE(70, PressurePlate.class),
136  IRON_DOOR_BLOCK(71, Door.class),
137  WOOD_PLATE(72, PressurePlate.class),
138  REDSTONE_ORE(73),
139  GLOWING_REDSTONE_ORE(74),
140  REDSTONE_TORCH_OFF(75, RedstoneTorch.class),
141  REDSTONE_TORCH_ON(76, RedstoneTorch.class),
142  STONE_BUTTON(77, Button.class),
143  SNOW(78),
144  ICE(79),
145  SNOW_BLOCK(80),
146  CACTUS(81, MaterialData.class),
147  CLAY(82),
148  SUGAR_CANE_BLOCK(83, MaterialData.class),
149  JUKEBOX(84),
150  FENCE(85),
151  PUMPKIN(86, Pumpkin.class),
152  NETHERRACK(87),
153  SOUL_SAND(88),
154  GLOWSTONE(89),
155  PORTAL(90),
156  JACK_O_LANTERN(91, Pumpkin.class),
157  CAKE_BLOCK(92, 64, Cake.class),
158  DIODE_BLOCK_OFF(93, Diode.class),
159  DIODE_BLOCK_ON(94, Diode.class),
160  @Deprecated
161  LOCKED_CHEST(95),
162  STAINED_GLASS(95),
163  TRAP_DOOR(96, TrapDoor.class),
164  MONSTER_EGGS(97, MonsterEggs.class),
165  SMOOTH_BRICK(98, SmoothBrick.class),
166  HUGE_MUSHROOM_1(99, Mushroom.class),
167  HUGE_MUSHROOM_2(100, Mushroom.class),
168  IRON_FENCE(101),
169  THIN_GLASS(102),
170  MELON_BLOCK(103),
171  PUMPKIN_STEM(104, MaterialData.class),
172  MELON_STEM(105, MaterialData.class),
173  VINE(106, Vine.class),
174  FENCE_GATE(107, Gate.class),
175  BRICK_STAIRS(108, Stairs.class),
176  SMOOTH_STAIRS(109, Stairs.class),
177  MYCEL(110),
178  WATER_LILY(111),
179  NETHER_BRICK(112),
180  NETHER_FENCE(113),
181  NETHER_BRICK_STAIRS(114, Stairs.class),
182  NETHER_WARTS(115, NetherWarts.class),
183  ENCHANTMENT_TABLE(116),
184  BREWING_STAND(117, MaterialData.class),
185  CAULDRON(118, Cauldron.class),
186  ENDER_PORTAL(119),
187  ENDER_PORTAL_FRAME(120),
188  ENDER_STONE(121),
189  DRAGON_EGG(122),
190  REDSTONE_LAMP_OFF(123),
191  REDSTONE_LAMP_ON(124),
192  WOOD_DOUBLE_STEP(125, WoodenStep.class),
193  WOOD_STEP(126, WoodenStep.class),
194  COCOA(127, CocoaPlant.class),
195  SANDSTONE_STAIRS(128, Stairs.class),
196  EMERALD_ORE(129),
197  ENDER_CHEST(130, EnderChest.class),
198  TRIPWIRE_HOOK(131, TripwireHook.class),
199  TRIPWIRE(132, Tripwire.class),
200  EMERALD_BLOCK(133),
201  SPRUCE_WOOD_STAIRS(134, Stairs.class),
202  BIRCH_WOOD_STAIRS(135, Stairs.class),
203  JUNGLE_WOOD_STAIRS(136, Stairs.class),
204  COMMAND(137, Command.class),
205  BEACON(138),
206  COBBLE_WALL(139),
207  FLOWER_POT(140, FlowerPot.class),
208  CARROT(141),
209  POTATO(142),
210  WOOD_BUTTON(143, Button.class),
211  SKULL(144, Skull.class),
212  ANVIL(145),
213  TRAPPED_CHEST(146),
214  GOLD_PLATE(147),
215  IRON_PLATE(148),
216  REDSTONE_COMPARATOR_OFF(149),
217  REDSTONE_COMPARATOR_ON(150),
218  DAYLIGHT_DETECTOR(151),
219  REDSTONE_BLOCK(152),
220  QUARTZ_ORE(153),
221  HOPPER(154),
222  QUARTZ_BLOCK(155),
223  QUARTZ_STAIRS(156, Stairs.class),
224  ACTIVATOR_RAIL(157, PoweredRail.class),
225  DROPPER(158, Dispenser.class),
226  STAINED_CLAY(159),
227  STAINED_GLASS_PANE(160),
228  LEAVES_2(161),
229  LOG_2(162),
230  ACACIA_STAIRS(163, Stairs.class),
231  DARK_OAK_STAIRS(164, Stairs.class),
232  HAY_BLOCK(170),
233  CARPET(171),
234  HARD_CLAY(172),
235  COAL_BLOCK(173),
236  PACKED_ICE(174),
237  DOUBLE_PLANT(175),
238  // ----- Item Separator -----
239  IRON_SPADE(256, 1, 250),
240  IRON_PICKAXE(257, 1, 250),
241  IRON_AXE(258, 1, 250),
242  FLINT_AND_STEEL(259, 1, 64),
243  APPLE(260),
244  BOW(261, 1, 384),
245  ARROW(262),
246  COAL(263, Coal.class),
247  DIAMOND(264),
248  IRON_INGOT(265),
249  GOLD_INGOT(266),
250  IRON_SWORD(267, 1, 250),
251  WOOD_SWORD(268, 1, 59),
252  WOOD_SPADE(269, 1, 59),
253  WOOD_PICKAXE(270, 1, 59),
254  WOOD_AXE(271, 1, 59),
255  STONE_SWORD(272, 1, 131),
256  STONE_SPADE(273, 1, 131),
257  STONE_PICKAXE(274, 1, 131),
258  STONE_AXE(275, 1, 131),
259  DIAMOND_SWORD(276, 1, 1561),
260  DIAMOND_SPADE(277, 1, 1561),
261  DIAMOND_PICKAXE(278, 1, 1561),
262  DIAMOND_AXE(279, 1, 1561),
263  STICK(280),
264  BOWL(281),
265  MUSHROOM_SOUP(282, 1),
266  GOLD_SWORD(283, 1, 32),
267  GOLD_SPADE(284, 1, 32),
268  GOLD_PICKAXE(285, 1, 32),
269  GOLD_AXE(286, 1, 32),
270  STRING(287),
271  FEATHER(288),
272  SULPHUR(289),
273  WOOD_HOE(290, 1, 59),
274  STONE_HOE(291, 1, 131),
275  IRON_HOE(292, 1, 250),
276  DIAMOND_HOE(293, 1, 1561),
277  GOLD_HOE(294, 1, 32),
278  SEEDS(295),
279  WHEAT(296),
280  BREAD(297),
281  LEATHER_HELMET(298, 1, 55),
282  LEATHER_CHESTPLATE(299, 1, 80),
283  LEATHER_LEGGINGS(300, 1, 75),
284  LEATHER_BOOTS(301, 1, 65),
285  CHAINMAIL_HELMET(302, 1, 165),
286  CHAINMAIL_CHESTPLATE(303, 1, 240),
287  CHAINMAIL_LEGGINGS(304, 1, 225),
288  CHAINMAIL_BOOTS(305, 1, 195),
289  IRON_HELMET(306, 1, 165),
290  IRON_CHESTPLATE(307, 1, 240),
291  IRON_LEGGINGS(308, 1, 225),
292  IRON_BOOTS(309, 1, 195),
293  DIAMOND_HELMET(310, 1, 363),
294  DIAMOND_CHESTPLATE(311, 1, 528),
295  DIAMOND_LEGGINGS(312, 1, 495),
296  DIAMOND_BOOTS(313, 1, 429),
297  GOLD_HELMET(314, 1, 77),
298  GOLD_CHESTPLATE(315, 1, 112),
299  GOLD_LEGGINGS(316, 1, 105),
300  GOLD_BOOTS(317, 1, 91),
301  FLINT(318),
302  PORK(319),
303  GRILLED_PORK(320),
304  PAINTING(321),
305  GOLDEN_APPLE(322),
306  SIGN(323, 16),
307  WOOD_DOOR(324, 1),
308  BUCKET(325, 16),
309  WATER_BUCKET(326, 1),
310  LAVA_BUCKET(327, 1),
311  MINECART(328, 1),
312  SADDLE(329, 1),
313  IRON_DOOR(330, 1),
314  REDSTONE(331),
315  SNOW_BALL(332, 16),
316  BOAT(333, 1),
317  LEATHER(334),
318  MILK_BUCKET(335, 1),
319  CLAY_BRICK(336),
320  CLAY_BALL(337),
321  SUGAR_CANE(338),
322  PAPER(339),
323  BOOK(340),
324  SLIME_BALL(341),
325  STORAGE_MINECART(342, 1),
326  POWERED_MINECART(343, 1),
327  EGG(344, 16),
328  COMPASS(345),
329  FISHING_ROD(346, 1, 64),
330  WATCH(347),
331  GLOWSTONE_DUST(348),
332  RAW_FISH(349),
333  COOKED_FISH(350),
334  INK_SACK(351, Dye.class),
335  BONE(352),
336  SUGAR(353),
337  CAKE(354, 1),
338  BED(355, 1),
339  DIODE(356),
340  COOKIE(357),
341  /**
342  * @see MapView
343  */
344  MAP(358, MaterialData.class),
345  SHEARS(359, 1, 238),
346  MELON(360),
347  PUMPKIN_SEEDS(361),
348  MELON_SEEDS(362),
349  RAW_BEEF(363),
350  COOKED_BEEF(364),
351  RAW_CHICKEN(365),
352  COOKED_CHICKEN(366),
353  ROTTEN_FLESH(367),
354  ENDER_PEARL(368, 16),
355  BLAZE_ROD(369),
356  GHAST_TEAR(370),
357  GOLD_NUGGET(371),
358  NETHER_STALK(372),
359  /**
360  * @see Potion
361  */
362  POTION(373, 1, MaterialData.class),
363  GLASS_BOTTLE(374),
364  SPIDER_EYE(375),
365  FERMENTED_SPIDER_EYE(376),
366  BLAZE_POWDER(377),
367  MAGMA_CREAM(378),
368  BREWING_STAND_ITEM(379),
369  CAULDRON_ITEM(380),
370  EYE_OF_ENDER(381),
371  SPECKLED_MELON(382),
372  MONSTER_EGG(383, 64, SpawnEgg.class),
373  EXP_BOTTLE(384, 64),
374  FIREBALL(385, 64),
375  BOOK_AND_QUILL(386, 1),
376  WRITTEN_BOOK(387, 16),
377  EMERALD(388, 64),
378  ITEM_FRAME(389),
379  FLOWER_POT_ITEM(390),
380  CARROT_ITEM(391),
381  POTATO_ITEM(392),
382  BAKED_POTATO(393),
383  POISONOUS_POTATO(394),
384  EMPTY_MAP(395),
385  GOLDEN_CARROT(396),
386  SKULL_ITEM(397),
387  CARROT_STICK(398, 1, 25),
388  NETHER_STAR(399),
389  PUMPKIN_PIE(400),
390  FIREWORK(401),
391  FIREWORK_CHARGE(402),
392  ENCHANTED_BOOK(403, 1),
393  REDSTONE_COMPARATOR(404),
394  NETHER_BRICK_ITEM(405),
395  QUARTZ(406),
396  EXPLOSIVE_MINECART(407, 1),
397  HOPPER_MINECART(408, 1),
398  IRON_BARDING(417, 1),
399  GOLD_BARDING(418, 1),
400  DIAMOND_BARDING(419, 1),
401  LEASH(420),
402  NAME_TAG(421),
403  COMMAND_MINECART(422, 1),
404  GOLD_RECORD(2256, 1),
405  GREEN_RECORD(2257, 1),
406  RECORD_3(2258, 1),
407  RECORD_4(2259, 1),
408  RECORD_5(2260, 1),
409  RECORD_6(2261, 1),
410  RECORD_7(2262, 1),
411  RECORD_8(2263, 1),
412  RECORD_9(2264, 1),
413  RECORD_10(2265, 1),
414  RECORD_11(2266, 1),
415  RECORD_12(2267, 1),
416  ;
417 
418  private final int id;
419  private final Constructor<? extends MaterialData> ctor;
420  private static Material[] byId = new Material[383];
421  private final static Map<String, Material> BY_NAME = Maps.newHashMap();
422  private final int maxStack;
423  private final short durability;
424 
425  private Material(final int id) {
426  this(id, 64);
427  }
428 
429  private Material(final int id, final int stack) {
430  this(id, stack, MaterialData.class);
431  }
432 
433  private Material(final int id, final int stack, final int durability) {
434  this(id, stack, durability, MaterialData.class);
435  }
436 
437  private Material(final int id, final Class<? extends MaterialData> data) {
438  this(id, 64, data);
439  }
440 
441  private Material(final int id, final int stack, final Class<? extends MaterialData> data) {
442  this(id, stack, 0, data);
443  }
444 
445  private Material(final int id, final int stack, final int durability, final Class<? extends MaterialData> data) {
446  this.id = id;
447  this.durability = (short) durability;
448  this.maxStack = stack;
449  // try to cache the constructor for this material
450  try {
451  this.ctor = data.getConstructor(int.class, byte.class);
452  } catch (NoSuchMethodException ex) {
453  throw new AssertionError(ex);
454  } catch (SecurityException ex) {
455  throw new AssertionError(ex);
456  }
457  }
458 
459  /**
460  * Gets the item ID or block ID of this Material
461  *
462  * @return ID of this material
463  * @deprecated Magic value
464  */
465  @Deprecated
466  public int getId() {
467  return id;
468  }
469 
470  /**
471  * Gets the maximum amount of this material that can be held in a stack
472  *
473  * @return Maximum stack size for this material
474  */
475  public int getMaxStackSize() {
476  return maxStack;
477  }
478 
479  /**
480  * Gets the maximum durability of this material
481  *
482  * @return Maximum durability for this material
483  */
484  public short getMaxDurability() {
485  return durability;
486  }
487 
488  /**
489  * Gets the MaterialData class associated with this Material
490  *
491  * @return MaterialData associated with this Material
492  */
493  public Class<? extends MaterialData> getData() {
494  return ctor.getDeclaringClass();
495  }
496 
497  /**
498  * Constructs a new MaterialData relevant for this Material, with the
499  * given initial data
500  *
501  * @param raw Initial data to construct the MaterialData with
502  * @return New MaterialData with the given data
503  * @deprecated Magic value
504  */
505  @Deprecated
506  public MaterialData getNewData(final byte raw) {
507  try {
508  return ctor.newInstance(id, raw);
509  } catch (InstantiationException ex) {
510  final Throwable t = ex.getCause();
511  if (t instanceof RuntimeException) {
512  throw (RuntimeException) t;
513  }
514  if (t instanceof Error) {
515  throw (Error) t;
516  }
517  throw new AssertionError(t);
518  } catch (Throwable t) {
519  throw new AssertionError(t);
520  }
521  }
522 
523  /**
524  * Checks if this Material is a placable block
525  *
526  * @return true if this material is a block
527  */
528  public boolean isBlock() {
529  return id < 256;
530  }
531 
532  /**
533  * Checks if this Material is edible.
534  *
535  * @return true if this Material is edible.
536  */
537  public boolean isEdible() {
538  switch (this) {
539  case BREAD:
540  case CARROT_ITEM:
541  case BAKED_POTATO:
542  case POTATO_ITEM:
543  case POISONOUS_POTATO:
544  case GOLDEN_CARROT:
545  case PUMPKIN_PIE:
546  case COOKIE:
547  case MELON:
548  case MUSHROOM_SOUP:
549  case RAW_CHICKEN:
550  case COOKED_CHICKEN:
551  case RAW_BEEF:
552  case COOKED_BEEF:
553  case RAW_FISH:
554  case COOKED_FISH:
555  case PORK:
556  case GRILLED_PORK:
557  case APPLE:
558  case GOLDEN_APPLE:
559  case ROTTEN_FLESH:
560  case SPIDER_EYE:
561  return true;
562  default:
563  return false;
564  }
565  }
566 
567  /**
568  * Attempts to get the Material with the given ID
569  *
570  * @param id ID of the material to get
571  * @return Material if found, or null
572  * @deprecated Magic value
573  */
574  @Deprecated
575  public static Material getMaterial(final int id) {
576  if (byId.length > id && id >= 0) {
577  return byId[id];
578  } else {
579  return null;
580  }
581  }
582 
583  /**
584  * Attempts to get the Material with the given name.
585  * <p>
586  * This is a normal lookup, names must be the precise name they are given
587  * in the enum.
588  *
589  * @param name Name of the material to get
590  * @return Material if found, or null
591  */
592  public static Material getMaterial(final String name) {
593  return BY_NAME.get(name);
594  }
595 
596  /**
597  * Attempts to match the Material with the given name.
598  * <p>
599  * This is a match lookup; names will be converted to uppercase, then
600  * stripped of special characters in an attempt to format it like the
601  * enum.
602  * <p>
603  * Using this for match by ID is deprecated.
604  *
605  * @param name Name of the material to get
606  * @return Material if found, or null
607  */
608  public static Material matchMaterial(final String name) {
609  Validate.notNull(name, "Name cannot be null");
610 
611  Material result = null;
612 
613  try {
614  result = getMaterial(Integer.parseInt(name));
615  } catch (NumberFormatException ex) {}
616 
617  if (result == null) {
618  String filtered = name.toUpperCase();
619 
620  filtered = filtered.replaceAll("\\s+", "_").replaceAll("\\W", "");
621  result = BY_NAME.get(filtered);
622  }
623 
624  return result;
625  }
626 
627  static {
628  for (Material material : values()) {
629  if (byId.length > material.id) {
630  byId[material.id] = material;
631  } else {
632  byId = Java15Compat.Arrays_copyOfRange(byId, 0, material.id + 2);
633  byId[material.id] = material;
634  }
635  BY_NAME.put(material.name(), material);
636  }
637  }
638 
639  /**
640  * @return True if this material represents a playable music disk.
641  */
642  public boolean isRecord() {
643  return id >= GOLD_RECORD.id && id <= RECORD_12.id;
644  }
645 
646  /**
647  * Check if the material is a block and solid (cannot be passed through by
648  * a player)
649  *
650  * @return True if this material is a block and solid
651  */
652  public boolean isSolid() {
653  if (!isBlock() || id == 0) {
654  return false;
655  }
656  switch (this) {
657  case STONE:
658  case GRASS:
659  case DIRT:
660  case COBBLESTONE:
661  case WOOD:
662  case BEDROCK:
663  case SAND:
664  case GRAVEL:
665  case GOLD_ORE:
666  case IRON_ORE:
667  case COAL_ORE:
668  case LOG:
669  case LEAVES:
670  case SPONGE:
671  case GLASS:
672  case LAPIS_ORE:
673  case LAPIS_BLOCK:
674  case DISPENSER:
675  case SANDSTONE:
676  case NOTE_BLOCK:
677  case BED_BLOCK:
678  case PISTON_STICKY_BASE:
679  case PISTON_BASE:
680  case PISTON_EXTENSION:
681  case WOOL:
682  case PISTON_MOVING_PIECE:
683  case GOLD_BLOCK:
684  case IRON_BLOCK:
685  case DOUBLE_STEP:
686  case STEP:
687  case BRICK:
688  case TNT:
689  case BOOKSHELF:
690  case MOSSY_COBBLESTONE:
691  case OBSIDIAN:
692  case MOB_SPAWNER:
693  case WOOD_STAIRS:
694  case CHEST:
695  case DIAMOND_ORE:
696  case DIAMOND_BLOCK:
697  case WORKBENCH:
698  case SOIL:
699  case FURNACE:
700  case BURNING_FURNACE:
701  case SIGN_POST:
702  case WOODEN_DOOR:
703  case COBBLESTONE_STAIRS:
704  case WALL_SIGN:
705  case STONE_PLATE:
706  case IRON_DOOR_BLOCK:
707  case WOOD_PLATE:
708  case REDSTONE_ORE:
709  case GLOWING_REDSTONE_ORE:
710  case ICE:
711  case SNOW_BLOCK:
712  case CACTUS:
713  case CLAY:
714  case JUKEBOX:
715  case FENCE:
716  case PUMPKIN:
717  case NETHERRACK:
718  case SOUL_SAND:
719  case GLOWSTONE:
720  case JACK_O_LANTERN:
721  case CAKE_BLOCK:
722  case LOCKED_CHEST:
723  case STAINED_GLASS:
724  case TRAP_DOOR:
725  case MONSTER_EGGS:
726  case SMOOTH_BRICK:
727  case HUGE_MUSHROOM_1:
728  case HUGE_MUSHROOM_2:
729  case IRON_FENCE:
730  case THIN_GLASS:
731  case MELON_BLOCK:
732  case FENCE_GATE:
733  case BRICK_STAIRS:
734  case SMOOTH_STAIRS:
735  case MYCEL:
736  case NETHER_BRICK:
737  case NETHER_FENCE:
738  case NETHER_BRICK_STAIRS:
739  case ENCHANTMENT_TABLE:
740  case BREWING_STAND:
741  case CAULDRON:
742  case ENDER_PORTAL_FRAME:
743  case ENDER_STONE:
744  case DRAGON_EGG:
745  case REDSTONE_LAMP_OFF:
746  case REDSTONE_LAMP_ON:
747  case WOOD_DOUBLE_STEP:
748  case WOOD_STEP:
749  case SANDSTONE_STAIRS:
750  case EMERALD_ORE:
751  case ENDER_CHEST:
752  case EMERALD_BLOCK:
753  case SPRUCE_WOOD_STAIRS:
754  case BIRCH_WOOD_STAIRS:
755  case JUNGLE_WOOD_STAIRS:
756  case COMMAND:
757  case BEACON:
758  case COBBLE_WALL:
759  case ANVIL:
760  case TRAPPED_CHEST:
761  case GOLD_PLATE:
762  case IRON_PLATE:
763  case DAYLIGHT_DETECTOR:
764  case REDSTONE_BLOCK:
765  case QUARTZ_ORE:
766  case HOPPER:
767  case QUARTZ_BLOCK:
768  case QUARTZ_STAIRS:
769  case DROPPER:
770  case STAINED_CLAY:
771  case HAY_BLOCK:
772  case HARD_CLAY:
773  case COAL_BLOCK:
774  case STAINED_GLASS_PANE:
775  case LEAVES_2:
776  case LOG_2:
777  case ACACIA_STAIRS:
778  case DARK_OAK_STAIRS:
779  case PACKED_ICE:
780  return true;
781  default:
782  return false;
783  }
784  }
785 
786  /**
787  * Check if the material is a block and does not block any light
788  *
789  * @return True if this material is a block and does not block any light
790  */
791  public boolean isTransparent() {
792  if (!isBlock()) {
793  return false;
794  }
795  switch (this) {
796  case AIR:
797  case SAPLING:
798  case POWERED_RAIL:
799  case DETECTOR_RAIL:
800  case LONG_GRASS:
801  case DEAD_BUSH:
802  case YELLOW_FLOWER:
803  case RED_ROSE:
804  case BROWN_MUSHROOM:
805  case RED_MUSHROOM:
806  case TORCH:
807  case FIRE:
808  case REDSTONE_WIRE:
809  case CROPS:
810  case LADDER:
811  case RAILS:
812  case LEVER:
813  case REDSTONE_TORCH_OFF:
814  case REDSTONE_TORCH_ON:
815  case STONE_BUTTON:
816  case SNOW:
817  case SUGAR_CANE_BLOCK:
818  case PORTAL:
819  case DIODE_BLOCK_OFF:
820  case DIODE_BLOCK_ON:
821  case PUMPKIN_STEM:
822  case MELON_STEM:
823  case VINE:
824  case WATER_LILY:
825  case NETHER_WARTS:
826  case ENDER_PORTAL:
827  case COCOA:
828  case TRIPWIRE_HOOK:
829  case TRIPWIRE:
830  case FLOWER_POT:
831  case CARROT:
832  case POTATO:
833  case WOOD_BUTTON:
834  case SKULL:
835  case REDSTONE_COMPARATOR_OFF:
836  case REDSTONE_COMPARATOR_ON:
837  case ACTIVATOR_RAIL:
838  case CARPET:
839  case DOUBLE_PLANT:
840  return true;
841  default:
842  return false;
843  }
844  }
845 
846  /**
847  * Check if the material is a block and can catch fire
848  *
849  * @return True if this material is a block and can catch fire
850  */
851  public boolean isFlammable() {
852  if (!isBlock()) {
853  return false;
854  }
855  switch (this) {
856  case WOOD:
857  case LOG:
858  case LEAVES:
859  case NOTE_BLOCK:
860  case BED_BLOCK:
861  case LONG_GRASS:
862  case DEAD_BUSH:
863  case WOOL:
864  case TNT:
865  case BOOKSHELF:
866  case WOOD_STAIRS:
867  case CHEST:
868  case WORKBENCH:
869  case SIGN_POST:
870  case WOODEN_DOOR:
871  case WALL_SIGN:
872  case WOOD_PLATE:
873  case JUKEBOX:
874  case FENCE:
875  case TRAP_DOOR:
876  case HUGE_MUSHROOM_1:
877  case HUGE_MUSHROOM_2:
878  case VINE:
879  case FENCE_GATE:
880  case WOOD_DOUBLE_STEP:
881  case WOOD_STEP:
882  case SPRUCE_WOOD_STAIRS:
883  case BIRCH_WOOD_STAIRS:
884  case JUNGLE_WOOD_STAIRS:
885  case TRAPPED_CHEST:
886  case DAYLIGHT_DETECTOR:
887  case CARPET:
888  case LEAVES_2:
889  case LOG_2:
890  case ACACIA_STAIRS:
891  case DARK_OAK_STAIRS:
892  return true;
893  default:
894  return false;
895  }
896  }
897 
898  /**
899  * Check if the material is a block and can burn away
900  *
901  * @return True if this material is a block and can burn away
902  */
903  public boolean isBurnable() {
904  if (!isBlock()) {
905  return false;
906  }
907  switch (this) {
908  case WOOD:
909  case LOG:
910  case LEAVES:
911  case LONG_GRASS:
912  case WOOL:
913  case YELLOW_FLOWER:
914  case RED_ROSE:
915  case TNT:
916  case BOOKSHELF:
917  case WOOD_STAIRS:
918  case FENCE:
919  case VINE:
920  case WOOD_DOUBLE_STEP:
921  case WOOD_STEP:
922  case SPRUCE_WOOD_STAIRS:
923  case BIRCH_WOOD_STAIRS:
924  case JUNGLE_WOOD_STAIRS:
925  case HAY_BLOCK:
926  case COAL_BLOCK:
927  case LEAVES_2:
928  case LOG_2:
929  case CARPET:
930  case DOUBLE_PLANT:
931  return true;
932  default:
933  return false;
934  }
935  }
936 
937  /**
938  * Check if the material is a block and completely blocks vision
939  *
940  * @return True if this material is a block and completely blocks vision
941  */
942  public boolean isOccluding() {
943  if (!isBlock()) {
944  return false;
945  }
946  switch (this) {
947  case STONE:
948  case GRASS:
949  case DIRT:
950  case COBBLESTONE:
951  case WOOD:
952  case BEDROCK:
953  case SAND:
954  case GRAVEL:
955  case GOLD_ORE:
956  case IRON_ORE:
957  case COAL_ORE:
958  case LOG:
959  case SPONGE:
960  case LAPIS_ORE:
961  case LAPIS_BLOCK:
962  case DISPENSER:
963  case SANDSTONE:
964  case NOTE_BLOCK:
965  case WOOL:
966  case GOLD_BLOCK:
967  case IRON_BLOCK:
968  case DOUBLE_STEP:
969  case BRICK:
970  case BOOKSHELF:
971  case MOSSY_COBBLESTONE:
972  case OBSIDIAN:
973  case MOB_SPAWNER:
974  case DIAMOND_ORE:
975  case DIAMOND_BLOCK:
976  case WORKBENCH:
977  case FURNACE:
978  case BURNING_FURNACE:
979  case REDSTONE_ORE:
980  case GLOWING_REDSTONE_ORE:
981  case SNOW_BLOCK:
982  case CLAY:
983  case JUKEBOX:
984  case PUMPKIN:
985  case NETHERRACK:
986  case SOUL_SAND:
987  case JACK_O_LANTERN:
988  case MONSTER_EGGS:
989  case SMOOTH_BRICK:
990  case HUGE_MUSHROOM_1:
991  case HUGE_MUSHROOM_2:
992  case MELON_BLOCK:
993  case MYCEL:
994  case NETHER_BRICK:
995  case ENDER_PORTAL_FRAME:
996  case ENDER_STONE:
997  case REDSTONE_LAMP_OFF:
998  case REDSTONE_LAMP_ON:
999  case WOOD_DOUBLE_STEP:
1000  case EMERALD_ORE:
1001  case EMERALD_BLOCK:
1002  case COMMAND:
1003  case QUARTZ_ORE:
1004  case QUARTZ_BLOCK:
1005  case DROPPER:
1006  case STAINED_CLAY:
1007  case HAY_BLOCK:
1008  case HARD_CLAY:
1009  case COAL_BLOCK:
1010  case LOG_2:
1011  case PACKED_ICE:
1012  return true;
1013  default:
1014  return false;
1015  }
1016  }
1017 
1018  /**
1019  * @return True if this material is affected by gravity.
1020  */
1021  public boolean hasGravity() {
1022  if (!isBlock()) {
1023  return false;
1024  }
1025  switch (this) {
1026  case SAND:
1027  case GRAVEL:
1028  case ANVIL:
1029  return true;
1030  default:
1031  return false;
1032  }
1033  }
1034 }
static Material getMaterial(final String name)
Definition: Material.java:592
boolean isOccluding()
Definition: Material.java:942
MaterialData getNewData(final byte raw)
Definition: Material.java:506
boolean hasGravity()
Definition: Material.java:1021
boolean isEdible()
Definition: Material.java:537
static Material getMaterial(final int id)
Definition: Material.java:575
boolean isRecord()
Definition: Material.java:642
boolean isFlammable()
Definition: Material.java:851
Class<?extends MaterialData > getData()
Definition: Material.java:493
static Material matchMaterial(final String name)
Definition: Material.java:608
short getMaxDurability()
Definition: Material.java:484
boolean isBurnable()
Definition: Material.java:903
boolean isTransparent()
Definition: Material.java:791