该方法必须重写或实现超类型方法

2022-09-04 23:46:53

我正在制作一个自定义盔甲,在我的盔甲类中,我得到了这个错误:

类型 ArmorE 的方法 getArmorTexture(ItemStack、Entity、int、int)必须覆盖或实现超类型方法

为什么我会收到此错误?

这是我的代码:

装甲等级:

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;
    }
}

主类的一部分:

//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

如果您使用的是 Eclipse,请尝试关闭并再次打开它。错误消失。


答案 2

要重写方法,签名需要与超类的签名相匹配。取代

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

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

推荐