From c699b349b565a3fd732ec7a56cfb27284dfb4785 Mon Sep 17 00:00:00 2001 From: bdew Date: Thu, 15 May 2014 11:24:20 +0300 Subject: [PATCH 1/8] Bump bdlib version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bc9a123..e7b649c 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'forge' apply plugin: 'scala' version = "1.1.2" -ext.bdlibver = "1.2.2.44" +ext.bdlibver = "1.2.2.45" ext.versuffix = "mc164" if (project.hasProperty('buildnum')) { From 5b4ba26a4aa0d03179568cb2b9b5f45104080f7c Mon Sep 17 00:00:00 2001 From: bdew Date: Mon, 19 May 2014 09:56:19 +0300 Subject: [PATCH 2/8] Added a public API --- build.gradle | 26 +++++++- src/net/bdew/gendustry/Gendustry.scala | 6 ++ .../bdew/gendustry/api/ApiaryModifiers.java | 59 +++++++++++++++++-- src/net/bdew/gendustry/api/GendustryAPI.java | 21 +++++++ .../api/blocks/IAdvancedMutatron.java | 28 +++++++++ .../bdew/gendustry/api/blocks/IBlockAPI.java | 48 +++++++++++++++ .../api/blocks/IIndustrialApiary.java | 34 +++++++++++ .../gendustry/api/blocks/IWorkerMachine.java | 22 +++++++ .../gendustry/api/items/IApiaryUpgrade.java | 51 ++++++++++++++++ .../bdew/gendustry/api/items/IGeneSample.java | 41 +++++++++++++ .../bdew/gendustry/api/items/IItemAPI.java | 57 ++++++++++++++++++ .../bdew/gendustry/api/items/IItemApi.java | 57 ++++++++++++++++++ src/net/bdew/gendustry/api/package-info.java | 13 ++++ .../bdew/gendustry/apiimpl/BlockApiImpl.scala | 37 ++++++++++++ .../bdew/gendustry/apiimpl/ItemApiImpl.scala | 49 +++++++++++++++ .../TileWorker.scala} | 13 ++-- .../gendustry/forestry/GeneSampleInfo.scala | 6 +- src/net/bdew/gendustry/items/GeneSample.scala | 2 +- .../bdew/gendustry/items/GeneTemplate.scala | 2 +- .../machines/advmutatron/SlotSelector.scala | 2 +- .../advmutatron/TileMutatronAdv.scala | 14 ++++- .../machines/apiary/TileApiary.scala | 15 ++++- .../apiary/upgrades/ItemApiaryUpgrade.scala | 48 ++++++++------- .../machines/extractor/TileExtractor.scala | 3 +- .../machines/imprinter/TileImprinter.scala | 3 +- .../machines/liquifier/TileLiquifier.scala | 3 +- .../mproducer/TileMutagenProducer.scala | 3 +- .../machines/mutatron/TileMutatron.scala | 3 +- .../machines/replicator/TileReplicator.scala | 3 +- .../machines/sampler/TileSampler.scala | 3 +- .../machines/transposer/TileTransposer.scala | 3 +- 31 files changed, 625 insertions(+), 50 deletions(-) create mode 100644 src/net/bdew/gendustry/api/GendustryAPI.java create mode 100644 src/net/bdew/gendustry/api/blocks/IAdvancedMutatron.java create mode 100644 src/net/bdew/gendustry/api/blocks/IBlockAPI.java create mode 100644 src/net/bdew/gendustry/api/blocks/IIndustrialApiary.java create mode 100644 src/net/bdew/gendustry/api/blocks/IWorkerMachine.java create mode 100644 src/net/bdew/gendustry/api/items/IApiaryUpgrade.java create mode 100644 src/net/bdew/gendustry/api/items/IGeneSample.java create mode 100644 src/net/bdew/gendustry/api/items/IItemAPI.java create mode 100644 src/net/bdew/gendustry/api/items/IItemApi.java create mode 100644 src/net/bdew/gendustry/api/package-info.java create mode 100644 src/net/bdew/gendustry/apiimpl/BlockApiImpl.scala create mode 100644 src/net/bdew/gendustry/apiimpl/ItemApiImpl.scala rename src/net/bdew/gendustry/{api/IApiaryUpgrade.java => apiimpl/TileWorker.scala} (54%) diff --git a/build.gradle b/build.gradle index e7b649c..125e925 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,10 @@ buildscript { apply plugin: 'forge' apply plugin: 'scala' -version = "1.1.2" +version = "1.1.3" ext.bdlibver = "1.2.2.45" ext.versuffix = "mc164" +ext.apiVer = version if (project.hasProperty('buildnum')) { project.version = project.version + '.' + project.buildnum @@ -37,6 +38,7 @@ minecraft { version = "1.6.4-9.11.1.964" replace("BDLIB_VER", project.bdlibver) replace("GENDUSTRY_VER", project.version) + replace("GENDUSTRY_APIVER", project.apiVer) } repositories { @@ -77,8 +79,16 @@ processResources { } } +task apiJar(type: Jar, dependsOn: 'classes') { + from (sourceSets.main.output) { + include 'net/bdew/gendustry/api/**' + } + + extension = 'jar' + classifier = 'api' +} + task sourceJar(type: Jar) { - from sourceSets.main.allSource } task deobfJar(type: Jar) { @@ -86,14 +96,24 @@ task deobfJar(type: Jar) { exclude "**/*.psd" } + jar { exclude "**/*.psd" appendix = project.versuffix } +afterEvaluate { project -> + // Fudge the inputs of api/source jars so we get the version after replacements + tasks.getByPath(":sourceJar").from(tasks.getByPath(":sourceMainScala").outputs.files) + tasks.getByPath(":apiJar").from(tasks.getByPath(":sourceMainScala").outputs.files, { + include 'net/bdew/gendustry/api/**' + }) +} + artifacts { archives sourceJar archives deobfJar + archives apiJar } apply plugin: 'maven-publish' @@ -141,6 +161,8 @@ publishing { artifact sourceJar { classifier "sources" } + + artifact apiJar } } repositories { diff --git a/src/net/bdew/gendustry/Gendustry.scala b/src/net/bdew/gendustry/Gendustry.scala index a431768..a278f3e 100644 --- a/src/net/bdew/gendustry/Gendustry.scala +++ b/src/net/bdew/gendustry/Gendustry.scala @@ -25,6 +25,8 @@ import net.bdew.gendustry.compat.triggers.TriggerProvider import net.minecraft.command.CommandHandler import net.bdew.gendustry.custom.CustomContent import net.bdew.gendustry.config.loader.TuningLoader +import net.bdew.gendustry.api.GendustryAPI +import net.bdew.gendustry.apiimpl.{BlockApiImpl, ItemApiImpl} @Mod(modid = Gendustry.modId, version = "GENDUSTRY_VER", name = "Gendustry", dependencies = "required-after:Forestry@[2.3.1.0,);after:BuildCraft|energy;after:BuildCraft|Silicon;after:IC2;after:CoFHCore;after:BinnieCore;after:ExtraBees;after:ExtraTrees;after:MineFactoryReloaded;required-after:bdlib@[BDLIB_VER,)", modLanguage = "scala") @NetworkMod(clientSideRequired = true, serverSideRequired = false) @@ -44,6 +46,10 @@ object Gendustry { @EventHandler def preInit(event: FMLPreInitializationEvent) { log = event.getModLog + + GendustryAPI.Items = ItemApiImpl + GendustryAPI.Blocks = BlockApiImpl + PowerProxy.logModVersions() configDir = new File(event.getModConfigurationDirectory, "gendustry") configFile = event.getSuggestedConfigurationFile diff --git a/src/net/bdew/gendustry/api/ApiaryModifiers.java b/src/net/bdew/gendustry/api/ApiaryModifiers.java index 264f3d6..6ca2c43 100644 --- a/src/net/bdew/gendustry/api/ApiaryModifiers.java +++ b/src/net/bdew/gendustry/api/ApiaryModifiers.java @@ -11,33 +11,84 @@ package net.bdew.gendustry.api; import net.minecraft.world.biome.BiomeGenBase; +/** + * Stores current modifiers from all upgrades in an apiary + */ public class ApiaryModifiers { + /** + * Territory modifier, multiplicative + */ public float territory = 1; - //max safe = 10 (degenerating - offspring become unnatural) + /** + * Mutation chance modifier, multiplicative + * max safe = 10 (degenerating - offspring become unnatural) + */ public float mutation = 1; - //increases lifespan + /** + * Lifespan modifier, multiplicative, higher = longer + */ public float lifespan = 1; - //increases chance to get products each cycle, max safe = 16 (overworked - becomes unnatural) + /** + * Production modifier - increases chance to get products each tick, multiplicative + * max safe = 10 (overworked - becomes unnatural) + */ public float production = 1; + /** + * Flowering and pollination chance modifier, multiplicative + */ public float flowering = 1; - // set to 0 to reduce decay from fatigue + /** + * Genetic decay chance, applies to fatigued unnatural bees, multiplicative + */ public float geneticDecay = 1; + /** + * Sealed - bees can work in rain without the required traits + */ public boolean isSealed = false; + + /** + * Self lighted - bees can work in the night without the required traits, makes block emit light + */ public boolean isSelfLighted = false; + + /** + * Sunlight simulated - bees can work in caves without the required traits + */ public boolean isSunlightSimulated = false; + + /** + * Automated - will auto move offspring to the right slots to allow further breeding + */ public boolean isAutomated = false; + + /** + * Allows collection of pollen from trees + */ public boolean isCollectingPollen = false; + /** + * If set - overrides biome as seen by jubilance checks, etc. + */ public BiomeGenBase biomeOverride = null; + /** + * Energy use modifier, multiplicative + */ public float energy = 1; + /** + * Temperature modifier, additive, same units as {@link BiomeGenBase#temperature} + */ public float temperature = 0; + + /** + * Humidity modifier, additive, same units as {@link BiomeGenBase#rainfall} + */ public float humidity = 0; } diff --git a/src/net/bdew/gendustry/api/GendustryAPI.java b/src/net/bdew/gendustry/api/GendustryAPI.java new file mode 100644 index 0000000..73349e8 --- /dev/null +++ b/src/net/bdew/gendustry/api/GendustryAPI.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api; + +import net.bdew.gendustry.api.blocks.IBlockAPI; +import net.bdew.gendustry.api.items.IItemAPI; + +/** + * Access to the API. This will be available after Gendustry PreInit runs. + */ +public class GendustryAPI { + public static IItemAPI Items; + public static IBlockAPI Blocks; +} diff --git a/src/net/bdew/gendustry/api/blocks/IAdvancedMutatron.java b/src/net/bdew/gendustry/api/blocks/IAdvancedMutatron.java new file mode 100644 index 0000000..49efe76 --- /dev/null +++ b/src/net/bdew/gendustry/api/blocks/IAdvancedMutatron.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.blocks; + +import net.minecraft.item.ItemStack; + +import java.util.Map; + +public interface IAdvancedMutatron extends IWorkerMachine { + /** + * @return List of possible mutations for current inventory + */ + Map getPossibleMutations(); + + /** + * Sets the requested mutation and start process if possible + * + * @param mutation key of the required mutation in the map + */ + void setMutation(int mutation); +} diff --git a/src/net/bdew/gendustry/api/blocks/IBlockAPI.java b/src/net/bdew/gendustry/api/blocks/IBlockAPI.java new file mode 100644 index 0000000..59b9570 --- /dev/null +++ b/src/net/bdew/gendustry/api/blocks/IBlockAPI.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.blocks; + +import net.minecraft.world.World; + +/** + * Interface to various informations about blocks and TileEntities + * WARNING: Everything retrieved from this interface is not guaranteed to be correct or up to date on client side! + */ +public interface IBlockAPI { + /** + * @return True if a valid Industrial Apiary + */ + boolean isIndustrialApiary(World w, int x, int y, int z); + + /** + * @return Industrial Apiary Interface + */ + IIndustrialApiary getIndustrialApiary(World w, int x, int y, int z); + + /** + * @return True if a valid Advanced mutatron + */ + boolean isAdvancedMutatron(World w, int x, int y, int z); + + /** + * @return Advanced mutatron Interface + */ + IAdvancedMutatron getAdvancedMutatron(World w, int x, int y, int z); + + /** + * @return True if a valid machine that does work (most machines in this mod) + */ + boolean isWorkerMachine(World w, int x, int y, int z); + + /** + * @return wroker interface + */ + IWorkerMachine getWorkerMachine(World w, int x, int y, int z); +} diff --git a/src/net/bdew/gendustry/api/blocks/IIndustrialApiary.java b/src/net/bdew/gendustry/api/blocks/IIndustrialApiary.java new file mode 100644 index 0000000..8dcb48a --- /dev/null +++ b/src/net/bdew/gendustry/api/blocks/IIndustrialApiary.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.blocks; + +import forestry.api.apiculture.IBeeHousing; +import net.bdew.gendustry.api.ApiaryModifiers; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Public interface to Industrial Apiary TileEntity + * Extends forestry IBeeHousing, IBeeModifier, IBeeListener, IHousing so all of those are usable as well + */ +public interface IIndustrialApiary extends IBeeHousing { + /** + * Do not cache, stored copies will not be updated + * + * @return calculated modifiers from all upgrades + */ + public ApiaryModifiers getModifiers(); + + /** + * @return List of upgrade itemstacks + */ + public List getUpgrades(); +} diff --git a/src/net/bdew/gendustry/api/blocks/IWorkerMachine.java b/src/net/bdew/gendustry/api/blocks/IWorkerMachine.java new file mode 100644 index 0000000..a9dc699 --- /dev/null +++ b/src/net/bdew/gendustry/api/blocks/IWorkerMachine.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.blocks; + +public interface IWorkerMachine { + /** + * @return true if a process is ongoing + */ + boolean isWorking(); + + /** + * @return Progress of current operation [0, 1] + */ + float getProgress(); +} diff --git a/src/net/bdew/gendustry/api/items/IApiaryUpgrade.java b/src/net/bdew/gendustry/api/items/IApiaryUpgrade.java new file mode 100644 index 0000000..7832f18 --- /dev/null +++ b/src/net/bdew/gendustry/api/items/IApiaryUpgrade.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.items; + +import net.bdew.gendustry.api.ApiaryModifiers; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Apiary upgrade, this interface is implemented by the Item subclass of the upgrade + * Can be implemented by other mods to add custom upgrades + */ +public interface IApiaryUpgrade { + /** + * @return Human readable name + */ + String getDisplayName(ItemStack stack); + + /** + * @return Human readable description (what would appear on a tooltip below the name) + */ + List getDisplayDetails(ItemStack stack); + + /** + * A unique ID for stacking purposes. If 2 itemstacks return the same ID they will + * be added together when counting upgrades to check maximum number. + * If two stacks return the same stacking ID they should return the same number from + * getMaxNumber or weirdness will ensue. + * + * @return Uniquie stacking id + */ + long getStackingId(ItemStack stack); + + /** + * @return How many times this upgrade can be installed. + */ + int getMaxNumber(ItemStack stack); + + /** + * Applies the effects of an upgrade + */ + void applyModifiers(ApiaryModifiers mods, ItemStack stack); +} diff --git a/src/net/bdew/gendustry/api/items/IGeneSample.java b/src/net/bdew/gendustry/api/items/IGeneSample.java new file mode 100644 index 0000000..9c19490 --- /dev/null +++ b/src/net/bdew/gendustry/api/items/IGeneSample.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.items; + +import forestry.api.genetics.IAllele; +import forestry.api.genetics.ISpeciesRoot; + +/** + * Represents a single genetic sample + * Returned from IItemApi.getSampleInfo and getTemplateSamples + */ +public interface IGeneSample { + + /** + * @return Species root object + */ + public ISpeciesRoot root(); + + /** + * Chromosome number, see {@link forestry.api.apiculture.EnumBeeChromosome}, + * {@link forestry.api.arboriculture.EnumTreeChromosome} and {@link forestry.api.lepidopterology.EnumButterflyChromosome} + */ + public int chromosome(); + + /** + * @return Sampled allele + */ + public IAllele allele(); + + /** + * Human-readable, localized string + */ + public String getLocalizedName(); +} diff --git a/src/net/bdew/gendustry/api/items/IItemAPI.java b/src/net/bdew/gendustry/api/items/IItemAPI.java new file mode 100644 index 0000000..9439b0a --- /dev/null +++ b/src/net/bdew/gendustry/api/items/IItemAPI.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.items; + +import forestry.api.genetics.IGenome; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public interface IItemAPI { + /** + * @return true if stack is a template with atleast 1 sample added + */ + boolean isFullTemplate(ItemStack stack); + + /** + * @return true if stack is a template with no samples added + */ + boolean isEmptyTemplate(ItemStack stack); + + /** + * @return true if stack is a template with all required sample added (usable in replicator) + */ + boolean isCompleteTemplate(ItemStack stack); + + /** + * @return true if stack is a filled sample + */ + boolean isFullSample(ItemStack stack); + + /** + * @return true if stack is an empty sample + */ + boolean isEmptySample(ItemStack stack); + + /** + * @return Contents of a sample + */ + IGeneSample getSampleInfo(ItemStack stack); + + /** + * @return Contents of a template as a list of samples + */ + List getTemplateSamples(ItemStack stack); + + /** + * Contents of a template as a forestry API genome. Any unfilled chromosomes will be taken from default template. + */ + IGenome getTemplateGenome(ItemStack stack); +} diff --git a/src/net/bdew/gendustry/api/items/IItemApi.java b/src/net/bdew/gendustry/api/items/IItemApi.java new file mode 100644 index 0000000..9439b0a --- /dev/null +++ b/src/net/bdew/gendustry/api/items/IItemApi.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.api.items; + +import forestry.api.genetics.IGenome; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public interface IItemAPI { + /** + * @return true if stack is a template with atleast 1 sample added + */ + boolean isFullTemplate(ItemStack stack); + + /** + * @return true if stack is a template with no samples added + */ + boolean isEmptyTemplate(ItemStack stack); + + /** + * @return true if stack is a template with all required sample added (usable in replicator) + */ + boolean isCompleteTemplate(ItemStack stack); + + /** + * @return true if stack is a filled sample + */ + boolean isFullSample(ItemStack stack); + + /** + * @return true if stack is an empty sample + */ + boolean isEmptySample(ItemStack stack); + + /** + * @return Contents of a sample + */ + IGeneSample getSampleInfo(ItemStack stack); + + /** + * @return Contents of a template as a list of samples + */ + List getTemplateSamples(ItemStack stack); + + /** + * Contents of a template as a forestry API genome. Any unfilled chromosomes will be taken from default template. + */ + IGenome getTemplateGenome(ItemStack stack); +} diff --git a/src/net/bdew/gendustry/api/package-info.java b/src/net/bdew/gendustry/api/package-info.java new file mode 100644 index 0000000..9a2c498 --- /dev/null +++ b/src/net/bdew/gendustry/api/package-info.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +@API(apiVersion = "GENDUSTRY_APIVER", owner = "gendustry", provides = "gendustryAPI") // + package net.bdew.gendustry.api; + +import cpw.mods.fml.common.API; \ No newline at end of file diff --git a/src/net/bdew/gendustry/apiimpl/BlockApiImpl.scala b/src/net/bdew/gendustry/apiimpl/BlockApiImpl.scala new file mode 100644 index 0000000..1c0d92e --- /dev/null +++ b/src/net/bdew/gendustry/apiimpl/BlockApiImpl.scala @@ -0,0 +1,37 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.apiimpl + +import net.bdew.gendustry.api.blocks.IBlockAPI +import net.minecraft.world.World +import net.bdew.gendustry.machines.advmutatron.TileMutatronAdv +import net.bdew.gendustry.machines.apiary.TileApiary + +object BlockApiImpl extends IBlockAPI { + override def isWorkerMachine(w: World, x: Int, y: Int, z: Int) = + w.blockHasTileEntity(x, y, z) && w.getBlockTileEntity(x, y, z).isInstanceOf[TileWorker] + + override def getWorkerMachine(w: World, x: Int, y: Int, z: Int) = + if (isWorkerMachine(w, x, y, z)) w.getBlockTileEntity(x, y, z).asInstanceOf[TileWorker] else null + + override def isAdvancedMutatron(w: World, x: Int, y: Int, z: Int) = + w.blockHasTileEntity(x, y, z) && w.getBlockTileEntity(x, y, z).isInstanceOf[TileMutatronAdv] + + override def getAdvancedMutatron(w: World, x: Int, y: Int, z: Int) = + if (isWorkerMachine(w, x, y, z)) w.getBlockTileEntity(x, y, z).asInstanceOf[TileMutatronAdv] else null + + override def isIndustrialApiary(w: World, x: Int, y: Int, z: Int) = + w.blockHasTileEntity(x, y, z) && w.getBlockTileEntity(x, y, z).isInstanceOf[TileApiary] + + override def getIndustrialApiary(w: World, x: Int, y: Int, z: Int) = + if (isWorkerMachine(w, x, y, z)) w.getBlockTileEntity(x, y, z).asInstanceOf[TileApiary] else null +} + + diff --git a/src/net/bdew/gendustry/apiimpl/ItemApiImpl.scala b/src/net/bdew/gendustry/apiimpl/ItemApiImpl.scala new file mode 100644 index 0000000..42c7e5f --- /dev/null +++ b/src/net/bdew/gendustry/apiimpl/ItemApiImpl.scala @@ -0,0 +1,49 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.apiimpl + +import net.minecraft.item.ItemStack +import net.bdew.gendustry.config.Items +import net.bdew.gendustry.api.items.IItemAPI + +object ItemApiImpl extends IItemAPI { + + import scala.collection.JavaConversions._ + + override def isEmptySample(stack: ItemStack) = + stack.getItem == Items.geneSampleBlank + + override def isFullSample(stack: ItemStack) = + stack.getItem == Items.geneSample + + override def isEmptyTemplate(stack: ItemStack) = + stack.getItem == Items.geneTemplate && Items.geneTemplate.getSamples(stack).isEmpty + + override def isFullTemplate(stack: ItemStack) = + stack.getItem == Items.geneTemplate && !Items.geneTemplate.getSamples(stack).isEmpty + + override def isCompleteTemplate(stack: ItemStack) = + stack.getItem == Items.geneTemplate && Items.geneTemplate.isComplete(stack) + + override def getTemplateGenome(stack: ItemStack) = { + val root = Items.geneTemplate.getSpecies(stack) + val samples = Items.geneTemplate.getSamples(stack) + val template = root.getDefaultTemplate + samples.foreach(x => template(x.chromosome) = x.allele) + root.templateAsGenome(template) + } + + override def getTemplateSamples(stack: ItemStack) = + Items.geneTemplate.getSamples(stack).toList + + override def getSampleInfo(stack: ItemStack) = + Items.geneSample.getInfo(stack) + +} diff --git a/src/net/bdew/gendustry/api/IApiaryUpgrade.java b/src/net/bdew/gendustry/apiimpl/TileWorker.scala similarity index 54% rename from src/net/bdew/gendustry/api/IApiaryUpgrade.java rename to src/net/bdew/gendustry/apiimpl/TileWorker.scala index 8744f4c..3be897e 100644 --- a/src/net/bdew/gendustry/api/IApiaryUpgrade.java +++ b/src/net/bdew/gendustry/apiimpl/TileWorker.scala @@ -7,14 +7,11 @@ * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt */ -package net.bdew.gendustry.api; +package net.bdew.gendustry.apiimpl -import net.minecraft.item.ItemStack; +import net.bdew.lib.power.TileBaseProcessor +import net.bdew.gendustry.api.blocks.IWorkerMachine -public interface IApiaryUpgrade { - void applyModifiers(ApiaryModifiers mods, ItemStack stack); - - long getStackingId(ItemStack stack); - - int getMaxNumber(ItemStack stack); +trait TileWorker extends TileBaseProcessor with IWorkerMachine { + override def getProgress = progress } diff --git a/src/net/bdew/gendustry/forestry/GeneSampleInfo.scala b/src/net/bdew/gendustry/forestry/GeneSampleInfo.scala index d4f4658..2535c6c 100644 --- a/src/net/bdew/gendustry/forestry/GeneSampleInfo.scala +++ b/src/net/bdew/gendustry/forestry/GeneSampleInfo.scala @@ -15,15 +15,17 @@ import forestry.api.apiculture.{EnumBeeChromosome, IBeeRoot} import forestry.api.arboriculture.{IAlleleGrowth, IAlleleFruit, EnumTreeChromosome, ITreeRoot} import forestry.api.lepidopterology.{EnumButterflyChromosome, IButterflyRoot} import net.bdew.lib.Misc +import net.bdew.gendustry.api.items.IGeneSample -case class GeneSampleInfo(root: ISpeciesRoot, chromosome: Int, allele: IAllele) { +case class GeneSampleInfo(root: ISpeciesRoot, chromosome: Int, allele: IAllele) extends IGeneSample { def writeToNBT(t: NBTTagCompound) { t.setString("species", root.getUID) t.setInteger("chromosome", chromosome) t.setString("allele", allele.getUID) } - def getText: String = { + @Override + def getLocalizedName: String = { import scala.collection.JavaConverters._ val chr = GeneSampleInfo.getChromosomeName(root, chromosome) val alstr = allele match { diff --git a/src/net/bdew/gendustry/items/GeneSample.scala b/src/net/bdew/gendustry/items/GeneSample.scala index f188ac5..d1d9547 100644 --- a/src/net/bdew/gendustry/items/GeneSample.scala +++ b/src/net/bdew/gendustry/items/GeneSample.scala @@ -39,7 +39,7 @@ class GeneSample(id: Int) extends SimpleItem(id, "GeneSample") { val tip = l.asInstanceOf[util.List[String]].asScala val info = getInfo(stack) tip += Misc.toLocal("gendustry.label.sample." + info.root.getUID) - tip += info.getText + tip += info.getLocalizedName } } } diff --git a/src/net/bdew/gendustry/items/GeneTemplate.scala b/src/net/bdew/gendustry/items/GeneTemplate.scala index d065d49..44df87f 100644 --- a/src/net/bdew/gendustry/items/GeneTemplate.scala +++ b/src/net/bdew/gendustry/items/GeneTemplate.scala @@ -91,7 +91,7 @@ class GeneTemplate(id: Int) extends SimpleItem(id, "GeneTemplate") { try { tip += Misc.toLocal("gendustry.label.template." + tag.getString("species")) val root = getSpecies(stack) - val samples = getSamples(stack).map(x => x.chromosome -> x.getText).toMap + val samples = getSamples(stack).map(x => x.chromosome -> x.getLocalizedName).toMap val required = getRequiredChromosomes(root) tip += diff --git a/src/net/bdew/gendustry/machines/advmutatron/SlotSelector.scala b/src/net/bdew/gendustry/machines/advmutatron/SlotSelector.scala index 8746d72..67b7952 100644 --- a/src/net/bdew/gendustry/machines/advmutatron/SlotSelector.scala +++ b/src/net/bdew/gendustry/machines/advmutatron/SlotSelector.scala @@ -17,7 +17,7 @@ import net.minecraft.item.ItemStack class SlotSelector(inv: TileMutatronAdv, slot: Int, x: Int, y: Int) extends Slot(inv, slot, x, y) with SlotClickable { def onClick(button: Int, mods: Int, player: EntityPlayer): ItemStack = { if (button == 0 && mods == 0 && !inv.worldObj.isRemote && !inv.isWorking && getHasStack) { - inv.selectedMutation := slotNumber + inv.setMutation(getSlotIndex) } return null } diff --git a/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala b/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala index 7f5ceff..04d794f 100644 --- a/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala +++ b/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala @@ -19,8 +19,10 @@ import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.lib.data.base.UpdateKind import net.bdew.gendustry.forestry.GeneticsHelper +import net.bdew.gendustry.api.blocks.IAdvancedMutatron +import net.bdew.gendustry.apiimpl.TileWorker -class TileMutatronAdv extends TileItemProcessor with TilePowered with ExposeTank { +class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered with ExposeTank with IAdvancedMutatron { lazy val cfg = Machines.mutatronAdv val outputSlots = Seq(slots.outIndividual) @@ -59,6 +61,16 @@ class TileMutatronAdv extends TileItemProcessor with TilePowered with ExposeTank } } + override def setMutation(mutation: Int) { + if (!isWorking && slots.selectors.contains(mutation) && inv(mutation) != null) + selectedMutation := mutation + } + + override def getPossibleMutations = { + import scala.collection.JavaConverters._ + (slots.selectors map (x => Integer.valueOf(x) -> inv(x)) filterNot (_._2 != null)).toMap.asJava + } + def canStart = getStackInSlot(slots.inIndividual1) != null && getStackInSlot(slots.inIndividual2) != null && diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index 04c4083..c1f4ee6 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -21,7 +21,7 @@ import forestry.api.arboriculture.EnumGermlingType import net.bdew.lib.tile.TileExtended import net.bdew.gendustry.config.{Config, Machines} import net.bdew.lib.items.ItemUtils -import net.bdew.gendustry.api.{ApiaryModifiers, IApiaryUpgrade} +import net.bdew.gendustry.api.ApiaryModifiers import net.minecraft.world.biome.BiomeGenBase import net.bdew.lib.data.base.{UpdateKind, TileDataSlots} import net.bdew.lib.data.DataSlotFloat @@ -32,6 +32,8 @@ import net.bdew.gendustry.power.TilePowered import net.bdew.lib.power.DataSlotPower import net.bdew.gendustry.compat.triggers.ForestryErrorSource import net.bdew.gendustry.gui.rscontrol.TileRSContollable +import net.bdew.gendustry.api.items.IApiaryUpgrade +import net.bdew.gendustry.api.blocks.IIndustrialApiary class TileApiary extends TileExtended with TileDataSlots @@ -41,7 +43,7 @@ with BreakableInventoryTile with TilePowered with ForestryErrorSource with TileRSContollable -with IBeeHousing { +with IIndustrialApiary { object slots { val queen = 0 @@ -186,6 +188,14 @@ with IBeeHousing { override def canInsertItem(slot: Int, stack: ItemStack, side: Int) = slots.bees.contains(slot) && isItemValidForSlot(slot, stack) override def canExtractItem(slot: Int, stack: ItemStack, side: Int) = slots.output.contains(slot) + //IIndustrialApiary + override def getUpgrades = { + import scala.collection.JavaConversions._ + slots.upgrades map inv filterNot (_ == null) + } + + override def getModifiers = mods + // IBeeListener def onPostQueenDeath(queen: IBee) { if (mods.isAutomated) movePrincess = true @@ -246,4 +256,5 @@ with IBeeHousing { p = ItemUtils.addStackToSlots(p, this, slots.output, false) return p == null } + } diff --git a/src/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala b/src/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala index a707754..f3f5372 100644 --- a/src/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala +++ b/src/net/bdew/gendustry/machines/apiary/upgrades/ItemApiaryUpgrade.scala @@ -10,7 +10,7 @@ package net.bdew.gendustry.machines.apiary.upgrades import net.minecraft.item.{ItemStack, Item} -import net.bdew.gendustry.api.{ApiaryModifiers, IApiaryUpgrade} +import net.bdew.gendustry.api.ApiaryModifiers import net.minecraft.client.renderer.texture.IconRegister import net.bdew.gendustry.Gendustry import net.minecraft.util.Icon @@ -20,6 +20,7 @@ import java.util import net.minecraft.entity.player.EntityPlayer import net.bdew.lib.Misc import cpw.mods.fml.common.registry.GameRegistry +import net.bdew.gendustry.api.items.IApiaryUpgrade class ItemApiaryUpgrade(id: Int) extends Item(id) with IApiaryUpgrade { val icons = collection.mutable.Map.empty[Int, Icon] @@ -33,50 +34,57 @@ class ItemApiaryUpgrade(id: Int) extends Item(id) with IApiaryUpgrade { def formatModifier(f: Float, base: Float) = (if (f > base) "+" else "") + "%.0f".format((f - base) * 100) + "%" - override def addInformation(stack: ItemStack, player: EntityPlayer, list: util.List[_], par4: Boolean) { - if (!Upgrades.map.contains(stack.getItemDamage)) return + override def getDisplayName(stack: ItemStack) = Misc.toLocal(getUnlocalizedName(stack)) + + override def getDisplayDetails(stack: ItemStack): util.ArrayList[String] = { + val list = new util.ArrayList[String]() + if (!Upgrades.map.contains(stack.getItemDamage)) return list val upgrade = Upgrades.map(stack.getItemDamage) - val l = list.asInstanceOf[util.List[String]] val mods = new ApiaryModifiers upgrade.mod(mods, 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.maxinstall") + " " + upgrade.maxNum.toString) + list.add(Misc.toLocal(Gendustry.modId + ".label.maxinstall") + " " + upgrade.maxNum.toString) if (mods.isAutomated) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.automated")) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.automated")) if (mods.biomeOverride != null) - l.add(Misc.toLocalF(Gendustry.modId + ".label.mod.biome", mods.biomeOverride.biomeName)) + list.add(Misc.toLocalF(Gendustry.modId + ".label.mod.biome", mods.biomeOverride.biomeName)) if (mods.isSealed) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.sealed")) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.sealed")) if (mods.isSelfLighted) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.selflighted")) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.selflighted")) if (mods.isSunlightSimulated) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.sky")) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.sky")) if (mods.isCollectingPollen) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.sieve")) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.sieve")) if (mods.lifespan != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.lifespan") + " " + formatModifier(mods.lifespan, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.lifespan") + " " + formatModifier(mods.lifespan, 1)) if (mods.flowering != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.flowering") + " " + formatModifier(mods.flowering, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.flowering") + " " + formatModifier(mods.flowering, 1)) if (mods.geneticDecay != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.geneticDecay") + " " + formatModifier(mods.geneticDecay, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.geneticDecay") + " " + formatModifier(mods.geneticDecay, 1)) if (mods.mutation != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.mutation") + " " + formatModifier(mods.mutation, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.mutation") + " " + formatModifier(mods.mutation, 1)) if (mods.production != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.production") + " " + formatModifier(mods.production, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.production") + " " + formatModifier(mods.production, 1)) if (mods.territory != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.territory") + " " + formatModifier(mods.territory, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.territory") + " " + formatModifier(mods.territory, 1)) if (mods.humidity != 0) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.humidity") + " " + formatModifier(mods.humidity, 0)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.humidity") + " " + formatModifier(mods.humidity, 0)) if (mods.temperature != 0) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.temperature") + " " + formatModifier(mods.temperature, 0)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.temperature") + " " + formatModifier(mods.temperature, 0)) if (mods.energy != 1) - l.add(Misc.toLocal(Gendustry.modId + ".label.mod.energy") + " " + formatModifier(mods.energy, 1)) + list.add(Misc.toLocal(Gendustry.modId + ".label.mod.energy") + " " + formatModifier(mods.energy, 1)) + return list + } + + override def addInformation(stack: ItemStack, player: EntityPlayer, list: util.List[_], par4: Boolean) { + list.asInstanceOf[util.List[String]].addAll(getDisplayDetails(stack)) } def getStackingId(stack: ItemStack) = itemID * Int.MaxValue + stack.getItemDamage diff --git a/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala b/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala index c7f338f..6997059 100644 --- a/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala +++ b/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala @@ -20,8 +20,9 @@ import net.bdew.lib.tile.ExposeTank import net.bdew.lib.data.base.UpdateKind import net.bdew.lib.power.TileBaseProcessor import net.bdew.gendustry.power.TilePowered +import net.bdew.gendustry.apiimpl.TileWorker -class TileExtractor extends TileBaseProcessor with TilePowered with ExposeTank { +class TileExtractor extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank { lazy val cfg = Machines.extractor object slots { diff --git a/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala b/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala index affbef1..ed86aaa 100644 --- a/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala +++ b/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala @@ -17,8 +17,9 @@ import forestry.api.apiculture.{EnumBeeType, IBeeRoot, IBee} import scala.util.Random import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered +import net.bdew.gendustry.apiimpl.TileWorker -class TileImprinter extends TileItemProcessor with TilePowered { +class TileImprinter extends TileItemProcessor with TileWorker with TilePowered { lazy val cfg = Machines.imprinter val outputSlots = Seq(slots.outIndividual) diff --git a/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala b/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala index 23ba4a7..3a671a9 100644 --- a/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala +++ b/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala @@ -20,8 +20,9 @@ import net.bdew.lib.tile.ExposeTank import net.bdew.lib.data.base.UpdateKind import net.bdew.lib.power.TileBaseProcessor import net.bdew.gendustry.power.TilePowered +import net.bdew.gendustry.apiimpl.TileWorker -class TileLiquifier extends TileBaseProcessor with TilePowered with ExposeTank { +class TileLiquifier extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank { lazy val cfg = Machines.liquifier val tank = DataSlotTankRestricted("tank", this, cfg.tankSize, Fluids.protein.getID).setUpdate(UpdateKind.GUI, UpdateKind.SAVE) diff --git a/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala b/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala index ad9ae8d..d093580 100644 --- a/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala +++ b/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala @@ -20,8 +20,9 @@ import net.bdew.lib.tile.ExposeTank import net.bdew.lib.data.base.UpdateKind import net.bdew.lib.power.TileBaseProcessor import net.bdew.gendustry.power.TilePowered +import net.bdew.gendustry.apiimpl.TileWorker -class TileMutagenProducer extends TileBaseProcessor with TilePowered with ExposeTank { +class TileMutagenProducer extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank { lazy val cfg = Machines.mutagenProducer val tank = DataSlotTankRestricted("tank", this, cfg.tankSize, Fluids.mutagen.getID).setUpdate(UpdateKind.GUI, UpdateKind.SAVE) diff --git a/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala b/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala index be656d8..e101799 100644 --- a/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala +++ b/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala @@ -19,8 +19,9 @@ import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.lib.data.base.UpdateKind import net.bdew.gendustry.forestry.GeneticsHelper +import net.bdew.gendustry.apiimpl.TileWorker -class TileMutatron extends TileItemProcessor with TilePowered with ExposeTank { +class TileMutatron extends TileItemProcessor with TileWorker with TilePowered with ExposeTank { lazy val cfg = Machines.mutatron val outputSlots = Seq(slots.outIndividual) diff --git a/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala b/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala index 6318b5a..6b249bb 100644 --- a/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala +++ b/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala @@ -17,8 +17,9 @@ import net.bdew.lib.data.DataSlotTankRestricted import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.forestry.GeneticsHelper +import net.bdew.gendustry.apiimpl.TileWorker -class TileReplicator extends TileItemProcessor with TilePowered with IFluidHandler { +class TileReplicator extends TileItemProcessor with TileWorker with TilePowered with IFluidHandler { lazy val cfg = Machines.replicator val outputSlots = Seq(slots.outIndividual) diff --git a/src/net/bdew/gendustry/machines/sampler/TileSampler.scala b/src/net/bdew/gendustry/machines/sampler/TileSampler.scala index 5f65c99..7bc409b 100644 --- a/src/net/bdew/gendustry/machines/sampler/TileSampler.scala +++ b/src/net/bdew/gendustry/machines/sampler/TileSampler.scala @@ -17,8 +17,9 @@ import net.bdew.gendustry.forestry.GeneSampleInfo import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.compat.ExtraBeesProxy +import net.bdew.gendustry.apiimpl.TileWorker -class TileSampler extends TileItemProcessor with TilePowered { +class TileSampler extends TileItemProcessor with TileWorker with TilePowered { lazy val cfg = Machines.sampler val outputSlots = Seq(slots.outSample) diff --git a/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala b/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala index 82ee4e3..01b5d9b 100644 --- a/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala +++ b/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala @@ -14,8 +14,9 @@ import net.minecraft.item.ItemStack import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.lib.items.IStack +import net.bdew.gendustry.apiimpl.TileWorker -class TileTransposer extends TileItemProcessor with TilePowered { +class TileTransposer extends TileItemProcessor with TileWorker with TilePowered { lazy val cfg = Machines.transposer val outputSlots = Seq(slots.outCopy) From eadfd0e26dcd8e57b4791f7d359259f04217f7f5 Mon Sep 17 00:00:00 2001 From: bdew Date: Mon, 19 May 2014 10:14:19 +0300 Subject: [PATCH 3/8] wtf case problems --- .../bdew/gendustry/api/items/IItemApi.java | 57 ------------------- 1 file changed, 57 deletions(-) delete mode 100644 src/net/bdew/gendustry/api/items/IItemApi.java diff --git a/src/net/bdew/gendustry/api/items/IItemApi.java b/src/net/bdew/gendustry/api/items/IItemApi.java deleted file mode 100644 index 9439b0a..0000000 --- a/src/net/bdew/gendustry/api/items/IItemApi.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) bdew, 2013 - 2014 - * https://github.com/bdew/gendustry - * - * This mod is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt - */ - -package net.bdew.gendustry.api.items; - -import forestry.api.genetics.IGenome; -import net.minecraft.item.ItemStack; - -import java.util.List; - -public interface IItemAPI { - /** - * @return true if stack is a template with atleast 1 sample added - */ - boolean isFullTemplate(ItemStack stack); - - /** - * @return true if stack is a template with no samples added - */ - boolean isEmptyTemplate(ItemStack stack); - - /** - * @return true if stack is a template with all required sample added (usable in replicator) - */ - boolean isCompleteTemplate(ItemStack stack); - - /** - * @return true if stack is a filled sample - */ - boolean isFullSample(ItemStack stack); - - /** - * @return true if stack is an empty sample - */ - boolean isEmptySample(ItemStack stack); - - /** - * @return Contents of a sample - */ - IGeneSample getSampleInfo(ItemStack stack); - - /** - * @return Contents of a template as a list of samples - */ - List getTemplateSamples(ItemStack stack); - - /** - * Contents of a template as a forestry API genome. Any unfilled chromosomes will be taken from default template. - */ - IGenome getTemplateGenome(ItemStack stack); -} From c8a32236c00a24e601e07a84190928074a7c25b1 Mon Sep 17 00:00:00 2001 From: bdew Date: Tue, 27 May 2014 12:15:13 +0300 Subject: [PATCH 4/8] Added sanity check for buggy mutations when placing an apiary --- .../gendustry/machines/apiary/Sanity.scala | 42 +++++++++++++++++++ .../machines/apiary/TileApiary.scala | 5 +++ 2 files changed, 47 insertions(+) create mode 100644 src/net/bdew/gendustry/machines/apiary/Sanity.scala diff --git a/src/net/bdew/gendustry/machines/apiary/Sanity.scala b/src/net/bdew/gendustry/machines/apiary/Sanity.scala new file mode 100644 index 0000000..ea44fa9 --- /dev/null +++ b/src/net/bdew/gendustry/machines/apiary/Sanity.scala @@ -0,0 +1,42 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.machines.apiary + +import _root_.forestry.api.apiculture.IBeeRoot +import _root_.forestry.api.genetics.AlleleManager +import net.bdew.gendustry.Gendustry +import net.minecraft.util.EnumChatFormatting + +object Sanity { + def check(house: TileApiary) { + import scala.collection.JavaConversions._ + try { + val bees = AlleleManager.alleleRegistry.getSpeciesRoot("rootBees").asInstanceOf[IBeeRoot] + val defGenome = bees.templateAsGenome(bees.getDefaultTemplate) + val defSpecies = defGenome.getPrimary + var found = false + for (mutation <- bees.getMutations(false)) { + if (mutation.getChance(house, defSpecies, defSpecies, defGenome, defGenome) > 0) { + found = true + Gendustry.logWarn("Detected probably bugged mutation! %s+%s (class: %s) doesn't check the species. Please report it to the mod author.", + mutation.getAllele0.getName, mutation.getAllele1.getName, mutation.getClass.getCanonicalName) + } + } + if (found) { + val player = house.worldObj.getClosestPlayer(house.xCoord, house.yCoord, house.zCoord, 20) + if (player != null) { + player.addChatMessage(EnumChatFormatting.RED + "[Gendustry] WARNING! Possibly bugged mutations detected, check the log for details.") + } + } + } catch { + case t: Throwable => t.printStackTrace() + } + } +} diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index c1f4ee6..5975501 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -257,4 +257,9 @@ with IIndustrialApiary { return p == null } + override def validate() { + super.validate() + if (worldObj!=null && !worldObj.isRemote) + Sanity.check(this) + } } From f237e8793943ff5209aa3a7eeaa05a53b8dd41cc Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 1 Jun 2014 15:09:55 +0300 Subject: [PATCH 5/8] Initial implementation of covers --- build.gradle | 2 +- resources/assets/gendustry/lang/en_US.lang | 2 + .../textures/blocks/covers/covers.psd | Bin 0 -> 43546 bytes .../textures/blocks/covers/eject.png | Bin 0 -> 1333 bytes .../textures/blocks/covers/import.png | Bin 0 -> 1325 bytes src/net/bdew/gendustry/config/Items.scala | 5 +- src/net/bdew/gendustry/items/EjectCover.scala | 46 +++++++++++++++++ .../bdew/gendustry/items/ImportCover.scala | 47 ++++++++++++++++++ .../machines/apiary/BlockApiary.scala | 7 ++- .../machines/apiary/TileApiary.scala | 6 ++- .../gendustry/waila/BaseDataProvider.scala | 2 - 11 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 resources/assets/gendustry/textures/blocks/covers/covers.psd create mode 100644 resources/assets/gendustry/textures/blocks/covers/eject.png create mode 100644 resources/assets/gendustry/textures/blocks/covers/import.png create mode 100644 src/net/bdew/gendustry/items/EjectCover.scala create mode 100644 src/net/bdew/gendustry/items/ImportCover.scala diff --git a/build.gradle b/build.gradle index 125e925..e76714c 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'forge' apply plugin: 'scala' version = "1.1.3" -ext.bdlibver = "1.2.2.45" +ext.bdlibver = "1.2.3.47" ext.versuffix = "mc164" ext.apiVer = version diff --git a/resources/assets/gendustry/lang/en_US.lang b/resources/assets/gendustry/lang/en_US.lang index d4d4100..7357d2b 100644 --- a/resources/assets/gendustry/lang/en_US.lang +++ b/resources/assets/gendustry/lang/en_US.lang @@ -27,6 +27,8 @@ item.gendustry.GeneSampleBlank.name=Blank Gene Sample item.gendustry.Waste.name=Genetic Waste item.gendustry.grafter.name=Industrial Grafter item.gendustry.scoop.name=Scooporator MX200 Turbo +item.gendustry.ImportCover.name=Item Import Cover +item.gendustry.EjectCover.name=Item Eject Cover # ==== FLUIDS ==== diff --git a/resources/assets/gendustry/textures/blocks/covers/covers.psd b/resources/assets/gendustry/textures/blocks/covers/covers.psd new file mode 100644 index 0000000000000000000000000000000000000000..237567aedec8fbbce7a82fa1052eb2402e54fed9 GIT binary patch literal 43546 zcmeHw30xFM_J0pIh~k09BqkY8JhhE5CVciAflis2qeZ|FUR76r ztEsVd^YOz-7;$LAjf|gq7z)E7*kbGE<*lWKM|9_DV3@|cJ{X?17*CsCm5_GE&rPzh z1jw>-?F!!(+mLQ024`GySv4D(c5r;c2 za76@iptld%T_9wW>E={(su|PLnnt#wnbWMO)>OJFnQCciYhh_)L9;ZY*xFO5_7q#P z>{#Gr0HKvaR6)6r`%XkrriufXPyp`rm0nZ|a z5n(|wx3o}jhJq_WEB5X}HbX2B`U?bHC!*~>p#rf$6e@@yyZc#@H*xqZL9}S4g?i@k z+Q<2@Js4uP6V;MJGow(H%*KOm?M8ET_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xm%L$SmXxPJ8{dpxwroXwik~S3KTLP!rM@*oN+(nB4^vtPb$m#3iqRq^gFPzUM(8l1!%S6`Y7mM&dP zo*z%3jRK*$CC%zkroWuNBSW-g@uEdxX)?6&&_NoNvL{JF-<2J0vSiu590l4~l3{5c z9qlJ?A0sDfiAhX}654n)$?Wy$=%7%>j-3FWAIcUk3QJKz8xLlrD5H&0qLjzb#wfw- zsmaNysj2Zo(UZ_d0W=ei70Z_`iB?7%ML5_CriCqDVzMH&455wLsb;v4cHb%z_ U!XvrrXd{ogbu09*KaDp2KTMTSZU6uP literal 0 HcmV?d00001 diff --git a/resources/assets/gendustry/textures/blocks/covers/eject.png b/resources/assets/gendustry/textures/blocks/covers/eject.png new file mode 100644 index 0000000000000000000000000000000000000000..a2d180cc7c79f7188d922996fde94ba91ea7e37c GIT binary patch literal 1333 zcmV-51e*LWZK23wxEMSIx)4K ze9EkXyPDvy82lb#hiPx|wauvX85dX4b!+!=-#=Oe(yaZf{gCnSo)z zpK`;onuTRJ&9;@kopHLRip8UKrHNzEx|*?`U^dROi_^cN+{moHq=3q>i^QUHxul1# zmw3#xk-wT}(7T<|y`RFTfWN4S$gPKrYCD{UXwA2nn1ElenR>~ymTOThM>{NZSTQg# zG1hf4sQ>^2OG!jQRCwBiQ)^q=NEn?+k|7Xc1PLiALz@o6~ex*8$$U zNXoL@K`^%|%XnifuO~0$4z8b$o3g5dW>Ux(Rx`K5$dD3fUKkE5gdkKZrO3?0XR4_K z^&-Drtslq3VOp_a`Au+x;3Y*7^TBL3xZBggsrsqj_@!P5(>8{E2r$f6fgp3xjHA=+ zqT2%6cmgEw`bW`%*wu<-Fzi-FIk%N~6`d}+4WQ{$K~PWM_c;}|T<7zcYa&)@v9uur&iz)jMMB8eu3O&W&xo-rKmZy!|5 z90qAO;Q_2RDP2Ne`5~GDpc>s=dXEh-+iY8x;Z_1P@UUdrm!rutglCdKw5O*r2tT~N zCl#8S&=NpXDc(Ape`jo){^jM_+2YaB(OUb#39OL_Fqc3i!_s;Ajxkd7m&cbm!oC?s zV8P~xrwO2UD$@KN!x%Af_VJ&mc`U-3~%Du*GD`=+n|3iu+%9L`}vC90=_ zu}cM6mNmGgLGdSmNEr^pehpUEWiVDF0KMn9_qpX)z%pND(EZnA={FfPT2s3R4##mz z=1&fNrHVdfLnD42M`lIn`xOL;cK;)3r4XxVS@iPY0pQgN=cI($SDD2&0^D6;d_+G1 zS}Q^*upBVn2$|yV#r~iDe*fOuVMBhBlx{sYajJ{fzBcI>=yNQ0W?Pm;N}04@5k-@J za+9!fIcQr_CK#(lqqSNswo?*B2qn?#zPNebHYKUMiqv|86n^AMpN|y9%9ES7hw*s4 zA_#>o<~b4UUkk|D{hJ@V&u)I+0U&+Y<@p~64CCFu`#!+n{zEObIODmAucG|c7IHoe zjzZqjqZmrW+1nb*`XX{ul{ZoeeDgbmSdR2;yZd$Evq^J4mcUa56{%Q1yslTT{WQT} zn&kX(Fe8zQB#HiXHk&Rr#{f@O@`X<&Dl!!b6QW2ABNQSm+)`6BGpKqhz?-PN9T``3 r74OLxsJxx$^0r>e`+xQSSAYQkEB4|c7+4=700000NkvXXu0mjfj&zQF literal 0 HcmV?d00001 diff --git a/resources/assets/gendustry/textures/blocks/covers/import.png b/resources/assets/gendustry/textures/blocks/covers/import.png new file mode 100644 index 0000000000000000000000000000000000000000..c19acc87ca7190242a02121c9a9417d978d4784c GIT binary patch literal 1325 zcmV+|1=9M7P)mxt(>l zkzB;Ai*;Eu$*O+Wz@gN{NZSTQg# zG2l7Q>Hq)(LrFwIRCwBiQ|n*aRv12{ph*sw2nRDFttbYGNw_331?4g+rP!`$Ny0%8 z6~t<7wcXZrj+p)HJ3;L}?)`Y)=l46$`&uVqoFeoY#iBR*F$~R(ke$8nDO%LDcn|fuq2moUU#!lyr;m$0(}oFt>FNHqO^uX*#q-S1RbmW8TW zU?JngT!7^bp+01xcbvJ5P;V;h>$kUl%k)}(t{VeQnnUsVt3Ejqj!`wS`};ZzAzSdK zUhjiBEe13N2)oAhl^HTK8ym~Z)4RK8aqk$GcBmkjTZs{p9BLWVmlR^&-#^YB3vUSF zsL(!&0lim5If|mLQ{wXdKeM@?!qTE)7&*i#dqv0Z34;BA2+hB>`Irb9IVn7&zE?0&MumpOL>V5&BaC&F;b|={oru? zJxv6U)Kp=MCT4}1sJo93{v&B+(uCDV(anPkXaxe%62i+*XHLCnKTQQzg|L1Cv~F1b z$yh9n`IaTUH3kGWyP!O=jk%Y!wR7 zvdCkoMD$xMnGD7vgh;dok8X~=CPD)&XFd@9s8<;hhY-t#M6oz?bF|0v{0oe^YI>$m z#1k(NXG>pSA3nI*4ra5yy@9Zorl^NVM*V*H>wIfxZOL_$eo0c@dR|~Z&+-^?Rs9Ud zKew8v`8DFEA{_=}^xJO`emlrDYS~(D_3wjt$V}y8bnrqUS8VN_=Nso&j4brc(ComF zijY|Lc|5*q#|Cur#pL2$6@(YUoGglRI}C~#;}KX`S|Zg`0No+w?MbwvEA&u0BjxQq jl(+j>-v6urzXA*ZaLwW250J!d00000NkvXXu0mjfW-W{8 literal 0 HcmV?d00001 diff --git a/src/net/bdew/gendustry/config/Items.scala b/src/net/bdew/gendustry/config/Items.scala index a37ace0..4979a45 100644 --- a/src/net/bdew/gendustry/config/Items.scala +++ b/src/net/bdew/gendustry/config/Items.scala @@ -10,7 +10,7 @@ package net.bdew.gendustry.config import cpw.mods.fml.common.registry.GameRegistry -import net.bdew.gendustry.items.{IndustrialScoop, IndustrialGrafter, GeneTemplate, GeneSample} +import net.bdew.gendustry.items._ import net.bdew.gendustry.machines.apiary.upgrades.ItemApiaryUpgrade import net.bdew.lib.config.ItemManager import net.bdew.gendustry.Gendustry @@ -43,5 +43,8 @@ object Items extends ItemManager(Config.IDs) { regSimpleItem("UpgradeFrame") regSimpleItem("ClimateModule") + val coverEject = regItem(new EjectCover(ids.getItemId("EjectCover"))) + val coverImport = regItem(new ImportCover(ids.getItemId("ImportCover"))) + Gendustry.logInfo("Items loaded") } \ No newline at end of file diff --git a/src/net/bdew/gendustry/items/EjectCover.scala b/src/net/bdew/gendustry/items/EjectCover.scala new file mode 100644 index 0000000..7413005 --- /dev/null +++ b/src/net/bdew/gendustry/items/EjectCover.scala @@ -0,0 +1,46 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.items + +import net.bdew.lib.items.{ItemUtils, SimpleItem} +import net.bdew.lib.covers.{TileCoverable, ItemCover} +import net.minecraftforge.common.ForgeDirection +import net.minecraft.inventory.{IInventory, ISidedInventory} +import net.minecraft.client.renderer.texture.IconRegister +import cpw.mods.fml.relauncher.{Side, SideOnly} +import net.bdew.gendustry.Gendustry +import net.bdew.lib.Misc + +class EjectCover(id: Int) extends SimpleItem(id, "EjectCover") with ItemCover { + override def getCoverIcon = itemIcon + override def getSpriteNumber = 0 + + override def isValidTile(te: TileCoverable) = te.isInstanceOf[ISidedInventory with IInventory] + + override def tickCover(te: TileCoverable, side: ForgeDirection): Unit = { + if (te.worldObj.getTotalWorldTime % 20 != 0) return + val inv = te.asInstanceOf[ISidedInventory with IInventory] + for { + target <- Misc.getNeighbourTile(te, side, classOf[IInventory]) + slot <- inv.getAccessibleSlotsFromSide(side.ordinal()) + stack <- Option(inv.getStackInSlot(slot)) + if inv.canExtractItem(slot, stack, side.ordinal()) + } { + val slots = ItemUtils.getAccessibleSlotsFromSide(target, side.getOpposite) + inv.setInventorySlotContents(slot, ItemUtils.addStackToSlots(stack, target, slots, true)) + inv.onInventoryChanged() + } + } + + @SideOnly(Side.CLIENT) + override def registerIcons(reg: IconRegister) { + itemIcon = reg.registerIcon(Gendustry.modId + ":covers/eject") + } +} diff --git a/src/net/bdew/gendustry/items/ImportCover.scala b/src/net/bdew/gendustry/items/ImportCover.scala new file mode 100644 index 0000000..1423c8a --- /dev/null +++ b/src/net/bdew/gendustry/items/ImportCover.scala @@ -0,0 +1,47 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.items + +import net.bdew.lib.items.{ItemUtils, SimpleItem} +import net.bdew.lib.covers.{TileCoverable, ItemCover} +import net.minecraftforge.common.ForgeDirection +import net.minecraft.inventory.{IInventory, ISidedInventory} +import net.minecraft.client.renderer.texture.IconRegister +import cpw.mods.fml.relauncher.{Side, SideOnly} +import net.bdew.gendustry.Gendustry +import net.bdew.lib.Misc + +class ImportCover(id: Int) extends SimpleItem(id, "ImportCover") with ItemCover { + override def getCoverIcon = itemIcon + override def getSpriteNumber = 0 + + override def isValidTile(te: TileCoverable) = te.isInstanceOf[ISidedInventory] + + override def tickCover(te: TileCoverable, side: ForgeDirection): Unit = { + if (te.worldObj.getTotalWorldTime % 20 != 0) return + val inv = te.asInstanceOf[ISidedInventory with IInventory] + val insertSlots = inv.getAccessibleSlotsFromSide(side.ordinal()) + for { + from <- Misc.getNeighbourTile(te, side, classOf[IInventory]) + slot <- ItemUtils.getAccessibleSlotsFromSide(from, side.getOpposite) + stack <- Option(from.getStackInSlot(slot)) + if (Misc.asInstanceOpt(from, classOf[ISidedInventory]) map (_.canExtractItem(slot, stack, side.getOpposite.ordinal())) + getOrElse true) + } { + from.setInventorySlotContents(slot, ItemUtils.addStackToSlots(stack, inv, insertSlots, true)) + from.onInventoryChanged() + } + } + + @SideOnly(Side.CLIENT) + override def registerIcons(reg: IconRegister) { + itemIcon = reg.registerIcon(Gendustry.modId + ":covers/import") + } +} diff --git a/src/net/bdew/gendustry/machines/apiary/BlockApiary.scala b/src/net/bdew/gendustry/machines/apiary/BlockApiary.scala index 08f2fb7..81f292d 100644 --- a/src/net/bdew/gendustry/machines/apiary/BlockApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/BlockApiary.scala @@ -24,8 +24,13 @@ import net.bdew.gendustry.config.Machines import net.minecraft.entity.EntityLivingBase import net.minecraft.item.ItemStack import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockApiary(id: Int) extends Block(id, Material.rock) with HasTE[TileApiary] with BlockGuiWrenchable with BreakableInventoryBlock { +class BlockApiary(id: Int) extends Block(id, Material.rock) +with HasTE[TileApiary] +with BlockGuiWrenchable +with BlockCoverable[TileApiary] +with BreakableInventoryBlock { private var icons: Array[Icon] = null val TEClass = classOf[TileApiary] lazy val guiId: Int = Machines.apiary.guiId diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index 5975501..d7df7b7 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -34,6 +34,7 @@ import net.bdew.gendustry.compat.triggers.ForestryErrorSource import net.bdew.gendustry.gui.rscontrol.TileRSContollable import net.bdew.gendustry.api.items.IApiaryUpgrade import net.bdew.gendustry.api.blocks.IIndustrialApiary +import net.bdew.lib.covers.{ItemCover, TileCoverable} class TileApiary extends TileExtended with TileDataSlots @@ -43,6 +44,7 @@ with BreakableInventoryTile with TilePowered with ForestryErrorSource with TileRSContollable +with TileCoverable with IIndustrialApiary { object slots { @@ -259,7 +261,9 @@ with IIndustrialApiary { override def validate() { super.validate() - if (worldObj!=null && !worldObj.isRemote) + if (worldObj != null && !worldObj.isRemote) Sanity.check(this) } + + override def isValidCover(side: ForgeDirection, cover: ItemCover) = true } diff --git a/src/net/bdew/gendustry/waila/BaseDataProvider.scala b/src/net/bdew/gendustry/waila/BaseDataProvider.scala index f6dc922..518955d 100644 --- a/src/net/bdew/gendustry/waila/BaseDataProvider.scala +++ b/src/net/bdew/gendustry/waila/BaseDataProvider.scala @@ -20,8 +20,6 @@ class BaseDataProvider[T](cls: Class[T]) extends IWailaDataProvider { def getHeadStrings(target: T, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = None def getBodyStrings(target: T, stack: ItemStack, acc: IWailaDataAccessor, cfg: IWailaConfigHandler): Iterable[String] = None - println("BDP: %s < %s".format(this, cls)) - import scala.collection.JavaConversions._ final override def getWailaTail(itemStack: ItemStack, currenttip: util.List[String], accessor: IWailaDataAccessor, config: IWailaConfigHandler) = { From 52edfcaad094a7b7be9b6a784404fe13e61be4ac Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 1 Jun 2014 16:00:54 +0300 Subject: [PATCH 6/8] Added item export into BC pipes and TE conduits --- src/net/bdew/gendustry/Gendustry.scala | 3 ++ .../compat/itempush/BCPipePushProxy.scala | 29 +++++++++++++++ .../itempush/CofhConduitPushProxy.scala | 23 ++++++++++++ .../gendustry/compat/itempush/ItemPush.scala | 37 +++++++++++++++++++ .../compat/itempush/ItemPushProxy.scala | 18 +++++++++ .../compat/itempush/VanillaPush.scala | 25 +++++++++++++ src/net/bdew/gendustry/items/EjectCover.scala | 14 ++++--- 7 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 src/net/bdew/gendustry/compat/itempush/BCPipePushProxy.scala create mode 100644 src/net/bdew/gendustry/compat/itempush/CofhConduitPushProxy.scala create mode 100644 src/net/bdew/gendustry/compat/itempush/ItemPush.scala create mode 100644 src/net/bdew/gendustry/compat/itempush/ItemPushProxy.scala create mode 100644 src/net/bdew/gendustry/compat/itempush/VanillaPush.scala diff --git a/src/net/bdew/gendustry/Gendustry.scala b/src/net/bdew/gendustry/Gendustry.scala index a278f3e..7102097 100644 --- a/src/net/bdew/gendustry/Gendustry.scala +++ b/src/net/bdew/gendustry/Gendustry.scala @@ -27,6 +27,7 @@ import net.bdew.gendustry.custom.CustomContent import net.bdew.gendustry.config.loader.TuningLoader import net.bdew.gendustry.api.GendustryAPI import net.bdew.gendustry.apiimpl.{BlockApiImpl, ItemApiImpl} +import net.bdew.gendustry.compat.itempush.ItemPush @Mod(modid = Gendustry.modId, version = "GENDUSTRY_VER", name = "Gendustry", dependencies = "required-after:Forestry@[2.3.1.0,);after:BuildCraft|energy;after:BuildCraft|Silicon;after:IC2;after:CoFHCore;after:BinnieCore;after:ExtraBees;after:ExtraTrees;after:MineFactoryReloaded;required-after:bdlib@[BDLIB_VER,)", modLanguage = "scala") @NetworkMod(clientSideRequired = true, serverSideRequired = false) @@ -51,6 +52,8 @@ object Gendustry { GendustryAPI.Blocks = BlockApiImpl PowerProxy.logModVersions() + ItemPush.init() + configDir = new File(event.getModConfigurationDirectory, "gendustry") configFile = event.getSuggestedConfigurationFile TuningLoader.loadConfigFiles() diff --git a/src/net/bdew/gendustry/compat/itempush/BCPipePushProxy.scala b/src/net/bdew/gendustry/compat/itempush/BCPipePushProxy.scala new file mode 100644 index 0000000..a778a9a --- /dev/null +++ b/src/net/bdew/gendustry/compat/itempush/BCPipePushProxy.scala @@ -0,0 +1,29 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.compat.itempush + +import net.minecraft.tileentity.TileEntity +import net.minecraftforge.common.ForgeDirection +import net.minecraft.item.ItemStack +import buildcraft.api.transport.IPipeTile +import net.bdew.lib.Misc + +object BCPipePushProxy extends ItemPushProxy { + override def pushStack(from: TileEntity, dir: ForgeDirection, stack: ItemStack) = + (for (pipe <- Misc.getNeighbourTile(from, dir, classOf[IPipeTile])) yield { + if (pipe.getPipeType == IPipeTile.PipeType.ITEM) { + val used = pipe.injectItem(stack, true, dir.getOpposite) + if (used >= stack.stackSize) + null + else + stack.splitStack(stack.stackSize - used) + } else stack + }).getOrElse(stack) +} diff --git a/src/net/bdew/gendustry/compat/itempush/CofhConduitPushProxy.scala b/src/net/bdew/gendustry/compat/itempush/CofhConduitPushProxy.scala new file mode 100644 index 0000000..ca8d651 --- /dev/null +++ b/src/net/bdew/gendustry/compat/itempush/CofhConduitPushProxy.scala @@ -0,0 +1,23 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.compat.itempush + +import net.minecraft.tileentity.TileEntity +import net.minecraftforge.common.ForgeDirection +import net.minecraft.item.ItemStack +import net.bdew.lib.Misc +import cofh.api.transport.IItemConduit + +object CofhConduitPushProxy extends ItemPushProxy { + override def pushStack(from: TileEntity, dir: ForgeDirection, stack: ItemStack) = + (for (conduit <- Misc.getNeighbourTile(from, dir, classOf[IItemConduit])) yield + conduit.insertItem(dir.getOpposite, stack) + ).getOrElse(stack) +} diff --git a/src/net/bdew/gendustry/compat/itempush/ItemPush.scala b/src/net/bdew/gendustry/compat/itempush/ItemPush.scala new file mode 100644 index 0000000..f93b3fa --- /dev/null +++ b/src/net/bdew/gendustry/compat/itempush/ItemPush.scala @@ -0,0 +1,37 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.compat.itempush + +import net.minecraft.tileentity.TileEntity +import net.minecraftforge.common.ForgeDirection +import net.minecraft.item.ItemStack +import net.bdew.gendustry.compat.PowerProxy + +object ItemPush { + var proxies = List.empty[ItemPushProxy] + + def init() { + register(VanillaPush) + if (PowerProxy.haveBC) register(BCPipePushProxy) + if (PowerProxy.haveTE) register(CofhConduitPushProxy) + } + + def register(p: ItemPushProxy) = proxies :+= p + + def pushStack(from: TileEntity, dir: ForgeDirection, st: ItemStack) = { + var stack = st + for (proxy <- proxies if stack != null && stack.stackSize > 0) + stack = proxy.pushStack(from, dir, stack) + if (stack != null && stack.stackSize <= 0) + null + else + stack + } +} diff --git a/src/net/bdew/gendustry/compat/itempush/ItemPushProxy.scala b/src/net/bdew/gendustry/compat/itempush/ItemPushProxy.scala new file mode 100644 index 0000000..b8ba286 --- /dev/null +++ b/src/net/bdew/gendustry/compat/itempush/ItemPushProxy.scala @@ -0,0 +1,18 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.compat.itempush + +import net.minecraft.tileentity.TileEntity +import net.minecraftforge.common.ForgeDirection +import net.minecraft.item.ItemStack + +trait ItemPushProxy { + def pushStack(from: TileEntity, dir: ForgeDirection, stack: ItemStack): ItemStack +} diff --git a/src/net/bdew/gendustry/compat/itempush/VanillaPush.scala b/src/net/bdew/gendustry/compat/itempush/VanillaPush.scala new file mode 100644 index 0000000..73a3f7c --- /dev/null +++ b/src/net/bdew/gendustry/compat/itempush/VanillaPush.scala @@ -0,0 +1,25 @@ +/* + * Copyright (c) bdew, 2013 - 2014 + * https://github.com/bdew/gendustry + * + * This mod is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * https://raw.github.com/bdew/gendustry/master/MMPL-1.0.txt + */ + +package net.bdew.gendustry.compat.itempush + +import net.bdew.lib.items.ItemUtils +import net.minecraft.inventory.IInventory +import net.bdew.lib.Misc +import net.minecraft.item.ItemStack +import net.minecraftforge.common.ForgeDirection +import net.minecraft.tileentity.TileEntity + +object VanillaPush extends ItemPushProxy { + override def pushStack(from: TileEntity, dir: ForgeDirection, stack: ItemStack) = + (for (target <- Misc.getNeighbourTile(from, dir, classOf[IInventory]) if stack != null) yield { + val slots = ItemUtils.getAccessibleSlotsFromSide(target, dir.getOpposite) + ItemUtils.addStackToSlots(stack, target, slots, true) + }) getOrElse stack +} diff --git a/src/net/bdew/gendustry/items/EjectCover.scala b/src/net/bdew/gendustry/items/EjectCover.scala index 7413005..a647e9b 100644 --- a/src/net/bdew/gendustry/items/EjectCover.scala +++ b/src/net/bdew/gendustry/items/EjectCover.scala @@ -9,14 +9,14 @@ package net.bdew.gendustry.items -import net.bdew.lib.items.{ItemUtils, SimpleItem} +import net.bdew.lib.items.SimpleItem import net.bdew.lib.covers.{TileCoverable, ItemCover} import net.minecraftforge.common.ForgeDirection import net.minecraft.inventory.{IInventory, ISidedInventory} import net.minecraft.client.renderer.texture.IconRegister import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.gendustry.Gendustry -import net.bdew.lib.Misc +import net.bdew.gendustry.compat.itempush.ItemPush class EjectCover(id: Int) extends SimpleItem(id, "EjectCover") with ItemCover { override def getCoverIcon = itemIcon @@ -27,15 +27,17 @@ class EjectCover(id: Int) extends SimpleItem(id, "EjectCover") with ItemCover { override def tickCover(te: TileCoverable, side: ForgeDirection): Unit = { if (te.worldObj.getTotalWorldTime % 20 != 0) return val inv = te.asInstanceOf[ISidedInventory with IInventory] + for { - target <- Misc.getNeighbourTile(te, side, classOf[IInventory]) slot <- inv.getAccessibleSlotsFromSide(side.ordinal()) stack <- Option(inv.getStackInSlot(slot)) if inv.canExtractItem(slot, stack, side.ordinal()) } { - val slots = ItemUtils.getAccessibleSlotsFromSide(target, side.getOpposite) - inv.setInventorySlotContents(slot, ItemUtils.addStackToSlots(stack, target, slots, true)) - inv.onInventoryChanged() + val stackLeft = ItemPush.pushStack(te, side, stack.copy()) + if (stackLeft == null || stackLeft.stackSize < stack.stackSize) { + inv.setInventorySlotContents(slot, stackLeft) + inv.onInventoryChanged() + } } } From 3cffe1b2136fc668ee8bc763ba6c27400e26ba22 Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 1 Jun 2014 17:00:12 +0300 Subject: [PATCH 7/8] changed how covers are stored, added cover recipes --- build.gradle | 2 +- resources/assets/gendustry/config/recipes.cfg | 15 +++++++++++++++ src/net/bdew/gendustry/items/EjectCover.scala | 7 ++++--- src/net/bdew/gendustry/items/ImportCover.scala | 7 ++++--- .../gendustry/machines/apiary/TileApiary.scala | 4 ++-- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index e76714c..103aeb9 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'forge' apply plugin: 'scala' version = "1.1.3" -ext.bdlibver = "1.2.3.47" +ext.bdlibver = "1.2.3.48" ext.versuffix = "mc164" ext.apiVer = version diff --git a/resources/assets/gendustry/config/recipes.cfg b/resources/assets/gendustry/config/recipes.cfg index 36ab56e..39000fb 100644 --- a/resources/assets/gendustry/config/recipes.cfg +++ b/resources/assets/gendustry/config/recipes.cfg @@ -270,6 +270,21 @@ OOO BXB => gendustry:"upgrade.cooler" BLB +// ==== COVERS ==== + +B = OD:ingotBronze +A = OD:gearBronze +S = B:pistonBase + +B_B +_S_ => gendustry:ImportCover +_A_ + +_A_ +_S_ => gendustry:EjectCover +B_B + + mutagen: I:redstone -> 100 mutagen: I:yellowDust -> 200 mutagen: B:lightgem -> 800 diff --git a/src/net/bdew/gendustry/items/EjectCover.scala b/src/net/bdew/gendustry/items/EjectCover.scala index a647e9b..3022f56 100644 --- a/src/net/bdew/gendustry/items/EjectCover.scala +++ b/src/net/bdew/gendustry/items/EjectCover.scala @@ -17,14 +17,15 @@ import net.minecraft.client.renderer.texture.IconRegister import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.gendustry.Gendustry import net.bdew.gendustry.compat.itempush.ItemPush +import net.minecraft.item.ItemStack class EjectCover(id: Int) extends SimpleItem(id, "EjectCover") with ItemCover { - override def getCoverIcon = itemIcon + override def getCoverIcon(stack: ItemStack) = itemIcon override def getSpriteNumber = 0 - override def isValidTile(te: TileCoverable) = te.isInstanceOf[ISidedInventory with IInventory] + override def isValidTile(te: TileCoverable, stack: ItemStack) = te.isInstanceOf[ISidedInventory with IInventory] - override def tickCover(te: TileCoverable, side: ForgeDirection): Unit = { + override def tickCover(te: TileCoverable, side: ForgeDirection, coverStack: ItemStack): Unit = { if (te.worldObj.getTotalWorldTime % 20 != 0) return val inv = te.asInstanceOf[ISidedInventory with IInventory] diff --git a/src/net/bdew/gendustry/items/ImportCover.scala b/src/net/bdew/gendustry/items/ImportCover.scala index 1423c8a..8d0cffb 100644 --- a/src/net/bdew/gendustry/items/ImportCover.scala +++ b/src/net/bdew/gendustry/items/ImportCover.scala @@ -17,14 +17,15 @@ import net.minecraft.client.renderer.texture.IconRegister import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.gendustry.Gendustry import net.bdew.lib.Misc +import net.minecraft.item.ItemStack class ImportCover(id: Int) extends SimpleItem(id, "ImportCover") with ItemCover { - override def getCoverIcon = itemIcon + override def getCoverIcon(stack: ItemStack) = itemIcon override def getSpriteNumber = 0 - override def isValidTile(te: TileCoverable) = te.isInstanceOf[ISidedInventory] + override def isValidTile(te: TileCoverable, stack: ItemStack) = te.isInstanceOf[ISidedInventory with IInventory] - override def tickCover(te: TileCoverable, side: ForgeDirection): Unit = { + override def tickCover(te: TileCoverable, side: ForgeDirection, coverStack: ItemStack): Unit = { if (te.worldObj.getTotalWorldTime % 20 != 0) return val inv = te.asInstanceOf[ISidedInventory with IInventory] val insertSlots = inv.getAccessibleSlotsFromSide(side.ordinal()) diff --git a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala index d7df7b7..a0ce9fa 100644 --- a/src/net/bdew/gendustry/machines/apiary/TileApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/TileApiary.scala @@ -34,7 +34,7 @@ import net.bdew.gendustry.compat.triggers.ForestryErrorSource import net.bdew.gendustry.gui.rscontrol.TileRSContollable import net.bdew.gendustry.api.items.IApiaryUpgrade import net.bdew.gendustry.api.blocks.IIndustrialApiary -import net.bdew.lib.covers.{ItemCover, TileCoverable} +import net.bdew.lib.covers.TileCoverable class TileApiary extends TileExtended with TileDataSlots @@ -265,5 +265,5 @@ with IIndustrialApiary { Sanity.check(this) } - override def isValidCover(side: ForgeDirection, cover: ItemCover) = true + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } From c6b18afe02747790be062d27c0ecd48cbecf84fe Mon Sep 17 00:00:00 2001 From: bdew Date: Sun, 1 Jun 2014 17:22:27 +0300 Subject: [PATCH 8/8] Added cover support to all machines --- src/net/bdew/gendustry/gui/BlockGuiWrenchable.scala | 5 ++++- .../gendustry/machines/advmutatron/BlockMutatronAdv.scala | 3 ++- .../gendustry/machines/advmutatron/TileMutatronAdv.scala | 5 ++++- .../bdew/gendustry/machines/extractor/BlockExtractor.scala | 3 ++- .../bdew/gendustry/machines/extractor/TileExtractor.scala | 5 ++++- .../bdew/gendustry/machines/imprinter/BlockImprinter.scala | 3 ++- .../bdew/gendustry/machines/imprinter/TileImprinter.scala | 6 +++++- .../bdew/gendustry/machines/liquifier/BlockLiquifier.scala | 3 ++- .../bdew/gendustry/machines/liquifier/TileLiquifier.scala | 5 ++++- .../machines/mproducer/BlockMutagenProducer.scala | 3 ++- .../gendustry/machines/mproducer/TileMutagenProducer.scala | 7 +++++-- .../bdew/gendustry/machines/mutatron/BlockMutatron.scala | 3 ++- .../bdew/gendustry/machines/mutatron/TileMutatron.scala | 5 ++++- .../gendustry/machines/replicator/BlockReplicator.scala | 3 ++- .../gendustry/machines/replicator/TileReplicator.scala | 5 ++++- src/net/bdew/gendustry/machines/sampler/BlockSampler.scala | 3 ++- src/net/bdew/gendustry/machines/sampler/TileSampler.scala | 6 +++++- .../gendustry/machines/transposer/BlockTransposer.scala | 3 ++- .../gendustry/machines/transposer/TileTransposer.scala | 6 +++++- 19 files changed, 62 insertions(+), 20 deletions(-) diff --git a/src/net/bdew/gendustry/gui/BlockGuiWrenchable.scala b/src/net/bdew/gendustry/gui/BlockGuiWrenchable.scala index 2f74d67..c4ab66b 100644 --- a/src/net/bdew/gendustry/gui/BlockGuiWrenchable.scala +++ b/src/net/bdew/gendustry/gui/BlockGuiWrenchable.scala @@ -42,7 +42,10 @@ trait BlockGuiWrenchable extends Block with IDismantleable { def canDismantle(player: EntityPlayer, world: World, x: Int, y: Int, z: Int): Boolean = true - override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, meta: Int, xoffs: Float, yoffs: Float, zoffs: Float): Boolean = { + override def onBlockActivated(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: Int, xoffs: Float, yoffs: Float, zoffs: Float): Boolean = { + // If the click can be handled by something else - ignore it + if (super.onBlockActivated(world, x, y, z, player, side, xoffs, yoffs, zoffs)) return true + if (player.isSneaking) { val equipped = if (player.getCurrentEquippedItem != null) player.getCurrentEquippedItem.getItem else null if (equipped.isInstanceOf[IToolWrench] && equipped.asInstanceOf[IToolWrench].canWrench(player, x, y, z)) { diff --git a/src/net/bdew/gendustry/machines/advmutatron/BlockMutatronAdv.scala b/src/net/bdew/gendustry/machines/advmutatron/BlockMutatronAdv.scala index f745a51..8eed487 100644 --- a/src/net/bdew/gendustry/machines/advmutatron/BlockMutatronAdv.scala +++ b/src/net/bdew/gendustry/machines/advmutatron/BlockMutatronAdv.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockMutatronAdv(id: Int) extends Block(id, Material.rock) with HasTE[TileMutatronAdv] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockMutatronAdv(id: Int) extends Block(id, Material.rock) with HasTE[TileMutatronAdv] with BlockCoverable[TileMutatronAdv] with BreakableInventoryBlock with BlockGuiWrenchable { val TEClass = classOf[TileMutatronAdv] private var icons: Array[Icon] = null lazy val guiId: Int = Machines.mutatronAdv.guiId diff --git a/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala b/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala index 04d794f..465f3e0 100644 --- a/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala +++ b/src/net/bdew/gendustry/machines/advmutatron/TileMutatronAdv.scala @@ -21,8 +21,9 @@ import net.bdew.lib.data.base.UpdateKind import net.bdew.gendustry.forestry.GeneticsHelper import net.bdew.gendustry.api.blocks.IAdvancedMutatron import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable -class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered with ExposeTank with IAdvancedMutatron { +class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered with ExposeTank with IAdvancedMutatron with TileCoverable { lazy val cfg = Machines.mutatronAdv val outputSlots = Seq(slots.outIndividual) @@ -125,4 +126,6 @@ class TileMutatronAdv extends TileItemProcessor with TileWorker with TilePowered override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = false override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack = null override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = null + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/extractor/BlockExtractor.scala b/src/net/bdew/gendustry/machines/extractor/BlockExtractor.scala index dcf9136..a127d48 100644 --- a/src/net/bdew/gendustry/machines/extractor/BlockExtractor.scala +++ b/src/net/bdew/gendustry/machines/extractor/BlockExtractor.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockExtractor(id: Int) extends Block(id, Material.rock) with HasTE[TileExtractor] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockExtractor(id: Int) extends Block(id, Material.rock) with HasTE[TileExtractor] with BlockCoverable[TileExtractor] with BreakableInventoryBlock with BlockGuiWrenchable { private var icons: Array[Icon] = null val TEClass = classOf[TileExtractor] lazy val guiId = Machines.extractor.guiId diff --git a/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala b/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala index 6997059..70b5618 100644 --- a/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala +++ b/src/net/bdew/gendustry/machines/extractor/TileExtractor.scala @@ -21,8 +21,9 @@ import net.bdew.lib.data.base.UpdateKind import net.bdew.lib.power.TileBaseProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable -class TileExtractor extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank { +class TileExtractor extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank with TileCoverable { lazy val cfg = Machines.extractor object slots { @@ -85,4 +86,6 @@ class TileExtractor extends TileBaseProcessor with TileWorker with TilePowered w override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean) = 0 override def canFill(from: ForgeDirection, fluid: Fluid) = false + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/imprinter/BlockImprinter.scala b/src/net/bdew/gendustry/machines/imprinter/BlockImprinter.scala index 9537dfe..fa0976c 100644 --- a/src/net/bdew/gendustry/machines/imprinter/BlockImprinter.scala +++ b/src/net/bdew/gendustry/machines/imprinter/BlockImprinter.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockImprinter(id: Int) extends Block(id, Material.rock) with HasTE[TileImprinter] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockImprinter(id: Int) extends Block(id, Material.rock) with HasTE[TileImprinter] with BlockCoverable[TileImprinter] with BreakableInventoryBlock with BlockGuiWrenchable { val TEClass = classOf[TileImprinter] private var icons: Array[Icon] = null lazy val guiId: Int = Machines.imprinter.guiId diff --git a/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala b/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala index ed86aaa..a3cdccb 100644 --- a/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala +++ b/src/net/bdew/gendustry/machines/imprinter/TileImprinter.scala @@ -18,8 +18,10 @@ import scala.util.Random import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable +import net.minecraftforge.common.ForgeDirection -class TileImprinter extends TileItemProcessor with TileWorker with TilePowered { +class TileImprinter extends TileItemProcessor with TileWorker with TilePowered with TileCoverable { lazy val cfg = Machines.imprinter val outputSlots = Seq(slots.outIndividual) @@ -114,4 +116,6 @@ class TileImprinter extends TileItemProcessor with TileWorker with TilePowered { override def canExtractItem(slot: Int, item: ItemStack, side: Int) = slot == slots.outIndividual || (slot == slots.inTemplate && inv(slots.inIndividual) == null && (output :== null)) + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/liquifier/BlockLiquifier.scala b/src/net/bdew/gendustry/machines/liquifier/BlockLiquifier.scala index 8c82806..9acc709 100644 --- a/src/net/bdew/gendustry/machines/liquifier/BlockLiquifier.scala +++ b/src/net/bdew/gendustry/machines/liquifier/BlockLiquifier.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockLiquifier(id: Int) extends Block(id, Material.rock) with HasTE[TileLiquifier] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockLiquifier(id: Int) extends Block(id, Material.rock) with HasTE[TileLiquifier] with BlockCoverable[TileLiquifier] with BreakableInventoryBlock with BlockGuiWrenchable { private var icons: Array[Icon] = null val TEClass = classOf[TileLiquifier] lazy val guiId = Machines.liquifier.guiId diff --git a/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala b/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala index 3a671a9..c3654a7 100644 --- a/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala +++ b/src/net/bdew/gendustry/machines/liquifier/TileLiquifier.scala @@ -21,8 +21,9 @@ import net.bdew.lib.data.base.UpdateKind import net.bdew.lib.power.TileBaseProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable -class TileLiquifier extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank { +class TileLiquifier extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank with TileCoverable { lazy val cfg = Machines.liquifier val tank = DataSlotTankRestricted("tank", this, cfg.tankSize, Fluids.protein.getID).setUpdate(UpdateKind.GUI, UpdateKind.SAVE) @@ -77,4 +78,6 @@ class TileLiquifier extends TileBaseProcessor with TileWorker with TilePowered w override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean) = 0 override def canFill(from: ForgeDirection, fluid: Fluid) = false + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/mproducer/BlockMutagenProducer.scala b/src/net/bdew/gendustry/machines/mproducer/BlockMutagenProducer.scala index 8f6e8a6..789e095 100644 --- a/src/net/bdew/gendustry/machines/mproducer/BlockMutagenProducer.scala +++ b/src/net/bdew/gendustry/machines/mproducer/BlockMutagenProducer.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockMutagenProducer(id: Int) extends Block(id, Material.rock) with HasTE[TileMutagenProducer] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockMutagenProducer(id: Int) extends Block(id, Material.rock) with HasTE[TileMutagenProducer] with BlockCoverable[TileMutagenProducer] with BreakableInventoryBlock with BlockGuiWrenchable { private var icons: Array[Icon] = null val TEClass = classOf[TileMutagenProducer] lazy val guiId = Machines.mutagenProducer.guiId diff --git a/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala b/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala index d093580..400e8c1 100644 --- a/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala +++ b/src/net/bdew/gendustry/machines/mproducer/TileMutagenProducer.scala @@ -9,7 +9,7 @@ package net.bdew.gendustry.machines.mproducer -import net.bdew.gendustry.config.{Fluids, Machines} +import net.bdew.gendustry.config.{Items, Fluids, Machines} import net.bdew.gendustry.fluids.MutagenSources import net.minecraft.item.ItemStack import net.minecraft.tileentity.TileEntity @@ -21,8 +21,9 @@ import net.bdew.lib.data.base.UpdateKind import net.bdew.lib.power.TileBaseProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable -class TileMutagenProducer extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank { +class TileMutagenProducer extends TileBaseProcessor with TileWorker with TilePowered with ExposeTank with TileCoverable { lazy val cfg = Machines.mutagenProducer val tank = DataSlotTankRestricted("tank", this, cfg.tankSize, Fluids.mutagen.getID).setUpdate(UpdateKind.GUI, UpdateKind.SAVE) @@ -73,4 +74,6 @@ class TileMutagenProducer extends TileBaseProcessor with TileWorker with TilePow override def fill(from: ForgeDirection, resource: FluidStack, doFill: Boolean) = 0 override def canFill(from: ForgeDirection, fluid: Fluid) = false + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = cover.getItem == Items.coverImport } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/mutatron/BlockMutatron.scala b/src/net/bdew/gendustry/machines/mutatron/BlockMutatron.scala index 89c8508..f782a87 100644 --- a/src/net/bdew/gendustry/machines/mutatron/BlockMutatron.scala +++ b/src/net/bdew/gendustry/machines/mutatron/BlockMutatron.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockMutatron(id: Int) extends Block(id, Material.rock) with HasTE[TileMutatron] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockMutatron(id: Int) extends Block(id, Material.rock) with HasTE[TileMutatron] with BlockCoverable[TileMutatron] with BreakableInventoryBlock with BlockGuiWrenchable { val TEClass = classOf[TileMutatron] private var icons: Array[Icon] = null lazy val guiId: Int = Machines.mutatron.guiId diff --git a/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala b/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala index e101799..33e2832 100644 --- a/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala +++ b/src/net/bdew/gendustry/machines/mutatron/TileMutatron.scala @@ -20,8 +20,9 @@ import net.bdew.gendustry.power.TilePowered import net.bdew.lib.data.base.UpdateKind import net.bdew.gendustry.forestry.GeneticsHelper import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable -class TileMutatron extends TileItemProcessor with TileWorker with TilePowered with ExposeTank { +class TileMutatron extends TileItemProcessor with TileWorker with TilePowered with ExposeTank with TileCoverable { lazy val cfg = Machines.mutatron val outputSlots = Seq(slots.outIndividual) @@ -78,4 +79,6 @@ class TileMutatron extends TileItemProcessor with TileWorker with TilePowered wi override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = false override def drain(from: ForgeDirection, resource: FluidStack, doDrain: Boolean): FluidStack = null override def drain(from: ForgeDirection, maxDrain: Int, doDrain: Boolean): FluidStack = null + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/replicator/BlockReplicator.scala b/src/net/bdew/gendustry/machines/replicator/BlockReplicator.scala index 473d4eb..af58220 100644 --- a/src/net/bdew/gendustry/machines/replicator/BlockReplicator.scala +++ b/src/net/bdew/gendustry/machines/replicator/BlockReplicator.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockReplicator(id: Int) extends Block(id, Material.rock) with HasTE[TileReplicator] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockReplicator(id: Int) extends Block(id, Material.rock) with HasTE[TileReplicator] with BlockCoverable[TileReplicator] with BreakableInventoryBlock with BlockGuiWrenchable { val TEClass = classOf[TileReplicator] private var icons: Array[Icon] = null lazy val guiId: Int = Machines.replicator.guiId diff --git a/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala b/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala index 6b249bb..c47edfe 100644 --- a/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala +++ b/src/net/bdew/gendustry/machines/replicator/TileReplicator.scala @@ -18,8 +18,9 @@ import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.forestry.GeneticsHelper import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable -class TileReplicator extends TileItemProcessor with TileWorker with TilePowered with IFluidHandler { +class TileReplicator extends TileItemProcessor with TileWorker with TilePowered with IFluidHandler with TileCoverable { lazy val cfg = Machines.replicator val outputSlots = Seq(slots.outIndividual) @@ -66,4 +67,6 @@ class TileReplicator extends TileItemProcessor with TileWorker with TilePowered def canFill(from: ForgeDirection, fluid: Fluid) = fluid == Fluids.dna || fluid == Fluids.protein def canDrain(from: ForgeDirection, fluid: Fluid) = false def getTankInfo(from: ForgeDirection) = Array(dnaTank.getInfo, proteinTank.getInfo) + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/sampler/BlockSampler.scala b/src/net/bdew/gendustry/machines/sampler/BlockSampler.scala index 5ecb5c6..46ca057 100644 --- a/src/net/bdew/gendustry/machines/sampler/BlockSampler.scala +++ b/src/net/bdew/gendustry/machines/sampler/BlockSampler.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockSampler(id: Int) extends Block(id, Material.rock) with HasTE[TileSampler] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockSampler(id: Int) extends Block(id, Material.rock) with HasTE[TileSampler] with BlockCoverable[TileSampler] with BreakableInventoryBlock with BlockGuiWrenchable { val TEClass = classOf[TileSampler] private var icons: Array[Icon] = null lazy val guiId: Int = Machines.sampler.guiId diff --git a/src/net/bdew/gendustry/machines/sampler/TileSampler.scala b/src/net/bdew/gendustry/machines/sampler/TileSampler.scala index 7bc409b..a968b27 100644 --- a/src/net/bdew/gendustry/machines/sampler/TileSampler.scala +++ b/src/net/bdew/gendustry/machines/sampler/TileSampler.scala @@ -18,8 +18,10 @@ import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.gendustry.compat.ExtraBeesProxy import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable +import net.minecraftforge.common.ForgeDirection -class TileSampler extends TileItemProcessor with TileWorker with TilePowered { +class TileSampler extends TileItemProcessor with TileWorker with TilePowered with TileCoverable { lazy val cfg = Machines.sampler val outputSlots = Seq(slots.outSample) @@ -85,4 +87,6 @@ class TileSampler extends TileItemProcessor with TileWorker with TilePowered { allowSided = true override def canExtractItem(slot: Int, item: ItemStack, side: Int) = slot == slots.outSample + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file diff --git a/src/net/bdew/gendustry/machines/transposer/BlockTransposer.scala b/src/net/bdew/gendustry/machines/transposer/BlockTransposer.scala index d179e31..f2e8f4f 100644 --- a/src/net/bdew/gendustry/machines/transposer/BlockTransposer.scala +++ b/src/net/bdew/gendustry/machines/transposer/BlockTransposer.scala @@ -20,8 +20,9 @@ import net.bdew.lib.block.HasTE import net.bdew.lib.tile.inventory.BreakableInventoryBlock import net.bdew.gendustry.config.Machines import net.bdew.gendustry.gui.BlockGuiWrenchable +import net.bdew.lib.covers.BlockCoverable -class BlockTransposer(id: Int) extends Block(id, Material.rock) with HasTE[TileTransposer] with BreakableInventoryBlock with BlockGuiWrenchable { +class BlockTransposer(id: Int) extends Block(id, Material.rock) with HasTE[TileTransposer] with BlockCoverable[TileTransposer] with BreakableInventoryBlock with BlockGuiWrenchable { val TEClass = classOf[TileTransposer] private var icons: Array[Icon] = null lazy val guiId: Int = Machines.transposer.guiId diff --git a/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala b/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala index 01b5d9b..8a2cbd4 100644 --- a/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala +++ b/src/net/bdew/gendustry/machines/transposer/TileTransposer.scala @@ -15,8 +15,10 @@ import net.bdew.lib.power.TileItemProcessor import net.bdew.gendustry.power.TilePowered import net.bdew.lib.items.IStack import net.bdew.gendustry.apiimpl.TileWorker +import net.bdew.lib.covers.TileCoverable +import net.minecraftforge.common.ForgeDirection -class TileTransposer extends TileItemProcessor with TileWorker with TilePowered { +class TileTransposer extends TileItemProcessor with TileWorker with TilePowered with TileCoverable { lazy val cfg = Machines.transposer val outputSlots = Seq(slots.outCopy) @@ -79,4 +81,6 @@ class TileTransposer extends TileItemProcessor with TileWorker with TilePowered allowSided = true override def canExtractItem(slot: Int, item: ItemStack, side: Int) = slot == slots.outCopy || (slot == slots.inTemplate && inv(slots.inBlank) == null && (output :== null)) + + override def isValidCover(side: ForgeDirection, cover: ItemStack) = true } \ No newline at end of file