Skip to content

Commit cfe67bd

Browse files

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

Diff for: ‎src/main/scala/li/cil/oc/integration/jei/ModPluginOpenComputers.scala

+27
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,33 @@ class ModPluginOpenComputers extends IModPlugin {
3535
registry.addRecipeHandlers(CallbackDocHandler.CallbackDocRecipeHandler)
3636
registry.addRecipes(CallbackDocHandler.getRecipes(registry))
3737

38+
def useNBT(names: String*) = names.map(name => {
39+
val info = Items.get(name)
40+
Option(info.item).getOrElse(Item.getItemFromBlock(info.block))
41+
}).filter(_ != null).distinct.foreach(registry.getJeiHelpers.getSubtypeRegistry.useNbtForSubtypes(_))
42+
43+
// Only the preconfigured blocks and items have to be here.
44+
useNBT(
45+
Constants.BlockName.Microcontroller,
46+
Constants.BlockName.Robot,
47+
48+
Constants.ItemName.Drone,
49+
Constants.ItemName.Tablet
50+
)
51+
52+
registry.getJeiHelpers.getSubtypeRegistry.registerNbtInterpreter(Items.get(Constants.ItemName.Floppy).item(), new ISubtypeInterpreter {
53+
override def getSubtypeInfo(stack: ItemStack): String = {
54+
if (!stack.hasTagCompound) return null
55+
val compound: NBTTagCompound = stack.getTagCompound
56+
val data = new NBTTagCompound
57+
// Separate loot disks from normal floppies
58+
if (compound.hasKey(Settings.namespace + "lootFactory")) {
59+
data.setTag(Settings.namespace + "lootFactory", compound.getTag(Settings.namespace + "lootFactory"))
60+
}
61+
if (data.hasNoTags) null else data.toString
62+
}
63+
})
64+
3865
registry.addAdvancedGuiHandlers(RelayGuiHandler)
3966
}
4067

0 commit comments

Comments
 (0)
Please sign in to comment.