允许使用撬棍调整卓越物品接口方向

This commit is contained in:
17146 2025-07-10 00:39:43 +08:00 committed by Light_Quanta
parent 2f0866e00b
commit e757a298f6
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -2,13 +2,16 @@ package com.atsuishio.superbwarfare.block;
import com.atsuishio.superbwarfare.block.entity.SuperbItemInterfaceBlockEntity;
import com.atsuishio.superbwarfare.init.ModBlockEntities;
import com.atsuishio.superbwarfare.init.ModItems;
import com.mojang.serialization.MapCodec;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.Item;
@ -75,6 +78,17 @@ public class SuperbItemInterfaceBlock extends BaseEntityBlock {
}
}
@Override
@ParametersAreNonnullByDefault
protected @NotNull ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
if (stack.is(ModItems.CROWBAR.get())) {
var facing = hitResult.getDirection();
level.setBlockAndUpdate(pos, state.setValue(FACING, facing));
return ItemInteractionResult.SUCCESS;
}
return super.useItemOn(stack, state, level, pos, player, hand, hitResult);
}
@Override
@ParametersAreNonnullByDefault
protected @NotNull InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {