MCPcopy Create free account
hub / github.com/Teneted/Tenet / setType

Method setType

src/main/java/org/bukkit/inventory/ItemStack.java:134–146  ·  view source on GitHub ↗

Sets the type of this item Note that in doing so you will reset the MaterialData for this stack. IMPORTANT: An Item Stack is only designed to contain items . Do not use this class to encapsulate Materials for which Material#isItem() returns false. @param type New

(@NotNull Material type)

Source from the content-addressed store, hash-verified

132 * @param type New type to set the items in this stack to
133 */
134 @Utility
135 public void setType(@NotNull Material type) {
136 Validate.notNull(type, "Material cannot be null");
137 this.type = type;
138 if (this.meta != null) {
139 this.meta = Bukkit.getItemFactory().asMetaFor(meta, type);
140 }
141 if (type.isLegacy()) {
142 createData((byte) 0);
143 } else {
144 this.data = null;
145 }
146 }
147
148 /**
149 * Gets the amount of items in this stack

Callers

nothing calls this directly

Calls 4

getItemFactoryMethod · 0.95
createDataMethod · 0.95
asMetaForMethod · 0.65
isLegacyMethod · 0.45

Tested by

no test coverage detected