Jump to content

Implicit super constructor ItemBase() is undefined. Must explicitly invoke another constructor


Recommended Posts

Posted

I am making a mod that adds a new fishing rod for catching other fish like swordfish or shark in 1.12.2. I finish making the class for the rod and there is an error. The error says, "Implicit super constructor ItemBase() is undefined. Must explicitly invoke another constructor." I'm fairly new to modding so I don't know what to do. The code is below. Someone help. The error is on this line:

 

public DeepSeaRod(String name) {
 

 

 

 

package com.tabulate.aquaticfoods.objects.items;

import com.tabulate.aquaticfoods.Main;
import com.tabulate.aquaticfoods.init.ItemInit;

import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityFishHook;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.IItemPropertyGetter;
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.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

 

public class DeepSeaRod extends ItemBase{

    public DeepSeaRod(String name) {
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(Main.aquaticfoodstab);
        setMaxDamage(400);
        setMaxStackSize(1);
        this.addPropertyOverride(new ResourceLocation("cast"), new IItemPropertyGetter(){
            
            @SideOnly(Side.CLIENT)
            public float apply(ItemStack stack, World world, EntityLivingBase entityIn) {
                if(entityIn == null) {
                    return 0.0f;
                }
                else {
                    boolean flag = entityIn.getHeldItemMainhand() == stack;
                    boolean flag1 = entityIn.getHeldItemOffhand() == stack;
                    if(entityIn.getHeldItemMainhand().getItem() instanceof DeepSeaRod) {
                        flag1 = false;
                    }
                    return(flag || flag1)&& entityIn instanceof EntityPlayer && ((EntityPlayer)entityIn).fishEntity != null ? 1.0f : 0.0f;
                }
            }
        });
        ItemInit.ITEMS.add(this);
    
    }
    
    @SideOnly(Side.CLIENT)
    public boolean isFull3D() {
        return true;
    }
    
    @SideOnly(Side.CLIENT)
    public boolean shouldRotateAroundWhenRendering() {
        return true;
    }
    
    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn){
        ItemStack itemStack = playerIn.getHeldItem(handIn);
        if(playerIn.fishEntity != null) {
            int i = playerIn.fishEntity.handleHookRetraction();
            itemStack.damageItem(1, playerIn);
            playerIn.swingArm(handIn);
            worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0f, 0.4f / (itemRand.nextFloat() * 0.4f + 0.8f));
        }
        else {
            worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_BOBBER_THROW, SoundCategory.NEUTRAL, 0.5f, 0.4f / (itemRand.nextFloat() * 0.4f + 0.8f));
            if(!worldIn.isRemote) {
                EntityFishHook entityFishHook = new EntityFishHook(worldIn, playerIn);
                int j = EnchantmentHelper.getFishingSpeedBonus(itemStack);
                if(j > 0) {
                    entityFishHook.setLureSpeed(j);
                }
                
                int k = EnchantmentHelper.getFishingLuckBonus(itemStack);
                if(k > 0) {
                    entityFishHook.setLuck(k);
                }
                
                worldIn.spawnEntity(entityFishHook);
            }
            playerIn.swingArm(handIn);
            playerIn.addStat(StatList.getObjectUseStats(this));
        
        }
        return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStack);
    }
    
    @Override
    public int getItemEnchantability() {
        return 15;
    }
    
    
    
    
    

}
 

 

Posted (edited)

ItemBase is the class you extended for your fishing rod class, can you post what your ItemBase class looks like so we can see what's wrong with it? 

Edited by Lumby
Posted

Do not use ItemBase. Read the Common issues and recommendations for more explanation.

The ItemBase class is basically pointless, and makes you write redundant code.

Some tips:

  Reveal hidden contents

 

Posted

package com.tabulate.aquaticfoods.objects.items;

import com.tabulate.aquaticfoods.Main;
import com.tabulate.aquaticfoods.init.ItemInit;
import com.tabulate.aquaticfoods.util.IHasModel;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

 

public class ItemBase extends Item implements IHasModel{

    public ItemBase(String name) {
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(Main.aquaticfoodstab);
        
        ItemInit.ITEMS.add(this);
    }

    @Override
    public void registerModels() {
        Main.proxy.registerItemRenderer(this, 0, "inventory");
    }

}
 

Posted
  On 6/13/2019 at 12:12 AM, DavidM said:

Read the Common issues and recommendations for more explanation.

Expand  

If you’re following a tutorial right now, stop. It’s making you write bad code that you will need to remove later.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
  On 6/13/2019 at 12:25 AM, TabulateJarl8 said:

public ItemBase(String name) {

Expand  

See this? This is your constructor.

 

  On 6/12/2019 at 11:47 PM, TabulateJarl8 said:

 public DeepSeaRod(String name) {

Expand  

See this? It does not call super. This means it calls public ItemBase() implicitly. Which is a function that does not exist.

 

There's your problem. But as Cadiboo already stated, you don't need ItemBase, that class already exists, its called Item.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

    • My name is Richie Leo, and I’m sharing this message with a heart full of gratitude and hope. Several months ago, I was a victim of a devastating online scam that cost me a staggering $873,463. I was devastated, confused, and had nearly given up on ever recovering my money — until I came across Wizard George Cyber Service. Through their exceptional cyber recovery expertise and deep investigative skills, Wizard George and his team were able to trace, track, and recover the full amount that was stolen from me. Their professionalism, speed, and transparency truly amazed me. If you’re reading this and you’ve been scammed — whether it’s crypto, investment fraud, or any kind of online theft — don’t give up. I strongly recommend reaching out to Wizard George Cyber Service. 📧 Em: wizardgeorgecyberservice(AT) g m a l L. C o M
    • Alright, here is the log file https://mclo.gs/5eCwafV
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post log files as described there, using a site such as https://mclo.gs/ and post the link here.  
    • I tried updating the mods in my modpack which caused incompatibilities so i have tried to revert them back to their older versions i was using before. In the logs it doesnt show me any clear incompatibilities except for tfmg & entity texture features, but when i try to remove those it still doesn't work. I have tried removing the forge-client.toml file which was a suggestion i found on  a few other posts. This is the log file i get. [inline log removed] Any help would be appreciated. Thanks in advance
    • I don't use KubeJS, never even heard of it. But after doing what "Ugdhar" suggested earlier in this post with the "config/Mekanism/generator-storage.toml", I tried going into an individual save's serverconfig folder, and just deleting everything except the parcool folder (I have that mod installed.) Then, a bit of loading and temporary freezing later, seems to have worked. Even when quitting to menu and loading back in, or also when quitting to menu, exiting to desktop, and re-launching MC, choose a save and loading it.
  • Topics

×
×
  • Create New...

Important Information

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