JK Tech
JK Tech

Reputation: 41

Error when trying to extend a class using 'mixin'

The following snippet of code is one that I have used from a tutorial I found online:

package com.jktech.minend.common.events;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(ItemEntity.class)
public abstract class itemevents extends ItemEntity {
    public itemevents(World world, double x, double y, double z, ItemStack stack, doublevelocityX, double velocityY, double velocityZ) {
        super(world, x, y, z, stack, velocityX, velocityY, velocityZ);
    }
}

Although the code compiles, it still shows errors on runtime, yet the game doesn't crash. However, my functions don't execute and nothing happens (as if they weren't applied in the first place).

[14:16:45] [main/ERROR] (mixin) minend.mixins.json:itemevents: Super class 'net.minecraft.entity.ItemEntity' of itemevents was not found in the hierarchy of target class 'net/minecraft/entity/ItemEntity'

org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException: Super class 'net.minecraft.entity.ItemEntity' of itemevents was not found in the hierarchy of target class 'net/minecraft/entity/ItemEntity'

Upvotes: 0

Views: 2390

Answers (1)

Elikill58
Elikill58

Reputation: 4908

There is multiple ways to do it:

  1. Use Entity

You can fix it by extends Entity instead of ItemEntity.

  1. Use a specific entity type

For example, AnimalEntity can solve your issue.

Finally, if for example you need to get entity's stack, you can thos like that:

public ItemStack getStack(){
   return ((ItemEntity) this).getStack();
}

Upvotes: 1

Related Questions