|
3 | 3 | import com.kipti.bnb.CreateBitsnBobs; |
4 | 4 | import com.kipti.bnb.content.nixie.nixie_board.NixieBoardBlock; |
5 | 5 | import com.mojang.serialization.MapCodec; |
| 6 | +import com.simibubi.create.AllBlocks; |
| 7 | +import com.simibubi.create.content.equipment.clipboard.ClipboardBlockItem; |
| 8 | +import com.simibubi.create.content.equipment.clipboard.ClipboardEntry; |
6 | 9 | import com.simibubi.create.content.equipment.wrench.IWrenchable; |
7 | 10 | import net.minecraft.core.BlockPos; |
8 | 11 | import net.minecraft.core.Direction; |
| 12 | +import net.minecraft.core.component.DataComponents; |
| 13 | +import net.minecraft.network.chat.Component; |
9 | 14 | import net.minecraft.world.InteractionHand; |
10 | 15 | import net.minecraft.world.InteractionResult; |
11 | 16 | import net.minecraft.world.ItemInteractionResult; |
@@ -98,14 +103,28 @@ public InteractionResult onWrenched(BlockState state, UseOnContext context) { |
98 | 103 | @Override |
99 | 104 | protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { |
100 | 105 | ItemStack heldItem = player.getItemInHand(hand); |
101 | | - if (heldItem.getItem() instanceof NameTagItem) { |
| 106 | + if (heldItem.getItem() instanceof NameTagItem && heldItem.has(DataComponents.CUSTOM_NAME)) { |
102 | 107 | BlockEntity blockEntity = level.getBlockEntity(pos); |
103 | 108 | if (blockEntity instanceof GenericNixieDisplayBlockEntity display) { |
104 | 109 | String name = heldItem.getHoverName().getString(); |
105 | 110 | display.findControllerBlockEntity().applyTextToDisplay(name, getLineForPlacement(state, hitResult.getBlockPos(), hitResult, level)); |
106 | 111 | } |
107 | 112 | return ItemInteractionResult.SUCCESS; |
108 | 113 | } |
| 114 | + if (AllBlocks.CLIPBOARD.isIn(stack)) { |
| 115 | + BlockEntity blockEntity = level.getBlockEntity(pos); |
| 116 | + List<ClipboardEntry> entries = ClipboardEntry.getLastViewedEntries(stack); |
| 117 | + int line = getLineForPlacement(state, hitResult.getBlockPos(), hitResult, level); |
| 118 | + for (ClipboardEntry entry : entries) { |
| 119 | + for (String string : entry.text.getString() |
| 120 | + .split("\n")) { |
| 121 | + if (blockEntity instanceof GenericNixieDisplayBlockEntity display) { |
| 122 | + display.findControllerBlockEntity().applyTextToDisplay(string, line++); |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + return ItemInteractionResult.SUCCESS; |
| 127 | + } |
109 | 128 | return super.useItemOn(stack, state, level, pos, player, hand, hitResult); |
110 | 129 | } |
111 | 130 |
|
|
0 commit comments