001 package org.bukkit.material; 002 003 import java.util.List; 004 005 import org.bukkit.Material; 006 007 /** 008 * Represents textured materials like steps and smooth bricks 009 */ 010 public abstract class TexturedMaterial extends MaterialData { 011 012 public TexturedMaterial(Material m) { 013 super(m); 014 } 015 016 /** 017 * 018 * @deprecated Magic value 019 */ 020 @Deprecated 021 public TexturedMaterial(int type) { 022 super(type); 023 } 024 025 /** 026 * 027 * @deprecated Magic value 028 */ 029 @Deprecated 030 public TexturedMaterial(final int type, final byte data) { 031 super(type, data); 032 } 033 034 /** 035 * 036 * @deprecated Magic value 037 */ 038 @Deprecated 039 public TexturedMaterial(final Material type, final byte data) { 040 super(type, data); 041 } 042 043 /** 044 * Retrieve a list of possible textures. The first element of the list 045 * will be used as a default. 046 * 047 * @return a list of possible textures for this block 048 */ 049 public abstract List<Material> getTextures(); 050 051 /** 052 * Gets the current Material this block is made of 053 * 054 * @return Material of this block 055 */ 056 public Material getMaterial() { 057 int n = getTextureIndex(); 058 if (n > getTextures().size() - 1) { 059 n = 0; 060 } 061 062 return getTextures().get(n); 063 } 064 065 /** 066 * Sets the material this block is made of 067 * 068 * @param material 069 * New material of this block 070 */ 071 public void setMaterial(Material material) { 072 if (getTextures().contains(material)) { 073 setTextureIndex(getTextures().indexOf(material)); 074 } else { 075 setTextureIndex(0x0); 076 } 077 } 078 079 /** 080 * Get material index from data 081 * 082 * @return index of data in textures list 083 * @deprecated Magic value 084 */ 085 @Deprecated 086 protected int getTextureIndex() { 087 return getData(); // Default to using all bits - override for other mappings 088 } 089 090 /** 091 * Set material index 092 * 093 * @param idx - index of data in textures list 094 * @deprecated Magic value 095 */ 096 @Deprecated 097 protected void setTextureIndex(int idx) { 098 setData((byte) idx); // Defult to using all bits - override for other mappings 099 } 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 }