#Clashing return types between mod and minecraft

1 messages · Page 1 of 1 (latest)

knotty lava
#

Hi, I'm reposting my issue since I made a github repo now which might help: https://github.com/VoodooLikesCoding/voodoos-modern-armor-1.21.1

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.Nameable;
import com.vicmatskiv.pointblank.attachment.Attachment;
import com.vicmatskiv.pointblank.attachment.AttachmentHost;
import com.vicmatskiv.pointblank.feature.Feature;
import com.vicmatskiv.pointblank.item.ItemExtra;
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, Nameable, ItemExtra {
    private String name;

    public AttachmentArmorItem(RegistryEntry<ArmorMaterial> material, Type type, Settings settings) {
        super(material, type, settings);
    }

    @Override
    public String getName() {
        return this.name;
    }

    @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?

tulip dew
#

Use an alternative mapping

#

You can use quilt mappings to avoid this conflict

#

Or, you can write your own mappings file and layer it on top of your current mappings

#

The idea is that we’re going to rename the getName method of the item class so it doesn’t conflict with the Nameable getName

#

Why do you need to implement Nameable here

knotty lava
knotty lava
#

So the solution is right there in that class

tulip dew
#

Look at the fabric wiki and documentation for how to write your own mappings file and layer it

knotty lava
#

Okay, will do

tulip dew
#

Look at quilt to see their mapping specifications if you want to do that instead

tulip dew
#

(In the base mod)

knotty lava
#

The GunItem class has it if I’m not mistaken

tulip dew
#

Do you have access to the source (not decompiled)

knotty lava
#

Nah, the mod is closed source. I'm using modrinth maven currently

#

That's why there's no code comments right?

tulip dew
#

Well that’s fun
Good luck figuring out how to do mappings

knotty lava
#

Lol

winter hollow
#

wait is this a mapping clash?

#

because i'm pretty sure this can be solved then

#

let me know if you run into any issues

tulip dew
#

That’s what I meant by layering

#

Thanks diced

knotty lava
#

I'll try it when I get back to my pc

winter hollow
#

@knotty lava sorry that i lead you astray that day. i should have known this is a mapping problem. the mod is multi platform so it should been using mojmap so the clash doesn't happen at all

#

you have 2 options:

  1. make your project use mojmap
  2. write a mapping override
#

for 2; i've named it getNameableName but you can change it to something appropriate.

winter hollow
knotty lava
#

You're a saint

knotty lava
winter hollow
#

nope

#

the "base layer" so to say is intermediary where all the classes/methods are in a format like class_1234 method_1234. so they never clash.

#

however, when there's a mapping layer (yarn, mojmap) they can clash because you can specify the name (at least in yarn. we can't modify mojmap)

#

so class_1234 = getName in yarn. since mod's own code is not remapped, there can be clashes. that's why GunItem's getName override has 2 parents

knotty lava
#

The delights of closed source

#

I’ll send my results in this thread

tulip dew
#

Wouldn’t this also clash with mojmap

winter hollow
#

in yarn, Item --> Text getName() conflicts with Nameable --> String getName()
in moj, Item --> Component getDescription() doesn't conflict with Nameable --> String getName()

tulip dew
#

I think it’s getName in the newer versions lol

knotty lava
winter hollow
#

project root

#

parallel to your build.gradle

knotty lava
#

ok

#

Is that a class without errors I see?

#

YESS, thanks!

#

I'll be back when I mess something up again

tulip dew
#

Wait what’s getNameableName

#

I’m so confused did you change the item getname mapping or the nameable getname mapping

#

Oh you changed the nameable’s getName to getNameableName

#

You can do that for other mods??

winter hollow
#

yes Clueless

#

hopefully this doesn't crash and burn at runtime but you'll find out

#

(if that happens switch to mojmap)

rare gull
#

why should it matter if you're dealing with mc code or mod code? foreign code is foreign code

tulip dew
#

I don’t think of mod code as having mappings in that sense, but I suppose it works

tulip dew
winter hollow
#

nope, i had to double check that too

tulip dew
#

Ah cool