2015-08-14 00:46:01 +02:00
|
|
|
package techreborn.events;
|
|
|
|
|
2015-11-23 15:40:30 +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 net.minecraft.entity.player.EntityPlayer;
|
2015-08-14 01:05:10 +02:00
|
|
|
import net.minecraft.item.Item;
|
2015-08-14 01:28:28 +02:00
|
|
|
import net.minecraft.potion.Potion;
|
2015-08-14 00:46:01 +02:00
|
|
|
import techreborn.init.ModItems;
|
|
|
|
|
2015-08-14 01:28:28 +02: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.getEquipmentInSlot(3) != null ? player.getEquipmentInSlot(3).getItem() : null;
|
|
|
|
|
|
|
|
if (previouslyWearing != chestslot && previouslyWearing == ModItems.cloakingDevice && player.isInvisible() && !player.isPotionActive(Potion.invisibility)) {
|
|
|
|
player.setInvisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
previouslyWearing = chestslot;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-14 00:46:01 +02:00
|
|
|
}
|