优化卓越物品接口交互
This commit is contained in:
parent
e757a298f6
commit
c86dc2341a
2 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.block;
|
||||||
import com.atsuishio.superbwarfare.block.entity.SuperbItemInterfaceBlockEntity;
|
import com.atsuishio.superbwarfare.block.entity.SuperbItemInterfaceBlockEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
import com.atsuishio.superbwarfare.init.ModBlockEntities;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
import com.mojang.serialization.MapCodec;
|
import com.mojang.serialization.MapCodec;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -81,7 +82,7 @@ public class SuperbItemInterfaceBlock extends BaseEntityBlock {
|
||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
protected @NotNull ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
|
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();
|
var facing = hitResult.getDirection();
|
||||||
level.setBlockAndUpdate(pos, state.setValue(FACING, facing));
|
level.setBlockAndUpdate(pos, state.setValue(FACING, facing));
|
||||||
return ItemInteractionResult.SUCCESS;
|
return ItemInteractionResult.SUCCESS;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.init;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.tags.TagKey;
|
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> LEGENDARY_BLUEPRINT = tag("blueprint/legendary");
|
||||||
public static final TagKey<Item> CANNON_BLUEPRINT = tag("blueprint/cannon");
|
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) {
|
private static TagKey<Item> tag(String name) {
|
||||||
return ItemTags.create(Mod.loc(name));
|
return ItemTags.create(Mod.loc(name));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue