public IToast.Visibility draw(GuiToast toastGui, long delta) { toastGui.getMinecraft().getTextureManager().bindTexture(TEXTURE_TOASTS); GlStateManager.color(1.0F, 1.0F, 1.0F); toastGui.drawTexturedModalRect(0, 0, 0, 0, 160, 32); toastGui.getMinecraft().fontRenderer.drawString( I18n.format(expanded ? "toast.arcanemagic.page_expanded" : "toast.arcanemagic.page_unlocked"), 30, 7, 0x5bc14d); toastGui.getMinecraft().fontRenderer.drawString(I18n.format(unlocked.getUnlocalizedName()), 30, 18, 0x65a595); if (!this.hasPlayedSound && delta > 0L) { this.hasPlayedSound = true; toastGui.getMinecraft().getSoundHandler() .playSound(PositionedSoundRecord.getRecord(ArcaneMagicSoundHandler.randomLearnSound(), 1.0F, 1.0F)); } RenderHelper.enableGUIStandardItemLighting(); toastGui.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI((EntityLivingBase) null, unlocked.getIcon(), 8, 8); return delta >= 5000L ? IToast.Visibility.HIDE : IToast.Visibility.SHOW; }
public void playRecord(String recordName, BlockPos blockPosIn) { ISound isound = (ISound)this.mapSoundPositions.get(blockPosIn); if (isound != null) { this.mc.getSoundHandler().stopSound(isound); this.mapSoundPositions.remove(blockPosIn); } if (recordName != null) { ItemRecord itemrecord = ItemRecord.getRecord(recordName); if (itemrecord != null) { this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal()); } PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.create(new ResourceLocation(recordName), (float)blockPosIn.getX(), (float)blockPosIn.getY(), (float)blockPosIn.getZ()); this.mapSoundPositions.put(blockPosIn, positionedsoundrecord); this.mc.getSoundHandler().playSound(positionedsoundrecord); } }
/** * par8 is loudness, all pars passed to minecraftInstance.sndManager.playSound */ public void playSound(double x, double y, double z, String soundName, float volume, float pitch, boolean distanceDelay) { double d0 = this.mc.getRenderViewEntity().getDistanceSq(x, y, z); PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord(new ResourceLocation(soundName), volume, pitch, (float)x, (float)y, (float)z); if (distanceDelay && d0 > 100.0D) { double d1 = Math.sqrt(d0) / 40.0D; this.mc.getSoundHandler().playDelayedSound(positionedsoundrecord, (int)(d1 * 20.0D)); } else { this.mc.getSoundHandler().playSound(positionedsoundrecord); } }
public void mouseReleased(int mouseX, int mouseY) { if (this.field_146155_p) { if (this.field_146153_r == SoundCategory.MASTER) { float f = 1.0F; } else { GuiScreenOptionsSounds.this.game_settings_4.getSoundLevel(this.field_146153_r); } GuiScreenOptionsSounds.this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); } this.field_146155_p = false; }
protected void func_148132_a(int p_148132_1_, int p_148132_2_) { this.field_148218_l = -1; if (p_148132_1_ >= 79 && p_148132_1_ < 115) { this.field_148218_l = 0; } else if (p_148132_1_ >= 129 && p_148132_1_ < 165) { this.field_148218_l = 1; } else if (p_148132_1_ >= 179 && p_148132_1_ < 215) { this.field_148218_l = 2; } if (this.field_148218_l >= 0) { this.func_148212_h(this.field_148218_l); this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F)); } }
@SubscribeEvent public void onScreenShotShield(final @Nonnull ScreenShotShieldEvent.Post event) { if (Config.getConfig().notifyChat.get()) { final String mode = ScreenShotShieldRegistery.getListener(Config.getConfig().ssmode.get()).name(); ChatBuilder.create("mchelishield.notification.chat.screenshot.message").useTranslation().setParams(mode).chatClient(); ChatBuilder.create("mchelishield.notification.chat.screenshot.message.mode").useTranslation().setParams(mode).chatClient(); } if (Config.getConfig().notifySound.get()) FMLClientHandler.instance().getClient().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("mchelishield", "notification.sound"), 1.0F)); if (Config.getConfig().notifyEffect.get()) this.effectStrength = .75f; if (Config.getConfig().notifyOverlay.get()) { this.text = I18n.format("mchelishield.notification.overlay.screenshot.message"); this.textStrength = 1f; } }
@SubscribeEvent public void onModListShield(final @Nonnull ModListShieldEvent.Post event) { if (Config.getConfig().notifyChat.get()) { final String mode = ModListShieldRegistery.getListener(Config.getConfig().mlmode.get()).name(); ChatBuilder.create("mchelishield.notification.chat.modlist.message").useTranslation().setParams(mode).chatClient(); ChatBuilder.create("mchelishield.notification.chat.modlist.message.mode").useTranslation().setParams(mode).chatClient(); } if (Config.getConfig().notifySound.get()) FMLClientHandler.instance().getClient().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("mchelishield", "notification.sound"), 1.0F)); if (Config.getConfig().notifyEffect.get()) this.effectStrength = .75f; if (Config.getConfig().notifyOverlay.get()) { this.text = I18n.format("mchelishield.notification.overlay.modlist.message"); this.textStrength = 1f; } }
public void playRecord(@Nullable SoundEvent soundIn, BlockPos pos) { ISound isound = (ISound)this.mapSoundPositions.get(pos); if (isound != null) { this.mc.getSoundHandler().stopSound(isound); this.mapSoundPositions.remove(pos); } if (soundIn != null) { ItemRecord itemrecord = ItemRecord.getBySound(soundIn); if (itemrecord != null) { this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal()); } PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.getRecordSoundRecord(soundIn, (float)pos.getX(), (float)pos.getY(), (float)pos.getZ()); this.mapSoundPositions.put(pos, positionedsoundrecord); this.mc.getSoundHandler().playSound(positionedsoundrecord); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onGuiOpen(GuiOpenEvent event) { if(event.getGui() instanceof GuiMainMenu && !played) { played = true; if(playOn == 1 || playOn == 3) { SoundEvent sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(name)); if(sound != null) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(sound, (float)pitch)); } else { logger.log(Level.WARN, "Could not find sound: %s", new ResourceLocation(name)); } } } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onWorldTick(TickEvent.WorldTickEvent event) { if(playWorld && event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().player != null && (Minecraft.getMinecraft().player.ticksExisted > 20 || Minecraft.getMinecraft().isGamePaused())) { playWorld = false; if(playOn == 2 || playOn == 3) { SoundEvent sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(nameWorld)); if(sound != null) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(sound, (float)pitchWorld)); } else { FMLLog.log("Ding", Level.WARN, "Could not find sound: %s", new ResourceLocation(nameWorld)); } } } }
public static ISound PlayMusic (ISound musicIn) { Minecraft mc = Minecraft.getMinecraft(); WorldClient world = mc.world; EntityPlayerSP player = mc.player; if (rand.nextFloat() > 0.5) { return musicIn; } if (world == null) { return musicIn; } else { switch (Biome.getIdForBiome(world.getBiome(player.getPosition()))) { case OCEAN: musicIn = PositionedSoundRecord.getMusicRecord(ModSound.OCEAN); return musicIn; case DEEP_OCEAN: musicIn = PositionedSoundRecord.getMusicRecord(ModSound.OCEAN); return musicIn; default: return musicIn; } } }
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); if (mouseButton == 0) { this.buttons.forEach(button -> { if (button.getKey().isMouseInside(mouseX - this.guiLeft, mouseY - this.guiTop)) { button.getValue().run(); this.mc.getSoundHandler().playSound( PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); } }); } }
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); if (mouseButton == 0) { int yClick = (mouseY - y - 25) / (fontRenderer.FONT_HEIGHT * 2 + 4) + scrollOffset; int yTask = y + 25 + (fontRenderer.FONT_HEIGHT + 2) * ((yClick - scrollOffset) * 2); if (mouseX >= x + 2 && mouseX <= x + 12 && mouseY >= yTask && mouseY <= yTask + fontRenderer.FONT_HEIGHT) { if (yClick < tasks.size() && yClick >= 0) { PacketHandler.INSTANCE.sendToServer(new MessageModifyTask(tasks.get(yClick).getTaskID())); tasks.remove(yClick); mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); if (tasks.size() <= maxTasks) { scrollBar.setVisible(false); scrollOffset = 0; } } } } }
@Override protected void mouseClicked(int mouseX, int mouseY, int button) { int x = (this.width-this.xSize)/2; int y = (this.height-this.ySize)/2; int scaleFactor = new ScaledResolution(Minecraft.getMinecraft(), x, y).getScaleFactor(); if (mouseX > x+(43*scaleFactor) && mouseX < x+(52*scaleFactor) && mouseY > y+(13*scaleFactor) && mouseY < y+(26*scaleFactor)) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); //TODO: Help (sub-)gui } else if (mouseX > x+(43*scaleFactor) && mouseX < x+(52*scaleFactor) && mouseY > y+(94*scaleFactor) && mouseY < y+(107*scaleFactor)) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); //TODO:Start infusion } else { super.mouseClicked(mouseX, mouseY, button); } }
@SubscribeEvent public void onBGMusic(PlaySoundEvent event) { if(event.getSound() != null && event.getSound().getCategory() != null && event.getSound().getCategory() == SoundCategory.MUSIC) { if(event.getManager().isSoundPlaying(iSound)) { event.setResultSound(null); } else { iSound = PositionedSoundRecord.getMusicRecord(TFC_Sounds.TFCMUSIC); event.setResultSound(iSound); } } }
/** * Plays the specified record. Arg: recordName, x, y, z */ public void playRecord(String par1Str, int par2, int par3, int par4) { ChunkCoordinates var5 = new ChunkCoordinates(par2, par3, par4); ISound var6 = (ISound)this.mapSoundPositions.get(var5); if (var6 != null) { this.mc.getSoundHandler().func_147683_b(var6); this.mapSoundPositions.remove(var5); } if (par1Str != null) { ItemRecord var7 = ItemRecord.func_150926_b(par1Str); if (var7 != null) { this.mc.ingameGUI.setRecordPlayingMessage(var7.func_150927_i()); } PositionedSoundRecord var8 = PositionedSoundRecord.func_147675_a(new ResourceLocation(par1Str), (float)par2, (float)par3, (float)par4); this.mapSoundPositions.put(var5, var8); this.mc.getSoundHandler().playSound(var8); } }
/** * par8 is loudness, all pars passed to minecraftInstance.sndManager.playSound */ public void playSound(double par1, double par3, double par5, String par7Str, float par8, float par9, boolean par10) { double var11 = this.mc.renderViewEntity.getDistanceSq(par1, par3, par5); PositionedSoundRecord var13 = new PositionedSoundRecord(new ResourceLocation(par7Str), par8, par9, (float)par1, (float)par3, (float)par5); if (par10 && var11 > 100.0D) { double var14 = Math.sqrt(var11) / 40.0D; this.mc.getSoundHandler().playDelayedSound(var13, (int)(var14 * 20.0D)); } else { this.mc.getSoundHandler().playSound(var13); } }
public void mouseReleased(int p_146118_1_, int p_146118_2_) { if (this.field_146155_p) { if (this.field_146153_r == SoundCategory.MASTER) { float var10000 = 1.0F; } else { GuiScreenOptionsSounds.this.field_146506_g.getSoundLevel(this.field_146153_r); } GuiScreenOptionsSounds.this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); } this.field_146155_p = false; }
protected void func_148132_a(int p_148132_1_, int p_148132_2_) { this.field_148218_l = -1; if (p_148132_1_ >= 79 && p_148132_1_ < 115) { this.field_148218_l = 0; } else if (p_148132_1_ >= 129 && p_148132_1_ < 165) { this.field_148218_l = 1; } else if (p_148132_1_ >= 179 && p_148132_1_ < 215) { this.field_148218_l = 2; } if (this.field_148218_l >= 0) { this.func_148212_h(this.field_148218_l); GuiStats.this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); } }
public static PositionedSoundRecord playAlarm(double x, double y, double z, String name, float volume) { float range = DEFAULT_RANGE; if (volume > 1.0F) { range *= volume; } Entity person = FMLClientHandler.instance().getClient().renderViewEntity; if (person != null && volume > 0 && person.getDistanceSq(x, y, z) < range * range) { PositionedSoundRecord sound = new PositionedSoundRecord( new ResourceLocation(name), volume, 1.0F, (float) x, (float) y, (float) z); playSound(sound); return sound; } return null; }
@Override public void update() { MusicTicker.MusicType musictype = this.field_147677_b.func_147109_W(); if (FMLClientHandler.instance().getWorldClient() != null && FMLClientHandler.instance().getWorldClient().provider instanceof IGalacticraftWorldProvider) { musictype = ClientProxy.MUSIC_TYPE_SPACE; } if (this.field_147678_c != null) { if (!musictype.getMusicTickerLocation().equals(this.field_147678_c.getPositionedSoundLocation())) { this.field_147677_b.getSoundHandler().stopSound(this.field_147678_c); this.field_147676_d = MathHelper.getRandomIntegerInRange(this.field_147679_a, 0, musictype.func_148634_b() / 2); } if (!this.field_147677_b.getSoundHandler().isSoundPlaying(this.field_147678_c)) { this.field_147678_c = null; this.field_147676_d = Math.min(MathHelper.getRandomIntegerInRange(this.field_147679_a, musictype.func_148634_b(), musictype.func_148633_c()), this.field_147676_d); } } if (this.field_147678_c == null && this.field_147676_d-- <= 0) { this.field_147678_c = PositionedSoundRecord.func_147673_a(musictype.getMusicTickerLocation()); this.field_147677_b.getSoundHandler().playSound(this.field_147678_c); this.field_147676_d = Integer.MAX_VALUE; } }
@Override public void keyTyped(char c, int i) { if (EMConfig.allowTeleportPlayers && (this.accept.isFocused() || this.receiver.isFocused()) && i != Keyboard.KEY_ESCAPE) { if (i == Keyboard.KEY_RETURN) { if (this.receiver.isFocused()) { this.requestPlayerTeleport(); } else if (this.accept.isFocused()) { this.acceptPlayer(); } } else { this.accept.textboxKeyTyped(c, i); this.receiver.textboxKeyTyped(c, i); } if (i != Keyboard.KEY_RETURN && i != Keyboard.KEY_BACK && i != Keyboard.KEY_LSHIFT && i != Keyboard.KEY_RSHIFT && i != Keyboard.KEY_LCONTROL && i != Keyboard.KEY_RCONTROL) { this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147673_a(new ResourceLocation("emobile", "phone"))); } } else { super.keyTyped(c, i); } }
@Override public void playSound(int soundId, float pitch, float volume, boolean repeat, boolean stop, float x, float y, float z) { SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler(); SoundEvent sound = SoundEvent.REGISTRY.getObjectById(soundId); if (sound != null) { if (stop) { soundHandler.stop(sound.getRegistryName().toString(), null); } else { PositionedSoundRecord positionedSound = new PositionedSoundRecord(sound.getSoundName(), SoundCategory.RECORDS, volume, pitch, repeat, 0, AttenuationType.LINEAR, x, y, z); soundHandler.playSound(positionedSound); } } }
public void mouseReleased(int p_146118_1_, int p_146118_2_) { if (this.field_146155_p) { if (this.field_146153_r == SoundCategory.MASTER) { float f = 1.0F; } else { GuiScreenOptionsSounds.this.field_146506_g.getSoundLevel(this.field_146153_r); } GuiScreenOptionsSounds.this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); } this.field_146155_p = false; }
public void initializeMainframe(String name, int i, int j, int k) { Minecraft mc = Minecraft.getMinecraft(); mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); int oriScale = mc.gameSettings.guiScale; mc.gameSettings.guiScale = mc.gameSettings.guiScale == 1 ? 1 : 2; mainframe = new Mainframe(); UUID uuid; try { uuid = UUIDTypeAdapter.fromString(mc.getSession().getPlayerID()); } catch(IllegalArgumentException e) { uuid = UUIDTypeAdapter.fromString("deadbeef-dead-beef-dead-beefdeadbeef"); } mainframe.addListener(mc.getSession().getUsername(), true); FMLClientHandler.instance().showGuiScreen(new GuiWorkspace(oriScale, false, true, name, i, j, k)); }
public void openInfoScreen(Update update) { openUpdate = update; updateButton.visible = true; closeButton.visible = true; changeLogList.disableInput = false; updateList.disableInput = true; buttonDownloaded.setUpdate(update); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.ui_button_click, 1.0F)); if (update.isDirectLink) { updateButton.displayString = I18n.translateToLocal(Strings.UPDATE); updateButton.enabled = update.updateURL != null && !update.isDownloaded(); } else { updateButton.displayString = I18n.translateToLocal(Strings.OPEN_WEBPAGE); updateButton.enabled = update.updateURL != null; } if (openUpdate.changeLog != null) { changeLogList.setText(openUpdate.changeLog); } tempDisableButtonPress = 5; }
@Override protected void elementClicked(int index, boolean doubleClicked, int mouseX, int mouseY) { if (this._clickTarget != null) { this._clickTarget.getControl().mouseReleased(mouseX, mouseY); if (this._clickTarget.getOption().getDisplayState() == ConfigOption.DisplayState.shown_dynamic) { refreshGui = 2; } this._clickTarget = null; } IOptionControl control = (IOptionControl)this._optionControls.get(index); if (control.getControl().mousePressed(mc, mouseX, mouseY)) { mc.getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F)); this._clickTarget = control; } }
@Override public void mouseClicked(int i, int j, int mouseButton) { if (mouseButton == 1) { for (Object button : buttonList) { GuiButton guibutton = (GuiButton) button; if (guibutton.mousePressed(mc, i, j)) { mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); HudItem hudItem = HUDRegistry.getHudItemByID(guibutton.id); if (hudItem != null) { Minecraft.getMinecraft().displayGuiScreen(hudItem.getConfigScreen()); } } } } super.mouseClicked(i, j, mouseButton); }