optional item/block tags display in tooltips
This commit is contained in:
parent
c4dbc79707
commit
ff547f9a5e
@ -865,6 +865,11 @@ private fun gui(provider: MatteryLanguageProvider) {
|
|||||||
gui("slot_filter.hint", "To remove slot filter press Ctrl + LMB")
|
gui("slot_filter.hint", "To remove slot filter press Ctrl + LMB")
|
||||||
|
|
||||||
gui("tooltip.enum.active", "> %s")
|
gui("tooltip.enum.active", "> %s")
|
||||||
|
|
||||||
|
gui("debug.tags.help", "Hold Shift to display tags")
|
||||||
|
gui("debug.tags.item.title", "Item tags:")
|
||||||
|
gui("debug.tags.block.title", "Block tags:")
|
||||||
|
gui("debug.tags.tag.entry", " - %s")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,6 +862,10 @@ private fun gui(provider: MatteryLanguageProvider) {
|
|||||||
gui("slot_filter.filtered", "Данный слот отфильтрован для автоматизации")
|
gui("slot_filter.filtered", "Данный слот отфильтрован для автоматизации")
|
||||||
gui("slot_filter.forbidden", "Данный слот запрещён для взаимодействия средствами автоматизации")
|
gui("slot_filter.forbidden", "Данный слот запрещён для взаимодействия средствами автоматизации")
|
||||||
gui("slot_filter.hint", "Для удаления фильтра нажмите Ctrl + ЛКМ")
|
gui("slot_filter.hint", "Для удаления фильтра нажмите Ctrl + ЛКМ")
|
||||||
|
|
||||||
|
gui("debug.tags.help", "Удерживайте Shift для отображения тегов")
|
||||||
|
gui("debug.tags.item.title", "Теги предмета:")
|
||||||
|
gui("debug.tags.block.title", "Теги блока:")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +242,7 @@ public final class OverdriveThatMatters {
|
|||||||
EVENT_BUS.addListener(EventPriority.LOWEST, ClientTickHandlerKt::onClientTick);
|
EVENT_BUS.addListener(EventPriority.LOWEST, ClientTickHandlerKt::onClientTick);
|
||||||
EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientConnected);
|
EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientConnected);
|
||||||
EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientDisconnected);
|
EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientDisconnected);
|
||||||
|
EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::tooltipEvent);
|
||||||
|
|
||||||
EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect);
|
EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect);
|
||||||
|
|
||||||
|
@ -2,16 +2,22 @@ package ru.dbotthepony.mc.otm.client
|
|||||||
|
|
||||||
import com.mojang.blaze3d.platform.InputConstants
|
import com.mojang.blaze3d.platform.InputConstants
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap
|
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap
|
||||||
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||||
import net.minecraft.client.gui.screens.Screen
|
import net.minecraft.client.gui.screens.Screen
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen
|
||||||
import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
import net.minecraft.client.gui.screens.inventory.InventoryScreen
|
||||||
|
import net.minecraft.tags.TagKey
|
||||||
import net.minecraft.world.inventory.InventoryMenu
|
import net.minecraft.world.inventory.InventoryMenu
|
||||||
import net.minecraft.world.inventory.Slot
|
import net.minecraft.world.inventory.Slot
|
||||||
|
import net.minecraft.world.item.BlockItem
|
||||||
|
import net.minecraft.world.item.Item
|
||||||
|
import net.minecraft.world.level.block.Block
|
||||||
import net.minecraftforge.client.event.MovementInputUpdateEvent
|
import net.minecraftforge.client.event.MovementInputUpdateEvent
|
||||||
import net.minecraftforge.client.event.ScreenEvent
|
import net.minecraftforge.client.event.ScreenEvent
|
||||||
import net.minecraftforge.client.event.ScreenEvent.MouseDragged
|
import net.minecraftforge.client.event.ScreenEvent.MouseDragged
|
||||||
import net.minecraftforge.client.event.ScreenEvent.MouseScrolled
|
import net.minecraftforge.client.event.ScreenEvent.MouseScrolled
|
||||||
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent
|
||||||
import ru.dbotthepony.mc.otm.config.ClientConfig
|
import ru.dbotthepony.mc.otm.config.ClientConfig
|
||||||
import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature
|
import ru.dbotthepony.mc.otm.android.feature.JumpBoostFeature
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||||
@ -27,6 +33,7 @@ import ru.dbotthepony.mc.otm.client.screen.panels.Panel2Widget
|
|||||||
import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket
|
import ru.dbotthepony.mc.otm.compat.vanilla.InventoryScrollPacket
|
||||||
import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorScreen
|
import ru.dbotthepony.mc.otm.compat.cos.isCosmeticArmorScreen
|
||||||
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
import ru.dbotthepony.mc.otm.core.TranslatableComponent
|
||||||
|
import ru.dbotthepony.mc.otm.core.addAll
|
||||||
import ru.dbotthepony.mc.otm.core.math.integerDivisionUp
|
import ru.dbotthepony.mc.otm.core.math.integerDivisionUp
|
||||||
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
import ru.dbotthepony.mc.otm.menu.MatteryMenu
|
||||||
import ru.dbotthepony.mc.otm.network.MenuNetworkChannel
|
import ru.dbotthepony.mc.otm.network.MenuNetworkChannel
|
||||||
@ -253,3 +260,42 @@ fun onScreenOpen(event: ScreenEvent.Opening) {
|
|||||||
event.newScreen = ExopackInventoryScreen(player.exoPackMenu)
|
event.newScreen = ExopackInventoryScreen(player.exoPackMenu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val TOOLTIP_TAG_DISPLAY_HELP = TranslatableComponent("otm.gui.debug.tags.help").withStyle(ChatFormatting.GRAY)
|
||||||
|
private val TOOLTIP_TAG_DISPLAY_ITEM_TITLE = TranslatableComponent("otm.gui.debug.tags.item.title").withStyle(ChatFormatting.DARK_GRAY)
|
||||||
|
private val TOOLTIP_TAG_DISPLAY_BLOCK_TITLE = TranslatableComponent("otm.gui.debug.tags.block.title").withStyle(ChatFormatting.DARK_GRAY)
|
||||||
|
|
||||||
|
fun tooltipEvent(event: ItemTooltipEvent) {
|
||||||
|
if (event.flags.isAdvanced && ClientConfig.TOOLTIP_DISPLAY_TAGS && !event.itemStack.isEmpty) {
|
||||||
|
val itemTags = ArrayList<TagKey<Item>>()
|
||||||
|
if (event.itemStack.tags.count() > 0) {
|
||||||
|
itemTags.addAll(event.itemStack.tags)
|
||||||
|
}
|
||||||
|
|
||||||
|
val blockTags = ArrayList<TagKey<Block>>()
|
||||||
|
if (event.itemStack.item is BlockItem) {
|
||||||
|
blockTags.addAll((event.itemStack.item as BlockItem).block.defaultBlockState().tags)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemTags.isNotEmpty() || blockTags.isNotEmpty()) {
|
||||||
|
if (!minecraft.window.isShiftDown) {
|
||||||
|
event.toolTip.add(TOOLTIP_TAG_DISPLAY_HELP)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemTags.isNotEmpty()) {
|
||||||
|
event.toolTip.add(TOOLTIP_TAG_DISPLAY_ITEM_TITLE)
|
||||||
|
for (tag in itemTags) {
|
||||||
|
event.toolTip.add(TranslatableComponent("otm.gui.debug.tags.tag.entry", tag.location).withStyle(ChatFormatting.DARK_GRAY))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockTags.isNotEmpty()) {
|
||||||
|
event.toolTip.add(TOOLTIP_TAG_DISPLAY_BLOCK_TITLE)
|
||||||
|
for (tag in blockTags) {
|
||||||
|
event.toolTip.add(TranslatableComponent("otm.gui.debug.tags.tag.entry", tag.location).withStyle(ChatFormatting.DARK_GRAY))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -28,4 +28,8 @@ object ClientConfig : AbstractConfig("client", ModConfig.Type.CLIENT) {
|
|||||||
.comment("Display redstone control button using items instead of custom sprites")
|
.comment("Display redstone control button using items instead of custom sprites")
|
||||||
.comment("For those who want it.")
|
.comment("For those who want it.")
|
||||||
.define("REDSTONE_CONTROLS_ITEM_ICONS", false)
|
.define("REDSTONE_CONTROLS_ITEM_ICONS", false)
|
||||||
|
|
||||||
|
var TOOLTIP_DISPLAY_TAGS: Boolean by builder
|
||||||
|
.comment("Display block/item tags in advanced item tooltips")
|
||||||
|
.define("TOOLTIP_DISPLAY_TAGS", false)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user