Jump to content

Recommended Posts

Posted

Well this is my mod Items class

 

 

package com.Thecheatgamer1.Annom.Item;

 

import com.Thecheatgamer1.Annom.Lib.ItemIds;

 

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

 

public class ModItems {

 

    /* Mod item instances */

    public static Item ItemFusionIngot;

    public static Item ItemIredantCrystal;

    public static Item ItemKI87ElementIngot;

    public static Item ItemHappyDaysMusicDisk;

   

 

    public static void init() {

 

        /* Initialize each mod item individually */

        ItemFusionIngot = new ItemFusionIngot(ItemIds.ITEMFUSIONINGOT);

        ItemIredantCrystal = new ItemIredantCrystal(ItemIds.ITEMIREDANTCRYSTAL);

        ItemKI87ElementIngot = new ItemKi87ElementIngot(ItemIds.ITEMKI87ELEMENT);

        ItemHappyDaysMusicDisk = new ItemHappyDaysMusicDisk(ItemIds.ITEMHAPPYDAYSMUSICDISK);

       

        LanguageRegistry.addName(ItemFusionIngot, "Fusion Ingot");

        LanguageRegistry.addName(ItemIredantCrystal, "Iredant Crystal");

        LanguageRegistry.addName(ItemKI87ElementIngot, "Ki87Element Ingot");

        LanguageRegistry.addName(ItemHappyDaysMusicDisk, "HappyDays Music Disk");

       

       

        GameRegistry.addRecipe(new ItemStack(ItemIredantCrystal), new Object[] { "aaa", "aba", "aaa", Character.valueOf('a'), ItemFusionIngot, Character.valueOf('b'), ItemKI87ElementIngot });

       

    }

}

 

 

This is my HappydaysMusic Disk class

 

 

package com.Thecheatgamer1.Annom.Item;

 

import com.Thecheatgamer1.Annom.Annom.Annom;

import com.Thecheatgamer1.Annom.Lib.Sounds;

import com.Thecheatgamer1.Annom.Lib.Textures;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockJukeBox;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemRecord;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class ItemHappyDaysMusicDisk extends ItemRecord {

   

        public final String recordName;

       

        public ItemHappyDaysMusicDisk(int id) {

           

              super(id, "HappyDays");

              this.setCreativeTab(Annom.tabsAnnom);

              this.maxStackSize = 1;

              this.recordName = "HappyDays";

             

}

 

    public String getSoundFile()

    {

            return Sounds.HAPPYDAYS;

    }

   

    public String getTextureFile()

    {

        return Textures.ITEMHAPPYDAYSMUSICDISK;

    } 

   

    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)

    {

        if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)

        {

            if (par3World.isRemote)

            {

                return true;

            }

            else

            {

                ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);

                par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);

                --par1ItemStack.stackSize;

                return true;

            }

        }

        else

        {

            return false;

        }

    }

   

}

 

 

 

This is my SoundHandler class

 

 

package com.Thecheatgamer1.Annom.Client.Audio;

 

 

import java.util.logging.Level;

 

import net.minecraftforge.client.event.sound.SoundLoadEvent;

import net.minecraftforge.event.ForgeSubscribe;

 

import com.Thecheatgamer1.Annom.Core.Util.LogHelper;

import com.Thecheatgamer1.Annom.Lib.Sounds;

 

public class SoundHandler {

 

    @ForgeSubscribe

    public void onSoundLoad(SoundLoadEvent event) {

 

        // For each custom sound file we have defined in Sounds

        for (String soundFile : Sounds.soundFiles) {

            // Try to add the custom sound file to the pool of sounds

            try {

                event.manager.soundPoolSounds.addSound(soundFile, this.getClass().getResource("/" + soundFile));

            }

            // If we cannot add the custom sound file to the pool, log the exception

            catch (Exception e) {

                LogHelper.log(Level.WARNING, "Failed loading sound file: " + soundFile);

            }

        }

    }

}

 

 

 

 

And this is my ClientProxy class

 

 

package com.Thecheatgamer1.Annom.Core.Proxy;

 

import com.Thecheatgamer1.Annom.Client.Audio.SoundHandler;

 

import net.minecraftforge.common.MinecraftForge;

 

public class ClientProxy extends CommonProxy {

 

 

 

    @Override

    public void registerSoundHandler() {

 

        MinecraftForge.EVENT_BUS.register(new SoundHandler());

    }

}

 

 

 

And this is my CommonProxy Class

 

 

package com.Thecheatgamer1.Annom.Core.Proxy;

 

public class CommonProxy {

 

 

    public void registerRenderTickHandler() {

 

    }

 

    public void registerDrawBlockHighlightHandler() {

 

    }

 

    public void registerSoundHandler() {

 

    }

 

    public void initRenderingAndTextures() {

 

    }

}

 

 

 

The Disk Works fine, but the music its supposed to play isnt playing so can someone tell me how to fix it or what i have to add!

Posted

Put this in ItemHappyDaysMusicDisk

public String getSoundFile()
    {
            return "/resources/mod/streaming/FILENAME.ogg";
    }

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

Put this in ItemHappyDaysMusicDisk

public String getSoundFile()
    {
            return "/resources/mod/streaming/FILENAME.ogg";
    }

 

Added and not working, sound is not playing at all!

Did you change the return to where your ogg file is located?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

Put this in ItemHappyDaysMusicDisk

public String getSoundFile()
    {
            return "/resources/mod/streaming/FILENAME.ogg";
    }

 

Added and not working, sound is not playing at all!

Did you change the return to where your ogg file is located?

 

Yes, i even tryed connecting it to my Sounds.java class what is supposed to direct all sounds

Posted

can i see what you put?

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

Posted

can i see what you put?

 

 

public class ItemHappyDaysMusicDisk extends ItemRecord {

   

        public final String recordName;

       

        public ItemHappyDaysMusicDisk(int id) {

           

              super(id, "HappyDays");

              this.setCreativeTab(Annom.tabsAnnom);

              this.maxStackSize = 1;

              this.recordName = "HappyDays";

             

}

 

        public String getSoundFile()

        {

                return "/resources/mod/Annom/Sound/HappyDyas.ogg";

        }

 

Posted

This is what I use.

 

Main Class:

public Item music1;
music1 = new ItemRecordMusic(11111, "musicone").setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("musicDiskOne");

//The first box is for item ID, and the second box is for file name.
//The file would be located in: \resources\mod\streaming\musicone.ogg

 

ItemRecordMusic

package com.musicraft.main;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemRecordMusic extends ItemRecord
{
public final String recordName;

public ItemRecordMusic(int par1, String par2Str)
{
	super(par1, par2Str);
	this.recordName = par2Str;
	this.maxStackSize = 1;
	this.setCreativeTab(CreativeTabs.tabMisc);
}

    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
    	
    }


public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
	if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
	{
		if (par3World.isRemote)
		{	
			return true;
		}
		else
		{
			((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);
			par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);
			--par1ItemStack.stackSize;
			return true;
		}
	}
	else
	{
		return false;
	}
}

@SideOnly(Side.CLIENT)

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if (this.recordName == "musicone")
	{
		par3List.add("HappyDays - " + this.recordName);
	}
}

    @SideOnly(Side.CLIENT)
    @Override
    public void updateIcons(IconRegister par1IconRegister)
    {
        this.iconIndex = par1IconRegister.registerIcon(this.recordName);
    }
    
    @Override
    public String getRecordTitle()
    {
        return "HappyDays";
    }
}

 

Some fields, you might have to change by yourself, but this is what I use, and it works fine.

Remember that the file needs to be in OGG format!

Posted

This is what I use.

 

Main Class:

public Item music1;
music1 = new ItemRecordMusic(11111, "musicone").setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName("musicDiskOne");

//The first box is for item ID, and the second box is for file name.
//The file would be located in: \resources\mod\streaming\musicone.ogg

 

ItemRecordMusic

package com.musicraft.main;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemRecordMusic extends ItemRecord
{
public final String recordName;

public ItemRecordMusic(int par1, String par2Str)
{
	super(par1, par2Str);
	this.recordName = par2Str;
	this.maxStackSize = 1;
	this.setCreativeTab(CreativeTabs.tabMisc);
}

    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
    {
    	
    }


public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
	if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0)
	{
		if (par3World.isRemote)
		{	
			return true;
		}
		else
		{
			((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack);
			par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID);
			--par1ItemStack.stackSize;
			return true;
		}
	}
	else
	{
		return false;
	}
}

@SideOnly(Side.CLIENT)

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
	if (this.recordName == "musicone")
	{
		par3List.add("HappyDays - " + this.recordName);
	}
}

    @SideOnly(Side.CLIENT)
    @Override
    public void updateIcons(IconRegister par1IconRegister)
    {
        this.iconIndex = par1IconRegister.registerIcon(this.recordName);
    }
    
    @Override
    public String getRecordTitle()
    {
        return "HappyDays";
    }
}

 

Some fields, you might have to change by yourself, but this is what I use, and it works fine.

Remember that the file needs to be in OGG format!

 

Still not working

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • log: https://mclo.gs/QJg3wYX as stated in the title, my game freezes upon loading into the server after i used a far-away waystone in it. The modpack i'm using is better minecraft V18. Issue only comes up in this specific server, singleplayer and other servers are A-okay. i've already experimented with removing possible culprits like modernfix and various others to no effect. i've also attempted a full reinstall of the modpack profile. Issue occurs shortly after the 'cancel' button dissapears on the 'loading world' section of the loading screen.   thanks in advance.
    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
  • Topics

×
×
  • Create New...

Important Information

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