refactor: Use custom ray trace provider

This commit is contained in:
Linnea Gräf
2025-03-06 21:43:11 +01:00
parent 9099abe955
commit 8a4bfe24b3
6 changed files with 119 additions and 38 deletions

View File

@@ -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? {