Skip to content

Crashes in Dev when using Yarn Mappings #17

@Estecka

Description

@Estecka

I wanted to test the compatibility of this mod with another one I'm working on. However, mavapi causes a crash when I run it in my development environment. (The crash does not occur when using the same two mods in a regular minecraft instance !)

java.lang.IllegalAccessError: Update to non-static final field net.minecraft.item.EntityBucketItem.entityType attempted from a different method (handler$zdb000$mavapi$onInit) than the initializer method <init>
        at net.minecraft.item.EntityBucketItem.handler$zdb000$mavapi$onInit(EntityBucketItem.java:568)
        at net.minecraft.item.EntityBucketItem.<init>(EntityBucketItem.java:48)
        at net.minecraft.item.Items.<clinit>(Items.java:1117)

Faulty code:

@Mixin(MobBucketItem.class)
public abstract class MobBucketItemMixin {
private EntityType<?> entityType;
@Inject(method = "<init>", at = @At("RETURN"))
public void onInit(EntityType<?> entityType, Fluid fluid, SoundEvent soundEvent, Item.Properties properties, CallbackInfo ci) {
this.entityType = entityType;
}

With Yarn, the field entityType that you declare already exists in the base class (with mojmap you know it as simply type), so this mixin ends up shadowing the original final field instead of creating its own mutable one.

The quickest fix would be to add @Unique to your own field. However at a glance, it looks like your field serves the same purpose as the original, so I'd suggest @Shadowing it instead, and removing onInit completely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions