Jump to content

Recommended Posts

Posted

Sounds need to be converted to the .ogg format, last I checked.

In assets/modid/sounds, add the .ogg files.

In assets/modid, add a sounds.json

In that, you would add something like this, if you have a file called testSound.ogg

{
"testSound": { "category": "block", "sounds": ["modid:testSound"], "subtitle": "modid.subtitle.testSound" }
}

You will have to look up the various categories inside SoundCategory.

Subtitle is the unlocalized string presented to those that have subtitles enable.

 

You then need to create a SoundHandler, that registers the sounds.

Vazkii's Psi has one you can look at: https://github.com/Vazkii/Psi/blob/98d44ba9e7852739e11515d53f6c0f21cef418d1/src/main/java/vazkii/psi/common/core/handler/PsiSoundHandler.java

 

Then in the various world#sound.... methods, you'd just call your SoundHandler#SoundYouWant along with the other variables (x,y,z, category, pitch, volume etc )

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

So, I've done everything and it's all there and working, but......

 

It only plays the sound when I run the command. (It does take a little for the sound to load, but that's because it's a big audio file)

 

I am using a playersleepevent for example:

package com.fire.testmodclient.Events;

import com.fire.testmodclient.SoundHandler;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

public class PlayerSleep {

@SubscribeEvent
public void onPlayerSleep(PlayerSleepInBedEvent event){
	final Minecraft minecraft = Minecraft.getMinecraft();
	final EntityPlayer player = event.getEntityPlayer();
	final World world = player.worldObj;

	world.playSound(player, player.getPosition(), SoundHandler.testSound, SoundCategory.MUSIC, 1, 1);

	System.out.println("Player Sleeping");

	event.setResult(EntityPlayer.SleepResult.OTHER_PROBLEM);
}

}

 

The command I used that worked:

/playsound testmodclient:testSound music FireControl1847

 

Edit: Also, how do I get the sound to follow the player, and only the player can hear?

 

Edit 2: Also also, is there an event for when a sound ends?

I am on my journey of making a remake of matmos, as explained here.

Posted

1. I'm not sure how to tell the difference between EntityPlayer and EntityPlayerSP. The only way I can get EntityPlayer is event.getEntityPlayer();

 

2. The code below is not working:

 

PlayerSleepInBedEvent

package com.fire.testmodclient.Events;

import com.fire.testmodclient.Reference;
import com.fire.testmodclient.SoundHandler;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayer.SleepResult;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

public class PlayerSleep {

@SubscribeEvent
public void onPlayerSleep(PlayerSleepInBedEvent event){
	final EntityPlayer player = event.getEntityPlayer();
	final World world = player.worldObj;

	// world.playSound(player, player.getPosition(), SoundHandler.testSound, SoundCategory.MUSIC, 0.5F, 1F);
	// player.playSound(SoundHandler.testSound, 1, 1);

	if (event.getResultStatus() == SleepResult.OK) {
		player.playSound(SoundHandler.testSound, 1.0F, 1.0F);
	}

}

}

 

SoundHandler

package com.fire.testmodclient;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;

public class SoundHandler {

public static SoundEvent testSound;
public static SoundEvent testSound2;

private static int size = 0;

public static void init() {
	size = SoundEvent.REGISTRY.getKeys().size();

	testSound = register(null, "testSound");
}

public static SoundEvent register(String folder, String name) {
	ResourceLocation location = new ResourceLocation(Reference.MOD_ID + ":" + name);
	SoundEvent event = new SoundEvent(location);

	SoundEvent.REGISTRY.register(size, location, event);
	size++;
	return event;
}

}

 

Sounds Json

{
"testSound": { 
        "category": "music", 
        "sounds": ["testmodclient:testSound"], 
        "subtitle": "testmodclient.subtitle.testSound" ,
        "stream": true
    }
}

I am on my journey of making a remake of matmos, as explained here.

Posted

I am trying to make a client side mod, not a regular mod, that's why I asked about the EntityPlayerSP.

 

I'm trying to make what my signature says.

 

Edit: Also, is it possible to put the sounds in folders? I'm having trouble doing that...

I am on my journey of making a remake of matmos, as explained here.

Posted

I mean... I'm pretty sure. All I know is what you guys tell me... That's why I asked how to play custom sounds  ;)

 

This is what I've tried:

 

SoundHandler

package com.fire.testmodclient;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;

public class SoundHandler {

public static SoundEvent testSound;
public static SoundEvent testSound2;

private static int size = 0;

public static void init() {
	size = SoundEvent.REGISTRY.getKeys().size();

	testSound = register(null, "testSound");
	testSound2 = register("test", "testSound2");
}

public static SoundEvent register(String folder, String name) {
	ResourceLocation location;
	if (folder != null) {
		location = new ResourceLocation(Reference.MOD_ID + ":" + folder + "\\" + name);
	} else {
		location = new ResourceLocation(Reference.MOD_ID + ":" + name);
	}

	SoundEvent event = new SoundEvent(location);

	SoundEvent.REGISTRY.register(size, location, event);
	size++;
	return event;
}

}

 

Sounds Json

{
"testSound": { 
        "category": "music", 
        "sounds": ["testmodclient:testSound"], 
        "subtitle": "testmodclient.subtitle.testSound" ,
        "stream": true
    },
    "testSound2": { 
        "category": "music", 
        "sounds": ["testmodclient:test\testSound2"], 
        "subtitle": "testmodclient.subtitle.testSound" ,
        "stream": true
    }
}

 

Console Output

[12:58:01] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:testSound' to FireControl1847
[12:58:05] [Client thread/WARN]: Unable to play unknown soundEvent: testmodclient:test\testSound
[12:58:05] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test\testSound' to FireControl1847
[12:58:09] [Client thread/WARN]: Unable to play unknown soundEvent: testmodclient:test/testSound
[12:58:09] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test/testSound' to FireControl1847
[12:58:16] [Client thread/WARN]: Unable to play unknown soundEvent: testmodclient:test/testSound2
[12:58:16] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test/testSound2' to FireControl1847
[12:58:20] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test\testSound2' to FireControl1847

I am on my journey of making a remake of matmos, as explained here.

Posted

Okay, I'll try that.

 

Back to playing a custom sound: I have no idea how to do it... Please help me >.<

^ Considering my whole mod is based around this, let's let this be our main priority.

 

Edit: That didn't work. It says it played the sound but it's not.

 

[13:05:49] [server thread/INFO]: [FireControl1847: Played sound 'testmodclient:testSound' to FireControl1847]
[13:05:49] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:testSound' to FireControl1847
[13:05:53] [server thread/INFO]: [FireControl1847: Played sound 'testmodclient:test/testSound' to FireControl1847]
[13:05:53] [Client thread/WARN]: Unable to play unknown soundEvent: testmodclient:test/testSound
[13:05:53] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test/testSound' to FireControl1847
[13:05:59] [server thread/INFO]: [FireControl1847: Played sound 'testmodclient:test/testSound2' to FireControl1847]
[13:05:59] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test/testSound2' to FireControl1847
[13:06:10] [server thread/INFO]: [FireControl1847: Played sound 'testmodclient:test/testSound2' to FireControl1847]
[13:06:10] [Client thread/INFO]: [CHAT] Played sound 'testmodclient:test/testSound2' to FireControl1847

I am on my journey of making a remake of matmos, as explained here.

Posted

Okay.....

 

How do I get EntityPlayerSP instead of EntityPlayer?

 

Also, Quotes of what this article was/is about:

 

  On 8/13/2016 at 6:58 PM, FireController1847 said:

I mean... I'm pretty sure. All I know is what you guys tell me... That's why I asked how to play custom sounds  ;)

 

  Quote

1. I'm not sure how to tell the difference between EntityPlayer and EntityPlayerSP. The only way I can get EntityPlayer is event.getEntityPlayer();

 

2. The code below is not working:

 

PlayerSleepInBedEvent

package com.fire.testmodclient.Events;

import com.fire.testmodclient.Reference;
import com.fire.testmodclient.SoundHandler;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayer.SleepResult;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

public class PlayerSleep {

@SubscribeEvent
public void onPlayerSleep(PlayerSleepInBedEvent event){
	final EntityPlayer player = event.getEntityPlayer();
	final World world = player.worldObj;

	// world.playSound(player, player.getPosition(), SoundHandler.testSound, SoundCategory.MUSIC, 0.5F, 1F);
	// player.playSound(SoundHandler.testSound, 1, 1);

	if (event.getResultStatus() == SleepResult.OK) {
		player.playSound(SoundHandler.testSound, 1.0F, 1.0F);
	}

}

}

 

SoundHandler

package com.fire.testmodclient;

import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;

public class SoundHandler {

public static SoundEvent testSound;
public static SoundEvent testSound2;

private static int size = 0;

public static void init() {
	size = SoundEvent.REGISTRY.getKeys().size();

	testSound = register(null, "testSound");
}

public static SoundEvent register(String folder, String name) {
	ResourceLocation location = new ResourceLocation(Reference.MOD_ID + ":" + name);
	SoundEvent event = new SoundEvent(location);

	SoundEvent.REGISTRY.register(size, location, event);
	size++;
	return event;
}

}

 

Sounds Json

{
"testSound": { 
        "category": "music", 
        "sounds": ["testmodclient:testSound"], 
        "subtitle": "testmodclient.subtitle.testSound" ,
        "stream": true
    }
}

 

  Quote

So, I've done everything and it's all there and working, but......

 

It only plays the sound when I run the command. (It does take a little for the sound to load, but that's because it's a big audio file)

 

I am using a playersleepevent for example:

package com.fire.testmodclient.Events;

import com.fire.testmodclient.SoundHandler;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

public class PlayerSleep {

@SubscribeEvent
public void onPlayerSleep(PlayerSleepInBedEvent event){
	final Minecraft minecraft = Minecraft.getMinecraft();
	final EntityPlayer player = event.getEntityPlayer();
	final World world = player.worldObj;

	world.playSound(player, player.getPosition(), SoundHandler.testSound, SoundCategory.MUSIC, 1, 1);

	System.out.println("Player Sleeping");

	event.setResult(EntityPlayer.SleepResult.OTHER_PROBLEM);
}

}

 

The command I used that worked:

/playsound testmodclient:testSound music FireControl1847

 

Edit: Also, how do I get the sound to follow the player, and only the player can hear?

 

Edit 2: Also also, is there an event for when a sound ends?

I am on my journey of making a remake of matmos, as explained here.

Posted
  On 8/13/2016 at 7:33 PM, FireController1847 said:

Okay.....

How do I get EntityPlayerSP instead of EntityPlayer?

If you know java you should know about casting.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com   I’ve been reluctant in purchasing this blank atm card I heard about online because everything seems too good to be true, but I was convinced & shocked when my friend at my place of work got the card from "recoveryintelligent wozniak" & we both confirmed it really works, without delay I gave it a go. Ever since then I’ve been withdrawing $4950 daily from the card & the money has been in my own account. So glad I gave it a try at last and this card has really changed my life financially without getting caught, it really & truly works and it’s legal also made me rich!! If you need this card from "recoveryintelligent wozniak" then, Email: wozniakrecoveryintelligent AT zohomail . com    You can also contact them for the service below   Western Union Transfer Bank Transfer PayPal / Skrill Transfer Crypto Mining CashApp Transfer Bitcoin Loans Recover Stolen/Missing Crypto/Funds/Assets Email: wozniakrecoveryintelligent AT zohomail . com
    • There is an issue with Modular Force Field System (mffs) Remove it or try other builds
    • I never imagined I would be writing this kind of testimony, but I feel it’s important to share my experience with Malice Cyber Recovery and how they helped me recover $230,000 I lost to crypto scammers. A few months ago, I got involved in a crypto investment opportunity that seemed legitimate at first. The scammers were incredibly convincing. They showed me impressive returns, sent regular updates, and even gave me access to what looked like a real trading platform. I was initially cautious, but after seeing the returns, I began to invest more, ultimately transferring over $230,000. Unfortunately, after a few weeks, when I tried to withdraw my funds, I found that the platform had disappeared, and I could no longer contact anyone involved. It was clear I had been scammed, and I felt completely helpless. For weeks, I tried everything to get my money back—contacting the authorities, reaching out to the platform’s so-called support team (who of course were unreachable), and trying to trace the transactions myself. But everything led to dead ends. The more I researched, the more I realized just how hard it was to recover stolen crypto. I began to lose hope. That’s when I came across Malice Cyber Recovery. At first, I was skeptical. Could they really help me recover my funds after everything I had been through? I decided to reach out anyway, just to see if they could offer any guidance. From the very first conversation, their team was not only professional but also deeply empathetic. They understood exactly how I was feeling and immediately made it clear that they were dedicated to helping me recover my lost funds. Malice Cyber Recovery’s team got to work quickly. They walked me through every step of the process, explaining the methods they would use to track down my stolen crypto. Their knowledge of blockchain technology and how to trace crypto transactions was incredibly impressive. They didn’t just give me vague promises they showed me the action they were taking and the progress they were making, which gave me hope that my money wasn’t gone forever. One of the most reassuring aspects of working with Malice Cyber Recovery was their transparency. They kept me updated regularly, letting me know what they were doing, what obstacles they encountered, and how they were overcoming them. It wasn’t an easy process; tracing funds through blockchain and dealing with scammers who hide behind fake identities and complex networks is incredibly difficult. But Malice Cyber Recovery’s team was relentless. They used advanced tools and techniques to trace the flow of my funds, and within just a few weeks, they managed to locate a significant portion of my lost funds. I couldn’t believe it when they informed me that they had successfully recovered a large chunk of my money. I never thought I’d see that $230,000 again. The recovery process wasn’t instantaneous it  took time, patience, and persistence but Malice Cyber Recovery delivered on their promise.  
    • Almost, just the java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui and if that doesn't work, try java --version
    • What so just copy and paste " java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui Pause >nul " into a cmd terminal? If that's what you mean, nothing happens
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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