16

I am making a custom armor, and in my armor class I am getting this error:

The method getArmorTexture(ItemStack, Entity, int, int) of type ArmorE must override or implement a supertype method

Why I am getting this error?

Here's my code:

Armor Class:

package com.domoq.EmeraldGear.armor;

import com.domoq.EmeraldGear.EmeraldGearMod;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

public class ArmorE extends ItemArmor {

    public ArmorE(ArmorMaterial part2ArmorE, int part3, int part4) {
        super(part2ArmorE, part3, part4);
        this.setCreativeTab(CreativeTabs.tabCombat);
    }

    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, int type) {
        if (stack.getItem() == EmeraldGearMod.EmeraldHelmet || stack.getItem() == EmeraldGearMod.EmeraldChest || stack.getIconIndex() == EmeraldGearMod.EmeraldBoots) {
            return "emeraldgearmod:textures/models/armor/ArmorL1.png";
        } else if (stack.getItem() == EmeraldGearMod.EmeraldLegs) {
            return "emeraldgearmod:textures/models/armor/ArmorL2.png";
        } else return null;
    }
}

Part of Main Class:

//Armor Material
public static ArmorMaterial ArmorE = EnumHelper.addArmorMaterial("AEmerald", 29, new int[]{3, 7, 4, 2}, 25);

//Armor Items
public static Item EmeraldHelmet = new ArmorE(ArmorE, 2, 0).setUnlocalizedName("EmeraldHelmet").setTextureName("emeraldgearmod:emerald_helmet");
public static Item EmeraldChest = new ArmorE(ArmorE, 2, 1).setUnlocalizedName("EmeraldChest").setTextureName("emeraldgearmod:emerald_chestplate");
public static Item EmeraldLegs = new ArmorE(ArmorE, 2, 2).setUnlocalizedName("EmeraldLegs").setTextureName("emeraldgearmod:emerald_leggings");
public static Item EmeraldBoots = new ArmorE(ArmorE, 2, 3).setUnlocalizedName("EmeraldBoots").setTextureName("emeraldgearmod:emerald_boots");
1
  • 4
    What supertype method is it supposed to override/implement? If none, remove @Override. If one, correct the signature such that it correctly matches. Commented Sep 29, 2014 at 23:23

12 Answers 12

38

If you are using Eclipse, try closing and opening it again. The error goes away.

9
  • 9
    Despite this answer being downvoted, (sadly) this is a valid answer for Eclipse problems far too often.
    – gdbj
    Commented Mar 10, 2017 at 16:13
  • 1
    This worked for me. I would vote this as the most correct answer. Commented Feb 26, 2020 at 22:43
  • 2
    March 2021 & this was the answer that helped
    – Jay
    Commented Mar 8, 2021 at 5:16
  • 1
    October 2021 and this still is the solution, lol. Thanks.
    – redbite
    Commented Oct 4, 2021 at 15:14
  • 1
    March 2023 - Worked like a charm. lol
    – user258959
    Commented Mar 26, 2023 at 23:44
15

To override a method the signature needs to match that of the super class. Replace

public String getArmorTexture(ItemStack stack, Entity entity, int slot, int type) {

with

public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
4
  • Where did you find the signature for the superclass method?
    – nanofarad
    Commented Sep 29, 2014 at 23:39
  • You have to open the ItemArmor class and look at the parameter types and return type of the method that you are overriding. Copy and paste usually works best to ensure that it accepts the same variables. In this case, your version is taking an int for its 'type' parameter instead of a string. Commented Nov 12, 2015 at 17:47
  • Usually you can refer to the javadocs - the link has gone dead here, but the corrected code remains :)
    – Reimeus
    Commented Nov 12, 2015 at 17:58
  • Thank you @Reimeus . I forgot to add method parameters and it worked after adding them. Commented Feb 4, 2021 at 15:16
15

It means that you don't need the override annotation since you aren't overriding or implementing something to that method. Therefore, you should merely delete

@Override
2
  • Correct - this helped me; as my method signature already matched the parent interface (e.g. as suggested by the accepted answer). Thanks!
    – Reece
    Commented Jan 5, 2017 at 15:11
  • I just got this on Eclipse and this worked to me. Thanks a lot.
    – 猫IT
    Commented Feb 28, 2019 at 11:01
4

I was brought here by a Google search and while this won't help OP (since clearly their issue is solved in the accepted answer) I want to share what my problem was for potential future visitors.

I was losing my mind - I was working with Jetty and had a method that just would not accept the Override annotation. I even COPIED AND PASTED it from the base class to ensure I hadn't mangled the method signature some how. And while many answers said ignore it, it's the entry point to a websocket and it wasn't firing - clearly, I can't ignore that!

It ended up being the import - I was importing Session from the wrong package - from a Jetty package, so it sure looked legit, but I needed to have org.eclipse.jetty.websocket.api.Session while I had org.eclipse.jetty.server.session.Session in my imports. Future visitors are unlikely to have that pairing of mismatched package imports, but I suspect some are going to be in the boat I was just in.

3

Save every classes from that package you are using in Eclipse IDE Ctrl+S

1
  • 1
    What a stupid mistake)) I spent about 20 minutes to figure what happened out. Interface that had just written wasn't saved and hence wasn't visible by the IDE Commented Feb 26, 2023 at 12:39
1

You may have unsaved content in Interface or Base-Class. This is why delete annotation @Override can clean the error.

0

In your defined interface ItemArmor remove any generic type in angle brackets.

0

If you are working on Java Spring Framework then you must provide the using of annotations by writing <context:annotation-config/> in your i.e config.xml file so to be able to use Annotations such as @Override,@Component,@Value and etc.

Right-click on your package and create a .xml(i.e config.xml) file for configuration if not exist.

and Add the following code inside it.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- This allows annotations -->
    <context:annotation-config />


</beans>
0

IF you have checked that signatures of super class/interface is matching but still getting error. try saving super class/interface first.

0

OP's issue is already solved, but for future visitors I wanted to say that I had this error and the problem was the type argument.

Instead of

field.addValueChangeHandler(new ValueChangeHandler<FieldType>() {
        @Override
        public void onValueChange(ValueChangeEvent<FieldType> event) {
            Window.alert("[DEBUG] I'm here");
        }
    });

I should write

field.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            Window.alert("[DEBUG] I'm here");
        }
    });

It tooked me a while to find the solution because the error message doesn't seem to talk about this.

0

If you're certain you don't have function with the same name in the super class then, it might be because you have an @Override somewhere above hidden in your code (that's not being used).

I had commented out an overridden function which was confusing the IDE.

0

Right click on your project

  1. go to build path --> configure build path
  2. in left panel go to Java Compiler
  3. untick the JDK compliance
  4. select the last or latest Compiler compliance level
  5. apply and close
  6. update the project from maven update
  7. Error will disappear
1
  • 2
    the question is not related to wrong compliance level. (would also be a different error).... but to wrong argument type (as we can see from the accepted answer almost 10 years ago... better spend time [correctly] answering actual/open/un-answered questions)
    – user85421
    Commented Sep 15, 2023 at 6:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.