The Method Must Override or Implement a Supertype Method
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...
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");
12 Answers
If you are using Eclipse, try closing and opening it again. The error goes away.
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) {
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
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.
Save every classes from that package you are using in Eclipse IDE Ctrl+S
In your defined interface ItemArmor remove any generic type in angle brackets.
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=""
xmlns:xsi=""
xmlns:context=""
xsi:schemaLocation="
">
<!-- This allows annotations -->
<context:annotation-config />
</beans>
You may have unsaved content in Interface or Base-Class. This is why delete annotation @Override can clean the error.
IF you have checked that signatures of super class/interface is matching but still getting error. try saving super class/interface first.
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.
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.
Right click on your project
- go to build path --> configure build path
- in left panel go to Java Compiler
- untick the JDK compliance
- select the last or latest Compiler compliance level
- apply and close
- update the project from maven update
- Error will disappear