mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Add limited support for Thaumcraft essentia containers
Item stacks of Thaumcraft items, such as esssentia jars, are a pain to work with if you can't see their contents. The contents are not hidden by Thaumcraft, so showing them isn't cheaty. Making these available makes it possible to use OC to sort essentia jars by contents, which is SUPER USEFUL since everything else I have which sorts inventory ignores them. this work was adjusted from PR #2942 by user @seebs
This commit is contained in:
parent
bfd2ceed8f
commit
8592241802
@ -35,6 +35,7 @@ object Mods {
|
|||||||
val ProjectRedTransmission = new SimpleMod((IDs.ProjectRedTransmission))
|
val ProjectRedTransmission = new SimpleMod((IDs.ProjectRedTransmission))
|
||||||
val DraconicEvolution = new SimpleMod(IDs.DraconicEvolution)
|
val DraconicEvolution = new SimpleMod(IDs.DraconicEvolution)
|
||||||
val EnderStorage = new SimpleMod(IDs.EnderStorage)
|
val EnderStorage = new SimpleMod(IDs.EnderStorage)
|
||||||
|
val Thaumcraft = new SimpleMod(IDs.Thaumcraft)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ object Mods {
|
|||||||
integration.projectred.ModProjectRed,
|
integration.projectred.ModProjectRed,
|
||||||
integration.computercraft.ModComputerCraft,
|
integration.computercraft.ModComputerCraft,
|
||||||
integration.enderstorage.ModEnderStorage,
|
integration.enderstorage.ModEnderStorage,
|
||||||
|
integration.thaumcraft.ModThaumcraft,
|
||||||
|
|
||||||
// We go late to ensure all other mod integration is done, e.g. to
|
// We go late to ensure all other mod integration is done, e.g. to
|
||||||
// allow properly checking if wireless redstone is present.
|
// allow properly checking if wireless redstone is present.
|
||||||
@ -97,6 +99,7 @@ object Mods {
|
|||||||
final val ProjectRedTransmission = "projectred-transmission"
|
final val ProjectRedTransmission = "projectred-transmission"
|
||||||
final val DraconicEvolution = "draconicevolution"
|
final val DraconicEvolution = "draconicevolution"
|
||||||
final val EnderStorage = "enderstorage"
|
final val EnderStorage = "enderstorage"
|
||||||
|
final val Thaumcraft = "thaumcraft"
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package li.cil.oc.integration.thaumcraft
|
||||||
|
|
||||||
|
import java.util
|
||||||
|
|
||||||
|
import li.cil.oc.api.driver.Converter
|
||||||
|
import net.minecraft.item.{Item, ItemStack}
|
||||||
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
import net.minecraftforge.common.util.Constants.NBT
|
||||||
|
|
||||||
|
import scala.collection.convert.WrapAsScala._
|
||||||
|
import scala.collection.mutable
|
||||||
|
|
||||||
|
object ConverterThaumcraftItems extends Converter {
|
||||||
|
override def convert(value: scala.Any, output: util.Map[AnyRef, AnyRef]): Unit = value match {
|
||||||
|
case stack: ItemStack =>
|
||||||
|
val name = Item.REGISTRY.getNameForObject(stack.getItem).toString
|
||||||
|
|
||||||
|
// Handle essentia/vis contents for Thaumcraft jars, phials, and crystals
|
||||||
|
if ((name == "thaumcraft:jar_normal") ||
|
||||||
|
(name == "thaumcraft:jar_void") ||
|
||||||
|
(name == "thaumcraft:phial") ||
|
||||||
|
(name == "thaumcraft:crystal_essence")) {
|
||||||
|
if (stack.hasTagCompound &&
|
||||||
|
stack.getTagCompound.hasKey("Aspects", NBT.TAG_LIST)) {
|
||||||
|
val aspects = mutable.ArrayBuffer.empty[mutable.Map[String, Any]]
|
||||||
|
val nbtAspects = stack.getTagCompound.getTagList("Aspects", NBT.TAG_COMPOUND).map {
|
||||||
|
case tag: NBTTagCompound => tag
|
||||||
|
}
|
||||||
|
for (nbtAspect <- nbtAspects) {
|
||||||
|
val key = nbtAspect.getString("key")
|
||||||
|
val amount = nbtAspect.getInteger("amount")
|
||||||
|
val aspect = mutable.Map[String, Any](
|
||||||
|
"aspect" -> key,
|
||||||
|
"amount" -> amount
|
||||||
|
)
|
||||||
|
aspects += aspect
|
||||||
|
}
|
||||||
|
output += "aspects" -> aspects
|
||||||
|
}
|
||||||
|
if (stack.hasTagCompound && stack.getTagCompound.hasKey("AspectFilter", NBT.TAG_STRING)) {
|
||||||
|
output += "aspectFilter" -> stack.getTagCompound.getString("AspectFilter")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package li.cil.oc.integration.thaumcraft
|
||||||
|
|
||||||
|
import li.cil.oc.api.Driver
|
||||||
|
import li.cil.oc.integration.ModProxy
|
||||||
|
import li.cil.oc.integration.Mods
|
||||||
|
|
||||||
|
object ModThaumcraft extends ModProxy {
|
||||||
|
override def getMod: Mods.ModBase = Mods.Thaumcraft
|
||||||
|
|
||||||
|
override def initialize() {
|
||||||
|
Driver.add(ConverterThaumcraftItems)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user