package com.slugterra.events;

import com.slugterra.entity.properties.ExtendedPlayer;
import com.slugterra.entity.properties.ExtendedSlingerAlly;
import com.slugterra.entity.properties.ExtendedSlingerEnemy;
import com.slugterra.entity.slingers.AllySlinger;
import com.slugterra.entity.slingers.EnemySlinger;
import com.slugterra.world.WorldGeneratorTheDrop;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;

public class SlugterraEventHandler {

	public static String playername;
	public static String text;

	@SubscribeEvent
	public void onEntityConstructing(EntityConstructing event)
	{
		if (event.entity instanceof EntityPlayer && ExtendedPlayer.get((EntityPlayer) event.entity) == null){
			ExtendedPlayer.register((EntityPlayer) event.entity);
		}

		if (event.entity instanceof EntityPlayer){
			EntityPlayer player = (EntityPlayer) event.entity;
		}

		if (event.entity instanceof EntityPlayer && event.entity.getExtendedProperties(ExtendedPlayer.EXT_PROP_NAME) == null){
			event.entity.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer((EntityPlayer) event.entity));
		}
	}

	@SubscribeEvent
	public void applySlingerProperties(EntityConstructing event)
	{
		if (event.entity instanceof EnemySlinger && ExtendedSlingerEnemy.get((EnemySlinger)event.entity) == null){
			ExtendedSlingerEnemy.register((EnemySlinger) event.entity);
		}

		if (event.entity instanceof EnemySlinger && event.entity.getExtendedProperties(ExtendedSlingerEnemy.EXT_PROP_NAME) == null){
			event.entity.registerExtendedProperties(ExtendedSlingerEnemy.EXT_PROP_NAME, new ExtendedSlingerEnemy((EnemySlinger) event.entity));
		}

		if (event.entity instanceof AllySlinger && ExtendedSlingerAlly.get((AllySlinger)event.entity) == null){
			ExtendedSlingerAlly.register((AllySlinger)event.entity);
		}

		if (event.entity instanceof AllySlinger && event.entity.getExtendedProperties(ExtendedSlingerAlly.EXT_PROP_NAME) == null){
			event.entity.registerExtendedProperties(ExtendedSlingerAlly.EXT_PROP_NAME, new ExtendedSlingerAlly((AllySlinger) event.entity));
		}
	}

	@SubscribeEvent
	public void updateUntilFire(LivingUpdateEvent event)
	{
		if (event.entity instanceof EntityPlayer)
		{
			ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) event.entity);
			props.updateTimetoFire();
		}
		if (event.entity instanceof EnemySlinger){
			ExtendedSlingerEnemy props = ExtendedSlingerEnemy.get((EnemySlinger) event.entity);
			props.updateTimetoFire();
		}
		if (event.entity instanceof AllySlinger){
			ExtendedSlingerAlly props = ExtendedSlingerAlly.get((AllySlinger)event.entity);
			props.updateTimetoFire();
		}
	}

	@SubscribeEvent
	public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){

		if (WorldGeneratorTheDrop.genmess != null){
			text = WorldGeneratorTheDrop.genmess;
		}
		else {
			text = "You are Stupid, Pack_of_14eggies.";
		}
		event.player.addChatMessage(new ChatComponentText(text));
	}
}

@@ -22,24 +22,66 @@
 .events;%0D%0A%0D%0A
+import com.slugterra.entity.EntityMecha;%0D%0A
 import com.s
@@ -120,24 +120,24 @@
 dedPlayer;%0D%0A
-
 import com.s
@@ -342,32 +342,126 @@
 .EnemySlinger;%0D%0A
+import com.slugterra.main.MainRegistry;%0D%0Aimport com.slugterra.packets.SyncPlayerPropsPacket;%0D%0A
 import com.slugt
@@ -601,24 +601,61 @@
 ayerEvent;%0D%0A
+import net.minecraft.entity.Entity;%0D%0A
 import net.m
@@ -688,24 +688,76 @@
 ityPlayer;%0D%0A
+import net.minecraft.entity.player.EntityPlayerMP;%0D%0A
 import net.m
@@ -939,16 +939,80 @@
 eEvent;%0D
+%0Aimport net.minecraftforge.event.entity.living.LivingFallEvent;%0D
 %0A%0D%0Apubli
@@ -1369,116 +1369,8 @@
 %0D%0A%0D%0A
-%09%09if (event.entity instanceof EntityPlayer)%7B%0D%0A%09%09%09EntityPlayer player = (EntityPlayer) event.entity;%0D%0A%09%09%7D%0D%0A%0D%0A
 %09%09if
@@ -1614,32 +1614,331 @@
 ));%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A
+%09@SubscribeEvent%0D%0A%09public void livingFall(LivingFallEvent event)%0D%0A%09%7B%0D%0A%09%09Entity entity = event.entity;%0D%0A%09%09if (entity instanceof EntityPlayer && entity.ridingEntity instanceof EntityMecha) %7B%0D%0A%09%09%09event.distance /= 5;%0D%0A%09%09%7D else if (entity instanceof EntityMecha) %7B%0D%0A%09%09%09event.distance /= 3;%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09%0D%0A
 %09@SubscribeEvent
@@ -3725,16 +3725,16 @@
 ;%0D%0A%09%09%7D%0D%0A
-
 %09%09event.
@@ -3786,15 +3786,119 @@
 ext));%0D%0A
+%09%09MainRegistry.network.sendTo(new SyncPlayerPropsPacket(event.player), (EntityPlayerMP) event.player);%0D%0A
 %09%7D%0D%0A%7D%0D%0A

Add new fall check to stop death from the mecha jumping