Jump to content

How to change Item's constructor?


frankstar10

Recommended Posts

I have a question, how do I change the constructor of a file? I made a new class named ItemEPRecord which extends ItemRecord. In it's constructor I would like to make it "super(par1, par2Str, par3Str);" instead of "super(par1, par2Str);". Everytime I do this I get an error and it wants me to change the ItemRecord constructor and if I do that It messes up every other record in the game. How would I do this?

 

Here is my ItemEPRecord class:

 

 

package EmeraldsPlus.common;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

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

import net.minecraft.item.Item;

import net.minecraft.item.ItemRecord;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

 

public class ItemEPRecord extends ItemRecord

{

    /** List of all record items and their names. */

    private static final Map records = new HashMap();

 

    /** The name of the record. */

    public final String recordName;

   

    /** The name of a record's artist */

    public final String artistName;

   

    protected ItemEPRecord(int par1, String par2Str, String par3Str)

    {

        super(par1, par2Str, par3Str);

        this.recordName = par2Str;

        this.artistName = par3Str;

        this.maxStackSize = 1;

        records.put(par2Str, this);

    }

 

    /**

    * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return

    * True if something happen and false if it don't. This is for ITEMS, not BLOCKS

    */

    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)

 

    /**

    * allows items to add custom lines of information to the mouseover description

    */

    public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)

    {

        par3List.add(this.getRecordTitle());

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Return the title for this record.

    */

    public String getRecordTitle()

    {

        return this.artistName + " - " + this.recordName;

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Return an item rarity from EnumRarity

    */

    public EnumRarity getRarity(ItemStack par1ItemStack)

    {

        return EnumRarity.rare;

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Return the record item corresponding to the given name.

    */

    public static ItemEPRecord getRecord(String par0Str)

    {

        return (ItemEPRecord)records.get(par0Str);

    }

}

 

 

Link to comment
Share on other sites

remove par3Str from

super(par1, par2Str, par3Str)

super is used to send things to the main class. since ItemRecord doesn't need par3Str for any calculations, it doesn't need it. If you look at this file from my mod, you see that I only pass the required variables through super

https://github.com/code-lyoko-modding/CodeLyokoMod/blob/master/lyoko/items/ItemLyokoFuel.java

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.



×
×
  • Create New...

Important Information

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