diff --git a/build.gradle b/build.gradle index 2bcdd25..cd886f8 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'forge' apply plugin: 'scala' version = "0.9.5" -ext.bdlibver = "0.9.3.8" +ext.bdlibver = "0.9.3.9" ext.versuffix = "mc164" if (project.hasProperty('buildnum')) { diff --git a/src/net/bdew/gendustry/Gendustry.scala b/src/net/bdew/gendustry/Gendustry.scala index 0ac1ccc..7fc915a 100644 --- a/src/net/bdew/gendustry/Gendustry.scala +++ b/src/net/bdew/gendustry/Gendustry.scala @@ -18,7 +18,6 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent import cpw.mods.fml.common.event.FMLPreInitializationEvent import cpw.mods.fml.common.network.NetworkMod import cpw.mods.fml.common.network.NetworkRegistry -import net.bdew.gendustry.gui.GuiHandler import java.io.File import net.bdew.gendustry.machines.apiary.upgrades.Upgrades import net.bdew.gendustry.compat.PowerProxy @@ -48,7 +47,7 @@ object Gendustry { @EventHandler def init(event: FMLInitializationEvent) { - NetworkRegistry.instance.registerGuiHandler(this, GuiHandler) + NetworkRegistry.instance.registerGuiHandler(this, Config.guiHandler) Upgrades.init() TuningLoader.load("recipes") } diff --git a/src/net/bdew/gendustry/config/Blocks.scala b/src/net/bdew/gendustry/config/Blocks.scala index 6abbc9d..4bc44da 100644 --- a/src/net/bdew/gendustry/config/Blocks.scala +++ b/src/net/bdew/gendustry/config/Blocks.scala @@ -17,8 +17,8 @@ import net.bdew.lib.config.BlockManager import net.bdew.gendustry.Gendustry object Blocks extends BlockManager(Config.IDs) { - var mutagen = regBlockCls(classOf[BlockMutagen], "Mutagen") - var testPowerEmitter = new PowerEmitterBlock(ids.getBlockId("Test Power Emitter")) + val mutagen = regBlockCls(classOf[BlockMutagen], "Mutagen") + val testPowerEmitter = new PowerEmitterBlock(ids.getBlockId("Test Power Emitter")) GameRegistry.registerBlock(testPowerEmitter, "PowerEmitterBlock") GameRegistry.registerTileEntity(classOf[PowerEmitterTile], "PowerEmitterBlock") Gendustry.logInfo("Blocks loaded") diff --git a/src/net/bdew/gendustry/config/Config.scala b/src/net/bdew/gendustry/config/Config.scala index 7564eb3..eb5669f 100644 --- a/src/net/bdew/gendustry/config/Config.scala +++ b/src/net/bdew/gendustry/config/Config.scala @@ -12,13 +12,12 @@ package net.bdew.gendustry.config import net.minecraftforge.common.Configuration import java.io.File import net.bdew.lib.config.IdManager -import net.bdew.gendustry.mutagen.FluidMutagen +import net.bdew.lib.gui.GuiHandler object Config { var neiAddSamples = false var IDs: IdManager = null - var - mutagenFluid = new FluidMutagen + val guiHandler = new GuiHandler def load(cfg: File) { val c = new Configuration(cfg) diff --git a/src/net/bdew/gendustry/config/Machines.scala b/src/net/bdew/gendustry/config/Machines.scala index 8eb51d3..0b8186c 100644 --- a/src/net/bdew/gendustry/config/Machines.scala +++ b/src/net/bdew/gendustry/config/Machines.scala @@ -17,7 +17,7 @@ import net.bdew.gendustry.machines.sampler.MachineSampler import net.bdew.lib.config.MachineManager import net.bdew.gendustry.Gendustry -object Machines extends MachineManager(Config.IDs, Tuning.getSection("Machines")) { +object Machines extends MachineManager(Config.IDs, Tuning.getSection("Machines"), Config.guiHandler) { val mutagenProducer = registerMachine(new MachineMutagenProducer) val mutatron = registerMachine(new MachineMutatron) val apiary = registerMachine(new MachineApiary) diff --git a/src/net/bdew/gendustry/gui/GuiHandler.scala b/src/net/bdew/gendustry/gui/GuiHandler.scala deleted file mode 100644 index 9408b22..0000000 --- a/src/net/bdew/gendustry/gui/GuiHandler.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) bdew, 2013 - * 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.gui - -import cpw.mods.fml.common.network.IGuiHandler -import scala.collection.mutable -import net.minecraft.entity.player.EntityPlayer -import net.minecraft.world.World - -object GuiHandler extends IGuiHandler { - val guis = mutable.Map.empty[Int, GuiProvider] - - def register(p: GuiProvider) = { - if (guis.isDefinedAt(p.guiId)) - sys.error("GUI ID Collision - %d was registered for %s and attemted to register by %s".format(p.guiId, guis(p.guiId), p)) - guis += (p.guiId -> p) - } - - def getServerGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = - guis(ID).getContainer(world.getBlockTileEntity(x, y, z), player) - - def getClientGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = - guis(ID).getGui(world.getBlockTileEntity(x, y, z), player) -} diff --git a/src/net/bdew/gendustry/gui/GuiProvider.scala b/src/net/bdew/gendustry/gui/GuiProvider.scala deleted file mode 100644 index 26cebd6..0000000 --- a/src/net/bdew/gendustry/gui/GuiProvider.scala +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) bdew, 2013 - * 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.gui - -import net.minecraft.tileentity.TileEntity -import net.minecraft.entity.player.EntityPlayer -import net.minecraft.client.gui.inventory.GuiContainer -import net.minecraft.inventory.Container -import cpw.mods.fml.relauncher.{Side, SideOnly} - -trait GuiProvider { - GuiHandler.register(this) - def guiId: Int - - @SideOnly(Side.CLIENT) - def getGui(te: TileEntity, player: EntityPlayer): GuiContainer - def getContainer(te: TileEntity, player: EntityPlayer): Container -} diff --git a/src/net/bdew/gendustry/machines/apiary/MachineApiary.scala b/src/net/bdew/gendustry/machines/apiary/MachineApiary.scala index 6f9805c..f3c2b9d 100644 --- a/src/net/bdew/gendustry/machines/apiary/MachineApiary.scala +++ b/src/net/bdew/gendustry/machines/apiary/MachineApiary.scala @@ -9,20 +9,18 @@ package net.bdew.gendustry.machines.apiary -import net.minecraft.tileentity.TileEntity import net.minecraft.entity.player.EntityPlayer -import net.minecraft.inventory.Container -import net.minecraft.client.gui.inventory.GuiContainer -import net.bdew.gendustry.gui.GuiProvider import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.lib.machine.{Machine, PoweredMachine} +import net.bdew.lib.gui.GuiProvider class MachineApiary extends Machine("IndustrialApiary", new BlockApiary(_)) with GuiProvider with PoweredMachine { def guiId = 3 + type TEClass = TileApiary lazy val baseMjPerTick = tuning.getInt("BaseMjPerTick") @SideOnly(Side.CLIENT) - def getGui(te: TileEntity, player: EntityPlayer): GuiContainer = new GuiApiary(te.asInstanceOf[TileApiary], player) - def getContainer(te: TileEntity, player: EntityPlayer): Container = new ContainerApiary(te.asInstanceOf[TileApiary], player) + def getGui(te: TileApiary, player: EntityPlayer) = new GuiApiary(te, player) + def getContainer(te: TileApiary, player: EntityPlayer) = new ContainerApiary(te, player) } diff --git a/src/net/bdew/gendustry/machines/imprinter/MachineImprinter.scala b/src/net/bdew/gendustry/machines/imprinter/MachineImprinter.scala index c023801..a840f3c 100644 --- a/src/net/bdew/gendustry/machines/imprinter/MachineImprinter.scala +++ b/src/net/bdew/gendustry/machines/imprinter/MachineImprinter.scala @@ -9,22 +9,20 @@ package net.bdew.gendustry.machines.imprinter -import net.minecraft.tileentity.TileEntity import net.minecraft.entity.player.EntityPlayer -import net.minecraft.inventory.Container -import net.minecraft.client.gui.inventory.GuiContainer -import net.bdew.gendustry.gui.GuiProvider import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.lib.machine.{Machine, ProcessorMachine} +import net.bdew.lib.gui.GuiProvider class MachineImprinter extends Machine("Imprinter", new BlockImprinter(_)) with GuiProvider with ProcessorMachine { def guiId = 4 + type TEClass = TileImprinter lazy val labwareConsumeChance = tuning.getInt("LabwareConsumeChance") lazy val deathChanceNatural = tuning.getInt("DeathChanceNatural") lazy val deathChanceArtificial = tuning.getInt("DeathChanceArtificial") @SideOnly(Side.CLIENT) - def getGui(te: TileEntity, player: EntityPlayer): GuiContainer = new GuiImprinter(te.asInstanceOf[TileImprinter], player) - def getContainer(te: TileEntity, player: EntityPlayer): Container = new ContainerImprinter(te.asInstanceOf[TileImprinter], player) + def getGui(te: TileImprinter, player: EntityPlayer) = new GuiImprinter(te, player) + def getContainer(te: TileImprinter, player: EntityPlayer) = new ContainerImprinter(te, player) } diff --git a/src/net/bdew/gendustry/machines/mproducer/MachineMutagenProducer.scala b/src/net/bdew/gendustry/machines/mproducer/MachineMutagenProducer.scala index ac172ba..2ddae95 100644 --- a/src/net/bdew/gendustry/machines/mproducer/MachineMutagenProducer.scala +++ b/src/net/bdew/gendustry/machines/mproducer/MachineMutagenProducer.scala @@ -9,18 +9,18 @@ package net.bdew.gendustry.machines.mproducer -import net.minecraft.tileentity.TileEntity import net.minecraft.entity.player.EntityPlayer -import net.bdew.gendustry.gui.GuiProvider import cpw.mods.fml.relauncher.{SideOnly, Side} import net.bdew.lib.machine.{Machine, ProcessorMachine} +import net.bdew.lib.gui.GuiProvider class MachineMutagenProducer extends Machine("MutagenProducer", new BlockMutagenProducer(_)) with GuiProvider with ProcessorMachine { def guiId = 1 + type TEClass = TileMutagenProducer lazy val tankSize = tuning.getInt("TankSize") @SideOnly(Side.CLIENT) - def getGui(te: TileEntity, player: EntityPlayer) = new GuiMutagenProducer(te.asInstanceOf[TileMutagenProducer], player) - def getContainer(te: TileEntity, player: EntityPlayer) = new ContainerMutagenProducer(te.asInstanceOf[TileMutagenProducer], player) + def getGui(te: TileMutagenProducer, player: EntityPlayer) = new GuiMutagenProducer(te, player) + def getContainer(te: TileMutagenProducer, player: EntityPlayer) = new ContainerMutagenProducer(te, player) } diff --git a/src/net/bdew/gendustry/machines/mutatron/MachineMutatron.scala b/src/net/bdew/gendustry/machines/mutatron/MachineMutatron.scala index 2e00116..cc95760 100644 --- a/src/net/bdew/gendustry/machines/mutatron/MachineMutatron.scala +++ b/src/net/bdew/gendustry/machines/mutatron/MachineMutatron.scala @@ -9,16 +9,14 @@ package net.bdew.gendustry.machines.mutatron -import net.minecraft.tileentity.TileEntity import net.minecraft.entity.player.EntityPlayer -import net.minecraft.inventory.Container -import net.minecraft.client.gui.inventory.GuiContainer -import net.bdew.gendustry.gui.GuiProvider import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.lib.machine.{Machine, ProcessorMachine} +import net.bdew.lib.gui.GuiProvider class MachineMutatron extends Machine("Mutatron", new BlockMutatron(_)) with GuiProvider with ProcessorMachine { def guiId = 2 + type TEClass = TileMutatron lazy val tankSize = tuning.getInt("TankSize") lazy val mutagenPerItem = tuning.getInt("MutagenPerItem") @@ -28,6 +26,6 @@ class MachineMutatron extends Machine("Mutatron", new BlockMutatron(_)) with Gui lazy val secretChance = tuning.getFloat("SecretMutationChance") @SideOnly(Side.CLIENT) - def getGui(te: TileEntity, player: EntityPlayer): GuiContainer = new GuiMutatron(te.asInstanceOf[TileMutatron], player) - def getContainer(te: TileEntity, player: EntityPlayer): Container = new ContainerMutatron(te.asInstanceOf[TileMutatron], player) + def getGui(te: TileMutatron, player: EntityPlayer) = new GuiMutatron(te, player) + def getContainer(te: TileMutatron, player: EntityPlayer) = new ContainerMutatron(te, player) } diff --git a/src/net/bdew/gendustry/machines/sampler/MachineSampler.scala b/src/net/bdew/gendustry/machines/sampler/MachineSampler.scala index 9ab9a5d..ec406a9 100644 --- a/src/net/bdew/gendustry/machines/sampler/MachineSampler.scala +++ b/src/net/bdew/gendustry/machines/sampler/MachineSampler.scala @@ -9,20 +9,20 @@ package net.bdew.gendustry.machines.sampler -import net.minecraft.tileentity.TileEntity import net.minecraft.entity.player.EntityPlayer import net.minecraft.inventory.Container import net.minecraft.client.gui.inventory.GuiContainer -import net.bdew.gendustry.gui.GuiProvider import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.lib.machine.{Machine, ProcessorMachine} +import net.bdew.lib.gui.GuiProvider class MachineSampler extends Machine("Sampler", new BlockSampler(_)) with GuiProvider with ProcessorMachine { def guiId = 5 + type TEClass = TileSampler lazy val labwareConsumeChance = tuning.getInt("LabwareConsumeChance") @SideOnly(Side.CLIENT) - def getGui(te: TileEntity, player: EntityPlayer): GuiContainer = new GuiSampler(te.asInstanceOf[TileSampler], player) - def getContainer(te: TileEntity, player: EntityPlayer): Container = new ContainerSampler(te.asInstanceOf[TileSampler], player) + def getGui(te: TileSampler, player: EntityPlayer): GuiContainer = new GuiSampler(te, player) + def getContainer(te: TileSampler, player: EntityPlayer): Container = new ContainerSampler(te, player) }