package com.hbm.main; import com.hbm.entity.mob.EntityHunterChopper; import com.hbm.entity.projectile.EntityChopperMine; import com.hbm.interfaces.IHoldableWeapon; import com.hbm.items.ModItems; import com.hbm.items.tool.ItemGeigerCounter; import com.hbm.items.weapon.ItemGunBase; import com.hbm.lib.Library; import com.hbm.packet.GunButtonPacket; import com.hbm.packet.PacketDispatcher; import com.hbm.render.misc.RenderScreenOverlay; import com.hbm.saveddata.RadEntitySavedData; import com.hbm.saveddata.RadiationSavedData; import com.hbm.sound.MovingSoundChopper; import com.hbm.sound.MovingSoundChopperMine; import com.hbm.sound.MovingSoundCrashing; import com.hbm.sound.MovingSoundPlayerLoop; import com.hbm.sound.MovingSoundXVL1456; import com.hbm.sound.MovingSoundPlayerLoop.EnumHbmSound; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.renderer.entity.RenderPlayer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ResourceLocation; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.client.event.sound.PlaySoundEvent17; public class ModEventHandlerClient { @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(event.type == ElementType.HOTBAR) { if(player.inventory.hasItem(ModItems.geiger_counter)) { float rads = 0; float abs = 0; RadEntitySavedData data = RadEntitySavedData.getData(player.worldObj); rads = data.getRadFromEntity(player); RenderScreenOverlay.renderRadCounter(event.resolution, rads, Minecraft.getMinecraft().ingameGUI); } } else if(event.type == ElementType.CROSSHAIRS && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IHoldableWeapon) { event.setCanceled(true); } } @SubscribeEvent public void renderGunPull(RenderPlayerEvent.Pre event) { RenderPlayer renderer = event.renderer; EntityPlayer player = event.entityPlayer; if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof IHoldableWeapon) renderer.modelBipedMain.aimedBow = true; } @SubscribeEvent public void clickHandler(MouseEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemGunBase) { if(event.button == 0) event.setCanceled(true); ItemGunBase item = (ItemGunBase)player.getHeldItem().getItem(); if(event.button == 0 && !item.m1 && !item.m2) { item.m1 = true; PacketDispatcher.wrapper.sendToServer(new GunButtonPacket(true, (byte) 0)); System.out.println("M1"); } else if(event.button == 1 && !item.m2 && !item.m1) { item.m2 = true; PacketDispatcher.wrapper.sendToServer(new GunButtonPacket(true, (byte) 1)); System.out.println("M2"); } } } @SubscribeEvent public void onPlaySound(PlaySoundEvent17 e) { ResourceLocation r = e.sound.getPositionedSoundLocation(); WorldClient wc = Minecraft.getMinecraft().theWorld; //Alright, alright, I give the fuck up, you've wasted my time enough with this bullshit. You win. //A winner is you. //Conglaturations. //Fuck you. if(r.toString().equals("hbm:misc.nullTau") && Library.getClosestPlayerForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2) != null) { EntityPlayer ent = Library.getClosestPlayerForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2); if(MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundTauLoop) == null) { MovingSoundPlayerLoop.globalSoundList.add(new MovingSoundXVL1456(new ResourceLocation("hbm:weapon.tauChargeLoop2"), ent, EnumHbmSound.soundTauLoop)); MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundTauLoop).setPitch(0.5F); } else { if(MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundTauLoop).getPitch() < 1.5F) MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundTauLoop).setPitch(MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundTauLoop).getPitch() + 0.01F); } } if(r.toString().equals("hbm:misc.nullChopper") && Library.getClosestChopperForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2) != null) { EntityHunterChopper ent = Library.getClosestChopperForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2); if(MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundChopperLoop) == null) { MovingSoundPlayerLoop.globalSoundList.add(new MovingSoundChopper(new ResourceLocation("hbm:entity.chopperFlyingLoop"), ent, EnumHbmSound.soundChopperLoop)); MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundChopperLoop).setVolume(10.0F); } } if(r.toString().equals("hbm:misc.nullCrashing") && Library.getClosestChopperForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2) != null) { EntityHunterChopper ent = Library.getClosestChopperForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2); if(MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundCrashingLoop) == null) { MovingSoundPlayerLoop.globalSoundList.add(new MovingSoundCrashing(new ResourceLocation("hbm:entity.chopperCrashingLoop"), ent, EnumHbmSound.soundCrashingLoop)); MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundCrashingLoop).setVolume(10.0F); } } if(r.toString().equals("hbm:misc.nullMine") && Library.getClosestMineForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2) != null) { EntityChopperMine ent = Library.getClosestMineForSound(wc, e.sound.getXPosF(), e.sound.getYPosF(), e.sound.getZPosF(), 2); if(MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundMineLoop) == null) { MovingSoundPlayerLoop.globalSoundList.add(new MovingSoundChopperMine(new ResourceLocation("hbm:entity.chopperMineLoop"), ent, EnumHbmSound.soundMineLoop)); MovingSoundPlayerLoop.getSoundByPlayer(ent, EnumHbmSound.soundMineLoop).setVolume(10.0F); } } for(MovingSoundPlayerLoop sounds : MovingSoundPlayerLoop.globalSoundList) { if(!sounds.init || sounds.isDonePlaying()) { sounds.init = true; sounds.setDone(false); Minecraft.getMinecraft().getSoundHandler().playSound(sounds); } } } }