Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
TexturedMaterial.java
1 package org.bukkit.material;
2 
3 import java.util.List;
4 
5 import org.bukkit.Material;
6 
7 /**
8  * Represents textured materials like steps and smooth bricks
9  */
10 public abstract class TexturedMaterial extends MaterialData {
11 
12  public TexturedMaterial(Material m) {
13  super(m);
14  }
15 
16  /**
17  *
18  * @deprecated Magic value
19  */
20  @Deprecated
21  public TexturedMaterial(int type) {
22  super(type);
23  }
24 
25  /**
26  *
27  * @deprecated Magic value
28  */
29  @Deprecated
30  public TexturedMaterial(final int type, final byte data) {
31  super(type, data);
32  }
33 
34  /**
35  *
36  * @deprecated Magic value
37  */
38  @Deprecated
39  public TexturedMaterial(final Material type, final byte data) {
40  super(type, data);
41  }
42 
43  /**
44  * Retrieve a list of possible textures. The first element of the list
45  * will be used as a default.
46  *
47  * @return a list of possible textures for this block
48  */
49  public abstract List<Material> getTextures();
50 
51  /**
52  * Gets the current Material this block is made of
53  *
54  * @return Material of this block
55  */
56  public Material getMaterial() {
57  int n = getTextureIndex();
58  if (n > getTextures().size() - 1) {
59  n = 0;
60  }
61 
62  return getTextures().get(n);
63  }
64 
65  /**
66  * Sets the material this block is made of
67  *
68  * @param material
69  * New material of this block
70  */
71  public void setMaterial(Material material) {
72  if (getTextures().contains(material)) {
73  setTextureIndex(getTextures().indexOf(material));
74  } else {
75  setTextureIndex(0x0);
76  }
77  }
78 
79  /**
80  * Get material index from data
81  *
82  * @return index of data in textures list
83  * @deprecated Magic value
84  */
85  @Deprecated
86  protected int getTextureIndex() {
87  return getData(); // Default to using all bits - override for other mappings
88  }
89 
90  /**
91  * Set material index
92  *
93  * @param idx - index of data in textures list
94  * @deprecated Magic value
95  */
96  @Deprecated
97  protected void setTextureIndex(int idx) {
98  setData((byte) idx); // Defult to using all bits - override for other mappings
99  }
100 
101  @Override
102  public String toString() {
103  return getMaterial() + " " + super.toString();
104  }
105 
106  @Override
107  public TexturedMaterial clone() {
108  return (TexturedMaterial) super.clone();
109  }
110 }
TexturedMaterial(final Material type, final byte data)
abstract List< Material > getTextures()
TexturedMaterial(final int type, final byte data)