2015-08-14 00:46:01 +02:00
|
|
|
package techreborn.events;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-13 18:38:12 +01:00
|
|
|
import net.minecraft.init.MobEffects;
|
2016-03-13 17:08:30 +01:00
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
2015-08-14 01:05:10 +02:00
|
|
|
import net.minecraft.item.Item;
|
2015-11-23 20:19:18 +01:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
|
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
2015-08-14 00:46:01 +02:00
|
|
|
import techreborn.init.ModItems;
|
|
|
|
|
2016-03-25 10:47:34 +01:00
|
|
|
public class TRTickHandler
|
|
|
|
{
|
|
|
|
|
|
|
|
public Item previouslyWearing;
|
|
|
|
|
|
|
|
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
|
|
|
|
public void onPlayerTick(TickEvent.PlayerTickEvent e)
|
|
|
|
{
|
|
|
|
EntityPlayer player = e.player;
|
|
|
|
Item chestslot = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null
|
|
|
|
? player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() : null;
|
|
|
|
|
|
|
|
if (previouslyWearing != chestslot && previouslyWearing == ModItems.cloakingDevice && player.isInvisible()
|
2016-05-06 23:13:24 +02:00
|
|
|
&& !player.isPotionActive(MobEffects.INVISIBILITY))
|
2016-03-25 10:47:34 +01:00
|
|
|
{
|
|
|
|
player.setInvisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
previouslyWearing = chestslot;
|
|
|
|
}
|
|
|
|
|
2015-08-14 00:46:01 +02:00
|
|
|
}
|