ModsJava
Item Class | Item.java | Developer API
Java mod listed for Minecraft 1.7–1.13. Downloads from the MC Java Mods app on Android.
⬇ Download on Spigot
Code (Text):
ItemStack item = new Item(Material).setDisplayName("Name").build());
Code (Text):
package de.flowcode.serversystem.util;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.Arrays;
import java.util.List;
public class Item {
private ItemStack itemStack;
private ItemMeta itemMeta;
public Item(ItemStack itemStack) {
this.itemStack = itemStack;
this.itemMeta = itemStack.getItemMeta();
}
public Item(Material material) {
this.itemStack = new ItemStack(material);
this.itemMeta = itemStack.getItemMeta();
}
public Item(Material material, int id) {
this.itemStack = new ItemStack(material, 1, (short) id);
this.itemMeta = itemStack.getItemMeta();
}
public Item setDisplayName(String name) {
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
return this;
}
@SuppressWarnings("deprecation")
public Item setMetaID(byte metaID) {
itemStack.getData().setData(metaID);
return this;
}
public Item setOwner(String name) {
SkullMeta m = (SkullMeta) itemMeta;
m.setOwner(name);
itemStack.setItemMeta(m);
return this;
}
public Item setAmount(int amount) {
this.itemStack.setAmount(amount);
return this;
}
public Item setDurability(short durability) {
this.itemStack.setDurability(durability);
return this;
}
public Item addEnchantment(Enchantment enchantment, int lvl) {
this.itemMeta.addEnchant(enchantment, lvl, false);
return this;
}
public Item clearEnchantments() {
this.itemMeta.getEnchants().forEach((enchantment, integer) -> this.itemMeta.removeEnchant(enchantment));
return this;
}
public Item removeEnchantment(Enchantment enchantment) {
if (this.itemMeta.getEnchants().containsKey(enchantment))
this.itemMeta.removeEnchant(enchantment);
return this;
}
public Item setLore(List<String> lines) {
this.itemMeta.setLore(lines);
return this;
}
public Item setLore(String... lines) {
this.itemMeta.setLore(Arrays.asList(lines));
return this;
}
public Item resetLore() {
this.itemMeta.getLore().clear();
return this;
}
public ItemStack build() {
itemStack.setItemMeta(itemMeta);
return itemStack;
}
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.7, 1.8, 1.9
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
Item Class | Item.java | Developer API is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 186 times (via Spigot). Download it and open it directly in the game.