Jump to content

Recommended Posts

Posted

Check out ItemRecord.java, especially the onItemUse method. That is where the code for the built-in music discs is, so you should be able to extend that class in order to make your own.

Posted

I've gotten as far as a working item, now there is just one more problem, getting the sound to play....

If I change the name for the sound to cat, it plays, so my item works, but the name I need doesn't work.

Do I need to convert to .mus?

Posted

I've gotten as far as a working item, now there is just one more problem, getting the sound to play....

If I change the name for the sound to cat, it plays, so my item works, but the name I need doesn't work.

Do I need to convert to .mus?

 

In your class for the record you will see somewhere it says about the record name being the name for your music disc. Your sound file name would need to be called YourRecordName.ogg and would need to be in the /resources/mod/streaming folder. That is what worked for me anyway...

Posted

package daki;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockJukeBox;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemGroovyDisc extends ItemRecord
{
public final String recordName;
public ItemGroovyDisc(int id) {
	  super(id, "groovy.ogg");
	  this.setCreativeTab(CreativeTabs.tabMisc);
	  this.maxStackSize = 1;
	  this.recordName = "groovy.ogg";
	  
}
public String getTextureFile()
    {
            return "/Daki/dakiitems.png";
    }


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;
        }
    }
    @Override
    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
    par3List.add("groovy");
    }

}

That's my record class, this whole thing is very confusing to me, I'm relatively new to modding and have have added multiple items and mobs before but these records are just so different.

I'd appreciate it if someone could point out what I'm doing wrong, and groovy.ogg is in my \resources\mod\streaming folder.

 

EDIT: I got it!

I added:

public String getSoundFile()

    {

            return "/resources/mod/streaming/groovy.ogg";

    }

 

  • 2 months later...
Posted

Hi I used your code and got my music disk working :) but I have a problem with the texture no matter where I like the texture to it never shows up in game.

and help I how I can fix this?

 

 

EDIT: I got it to Work :)

 

I just used this code

    @Override
    public void registerIcons(IconRegister iconRegister) {
        this.blockIcon = iconRegister.registerIcon("Folder:Texture");
    }

in place of your texture code and it worked

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

    • Back then there was a number which determined the tier of an item and block. If the block tier is lower or equal to the item number, the block would be mined. this however, has changed and now it goes by "needs_netherite_tool" which is fine, until you realized that some mods had items and blocks that exceeded these values. You can make you own "needs_mod_tool" but I feel that this is more limiting(and just more work) than before. So is there anyway to use something similar to the old tier system while also still being compatible with a lot of other mod tools?
    • Well, when I log in to the server, sometimes within an hour, sometimes within a minute, the server closes and informs me that there was a Ticking entity error. Below is the crash report
    • Try switching to Windowed or Borderless Window mode in Minecraft. These modes make it easier for the recorder to capture gameplay, as it still has access to the display without the game taking up all of the graphics resources.
    • This forum is for Forge, not NeoForge. Please go to them for support.
    • Forge version: 55.0.0 Minecraft version: 1.21.5 Downloads: As this is the start of a new version, it is recommended that you check the downloads page and use the latest version to receive any bug fixes. Downloads page Intro: Good evening! Today, we have released our initial build of Forge 55.0 for Minecraft 1.21.5. 1.21.5 is the newest member of the 1.21 family of versions, which was released yesterday on March 25, 2025. As a reminder, the first minor (X.0) of a Forge version is a beta. Forge betas are marked as such on the bottom left of the title screen and are candidates for any breaking changes. Additionally, there are a couple of important things to note about this update, which I've made sure to mention in this post as well. Feel free to chat with us about bugs or these implementation changes on GitHub and in our Discord server. As always, we will continue to keep all versions of 1.21 and 1.20 in active support as covered by our tiered support policy. Cheers, happy modding, and good luck porting! Rendering Refactor For those who tuned in to Minecraft Live on March 22, 2025, you may already know that Mojang have announced their intention to bring their new Vibrant Visuals overhaul to Java in the future. They've taken the first steps toward this by refactoring how rendering pipelines and render types are handled internally. This has, in turn, made many of Forge's rendering APIs that have existed for years obsolete, as they (for the most part) can be done directly in vanilla. If there was a rendering API that was provided by Forge which you believe should be re-implemented, we're happy to discuss on GitHub through an issue or a pull request. Deprecation of weapon-like ToolActions In 1.21.5, Minecraft added new data components for defining the characteristics of weapons in data. This includes attack speed, block tags which define efficient blocks, and more. As such, we will begin marking our ToolActions solution for this as deprecated. ToolActions were originally added to address the problem of creating modded tools that needed to perform the same actions as vanilla tools. There are still a few tool actions that will continue to be used, such as the shears tool action for example. There are some existing Forge tool actions that are currently obsolete and have no effect given the way the new data components are implemented. We will continue to work on these deprecations and invite you to chat with us on GitHub or Discord if you have any questions.
  • Topics

×
×
  • Create New...

Important Information

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