From 4b2b76020f43fd0b83dade1d384b8ff9e0f2d8cf Mon Sep 17 00:00:00 2001 From: dragoncommands Date: Wed, 4 Oct 2023 18:15:36 -0400 Subject: [PATCH] Begin IMPL of fishing net custom tool tips Added: - Fishing net tooltip data class - Callback to handle the tooltip --- .../dev/hybridlabs/aquatic/HybridAquaticClient.kt | 2 ++ .../aquatic/client/item/FishingNetTooltip.kt | 12 ++++++++++++ .../dev/hybridlabs/aquatic/item/FishingNetItem.kt | 6 ++++++ .../hybridlabs/aquatic/item/FishingNetTooltipData.kt | 7 +++++++ 4 files changed, 27 insertions(+) create mode 100644 src/client/kotlin/dev/hybridlabs/aquatic/client/item/FishingNetTooltip.kt create mode 100644 src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetTooltipData.kt diff --git a/src/client/kotlin/dev/hybridlabs/aquatic/HybridAquaticClient.kt b/src/client/kotlin/dev/hybridlabs/aquatic/HybridAquaticClient.kt index d871d6fa8..3a10c6b18 100644 --- a/src/client/kotlin/dev/hybridlabs/aquatic/HybridAquaticClient.kt +++ b/src/client/kotlin/dev/hybridlabs/aquatic/HybridAquaticClient.kt @@ -2,6 +2,7 @@ package dev.hybridlabs.aquatic import dev.hybridlabs.aquatic.block.HybridAquaticBlocks import dev.hybridlabs.aquatic.block.entity.HybridAquaticBlockEntityTypes +import dev.hybridlabs.aquatic.client.item.FishingNetTooltip import dev.hybridlabs.aquatic.client.item.MessageInABottleTooltip import dev.hybridlabs.aquatic.client.model.HybridAquaticEntityModelLayers import dev.hybridlabs.aquatic.client.network.HybridAquaticClientNetworking @@ -35,6 +36,7 @@ object HybridAquaticClient : ClientModInitializer { private fun registerTooltips() { ItemTooltipCallback.EVENT.register(MessageInABottleTooltip()) + ItemTooltipCallback.EVENT.register(FishingNetTooltip()) } private fun registerBlockRenderLayers(registry: BlockRenderLayerMap = BlockRenderLayerMap.INSTANCE) { diff --git a/src/client/kotlin/dev/hybridlabs/aquatic/client/item/FishingNetTooltip.kt b/src/client/kotlin/dev/hybridlabs/aquatic/client/item/FishingNetTooltip.kt new file mode 100644 index 000000000..dee81e892 --- /dev/null +++ b/src/client/kotlin/dev/hybridlabs/aquatic/client/item/FishingNetTooltip.kt @@ -0,0 +1,12 @@ +package dev.hybridlabs.aquatic.client.item + +import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback +import net.minecraft.client.item.TooltipContext +import net.minecraft.item.ItemStack +import net.minecraft.text.Text + +class FishingNetTooltip : ItemTooltipCallback { + override fun getTooltip(stack: ItemStack?, context: TooltipContext?, lines: MutableList?) { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetItem.kt b/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetItem.kt index b65c1d297..08a9c988c 100644 --- a/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetItem.kt +++ b/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetItem.kt @@ -6,6 +6,7 @@ import dev.hybridlabs.aquatic.tag.HybridAquaticEntityTags import net.fabricmc.fabric.impl.event.interaction.InteractionEventsRouter import net.minecraft.block.Block import net.minecraft.client.item.TooltipContext +import net.minecraft.client.item.TooltipData import net.minecraft.entity.Entity import net.minecraft.entity.EntityType import net.minecraft.entity.LivingEntity @@ -17,6 +18,7 @@ import net.minecraft.text.Text import net.minecraft.util.ActionResult import net.minecraft.util.Hand import net.minecraft.world.World +import java.util.* import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull @@ -76,6 +78,10 @@ class FishingNetItem(settings: Settings?) : Item(settings) { super.appendTooltip(stack, world, tooltip, context) } + override fun getTooltipData(stack: ItemStack?): Optional { + return super.getTooltipData(stack) + } + companion object { const val ENTITY_KEY : String = "storedEntity" } diff --git a/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetTooltipData.kt b/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetTooltipData.kt new file mode 100644 index 000000000..80cec07c9 --- /dev/null +++ b/src/main/kotlin/dev/hybridlabs/aquatic/item/FishingNetTooltipData.kt @@ -0,0 +1,7 @@ +package dev.hybridlabs.aquatic.item + +import net.minecraft.client.item.TooltipData + +class FishingNetTooltipData : TooltipData { + +} \ No newline at end of file