Daniel Dixon
Daniel Dixon

Reputation: 1

Unexpected return statement that can't be fixed

I'm creating a mixin class for custom crafting tables. Here's the return statement.

return world.getBlockState(pos).getBlock() instanceof CraftingTableBlock;

How do you fix the unexpected return statement problem?

import net.minecraft.block.CraftingTableBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.CraftingScreenHandler;
import net.minecraft.screen.ScreenHandlerContext;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin({CraftingScreenHandler.class})
public abstract class CraftingScreenHandlerMixin {
    @Shadow
    @Final
    private ScreenHandlerContext context;

    @Inject(method = {"canUse"}, at = {@At("HEAD")}, cancellable = true)
    private void canUse(PlayerEntity player, CallbackInfoReturnable<Boolean> info) {
        if ((Boolean)this.context.run((world, pos) -> {
            return world.getBlockState(pos).getBlock() instanceof CraftingTableBlock;
        }, true)) {
            info.setReturnValue(true);
        }
    }
}

Upvotes: 0

Views: 28

Answers (0)

Related Questions