minecraft-src/net/minecraft/world/item/SignItem.java
2025-07-04 02:49:36 +03:00

35 lines
1.3 KiB
Java

package net.minecraft.world.item;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SignBlock;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
public class SignItem extends StandingAndWallBlockItem {
public SignItem(Block standingBlock, Block wallBlock, Item.Properties properties) {
super(standingBlock, wallBlock, Direction.DOWN, properties);
}
public SignItem(Item.Properties properties, Block standingBlock, Block wallBlock, Direction attachmentDirection) {
super(standingBlock, wallBlock, attachmentDirection, properties);
}
@Override
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level level, @Nullable Player player, ItemStack stack, BlockState state) {
boolean bl = super.updateCustomBlockEntityTag(pos, level, player, stack, state);
if (!level.isClientSide
&& !bl
&& player != null
&& level.getBlockEntity(pos) instanceof SignBlockEntity signBlockEntity
&& level.getBlockState(pos).getBlock() instanceof SignBlock signBlock) {
signBlock.openTextEdit(player, signBlockEntity, true);
}
return bl;
}
}