2014-08-25 07:58:39 -04:00
package WayofTime.alchemicalWizardry.client ;
2015-01-13 21:02:11 -05:00
import net.minecraft.client.Minecraft ;
import net.minecraft.entity.player.EntityPlayer ;
import net.minecraftforge.client.event.RenderBlockOverlayEvent ;
import net.minecraftforge.client.event.sound.SoundEvent ;
2014-09-14 18:21:45 -04:00
import WayofTime.alchemicalWizardry.AlchemicalWizardry ;
2015-01-13 21:02:11 -05:00
import WayofTime.alchemicalWizardry.ModBlocks ;
2014-08-25 07:58:39 -04:00
import WayofTime.alchemicalWizardry.client.renderer.RenderHelper ;
2015-01-13 21:02:11 -05:00
import WayofTime.alchemicalWizardry.common.ClientToServerPacketHandler ;
import WayofTime.alchemicalWizardry.common.MessageKeyPressed ;
2014-08-25 07:58:39 -04:00
import cpw.mods.fml.client.FMLClientHandler ;
2014-09-14 18:21:45 -04:00
import cpw.mods.fml.common.eventhandler.Event.Result ;
2014-08-25 07:58:39 -04:00
import cpw.mods.fml.common.eventhandler.SubscribeEvent ;
2015-01-13 21:02:11 -05:00
import cpw.mods.fml.common.gameevent.InputEvent ;
2014-08-25 07:58:39 -04:00
import cpw.mods.fml.common.gameevent.TickEvent.Phase ;
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent ;
2014-10-13 22:33:20 +02:00
public class ClientEventHandler
2014-08-25 07:58:39 -04:00
{
2014-10-13 22:33:20 +02:00
private Minecraft mcClient = FMLClientHandler . instance ( ) . getClient ( ) ;
2014-08-25 07:58:39 -04:00
2015-01-13 21:02:11 -05:00
@SubscribeEvent
public void onKeyInput ( InputEvent . KeyInputEvent event )
{
if ( KeyBindings . omegaTest . isPressed ( ) )
{
System . out . println ( " ping " ) ;
// NewPacketHandler.INSTANCE.sendToServer(NewPacketHandler.getKeyboardPressPacket((byte)2));
ClientToServerPacketHandler . INSTANCE . sendToServer ( new MessageKeyPressed ( MessageKeyPressed . Key . OMEGA_ACTIVE ) ) ;
}
}
2014-09-14 18:21:45 -04:00
@SubscribeEvent
public void onPlayerSoundEvent ( SoundEvent event )
{
2014-10-13 22:33:20 +02:00
if ( Minecraft . getMinecraft ( ) ! = null )
{
EntityPlayer player = Minecraft . getMinecraft ( ) . thePlayer ;
if ( player ! = null & & player . isPotionActive ( AlchemicalWizardry . customPotionDeaf ) )
{
event . setResult ( Result . DENY ) ;
2015-01-13 21:02:11 -05:00
if ( event . isCancelable ( ) )
event . setCanceled ( true ) ;
2014-10-13 22:33:20 +02:00
}
}
2014-09-14 18:21:45 -04:00
}
2015-01-13 21:02:11 -05:00
@SubscribeEvent
public void onOverlayEvent ( RenderBlockOverlayEvent event )
{
if ( event . overlayType = = RenderBlockOverlayEvent . OverlayType . WATER & & event . player . isPotionActive ( AlchemicalWizardry . customPotionAmphibian . id ) ) //TODO Placeholder for new potion effect
if ( event . isCancelable ( ) )
{
event . setCanceled ( true ) ;
}
if ( event . blockForOverlay = = ModBlocks . blockMimic & & event . isCancelable ( ) )
{
event . setCanceled ( true ) ;
}
}
2014-10-13 22:33:20 +02:00
2014-08-25 07:58:39 -04:00
@SubscribeEvent
public void onTick ( RenderTickEvent event )
{
if ( event . phase . equals ( Phase . START ) )
return ;
2014-10-13 22:33:20 +02:00
2014-08-25 07:58:39 -04:00
if ( ! RenderHelper . onTickInGame ( mcClient ) )
{
}
}
2014-10-13 22:33:20 +02:00
2015-01-13 21:02:11 -05:00
// @SubscribeEvent
// public void onRenderLivingPlayerPre(RenderPlayerEvent.Pre event)
// {
// GL11.glDisable(2929);
// }
//
// @SubscribeEvent
// public void onRenderLivingPlayerPost(RenderPlayerEvent.Post event)
// {
// GL11.glEnable(2929);
// }
2014-08-25 07:58:39 -04:00
}