Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So I am working on my project NBS Recorder for 1.12 and I need to get the pitch of sounds in order to record them. However, when I try getting the pitch of a sound on PlaySoundEvent:

event.getSound().getPitch()

it fires NullPointerException:

[14:10:57] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.sound.PlaySoundEvent@7e4594ac:
java.lang.NullPointerException: null
	at net.minecraft.client.audio.PositionedSound.getPitch(PositionedSound.java:90) ~[PositionedSound.class:?]
	at cf.leduyquang753.nbsrecorder.Events.onSound(Events.java:47) ~[Events.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_13_Events_onSound_PlaySoundEvent.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraftforge.client.ForgeHooksClient.playSound(ForgeHooksClient.java:353) [ForgeHooksClient.class:?]
	at net.minecraft.client.audio.SoundManager.playSound(SoundManager.java:375) [SoundManager.class:?]
	at net.minecraft.client.audio.SoundHandler.playSound(SoundHandler.java:261) [SoundHandler.class:?]
	at net.minecraft.client.multiplayer.WorldClient.playSound(WorldClient.java:518) [WorldClient.class:?]
	at net.minecraft.client.multiplayer.WorldClient.playSound(WorldClient.java:497) [WorldClient.class:?]
	at net.minecraft.client.network.NetHandlerPlayClient.handleSoundEffect(NetHandlerPlayClient.java:1828) [NetHandlerPlayClient.class:?]
	at net.minecraft.network.play.server.SPacketSoundEffect.processPacket(SPacketSoundEffect.java:78) [SPacketSoundEffect.class:?]
	at net.minecraft.network.play.server.SPacketSoundEffect.processPacket(SPacketSoundEffect.java:13) [SPacketSoundEffect.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) [PacketThreadUtil$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_131]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_131]
	at net.minecraft.util.Util.runTask(Util.java:53) [Util.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1176) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]

 

I'm so confused now because this is the only way to record sounds for my mod (maybe not)...

  • Author

Uhhh, I'm confused because the ISoundEventListener class seems to be having only one method which maybe used to trigger the event:

void soundPlay(ISound soundIn, SoundEventAccessor accessor);

Did you tell me to hook up to something related to this?

I need these things when a sound is played: The name and the pitch of the sound.

Edited by leduyquang753
More info.

  • Author
7 minutes ago, diesieben07 said:

Those can be obtained from the ISound instance given to the method.

But, there aren't anything to retrieve from the ISoundEventListener class or soundPlay method? The whole class is just...

package net.minecraft.client.audio;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public interface ISoundEventListener
{
    void soundPlay(ISound soundIn, SoundEventAccessor accessor);
}

and nothing else?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.