package com.hbm.main; import com.hbm.entity.mob.EntityHunterChopper; import com.hbm.entity.projectile.EntityChopperMine; import com.hbm.items.ModItems; import com.hbm.items.tool.ItemGeigerCounter; import com.hbm.lib.Library; import com.hbm.render.misc.RenderScreenOverlay; 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.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ResourceLocation; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.client.event.sound.PlaySoundEvent17; public class ModEventHandlerClient { @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent event) { if(event.type == ElementType.HOTBAR) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(player.inventory.hasItem(ModItems.geiger_counter)) { float rads = 0; for(int i = 0; i < player.inventory.getSizeInventory(); i++) { if(player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() == ModItems.geiger_counter) { rads = ItemGeigerCounter.getInt(player.inventory.getStackInSlot(i), "ticker"); break; } } ////TEST RadiationSavedData data = RadiationSavedData.getData(player.worldObj); Chunk chunk = player.worldObj.getChunkFromBlockCoords((int)player.posX, (int)player.posZ); rads = data.getRadNumFromCoord(chunk.xPosition, chunk.zPosition); ////TEST //if(player.worldObj.rand.nextInt(100) == 0) // System.out.println(rads); RenderScreenOverlay.renderRadCounter(event.resolution, rads, Minecraft.getMinecraft().ingameGUI); } } } @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); } } } }