package techreborn.events;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
import techreborn.api.TechRebornItems;
import techreborn.init.ModItems;
import techreborn.items.tools.ItemCloakingDevice;

public class TRTickHandler extends TickEvent {
	public TRTickHandler(Type type, Side side, Phase phase) {
		super(type, side, phase);
		
	}
	
	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onPlayerTick(TickEvent.PlayerTickEvent e) {
		EntityPlayer player = e.player;
		
		if(player.getEquipmentInSlot(3)== null) {
			player.setInvisible(false);
		
		}			
		else if(player.getEquipmentInSlot(3).getItem() != ModItems.cloakingDevice) {
			player.setInvisible(false);
		}
			
		
			
	}

	
}

@@ -330,16 +330,90 @@
 Player;%0A
+import net.minecraft.item.Item;%0Aimport tconstruct.armor.ArmorTickHandler;%0A
 import t
@@ -668,16 +668,46 @@
 %0A%09%09%0A%09%7D%0A%09
+public Item previouslyWearing;
 %0A%09@Subsc
@@ -866,14 +866,25 @@
 ;%0A%09%09
-%0A%09%09if(
+Item chestslot = 
 play
@@ -911,138 +911,177 @@
 t(3)
-=
+ !
 = null
-) %7B%0A%09%09%09player.setInvisible(false);%0A%09%09%0A%09%09%7D%09%09%09%0A%09%09else if(player.getEquipmentInSlot(3).getItem() != ModItems.cloakingDevice) %7B
+ ? player.getEquipmentInSlot(3).getItem() : null;%0A%09%09%0A%09%09if(previouslyWearing != chestslot && previouslyWearing == ModItems.cloakingDevice && player.isInvisible())
 %0A%09%09%09
@@ -1114,20 +1114,38 @@
 ;%0A%09%09
-%7D%0A%09%09%09%0A%09%09%0A%09%09%09
+previouslyWearing = chestslot;
 %0A%09%7D%0A

Fix invisibility potions and cloaking device