#Methods with incompatible return types clash

27 messages · Page 1 of 1 (latest)

fervent raft
#

I'm making a mod that adds armor that can take attachments like a gun in Vic's Point Blank, but my class for the AttachmentArmorItem gives the following error:
'getName()' in 'net.minecraft.item.Item' clashes with 'getName()' in 'com.vicmatskiv.pointblank.Nameable'; attempting to use incompatible return type

My Class currently looks like this:

package net.iamvoodoo.voodoosmodernarmor.item.custom;

import com.vicmatskiv.pointblank.attachment.Attachment;
import com.vicmatskiv.pointblank.attachment.AttachmentHost;
import com.vicmatskiv.pointblank.feature.Feature;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.registry.entry.RegistryEntry;

import java.util.Collection;
import java.util.List;

public class AttachmentArmorItem extends ArmorItem implements AttachmentHost {

    public AttachmentArmorItem(RegistryEntry<ArmorMaterial> material, Type type, Settings settings) {
        super(material, type, settings);
    }
    
    @Override
    public Collection<Attachment> getCompatibleAttachments() {
        return List.of();
    }

    @Override
    public Collection<Feature> getFeatures() {
        return List.of();
    }
}

I tried to figure out how the gunItem class fixes this issue, but I haven't had much luck yet. Does anyone know a solution?

fiery spruce
#

do you know java?

#

there are two methods that from super classes that clash

fervent raft
#

Yes, I do understand that

#

I also noticed that the GunItem class does this

fiery spruce
#

have you checked what any other class does?

fervent raft
#
public String getName() {
        return this.name;
    }

    public Text getName(ItemStack itemStack) {
        return Text.translatable(this.getTranslationKey(itemStack));
    }

#

So it overrides it?

#

But I tried doing that and that just moved the error to the lines of the methods

fiery spruce
#

that should not conflict

fervent raft
#

With the methods it currently looks like this

fiery spruce
#

at an @Override to Text getName

fervent raft
#

Ok, i did that

#

But line 27 still seems to be giving an error

fiery spruce
#

hmm let me see

fervent raft
#

According to one of the warnings, the Text getName is entirely redundant because it is identical to the super method

fiery spruce
#

that's just a warning

fervent raft
#

Then what precisely is the point of overriding a method but not changing anything? Sorry if this is a dumb question

fiery spruce
#

this is odd indeed

#

can you explain what's your end goal?

#

what are you trying to make?

#

i've hacked into this mod once so idk what might have changed in newer versions

#

yeah i don't see a solution

fervent raft
fervent raft
fiery spruce
#

i'd ask the author tbh