/*
 * Copyright  2014 - 2017 | 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 net.wurstclient.features.mods;

import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
import net.wurstclient.compatibility.WConnection;
import net.wurstclient.compatibility.WMinecraft;
import net.wurstclient.utils.ChatUtils;

@Mod.Info(
	description = "Generates an incredibly annoying potion.\n"
		+ "Tip: AntiBlind makes you partially immune to it.",
	name = "TrollPotion",
	tags = "troll potion",
	help = "Mods/TrollPotion")
@Mod.Bypasses
public final class TrollPotionMod extends Mod
{
	@Override
	public void onEnable()
	{
		if(WMinecraft.getPlayer().inventory.getStackInSlot(0) != null)
		{
			ChatUtils.error("Please clear the first slot in your hotbar.");
			setEnabled(false);
			return;
		}else if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
		{
			ChatUtils.error("Creative mode only.");
			setEnabled(false);
			return;
		}
		ItemStack stack = new ItemStack(Items.SPLASH_POTION);
		NBTTagList effects = new NBTTagList();
		for(int i = 1; i <= 23; i++)
		{
			NBTTagCompound effect = new NBTTagCompound();
			effect.setInteger("Amplifier", Integer.MAX_VALUE);
			effect.setInteger("Duration", Integer.MAX_VALUE);
			effect.setInteger("Id", i);
			effects.appendTag(effect);
		}
		stack.setTagInfo("CustomPotionEffects", effects);
		stack.setStackDisplayName("clTroll6lPotion");
		WConnection.sendPacket(new CPacketCreativeInventoryAction(36, stack));
		ChatUtils.message("Potion created. Trololo!");
		setEnabled(false);
	}
}

@@ -315,41 +315,8 @@
 s;%0A%0A
-import net.minecraft.init.Items;%0A
 impo
@@ -348,16 +348,16 @@
 mStack;%0A
+
 import n
@@ -430,131 +430,8 @@
 st;%0A
-import net.minecraft.network.play.client.CPacketCreativeInventoryAction;%0Aimport net.wurstclient.compatibility.WConnection;%0A
 impo
@@ -514,16 +514,61 @@
 atUtils;
+%0Aimport net.wurstclient.utils.InventoryUtils;
 %0A%0A@Mod.I
@@ -869,183 +869,28 @@
 %7B%0A%09%09
-if(WMinecraft.getPlayer().inventory.getStackInSlot(0) != null)%0A%09%09%7B%0A%09%09%09ChatUtils.error(%22Please clear the first slot in your hotbar.%22);%0A%09%09%09setEnabled(false);%0A%09%09%09return;%0A%09%09%7Delse 
+// check gamemode%0A%09%09
 if(!
@@ -1031,59 +1031,84 @@
 %7D%0A%09%09
-ItemStack stack = new ItemStack(Items.SPLASH_POTION
+%0A%09%09// generate potion%0A%09%09ItemStack stack = InventoryUtils.createSplashPotion(
 );%0A%09
@@ -1488,100 +1488,106 @@
 me(%22
-clTroll6lPotion%22);%0A%09%09WConnection.sendPacket(new CPacketCreativeInventoryAction(36, 
+rSplash Potion of Trolling%22);%0A%09%09%0A%09%09// give potion%0A%09%09if(InventoryUtils.placeStackInHotbar(
 stack))
-;
 %0A
+%09
 %09%09Ch
@@ -1622,20 +1622,80 @@
 ted.
- Trololo!%22);
+%22);%0A%09%09else%0A%09%09%09ChatUtils.error(%22Please clear a slot in your hotbar.%22);%0A%09%09
 %0A%09%09s

Update TrollPotionMod