Sets the MaterialData for this stack of items @param data New MaterialData for this item
(MaterialData data)
| 132 | * @param data New MaterialData for this item |
| 133 | */ |
| 134 | public void setData(MaterialData data) { |
| 135 | Material mat = getType(); |
| 136 | |
| 137 | if ((mat == null) || (mat.getData() == null)) { |
| 138 | this.data = data; |
| 139 | } else { |
| 140 | if ((data.getClass() == mat.getData()) || (data.getClass() == MaterialData.class)) { |
| 141 | this.data = data; |
| 142 | } else { |
| 143 | throw new IllegalArgumentException("Provided data is not of type " + mat.getData().getName() + ", found " + data.getClass().getName()); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Sets the durability of this item |