So I am using IntelliJ IDEA to mod Minecraft Forge 1.18.2 and I am trying to change the isEmptyBlock method of the LevelReader class using SpongePowered mixins.
But LevelReader is an interface, and the mod won't run if I try to edit an Interface.
And after looking for quite a while on the InterWebs, I have found nothing.
So the question is:
So how do I change the method of an Interface?
I am using this code: in: MixinLevelReader
package net.iateminecraft.jetpacksfix.mixin;
import com.mojang.logging.LogUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LevelAccessor;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(LevelReader.class)
public abstract class MixinLevelReader {
@Unique
private static final Logger LOGGER = LogUtils.getLogger();
@Unique
LevelAccessor world = (LevelAccessor) (Object) this;
@Inject(at = @At("HEAD"), method = "isEmptyBlock(Lnet/minecraft/core/BlockPos;)Z", cancellable = true)
private void isEmptyBlock(BlockPos blockposition, CallbackInfoReturnable<Boolean> callback) {
LOGGER.info(String.valueOf(world.getBlockState(blockposition).isAir()));
callback.setReturnValue(world.getBlockState(blockposition).isAir());
}
}
It will compile fine when I run ./gradlew :build, but as soon as I do ./gradlew :runClient it errors with: Caused by: org.spongepowered.asm.mixin.transformer.throwables.InvalidMixinException: @Mixin target type mismatch: net.minecraft.world.level.LevelReader is an interface in org.spongepowered.asm.mixin.transformer.MixinInfo$SubType$Standard@75b6dd5b