diff --git a/src/main/kotlin/insight/ColorUtil.kt b/src/main/kotlin/insight/ColorUtil.kt index a22eb691b..69824ae6c 100644 --- a/src/main/kotlin/insight/ColorUtil.kt +++ b/src/main/kotlin/insight/ColorUtil.kt @@ -78,7 +78,7 @@ private fun findColorFromExpression( val facet = MinecraftFacet.getInstance(module) ?: return null val resolvedName = expression.resolvedName ?: return null for (abstractModuleType in facet.types) { - val map = abstractModuleType.classToColorMappings + val map = abstractModuleType.classToColorMappings(module) for (entry in map.entries) { // This is such a hack // Okay, type will be the fully-qualified class, but it will exclude the actual enum diff --git a/src/main/kotlin/platform/AbstractModuleType.kt b/src/main/kotlin/platform/AbstractModuleType.kt index d88258293..f27254eac 100644 --- a/src/main/kotlin/platform/AbstractModuleType.kt +++ b/src/main/kotlin/platform/AbstractModuleType.kt @@ -25,6 +25,7 @@ import com.demonwav.mcdev.insight.generation.ui.EventGenerationPanel import com.demonwav.mcdev.util.findContainingClass import com.intellij.codeInspection.ex.EntryPointsManager import com.intellij.codeInspection.ex.EntryPointsManagerBase +import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleUtilCore import com.intellij.openapi.project.Project import com.intellij.psi.PsiClass @@ -51,8 +52,7 @@ abstract class AbstractModuleType(val groupId: String, v abstract val listenerAnnotations: List - val classToColorMappings: Map - get() = this.colorMap + open fun classToColorMappings(module: Module): Map = this.colorMap abstract fun generateModule(facet: MinecraftFacet): T diff --git a/src/main/kotlin/platform/mcp/McpModuleType.kt b/src/main/kotlin/platform/mcp/McpModuleType.kt index 12d98b3a1..be617faf7 100644 --- a/src/main/kotlin/platform/mcp/McpModuleType.kt +++ b/src/main/kotlin/platform/mcp/McpModuleType.kt @@ -23,9 +23,12 @@ package com.demonwav.mcdev.platform.mcp import com.demonwav.mcdev.facet.MinecraftFacet import com.demonwav.mcdev.platform.AbstractModuleType import com.demonwav.mcdev.platform.PlatformType +import com.demonwav.mcdev.platform.mcp.mappings.getMappedClass +import com.demonwav.mcdev.platform.mcp.mappings.getMappedField import com.demonwav.mcdev.platform.mcp.util.McpConstants import com.demonwav.mcdev.util.CommonColors -import com.demonwav.mcdev.util.SemanticVersion +import com.intellij.openapi.module.Module +import java.awt.Color import javax.swing.Icon object McpModuleType : AbstractModuleType("", "") { @@ -33,10 +36,18 @@ object McpModuleType : AbstractModuleType("", "") { private const val ID = "MCP_MODULE_TYPE" init { - CommonColors.applyStandardColors(colorMap, McpConstants.TEXT_FORMATTING) CommonColors.applyStandardColors(colorMap, McpConstants.CHAT_FORMATTING) } + override fun classToColorMappings(module: Module): Map { + return colorMap.mapKeys { key -> + val parts = key.key.split('.') + val className = parts.dropLast(1).joinToString(".") + val fieldName = parts.last() + "${module.getMappedClass(className)}.${module.getMappedField(className, fieldName)}" + } + } + override val platformType = PlatformType.MCP override val icon: Icon? = null override val id = ID @@ -45,6 +56,4 @@ object McpModuleType : AbstractModuleType("", "") { override val hasIcon = false override fun generateModule(facet: MinecraftFacet) = McpModule(facet) - - val MC_1_12_2 = SemanticVersion.release(1, 12, 2) } diff --git a/src/main/kotlin/platform/mcp/mappings/HardcodedYarnToMojmap.kt b/src/main/kotlin/platform/mcp/mappings/HardcodedYarnToMojmap.kt index 4e17692d7..7dfd4ea7c 100644 --- a/src/main/kotlin/platform/mcp/mappings/HardcodedYarnToMojmap.kt +++ b/src/main/kotlin/platform/mcp/mappings/HardcodedYarnToMojmap.kt @@ -28,7 +28,8 @@ import com.google.common.collect.ImmutableBiMap object HardcodedYarnToMojmap { fun createMappings() = Mappings( ImmutableBiMap.ofEntries( - "net.minecraft.item.ItemStack" mapTo "net.minecraft.world.item.ItemStack" + "net.minecraft.item.ItemStack" mapTo "net.minecraft.world.item.ItemStack", + "net.minecraft.util.Formatting" mapTo "net.minecraft.ChatFormatting", ), ImmutableBiMap.ofEntries(), ImmutableBiMap.ofEntries(), diff --git a/src/main/kotlin/platform/mcp/util/McpConstants.kt b/src/main/kotlin/platform/mcp/util/McpConstants.kt index 98ef295d5..f04747a23 100644 --- a/src/main/kotlin/platform/mcp/util/McpConstants.kt +++ b/src/main/kotlin/platform/mcp/util/McpConstants.kt @@ -22,14 +22,7 @@ package com.demonwav.mcdev.platform.mcp.util object McpConstants { - const val TEXT_FORMATTING = "net.minecraft.util.text.TextFormatting" const val CHAT_FORMATTING = "net.minecraft.ChatFormatting" - const val ENTITY = "net.minecraft.entity.Entity" - const val ENTITY_FX = "net.minecraft.client.particle.EntityFX" - const val WORLD = "net.minecraft.world.World" - const val ITEM_STACK = "net.minecraft.item.ItemStack" - const val BLOCK = "net.minecraft.block.Block" - const val ITEM = "net.minecraft.item.Item" const val MINECRAFT_SERVER = "net.minecraft.server.MinecraftServer" const val PNG_MCMETA = "*.png.mcmeta" }