DeathChests/src/main/java/lostcave/deathchests/item/ItemObituary.java

49 lines
1.4 KiB
Java

package lostcave.deathchests.item;
import java.util.List;
import lostcave.deathchests.util.Config;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
public class ItemObituary extends Item {
private static final ItemObituary instance = new ItemObituary();
public static ItemObituary getInstance() {
return instance;
}
private ItemObituary() {
this.setUnlocalizedName("obituary");
this.setTextureName("paper");
this.setMaxStackSize(1);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (world.isRemote) return stack;
String chatMessage = "§4Error: Missing data";
if (stack.hasTagCompound()) {
NBTTagCompound compound = stack.getTagCompound();
if (compound.hasKey("message")) {
chatMessage = compound.getString("message");
}
}
player.addChatMessage(new ChatComponentText(chatMessage));
return stack;
}
//TODO: item description
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List lores, boolean bool) {
lores.add("Right-click me!");
}
}