Jump to content

Recommended Posts

Posted

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/

Posted

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

Posted

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

Posted

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?

Posted

I've just found out what it was..

I forgot to put register sounds in my base file

i feel so stupid, lol

 

but now when i throw it, i hear the sound but its like a bit slowed down or something

 

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.

Announcements



×
×
  • Create New...

Important Information

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