data stick may have null nbt

This commit is contained in:
repo_alt 2020-07-20 16:33:16 +03:00
parent 3141b56472
commit f99044ad18

View File

@ -16,39 +16,40 @@ class ConverterDataStick extends Converter {
override def convert(value: Any, output: util.Map[AnyRef, AnyRef]): Unit = if (value.isInstanceOf[ItemStack]) { override def convert(value: Any, output: util.Map[AnyRef, AnyRef]): Unit = if (value.isInstanceOf[ItemStack]) {
val stack = value.asInstanceOf[ItemStack] val stack = value.asInstanceOf[ItemStack]
val nbt = stack.stackTagCompound val nbt = stack.stackTagCompound
if (nbt.hasKey("prospection_tier")) if (nbt != null) {
nbt.getString("title") match { if (nbt.hasKey("prospection_tier"))
case "Raw Prospection Data" => getRawProspectionData(output, nbt) nbt.getString("title") match {
case "Analyzed Prospection Data" => { case "Raw Prospection Data" => getRawProspectionData(output, nbt)
getRawProspectionData(output, nbt) case "Analyzed Prospection Data" =>
output += "Analyzed Prospection Data" -> getRawProspectionData(output, nbt)
nbt.getTagList("pages", NBT.TAG_STRING) output += "Analyzed Prospection Data" ->
.toArray[NBTTagString].map( (tag: NBTTagString) => tag.func_150285_a_().split('\n')) nbt.getTagList("pages", NBT.TAG_STRING)
.toArray[NBTTagString].map((tag: NBTTagString) => tag.func_150285_a_().split('\n'))
case _ =>
} }
case _ => else if (nbt.hasKey("author") && nbt.getString("author") == "Assembling Line Recipe Generator" && nbt.hasKey("output")) {
val outputItem = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("output"))
output += "output" -> outputItem.getDisplayName
output += "time" -> nbt.getInteger("time").toString
output += "eu" -> nbt.getInteger("eu").toString
val inputs = new ArrayBuffer[ItemStack]()
var index = 0
while (nbt.hasKey(index.toString)) {
inputs += ItemStack.loadItemStackFromNBT(nbt.getCompoundTag(index.toString))
index += 1
}
output += "inputItems" -> inputs.map((s: ItemStack) => s.getDisplayName -> s.stackSize)
index = 0
val inputFluids = new ArrayBuffer[FluidStack]()
while (nbt.hasKey("f" + index)) {
inputFluids += FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("f" + index))
index += 1
}
output += "inputFluids" -> inputFluids.map((s: FluidStack) => s.getLocalizedName -> s.amount)
} }
else if (nbt.hasKey("author") && nbt.getString("author") == "Assembling Line Recipe Generator" && nbt.hasKey("output")) {
val outputItem = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("output"))
output += "output" -> outputItem.getDisplayName
output += "time" -> nbt.getInteger("time").toString
output += "eu" -> nbt.getInteger("eu").toString
val inputs = new ArrayBuffer[ItemStack]()
var index = 0
while (nbt.hasKey(index.toString)) {
inputs += ItemStack.loadItemStackFromNBT(nbt.getCompoundTag(index.toString))
index += 1
}
output += "inputItems" -> inputs.map((s:ItemStack) => s.getDisplayName -> s.stackSize)
index = 0
val inputFluids = new ArrayBuffer[FluidStack]()
while (nbt.hasKey("f" + index)) {
inputFluids += FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("f" + index))
index += 1
}
output += "inputFluids" -> inputFluids.map((s:FluidStack) => s.getLocalizedName -> s.amount)
} }
} }
def getRawProspectionData(output: util.Map[AnyRef, AnyRef], nbt: NBTTagCompound) = private def getRawProspectionData(output: util.Map[AnyRef, AnyRef], nbt: NBTTagCompound) =
output += "Raw Prospection Data" -> Map( output += "Raw Prospection Data" -> Map(
"prospection_tier" -> nbt.getByte("prospection_tier"), "prospection_tier" -> nbt.getByte("prospection_tier"),
"prospection_pos" -> nbt.getString("prospection_pos"), "prospection_pos" -> nbt.getString("prospection_pos"),