Fixed crashes with samples without NBT data (from NEI), fixes #4

This commit is contained in:
bdew committed 2014-01-05 20:15:03 +02:00
1 parent b7de3e870d
commit b341d364ee
4 files changed
+13 -8

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ buildscript {
apply plugin: 'forge'
apply plugin: 'scala'
version = "0.9.7"
version = "0.9.8"
ext.bdlibver = "0.9.5.13"
ext.versuffix = "mc164"
@@ -23,7 +23,7 @@ class GeneRecipe extends IRecipe {
var samples = Seq.empty[GeneSampleInfo]
for (i <- 0 until 3; j <- 0 until 3) {
val itm = inv.getStackInRowAndColumn(i, j)
if (itm != null && itm.getItem.isInstanceOf[GeneSample])
if (itm != null && itm.getItem.isInstanceOf[GeneSample] && itm.hasTagCompound)
samples :+= Items.geneSample.getInfo(itm)
else if (itm != null && itm.getItem.isInstanceOf[GeneTemplate] && template == null)
template = itm
@@ -50,6 +50,7 @@ case class GeneSampleInfo(root: ISpeciesRoot, chromosome: Int, allele: IAllele)
object GeneSampleInfo {
def fromNBT(t: NBTTagCompound): GeneSampleInfo = {
if (t == null) return null
val species = AlleleManager.alleleRegistry.getSpeciesRoot(t.getString("species"))
val allele = AlleleManager.alleleRegistry.getAllele(t.getString("allele"))
return GeneSampleInfo(species, t.getInteger("chromosome"), allele)
@@ -103,12 +103,16 @@ class SamplerHandler extends BaseRecipeHandler {
Some(outputId, results) collect {
case ("item", Seq(stack: ItemStack)) if stack.itemID == Items.geneSample.itemID =>
val info = Items.geneSample.getInfo(stack)
for (species <- NEICache.speciesChromosomes(info)) {
arecipes.add(new SamplerRecipe(info, getRecipeStack(species)))
}
if (Machines.sampler.convertEBSerums && ExtraBeesProxy.ebLoaded) {
val serum = ExtraBeesProxy.makeSerumFromSample(info)
if (serum != null) arecipes.add(new SamplerRecipe(info, serum))
if (info == null) {
addAllRecipes()
} else {
for (species <- NEICache.speciesChromosomes(info)) {
arecipes.add(new SamplerRecipe(info, getRecipeStack(species)))
}
if (Machines.sampler.convertEBSerums && ExtraBeesProxy.ebLoaded) {
val serum = ExtraBeesProxy.makeSerumFromSample(info)
if (serum != null) arecipes.add(new SamplerRecipe(info, serum))
}
}
case ("Sampler", _) => addAllRecipes()
}