Jump to content

[1.10.2]Sound does not work on item


NotLukas_

Recommended Posts

Hi,

I have been trying to test my sounds and copied a egg item onto my custom item

I replaced the sounds to make it run my sounds when it is thrown, but my sound is not playing

 

My item:


package notlukas.mod.item;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import notlukas.mod.init.soundHandler;

public class itemManaCrystal extends Item {

public itemManaCrystal(String unlocalizedName, String registryName) {

      this.setUnlocalizedName(unlocalizedName);
      this.setRegistryName(registryName);
      this.setCreativeTab(CreativeTabs.MISC);
}

    public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
    {
        if (!playerIn.capabilities.isCreativeMode)
        {
            --itemStackIn.stackSize;
        }

        worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, soundHandler.mana_crystal, SoundCategory.AMBIENT, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!worldIn.isRemote)
        {
            EntityEgg entityegg = new EntityEgg(worldIn, playerIn);
            entityegg.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
            worldIn.spawnEntityInWorld(entityegg);
        }

        playerIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
    }
}

 

My log :

 

Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
[18:58:51] [main/INFO] [GradleStart]: Extra: []
[18:58:52] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, /Users/Lukas/.gradle/caches/minecraft/assets, --assetIndex, 1.10, --accessToken{REDACTED}, --version, 1.10.2, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[18:58:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[18:58:52] [main/INFO] [FML]: Forge Mod Loader version 12.18.3.2185 for Minecraft 1.10.2 loading
[18:58:52] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_112, running on Mac OS X:x86_64:10.12.2, installed at /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre
[18:58:52] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[18:58:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[18:58:52] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[18:58:52] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[18:58:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:58:52] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:58:52] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[18:58:53] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing
[18:58:53] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:58:53] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:58:54] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[18:58:54] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:58:54] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:58:54] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[18:58:56] [Client thread/INFO]: Setting user: Player598
[18:59:02] [Client thread/WARN]: Skipping bad option: lastServer:
[18:59:02] [Client thread/INFO]: LWJGL Version: 2.9.2
[18:59:03] [Client thread/INFO] [FML]: MinecraftForge v12.18.3.2185 Initialized
[18:59:03] [Client thread/INFO] [FML]: Replaced 231 ore recipes
[18:59:03] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer
[18:59:03] [Client thread/INFO] [FML]: Searching /Users/Lukas/Desktop/terrariamod/run/mods for mods
[18:59:05] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load
[18:59:06] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, notl] at CLIENT
[18:59:06] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, notl] at SERVER
[18:59:06] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Terraria Mod
[18:59:07] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[18:59:07] [Client thread/INFO] [FML]: Found 423 ObjectHolder annotations
[18:59:07] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations
[18:59:07] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations
[18:59:07] [Client thread/INFO] [FML]: Applying holder lookups
[18:59:07] [Client thread/INFO] [FML]: Holder lookups applied
[18:59:07] [Client thread/INFO] [FML]: Applying holder lookups
[18:59:07] [Client thread/INFO] [FML]: Holder lookups applied
[18:59:07] [Client thread/INFO] [FML]: Applying holder lookups
[18:59:07] [Client thread/INFO] [FML]: Holder lookups applied
[18:59:07] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[18:59:07] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[18:59:07] [Client thread/INFO] [notl]: Registered item: fallen_star
[18:59:07] [Client thread/INFO] [notl]: Registered item: mana_crystal
[18:59:07] [Client thread/INFO] [notl]: Registered item: life_crystal
[18:59:07] [Client thread/INFO] [notl]: Registered item: life_fruit
[18:59:07] [Client thread/INFO] [notl]: Registered block: heart_lantern
[18:59:07] [Client thread/INFO] [notl]: Register Render for fallen_star
[18:59:07] [Client thread/INFO] [notl]: Register Render for mana_crystal
[18:59:07] [Client thread/INFO] [notl]: Register Render for life_crystal
[18:59:07] [Client thread/INFO] [notl]: Register Render for life_fruit
[18:59:07] [Client thread/INFO] [notl]: Register Render for heart_lantern
[18:59:07] [Client thread/INFO] [FML]: Applying holder lookups
[18:59:07] [Client thread/INFO] [FML]: Holder lookups applied
[18:59:07] [Client thread/INFO] [FML]: Injecting itemstacks
[18:59:07] [Client thread/INFO] [FML]: Itemstack injection complete
[18:59:07] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: UP_TO_DATE Target: null
[18:59:09] [sound Library Loader/INFO]: Starting up SoundSystem...
[18:59:09] [Thread-6/INFO]: Initializing LWJGL OpenAL
[18:59:09] [Thread-6/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[18:59:09] [Thread-6/INFO]: OpenAL initialized.
[18:59:10] [sound Library Loader/INFO]: Sound engine started
[18:59:13] [Client thread/INFO] [FML]: Max texture size: 4096
[18:59:13] [Client thread/INFO]: Created: 16x16 textures-atlas
[18:59:16] [Client thread/INFO] [FML]: Injecting itemstacks
[18:59:16] [Client thread/INFO] [FML]: Itemstack injection complete
[18:59:16] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods
[18:59:16] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Terraria Mod
[18:59:19] [Client thread/INFO]: SoundSystem shutting down...
[18:59:19] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com
[18:59:19] [sound Library Loader/INFO]: Starting up SoundSystem...
[18:59:19] [Thread-8/INFO]: Initializing LWJGL OpenAL
[18:59:19] [Thread-8/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)
[18:59:19] [Thread-8/INFO]: OpenAL initialized.
[18:59:19] [sound Library Loader/INFO]: Sound engine started
[18:59:22] [Client thread/INFO] [FML]: Max texture size: 4096
[18:59:23] [Client thread/INFO]: Created: 512x512 textures-atlas
[18:59:25] [Client thread/WARN]: Skipping bad option: lastServer:
[18:59:25] [Client thread/ERROR]: ########## GL ERROR ##########
[18:59:25] [Client thread/ERROR]: @ Post startup
[18:59:25] [Client thread/ERROR]: 1281: Invalid value
[18:59:26] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id

 

 

My .json file for the sounds:

 

{
  "heart_crystal":{"category": "record", "sounds": [{"name": "notl:heart_crystal","stream":false}]},
    "mana_crystal":{"category": "record", "sounds": [{"name": "notl:mana_crystal","stream":false}]}
  
}

 

I put my .json file in my assets and made a new folder called sounds in my assets and put the sounds there

so my json would be in assets/notl/sounds.json

and my sounds folder would be in assets/notl/sounds/

Link to comment
Share on other sites

Oh yes, sorry I forgot about it

 

package notlukas.mod.init;

import net.minecraft.client.audio.Sound;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import notlukas.mod.ref;
import notlukas.mod.util.utils;

public class soundHandler {

public static SoundEvent heart_crystal;
public static SoundEvent mana_crystal;

public static void registerSounds() {
	heart_crystal = registerSound("heart_crystal");
	mana_crystal = registerSound("mana_crystal");

}

private static SoundEvent registerSound(String soundName) {
	final ResourceLocation id = new ResourceLocation(ref.MODID, soundName);
	return GameRegistry.register(new SoundEvent(id).setRegistryName(id));
}

}



 

I also tried to play the sound with the /playsound and I can't tab it but if I type the sound in (mana_crystal) I can hear the sound its meant to play

Link to comment
Share on other sites

That's weird... Maybe do it like this: in your registerSounds do:

heart_crystal = new SoundEvent(new ResourceLocation(ref.MODID, "heart_crystal")).setRegistryName(new ResourceLocation(ref.MODID, "heart_crystal"));
GameRegistry.register(heart_crystal)

and same for mana_crystal so you can make sure it is initialized right...

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Link to comment
Share on other sites

Hi, i replaced the code for both so now my class looks like this:

 

 

 

 

package notlukas.mod.init;

import net.minecraft.client.audio.Sound;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import notlukas.mod.ref;
import notlukas.mod.util.utils;

public class soundHandler {

public static SoundEvent life_crystal;
public static SoundEvent mana_crystal;

public static void registerSounds() {
	life_crystal = new SoundEvent(new ResourceLocation(ref.MODID, "life_crystal")).setRegistryName(new ResourceLocation(ref.MODID, "life_crystal"));
	GameRegistry.register(life_crystal);

	mana_crystal = new SoundEvent(new ResourceLocation(ref.MODID, "mana_crystal")).setRegistryName(new ResourceLocation(ref.MODID, "mana_crystal"));
	GameRegistry.register(mana_crystal);

}

private static SoundEvent registerSound(String soundName) {
	final ResourceLocation id = new ResourceLocation(ref.MODID, soundName);
	return GameRegistry.register(new SoundEvent(id).setRegistryName(id));
}

}


 

 

 

i still get the same results as last time,

could it be that maybe the sound category in the item class has something to do with this?

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • LAYANAN DAFTAR TRANSTOGEL ! WA : 082213952901 SEARCH GOOGLE > TRANSTOGEL  
    • If you’ve ever experienced the sinking feeling of losing funds online, you’re not alone. Enter recovery services like ADWARE RECOVERY SPECIALIST, the heroes of the digital age who help individuals track down and retrieve lost funds. These services act as modern-day sheriffs in the Wild West of the internet, bringing justice to those who have fallen victim to online scams and fraud. In a world where online transactions are as common as selfies, the need for recovery services is more pressing than ever. Individuals worldwide are vulnerable to various online schemes, from investment fraud to phishing scams. Recovery services provide a glimmer of hope for those who have lost money, offering a chance to recover what's rightfully theirs and restore faith in the digital realm. The beauty of recovery services like ADWARE RECOVERY SPECIALIST lies in their global reach. Email: Adwarerecoveryspecialist@auctioneer. net  Regardless of where individuals are located worldwide, these services extend their virtual arms to help victims of online fraud. From bustling metropolises to remote villages, no corner of the world is beyond the grasp of these modern-day Robin Hoods. Thanks to the wonders of globalization, recovery services have transcended geographical boundaries to serve individuals worldwide. The interconnected nature of the digital world means that help is just a click away, bridging gaps between nations and bringing relief to those in need. In a world where borders are becoming increasingly blurred, recovery services stand as beacons of accessibility and assistance. When a broker stole from me and withheld access from me for five months, I had no idea that I would be able to recover my trading money back. I'm relieved that I was able to get my money returned without any issues. The impact of recovery services like ADWARE RECOVERY SPECIALIST extends far beyond individual wallets. Communities worldwide have experienced a renewed sense of trust and security, knowing that there are dedicated professionals working tirelessly to recover their lost assets. These services not only bring financial relief but also restore faith in the integrity of the digital world. Trust is the cornerstone of any successful recovery service, and building credibility in a global market can pose unique challenges. ADWARE RECOVERY SPECIALIST strives to maintain transparency and reliability in all its interactions, earning the trust of clients worldwide. ADWARE RECOVERY SPECIALIST can be talked to through:  Website: www.adwarerecoveryspecialist.expert  Telegram: @ADWARE_RECOVERY_SPECIALIST
    • The game wont start and keeps crashing everytime I hit play "The game crashed whilst rendering overlay Error: java.lang.IllegalAccessError: failed to access class com.mojang.blaze3d.platform.GlStateManager$TextureState from class net.coderbot.iris.gl.IrisRenderSystem$DSAARB (com.mojang.blaze3d.platform.GlStateManager$TextureState is in module minecraft@1.18.2 of loader 'TRANSFORMER' @724b939e; net.coderbot.iris.gl.IrisRenderSystem$DSAARB is in module oculus@1.6.4 of loader 'TRANSFORMER' @724b939e)" How do I get it to stop? Log error here: https://pastebin.com/byv1dR54
    • In case anyone happens on this with the same issue, I was able to overcome it. After re-reading @Paint_Ninja's last post numerous time, it finally dawned on me that he was referring wholly to the forge installer, which has nothing to do with the packaged modpack installer. As such, I downloaded the new copy of the forge installer and copied it to my linux host, then opened a second ssh session and prepared a cp command to move the new (correct) installer over to the install directory where I was installing the modpack. After the modpack installer had just about finished retrieving files, I overwrote the installer.jar file with the correct one in a seperate ssh session. The modpack (packaged) installer then used that jar to install forge with the included files, and the install finished as I would have expected. Thanks all!
  • Topics

×
×
  • Create New...

Important Information

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