Skip to content

Commit 6f67cff

Browse files
committed
fix: format tooltips in the same way as other Galacticraft blocks by splitting into lines of at most 150 characters
1 parent 3370bdc commit 6f67cff

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/dev/galacticraft/machinelib/api/block/MachineBlock.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import dev.galacticraft.machinelib.client.api.util.DisplayUtil;
3535
import dev.galacticraft.machinelib.impl.Constant;
3636
import dev.galacticraft.machinelib.impl.block.entity.MachineBlockEntityTicker;
37+
import net.minecraft.client.Minecraft;
3738
import net.minecraft.client.gui.screens.Screen;
3839
import net.minecraft.core.BlockPos;
3940
import net.minecraft.core.component.DataComponentPatch;
@@ -43,6 +44,7 @@
4344
import net.minecraft.nbt.Tag;
4445
import net.minecraft.network.chat.Component;
4546
import net.minecraft.network.chat.MutableComponent;
47+
import net.minecraft.network.chat.Style;
4648
import net.minecraft.server.level.ServerPlayer;
4749
import net.minecraft.world.InteractionResult;
4850
import net.minecraft.world.entity.LivingEntity;
@@ -212,7 +214,7 @@ public void onPlace(BlockState state, Level level, BlockPos pos, BlockState bloc
212214
@Override
213215
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltip, @NotNull TooltipFlag flag) {
214216
if (Screen.hasShiftDown()) {
215-
tooltip.addAll(DisplayUtil.wrapText(Component.translatable(this.getDescriptionId() + ".description"), 128));
217+
tooltip.addAll(Minecraft.getInstance().font.getSplitter().splitLines(this.getDescriptionId() + ".description", 150, Style.EMPTY).stream().map(formattedText -> Component.literal(formattedText.getString()).withStyle(Constant.Text.GRAY_STYLE)).toList());
216218
} else {
217219
tooltip.add(PRESS_SHIFT);
218220
}

0 commit comments

Comments
 (0)