So I have set up a mixin environment correctly (using sponge of course), and I want to change the isEmptyBlock
method of LevelReader
, 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
After some research it means that I’m trying to mixin with an interface which is incorrect, so how do I do it?