diff options
author | Linnea Gräf <nea@nea.moe> | 2025-03-06 21:43:11 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-03-08 16:01:00 +0100 |
commit | 8a4bfe24b364612e3e783ed9569082b130aa2bfc (patch) | |
tree | 5a98ab8ebecbde6e32e13479a8fb9e17632a93ba /src/main/kotlin/repo | |
parent | 9099abe955d88f7e0f1a1a8feba519a8a098858d (diff) | |
download | Firmament-8a4bfe24b364612e3e783ed9569082b130aa2bfc.tar.gz Firmament-8a4bfe24b364612e3e783ed9569082b130aa2bfc.tar.bz2 Firmament-8a4bfe24b364612e3e783ed9569082b130aa2bfc.zip |
refactor: Use custom ray trace provider
Diffstat (limited to 'src/main/kotlin/repo')
-rw-r--r-- | src/main/kotlin/repo/MiningRepoData.kt | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/main/kotlin/repo/MiningRepoData.kt b/src/main/kotlin/repo/MiningRepoData.kt index 46eaeb0..7c4a2ef 100644 --- a/src/main/kotlin/repo/MiningRepoData.kt +++ b/src/main/kotlin/repo/MiningRepoData.kt @@ -11,11 +11,14 @@ import net.minecraft.block.Block import net.minecraft.item.BlockItem import net.minecraft.item.ItemStack import net.minecraft.nbt.NbtCompound +import net.minecraft.text.Text import moe.nea.firmament.repo.ReforgeStore.kJson import moe.nea.firmament.util.MC import moe.nea.firmament.util.SBData import moe.nea.firmament.util.SkyBlockIsland import moe.nea.firmament.util.SkyblockId +import moe.nea.firmament.util.mc.FirmamentDataComponentTypes +import moe.nea.firmament.util.mc.displayNameAccordingToNbt class MiningRepoData : IReloadable { var customMiningAreas: Map<SkyBlockIsland, CustomMiningArea> = mapOf() @@ -41,7 +44,23 @@ class MiningRepoData : IReloadable { val name: String? = null, val baseDrop: SkyblockId? = null, val blocks189: List<Block189> = emptyList() - ) + ) { + @Transient + val dropItem = baseDrop?.let(::SBItemStack) + private val labeledStack by lazy { + dropItem?.asCopiedItemStack()?.also(::markItemStack) + } + + private fun markItemStack(itemStack: ItemStack) { + itemStack.set(FirmamentDataComponentTypes.CUSTOM_MINING_BLOCK_DATA, this) + if (name != null) + itemStack.displayNameAccordingToNbt = Text.literal(name) + } + + fun getDisplayItem(block: Block): ItemStack { + return labeledStack ?: ItemStack(block).also(::markItemStack) + } + } @Serializable data class Block189( @@ -54,6 +73,7 @@ class MiningRepoData : IReloadable { val isCurrentlyActive: Boolean get() = isActiveIn(SBData.skyblockLocation ?: SkyBlockIsland.NIL) + fun isActiveIn(location: SkyBlockIsland) = onlyIn == null || location in onlyIn private fun convertToModernBlock(): Block? { |