Bukkit  1.4.7-R1.0
 All Classes Namespaces Files Functions Variables Enumerator Pages
TexturedMaterial.java
Go to the documentation of this file.
1 package org.bukkit.material;
2 
3 import java.util.List;
4 
5 import org.bukkit.Material;
6 
10 public abstract class TexturedMaterial extends MaterialData {
11 
13  super(m);
14  }
15 
16  public TexturedMaterial(int type) {
17  super(type);
18  }
19 
20  public TexturedMaterial(final int type, final byte data) {
21  super(type, data);
22  }
23 
24  public TexturedMaterial(final Material type, final byte data) {
25  super(type, data);
26  }
27 
33  public abstract List<Material> getTextures();
34 
40  public Material getMaterial() {
41  int n = getTextureIndex();
42  if (n > getTextures().size() - 1) {
43  n = 0;
44  }
45 
46  return getTextures().get(n);
47  }
48 
55  public void setMaterial(Material material) {
56  if (getTextures().contains(material)) {
57  setTextureIndex(getTextures().indexOf(material));
58  } else {
59  setTextureIndex(0x0);
60  }
61  }
62 
67  protected int getTextureIndex() {
68  return getData(); // Default to using all bits - override for other mappings
69  }
70 
75  protected void setTextureIndex(int idx) {
76  setData((byte) idx); // Defult to using all bits - override for other mappings
77  }
78 
79  @Override
80  public String toString() {
81  return getMaterial() + " " + super.toString();
82  }
83 
84  @Override
86  return (TexturedMaterial) super.clone();
87  }
88 }