mirror of
https://github.com/GTNewHorizons/gendustry.git
synced 2026-11-19 19:59:50 +00:00
Made Serum->Sample conversion configurable, improved NEI recipe handler
This commit is contained in:
1 parent
fac117a3dc
commit
2f199cbf06
6 files changed
+42
-8
No files matched your search
@@ -75,6 +75,7 @@ cfg Machines {
|
||||
ActivationEnergy = 10
|
||||
|
||||
LabwareConsumeChance = 100 // Chance that the Genetic Labware will be consumed, 0-100
|
||||
ConvertEBSerums = Y
|
||||
}
|
||||
|
||||
cfg Imprinter {
|
||||
@@ -221,7 +222,7 @@ cfg Upgrades {
|
||||
|
||||
cfg Power {
|
||||
RF_MJ_Ratio = 10 // 10 RF = 1 MJ
|
||||
EU_MJ_Ratio = 2.5 // 5 MJ = 2 EU
|
||||
EU_MJ_Ratio = 2.5 // 5 EU = 2 MJ
|
||||
|
||||
cfg EU {
|
||||
// Maximum packet size before stuff explodes
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.item.{ItemStack, Item}
|
||||
import net.bdew.gendustry.Gendustry
|
||||
import net.bdew.gendustry.forestry.GeneSampleInfo
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import forestry.api.apiculture.EnumBeeChromosome
|
||||
import forestry.api.apiculture.{IBeeRoot, EnumBeeChromosome}
|
||||
import forestry.api.genetics.AlleleManager
|
||||
|
||||
object ExtraBeesProxy {
|
||||
@@ -32,7 +32,7 @@ object ExtraBeesProxy {
|
||||
else
|
||||
null
|
||||
|
||||
if (itemSerum != null) Gendustry.logInfo("ExtraBees serum item ID: ", itemSerum.itemID)
|
||||
if (itemSerum != null) Gendustry.logInfo("ExtraBees serum item: %s", itemSerum)
|
||||
|
||||
def isSerum(stack: ItemStack) = if (itemSerum != null) stack.itemID == itemSerum.itemID else false
|
||||
|
||||
@@ -49,4 +49,21 @@ object ExtraBeesProxy {
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
def makeSerumFromSample(sample: GeneSampleInfo): ItemStack = {
|
||||
if (itemSerum == null || !sample.root.isInstanceOf[IBeeRoot]) return null
|
||||
val serum = new ItemStack(itemSerum)
|
||||
val nbt = new NBTTagCompound
|
||||
nbt.setString("uid", sample.allele.getUID)
|
||||
|
||||
if (sample.chromosome >= EnumBeeChromosome.HUMIDITY.ordinal)
|
||||
nbt.setInteger("chromosome", sample.chromosome - 1)
|
||||
else
|
||||
nbt.setInteger("chromosome", sample.chromosome)
|
||||
|
||||
nbt.setInteger("quality", 10)
|
||||
|
||||
serum.setTagCompound(nbt)
|
||||
return serum
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ case class GeneSampleInfo(root: ISpeciesRoot, chromosome: Int, allele: IAllele)
|
||||
case p: IAllelePlantType => if (p.getPlantTypes.isEmpty) "-" else p.getPlantTypes.asScala.mkString(", ")
|
||||
case b: IAlleleBoolean => if (b.getValue) Misc.toLocal("gendustry.allele.true") else Misc.toLocal("gendustry.allele.false")
|
||||
case g: IAlleleGrowth => g.getProvider.getDescription
|
||||
case x => x.getName
|
||||
case x => StringUtil.localize(x.getName)
|
||||
}
|
||||
return "%s: %s".format(Misc.toLocal("gendustry.chromosome." + chr), alstr)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class MachineSampler extends Machine("Sampler", new BlockSampler(_)) with GuiPro
|
||||
type TEClass = TileSampler
|
||||
|
||||
lazy val labwareConsumeChance = tuning.getInt("LabwareConsumeChance")
|
||||
lazy val convertEBSerums = tuning.getBoolean("ConvertEBSerums")
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
def getGui(te: TileSampler, player: EntityPlayer): GuiContainer = new GuiSampler(te, player)
|
||||
|
||||
@@ -19,13 +19,13 @@ import net.bdew.gendustry.power.TilePowered
|
||||
import net.bdew.gendustry.compat.ExtraBeesProxy
|
||||
|
||||
class TileSampler extends TileItemProcessor with TilePowered {
|
||||
lazy val cfg = Machines.imprinter
|
||||
lazy val cfg = Machines.sampler
|
||||
val outputSlots = Seq(3)
|
||||
|
||||
def getSizeInventory = 4
|
||||
|
||||
def selectRandomAllele(stack: ItemStack): ItemStack = {
|
||||
if (ExtraBeesProxy.isSerum(stack)) {
|
||||
if (cfg.convertEBSerums && ExtraBeesProxy.isSerum(stack)) {
|
||||
val sample = ExtraBeesProxy.getSerumSample(stack)
|
||||
if (sample != null) return Items.geneSample.newStack(sample)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class TileSampler extends TileItemProcessor with TilePowered {
|
||||
case 1 =>
|
||||
return itemstack.getItem == Items.labware
|
||||
case 2 =>
|
||||
return AlleleManager.alleleRegistry.getIndividual(itemstack) != null || ExtraBeesProxy.isSerum(itemstack)
|
||||
return AlleleManager.alleleRegistry.getIndividual(itemstack) != null || (cfg.convertEBSerums && ExtraBeesProxy.isSerum(itemstack))
|
||||
case _ =>
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util
|
||||
import net.bdew.lib.Misc
|
||||
import net.bdew.gendustry.forestry.GeneSampleInfo
|
||||
import scala.Some
|
||||
import net.bdew.gendustry.compat.ExtraBeesProxy
|
||||
|
||||
class SamplerHandler extends BaseRecipeHandler {
|
||||
lazy val offset = new Point(5, 13)
|
||||
@@ -65,6 +66,12 @@ class SamplerHandler extends BaseRecipeHandler {
|
||||
for (info <- NEICache.geneSamples; species <- NEICache.speciesChromosomes(info)) {
|
||||
arecipes.add(new SamplerRecipe(info, getRecipeStack(species)))
|
||||
}
|
||||
if (Machines.sampler.convertEBSerums && ExtraBeesProxy.ebLoaded) {
|
||||
for (sample <- NEICache.geneSamples if sample.root.isInstanceOf[IBeeRoot]) {
|
||||
val serum = ExtraBeesProxy.makeSerumFromSample(sample)
|
||||
if (serum != null) arecipes.add(new SamplerRecipe(sample, serum))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def loadUsageRecipes(outputId: String, results: AnyRef*): Unit = {
|
||||
@@ -83,6 +90,10 @@ class SamplerHandler extends BaseRecipeHandler {
|
||||
alleles += GeneSampleInfo(root, n, chromosome.getSecondaryAllele)
|
||||
}
|
||||
alleles.foreach(sample => arecipes.add(new SamplerRecipe(sample, stack)))
|
||||
} else if (Machines.sampler.convertEBSerums && ExtraBeesProxy.isSerum(stack)) {
|
||||
val sample = ExtraBeesProxy.getSerumSample(stack)
|
||||
if (sample != null)
|
||||
arecipes.add(new SamplerRecipe(sample, stack))
|
||||
}
|
||||
case ("Sampler", _) => addAllRecipes()
|
||||
}
|
||||
@@ -95,6 +106,10 @@ class SamplerHandler extends BaseRecipeHandler {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user