15

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");
Unihedron
  • 10,902
  • 13
  • 62
  • 72
GriffinMite
  • 193
  • 1
  • 3
  • 9
  • 4
    What supertype method is it supposed to override/implement? If none, *remove* `@Override`. If one, *correct* the signature such that it correctly matches. – user2864740 Sep 29 '14 at 23:23

11 Answers11

36

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

sofs1
  • 3,834
  • 11
  • 51
  • 89
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) {
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Where did you find the signature for the superclass method? – nanofarad Sep 29 '14 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. – Robert Rapplean Nov 12 '15 at 17:47
  • Usually you can refer to the javadocs - the link has gone dead here, but the corrected code remains :) – Reimeus Nov 12 '15 at 17:58
  • Thank you @Reimeus . I forgot to add method parameters and it worked after adding them. – Himanshu Suthar Feb 04 '21 at 15:16
14

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
PsyCode
  • 644
  • 5
  • 14
  • Correct - this helped me; as my method signature already matched the parent interface (e.g. as suggested by the accepted answer). Thanks! – Reece Jan 05 '17 at 15:11
  • I just got this on Eclipse and this worked to me. Thanks a lot. – 猫IT Feb 28 '19 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.

corsiKa
  • 81,495
  • 25
  • 153
  • 204
1

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

  • 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 – Zephyr Zephyroff Feb 26 '23 at 12:39
0

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

Rare Case
  • 11
  • 2
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>
Niamatullah Bakhshi
  • 1,445
  • 16
  • 27
0

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

Wincent
  • 29
  • 3
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.