优化卓越物品接口交互

This commit is contained in:
Light_Quanta 2025-07-10 14:39:01 +08:00
parent e757a298f6
commit c86dc2341a
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 6 additions and 1 deletions

View file

@ -3,6 +3,7 @@ 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.atsuishio.superbwarfare.init.ModTags;
import com.mojang.serialization.MapCodec;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
@ -81,7 +82,7 @@ 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())) {
if (stack.is(ModItems.CROWBAR.get()) || stack.is(ModTags.Items.WRENCHES_TAG) || stack.is(ModTags.Items.WRENCH_TAG)) {
var facing = hitResult.getDirection();
level.setBlockAndUpdate(pos, state.setValue(FACING, facing));
return ItemInteractionResult.SUCCESS;

View file

@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.init;
import com.atsuishio.superbwarfare.Mod;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
@ -42,6 +43,9 @@ public class ModTags {
public static final TagKey<Item> LEGENDARY_BLUEPRINT = tag("blueprint/legendary");
public static final TagKey<Item> CANNON_BLUEPRINT = tag("blueprint/cannon");
public static final TagKey<Item> WRENCHES_TAG = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "wrenches"));
public static final TagKey<Item> WRENCH_TAG = ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", "tools/wrench"));
private static TagKey<Item> tag(String name) {
return ItemTags.create(Mod.loc(name));
}