package makeo.gadomancy.common.events; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import makeo.gadomancy.common.data.ModConfig; import makeo.gadomancy.common.familiar.FamiliarAIController; import makeo.gadomancy.common.utils.world.TCMazeHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import thaumcraft.common.items.armor.Hover; /** * This class is part of the Gadomancy Mod * Gadomancy is Open Source and distributed under the * GNU LESSER GENERAL PUBLIC LICENSE * for more read the LICENSE file *

* Created by HellFirePvP @ 31.10.2015 15:28 */ public class EventHandlerEntity { @SubscribeEvent(priority = EventPriority.LOWEST) public void on(EntityEvent.EntityConstructing e) { if (e.entity instanceof EntityPlayer) { //e.entity.registerExtendedProperties(Gadomancy.MODID, new ExtendedPlayerProperties((EntityPlayer) e.entity)); } } @SubscribeEvent public void on(LivingSetAttackTargetEvent targetEvent) { if(targetEvent.target instanceof EntityPlayer) { FamiliarAIController.notifyTargetEvent(targetEvent.entityLiving, (EntityPlayer) targetEvent.target); } } @SubscribeEvent public void on(LivingDeathEvent event) { if(!event.entity.worldObj.isRemote && event.entityLiving instanceof EntityPlayer) { TCMazeHandler.closeSession((EntityPlayer) event.entityLiving, false); } } @SubscribeEvent public void on(LivingEvent.LivingUpdateEvent event) { if(event.entityLiving == null || !(event.entityLiving instanceof EntityPlayer)) return; EntityPlayer player = (EntityPlayer)event.entity; if ((event.entity.worldObj.provider.dimensionId == ModConfig.dimOuterId) && ((player.ticksExisted & 7) == 0) && ((player.capabilities.isFlying) || (Hover.getHover(player.getEntityId())))){ player.capabilities.isFlying = false; Hover.setHover(player.getEntityId(), false); if(!((EntityPlayer) event.entityLiving).worldObj.isRemote) { String msg = StatCollector.translateToLocal("tc.break.fly"); if(player.capabilities.isCreativeMode) { msg += " " + StatCollector.translateToLocal("gadomancy.eldritch.noflyCreative"); } player.addChatMessage(new ChatComponentText(EnumChatFormatting.ITALIC + "" + EnumChatFormatting.GRAY + msg)); } } } }