Fixed some errors made so many more

This commit is contained in:
Robert S 2014-08-11 01:44:06 -04:00
parent f394508574
commit b1a148ee97
10 changed files with 210 additions and 221 deletions

View file

@ -12,14 +12,11 @@ import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.oredict.OreDictionary import net.minecraftforge.oredict.OreDictionary
import resonant.api.IFilterable import resonant.api.IFilterable
import resonant.api.IRemovable.ISneakPickup import resonant.api.IRemovable.ISneakPickup
import resonant.content.spatial.block.SpatialTile import resonant.lib.content.prefab.java.TileInventory
import resonant.engine.ResonantEngine
import resonant.lib.content.prefab.TInventory
import resonant.lib.network.ByteBufWrapper._ import resonant.lib.network.ByteBufWrapper._
import resonant.lib.network.discriminator.{PacketTile, PacketType} import resonant.lib.network.discriminator.{PacketTile, PacketType}
import resonant.lib.network.handle.TPacketReceiver import resonant.lib.network.handle.TPacketReceiver
import resonantinduction.archaic.ArchaicBlocks import resonantinduction.archaic.ArchaicBlocks
import universalelectricity.core.transform.vector.Vector3
/** Basic single stack inventory. /** Basic single stack inventory.
* <p/> * <p/>
@ -42,7 +39,7 @@ object TileCrate {
final val maxSize: Int = 2 final val maxSize: Int = 2
} }
class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketReceiver with IFilterable with ISneakPickup { class TileCrate extends TileInventory(Material.rock) with TPacketReceiver with IFilterable with ISneakPickup {
/** delay from last click */ /** delay from last click */
var prevClickTime: Long = -1000 var prevClickTime: Long = -1000
@ -66,7 +63,7 @@ class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketR
} }
if (doUpdate) { if (doUpdate) {
doUpdate = false doUpdate = false
ResonantEngine.instance.packetHandler.sendToAllAround(getDescriptionPacket, this.worldObj, new Vector3(this), 50) sendPacket(getDescPacket)
} }
} }
} }
@ -90,7 +87,7 @@ class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketR
if (worldObj == null || !worldObj.isRemote) { if (worldObj == null || !worldObj.isRemote) {
var newSampleStack: ItemStack = null var newSampleStack: ItemStack = null
var rebuildBase: Boolean = false var rebuildBase: Boolean = false
for (slot <- getSizeInventory) { for (slot <- 0 until getSizeInventory) {
val slotStack: ItemStack = this.getInventory.getStackInSlot(slot) val slotStack: ItemStack = this.getInventory.getStackInSlot(slot)
if (slotStack != null && slotStack.getItem != null && slotStack.stackSize > 0) { if (slotStack != null && slotStack.getItem != null && slotStack.stackSize > 0) {
@ -210,15 +207,16 @@ class TileCrate extends SpatialTile(Material.rock) with TInventory with TPacketR
} }
override def getDescPacket: PacketTile = { override def getDescPacket: PacketTile = {
var packet: PacketTile = null var packet: PacketTile = new PacketTile(this)
this.buildSampleStack this.buildSampleStack
val stack: ItemStack = this.getSampleStack val stack: ItemStack = this.getSampleStack
if (stack != null) { if (stack != null) {
packet <<< true
packet = new PacketTile(this, true, stack.writeToNBT(new NBTTagCompound), stack.stackSize) packet <<< stack
packet <<< stack.stackSize
} }
else { else {
packet = new PacketTile(this, false) packet <<< false
} }
return packet return packet
} }

View file

@ -44,11 +44,11 @@ class ItemBlockTank(block: Block) extends ItemBlock(block: Block) with IFluidCon
} }
override def getUnlocalizedName(itemStack: ItemStack): String = { override def getUnlocalizedName(itemStack: ItemStack): String = {
val translation: String = LanguageUtility.getLocal(getUnlocalizedName + "." + itemStack.getItemDamage) val translation: String = LanguageUtility.getLocal(getUnlocalizedName() + "." + itemStack.getItemDamage)
if (translation == null || translation.isEmpty) { if (translation == null || translation.isEmpty) {
return getUnlocalizedName return getUnlocalizedName()
} }
return getUnlocalizedName + "." + itemStack.getItemDamage return getUnlocalizedName() + "." + itemStack.getItemDamage
} }
override def placeBlockAt(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float, metadata: Int): Boolean = { override def placeBlockAt(stack: ItemStack, player: EntityPlayer, world: World, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float, metadata: Int): Boolean = {

View file

@ -80,8 +80,11 @@ object AtomicContent extends ContentHolder
super.postInit() super.postInit()
recipes += shaped(new ItemStack(itemAntimatter, 1, 1), itemAntimatter, itemAntimatter, itemAntimatter, itemAntimatter, itemAntimatter, AtomicContent.itemAntimatter, itemAntimatter, itemAntimatter) recipes += shaped(new ItemStack(itemAntimatter, 1, 1), itemAntimatter, itemAntimatter, itemAntimatter, itemAntimatter, itemAntimatter, AtomicContent.itemAntimatter, itemAntimatter, itemAntimatter)
recipes += shaped(new ItemStack(itemAntimatter, 8, 0), new ItemStack(AtomicContent.itemAntimatter, 1, 1)) recipes += shaped(new ItemStack(itemAntimatter, 8, 0), new ItemStack(AtomicContent.itemAntimatter, 1, 1))
recipes += shaped(new ItemStack(blockSteamFunnel, 2), " B ", "B B", "B B", 'B', UniversalRecipe.SECONDARY_METAL.get) recipes += shaped(new ItemStack(blockSteamFunnel, 2), " B ", "B B", "B B", 'B', UniversalRecipe.SECONDARY_METAL.get)
recipes += shaped(new ItemStack(blockSteamFunnel, 2), " B ", "B B", "B B", 'B', "ingotIron") recipes += shaped(new ItemStack(blockSteamFunnel, 2), " B ", "B B", "B B", 'B', "ingotIron")
recipes += shaped(blockQuantumAssembler, "CCC", "SXS", "SSS", 'X', blockCentrifuge, 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get) recipes += shaped(blockQuantumAssembler, "CCC", "SXS", "SSS", 'X', blockCentrifuge, 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get)
recipes += shaped(blockFulmination, "OSO", "SCS", "OSO", 'O', Blocks.obsidian, 'C', UniversalRecipe.CIRCUIT_T2.get, 'S', UniversalRecipe.PRIMARY_PLATE.get) recipes += shaped(blockFulmination, "OSO", "SCS", "OSO", 'O', Blocks.obsidian, 'C', UniversalRecipe.CIRCUIT_T2.get, 'S', UniversalRecipe.PRIMARY_PLATE.get)
recipes += shaped(blockAccelerator, "SCS", "CMC", "SCS", 'M', UniversalRecipe.MOTOR.get, 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get) recipes += shaped(blockAccelerator, "SCS", "CMC", "SCS", 'M', UniversalRecipe.MOTOR.get, 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get)
@ -92,19 +95,22 @@ object AtomicContent extends ContentHolder
recipes += shaped(new ItemStack(blockSiren, 2), "NPN", 'N', Blocks.noteblock, 'P', UniversalRecipe.SECONDARY_PLATE.get) recipes += shaped(new ItemStack(blockSiren, 2), "NPN", 'N', Blocks.noteblock, 'P', UniversalRecipe.SECONDARY_PLATE.get)
recipes += shaped(blockReactorCell, "SCS", "MEM", "SCS", 'E', "cellEmpty", 'C', UniversalRecipe.CIRCUIT_T2.get, 'S', UniversalRecipe.PRIMARY_PLATE.get, 'M', UniversalRecipe.MOTOR.get) recipes += shaped(blockReactorCell, "SCS", "MEM", "SCS", 'E', "cellEmpty", 'C', UniversalRecipe.CIRCUIT_T2.get, 'S', UniversalRecipe.PRIMARY_PLATE.get, 'M', UniversalRecipe.MOTOR.get)
recipes += shaped(blockFusionCore, "CPC", "PFP", "CPC", 'P', UniversalRecipe.PRIMARY_PLATE.get, 'F', AtomicContent.blockReactorCell, 'C', UniversalRecipe.CIRCUIT_T3.get) recipes += shaped(blockFusionCore, "CPC", "PFP", "CPC", 'P', UniversalRecipe.PRIMARY_PLATE.get, 'F', AtomicContent.blockReactorCell, 'C', UniversalRecipe.CIRCUIT_T3.get)
recipes += shaped(new ItemStack(itemCell, 16), " T ", "TGT", " T ", 'T', "ingotTin", 'G', Blocks.glass) recipes += shaped(new ItemStack(itemCell, 16), " T ", "TGT", " T ", 'T', "ingotTin", 'G', Blocks.glass)
recipes += shaped(blockThermometer, "SSS", "GCG", "GSG", 'S', UniversalRecipe.PRIMARY_METAL.get, 'G', Blocks.glass, 'C', UniversalRecipe.CIRCUIT_T1.get) recipes += shaped(blockThermometer, "SSS", "GCG", "GSG", 'S', UniversalRecipe.PRIMARY_METAL.get, 'G', Blocks.glass, 'C', UniversalRecipe.CIRCUIT_T1.get)
recipes += shaped(blockControlRod, "I", "I", "I", 'I', Items.iron_ingot) recipes += shaped(blockControlRod, "I", "I", "I", 'I', Items.iron_ingot)
recipes += shaped(itemFissileFuel, "CUC", "CUC", "CUC", 'U', "ingotUranium", 'C', "cellEmpty") recipes += shaped(itemFissileFuel, "CUC", "CUC", "CUC", 'U', "ingotUranium", 'C', "cellEmpty")
recipes += shaped(itemBreedingRod, "CUC", "CUC", "CUC", 'U', "breederUranium", 'C', "cellEmpty") recipes += shaped(itemBreedingRod, "CUC", "CUC", "CUC", 'U', "breederUranium", 'C', "cellEmpty")
recipes += shaped(new ItemStack(blockElectromagnet, 2, 0), "BBB", "BMB", "BBB", 'B', UniversalRecipe.SECONDARY_METAL.get, 'M', UniversalRecipe.MOTOR.get)
//Hazmat recipes
recipes += shaped(itemHazmatTop, "SSS", "BAB", "SCS", 'A', Items.leather_helmet, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatTop, "SSS", "BAB", "SCS", 'A', Items.leather_helmet, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool)
recipes += shaped(itemHazmatBody, "SSS", "BAB", "SCS", 'A', Items.leather_chestplate, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatBody, "SSS", "BAB", "SCS", 'A', Items.leather_chestplate, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool)
recipes += shaped(itemHazmatLeggings, "SSS", "BAB", "SCS", 'A', Items.leather_leggings, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatLeggings, "SSS", "BAB", "SCS", 'A', Items.leather_leggings, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool)
recipes += shaped(itemHazmatBoots, "SSS", "BAB", "SCS", 'A', Items.leather_boots, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool) recipes += shaped(itemHazmatBoots, "SSS", "BAB", "SCS", 'A', Items.leather_boots, 'C', UniversalRecipe.CIRCUIT_T1.get, 'S', Blocks.wool)
//Electro magnets
recipes += shaped(new ItemStack(blockElectromagnet, 2, 0), "BBB", "BMB", "BBB", 'B', UniversalRecipe.SECONDARY_METAL.get, 'M', UniversalRecipe.MOTOR.get)
recipes += shapeless(new ItemStack(AtomicContent.blockElectromagnet, 1, 1), AtomicContent.blockElectromagnet, Blocks.glass) recipes += shapeless(new ItemStack(AtomicContent.blockElectromagnet, 1, 1), AtomicContent.blockElectromagnet, Blocks.glass)
recipes += shapeless(new ItemStack(AtomicContent.itemWaterCell), "cellEmpty", Items.water_bucket) recipes += shapeless(new ItemStack(AtomicContent.itemWaterCell), "cellEmpty", Items.water_bucket)
} }

View file

@ -19,10 +19,8 @@ import scala.util.control.Breaks._
import resonant.lib.wrapper.WrapList._ import resonant.lib.wrapper.WrapList._
class ItemQuantumGlyph extends JItemMultiPart with IHighlight { class ItemQuantumGlyph extends JItemMultiPart with IHighlight {
def this() {
this() setHasSubtypes(true)
setHasSubtypes(true)
}
override def getUnlocalizedName(itemStack: ItemStack): String = { override def getUnlocalizedName(itemStack: ItemStack): String = {
return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage
@ -65,7 +63,7 @@ class ItemQuantumGlyph extends JItemMultiPart with IHighlight {
override def getSubItems(item: Item, tab: CreativeTabs, listToAddTo: List[_]) { override def getSubItems(item: Item, tab: CreativeTabs, listToAddTo: List[_]) {
for(i <- PartQuantumGlyph.MAX_GLYPH) for(i <- 0 until PartQuantumGlyph.MAX_GLYPH)
{ {
{ {
listToAddTo.add(new ItemStack(item, 1, i)) listToAddTo.add(new ItemStack(item, 1, i))

View file

@ -1,38 +1,22 @@
package resonantinduction.atomic.gate package resonantinduction.atomic.gate
import java.util.ArrayList import java.util.{ArrayList, List, Set}
import java.util.Arrays
import java.util.HashMap import codechicken.lib.data.{MCDataInput, MCDataOutput}
import java.util.List import codechicken.lib.vec.{Cuboid6, Vector3}
import java.util.Set import codechicken.multipart.{JCuboidPart, JNormalOcclusion, TSlottedPart}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraft.util.MovingObjectPosition import net.minecraft.util.{ChatComponentText, MovingObjectPosition}
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.Fluid
import net.minecraftforge.fluids.FluidContainerRegistry
import net.minecraftforge.fluids.FluidStack
import net.minecraftforge.fluids.FluidTank
import net.minecraftforge.fluids.FluidTankInfo
import resonant.api.IExternalInventory
import resonant.api.blocks.IBlockFrequency import resonant.api.blocks.IBlockFrequency
import resonant.api.mffs.fortron.FrequencyGridRegistry import resonant.api.mffs.fortron.FrequencyGridRegistry
import resonant.engine.grid.frequency.FrequencyGrid
import resonant.lib.utility.inventory.ExternalInventory
import codechicken.lib.data.MCDataInput
import codechicken.lib.data.MCDataOutput
import codechicken.lib.vec.Cuboid6
import codechicken.lib.vec.Vector3
import codechicken.multipart.JCuboidPart
import codechicken.multipart.JNormalOcclusion
import codechicken.multipart.TSlottedPart
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import resonantinduction.electrical.Electrical import resonantinduction.electrical.Electrical
import universalelectricity.core.transform.vector.VectorWorld import universalelectricity.core.transform.vector.VectorWorld
import scala.collection.JavaConversions._
object PartQuantumGlyph { object PartQuantumGlyph {
final val MAX_GLYPH: Int = 4 final val MAX_GLYPH: Int = 4
@ -40,6 +24,11 @@ object PartQuantumGlyph {
} }
class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusion with IQuantumGate { class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusion with IQuantumGate {
private var slot: Byte = 0
private[gate] var number: Byte = 0
private[gate] var ticks: Int = 0
def preparePlacement(side: Int, itemDamage: Int) { def preparePlacement(side: Int, itemDamage: Int) {
this.slot = side.asInstanceOf[Byte] this.slot = side.asInstanceOf[Byte]
this.number = itemDamage.asInstanceOf[Byte] this.number = itemDamage.asInstanceOf[Byte]
@ -62,21 +51,31 @@ class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusi
} }
} }
def transport(entity: Entity) { def transport(`ob`: scala.Any)
if (ticks % 10 == 0 && (tile.asInstanceOf[IQuantumGate]).getFrequency != -1) { {
if (ticks % 10 == 0 && (tile.asInstanceOf[IQuantumGate]).getFrequency != -1)
{
val frequencyBlocks: Set[IBlockFrequency] = FrequencyGridRegistry.instance.getNodes((tile.asInstanceOf[IQuantumGate]).getFrequency) val frequencyBlocks: Set[IBlockFrequency] = FrequencyGridRegistry.instance.getNodes((tile.asInstanceOf[IQuantumGate]).getFrequency)
val gates: List[IQuantumGate] = new ArrayList[IQuantumGate] val gates: List[IQuantumGate] = new ArrayList[IQuantumGate]
import scala.collection.JavaConversions._
for (frequencyBlock <- frequencyBlocks) {
if (frequencyBlock.isInstanceOf[IQuantumGate]) { for (frequencyBlock <- frequencyBlocks)
{
if (frequencyBlock.isInstanceOf[IQuantumGate])
{
gates.add(frequencyBlock.asInstanceOf[IQuantumGate]) gates.add(frequencyBlock.asInstanceOf[IQuantumGate])
} }
} }
gates.remove(tile) gates.remove(tile)
if (gates.size > 0) { if (gates.size > 0) {
val gate: IQuantumGate = gates.get(if (gates.size > 1) entity.worldObj.rand.nextInt(gates.size - 1) else 0) if (ob.isInstanceOf[Entity])
val position: VectorWorld = new VectorWorld(gate.asInstanceOf[TileEntity]).add(0.5, 2, 0.5) {
if (QuantumGateManager.moveEntity(entity, position)) world.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F) val gate: IQuantumGate = gates.get(if (gates.size > 1) ob.asInstanceOf[Entity].worldObj.rand.nextInt(gates.size - 1) else 0)
val position: VectorWorld = new VectorWorld(gate.asInstanceOf[TileEntity]).add(0.5, 2, 0.5)
if (QuantumGateManager.moveEntity(ob.asInstanceOf[Entity], position)) world.playSoundAtEntity(ob.asInstanceOf[Entity], "mob.endermen.portal", 1.0F, 1.0F)
}
} }
} }
} }
@ -97,7 +96,7 @@ class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusi
val frequency: Int = (tile.asInstanceOf[IBlockFrequency]).getFrequency val frequency: Int = (tile.asInstanceOf[IBlockFrequency]).getFrequency
if (frequency > -1) { if (frequency > -1) {
if (!world.isRemote) { if (!world.isRemote) {
player.addChatMessage(new ChatMessageComponent("Quantum Gate Frequency: " + frequency)) player.addChatMessage(new ChatComponentText("Quantum Gate Frequency: " + frequency))
} }
return true return true
} }
@ -167,7 +166,7 @@ class PartQuantumGlyph extends JCuboidPart with TSlottedPart with JNormalOcclusi
} }
} }
private var slot: Byte = 0 override def setFrequency(frequency: Int): Unit = ???
private[gate] var number: Byte = 0
private[gate] var ticks: Int = 0 override def getFrequency: Int = ???
} }

View file

@ -28,7 +28,7 @@ class TraitQuantumGate extends TileMultipart with IQuantumGate {
{ {
if (part.isInstanceOf[IQuantumGate]) if (part.isInstanceOf[IQuantumGate])
{ {
frequency += Math.pow(PartQuantumGlyph.MAX_GLYPH, i) * (part.asInstanceOf[IBlockFrequency]).getFrequency frequency += (Math.pow(PartQuantumGlyph.MAX_GLYPH, i) * (part.asInstanceOf[IBlockFrequency]).getFrequency).asInstanceOf[Int]
i += 1 i += 1
} }
} }

View file

@ -1,47 +1,38 @@
package resonantinduction.atomic.machine.reactor package resonantinduction.atomic.machine.reactor
import java.util.ArrayList import java.util.{ArrayList, List}
import java.util.List
import net.minecraft.block.material.Material import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.init.Blocks
import resonant.api.event.PlasmaEvent
import resonant.engine.grid.thermal.{ThermalGrid, ThermalPhysics}
import resonant.lib.content.prefab.java.TileInventory
import resonant.lib.multiblock.reference.{MultiBlockHandler, IMultiBlockStructure}
import resonant.lib.network.discriminator.PacketAnnotation
import resonant.lib.network.netty.PacketManager
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.entity.EntityLiving import net.minecraft.entity.EntityLiving
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraft.util.AxisAlignedBB import net.minecraft.util.AxisAlignedBB
import net.minecraft.world.World import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.common.MinecraftForge import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fluids.Fluid import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.FluidContainerRegistry import net.minecraftforge.fluids.{Fluid, FluidContainerRegistry, FluidStack, FluidTank, FluidTankInfo, IFluidHandler}
import net.minecraftforge.fluids.FluidStack import resonant.api.{IReactor, IReactorComponent}
import net.minecraftforge.fluids.FluidTank import resonant.api.event.PlasmaEvent
import net.minecraftforge.fluids.FluidTankInfo import resonant.engine.grid.thermal.{ThermalGrid, ThermalPhysics}
import net.minecraftforge.fluids.IFluidHandler import resonant.lib.content.prefab.java.TileInventory
import resonant.api.IReactor import resonant.lib.multiblock.reference.{IMultiBlockStructure, MultiBlockHandler}
import resonant.api.IReactorComponent
import resonant.lib.network.Synced import resonant.lib.network.Synced
import resonant.lib.network.Synced.SyncedInput import resonant.lib.network.Synced.{SyncedInput, SyncedOutput}
import resonant.lib.network.Synced.SyncedOutput import resonant.lib.network.discriminator.PacketAnnotation
import resonant.lib.prefab.poison.PoisonRadiation import resonant.lib.prefab.poison.PoisonRadiation
import resonant.lib.utility.inventory.InventoryUtility import resonant.lib.utility.inventory.InventoryUtility
import resonantinduction.atomic.Atomic
import resonantinduction.atomic.ReactorExplosion
import resonantinduction.atomic.machine.plasma.TilePlasma import resonantinduction.atomic.machine.plasma.TilePlasma
import resonantinduction.atomic.{Atomic, AtomicContent}
import resonantinduction.core.Reference import resonantinduction.core.Reference
import resonantinduction.core.ResonantInduction import universalelectricity.core.transform.vector.{Vector3, VectorWorld}
import universalelectricity.core.transform.vector.{VectorWorld, Vector3}
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import scala.util.control.Breaks._ import scala.util.control.Breaks._
import scala.collection.convert.wrapAll._
/** The primary reactor component cell used to build reactors with. /** The primary reactor component cell used to build reactors with.
* *
@ -66,13 +57,10 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
/** Multiblock Methods. */ /** Multiblock Methods. */
private var multiBlock: MultiBlockHandler[TileReactorCell] = null private var multiBlock: MultiBlockHandler[TileReactorCell] = null
def this() { textureName = "machine"
this isOpaqueCube = false
textureName = "machine" normalRender = false
isOpaqueCube = false customItemRender = true
normalRender = false
customItemRender = true
}
override protected def onWorldJoin { override protected def onWorldJoin {
updatePositionStatus updatePositionStatus
@ -128,7 +116,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
} }
} }
if (!getWorld.isRemote) { if (!getWorld.isRemote) {
if (getMultiBlock().isPrimary() && tank.getFluid != null && tank.getFluid.fluidID == Atomic.FLUID_PLASMA.getID) { if (getMultiBlock().isPrimary() && tank.getFluid != null && tank.getFluid.fluidID == AtomicContent.FLUID_PLASMA.getID) {
val drain: FluidStack = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false) val drain: FluidStack = tank.drain(FluidContainerRegistry.BUCKET_VOLUME, false)
if (drain != null && drain.amount >= FluidContainerRegistry.BUCKET_VOLUME) { if (drain != null && drain.amount >= FluidContainerRegistry.BUCKET_VOLUME) {
val spawnDir: ForgeDirection = ForgeDirection.getOrientation(worldObj.rand.nextInt(3) + 2) val spawnDir: ForgeDirection = ForgeDirection.getOrientation(worldObj.rand.nextInt(3) + 2)
@ -153,7 +141,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
} }
if (ticks % 20 == 0) { if (ticks % 20 == 0) {
if (worldObj.rand.nextFloat > 0.65) { if (worldObj.rand.nextFloat > 0.65) {
val entities: List[_] = worldObj.getEntitiesWithinAABB(classOf[EntityLiving], AxisAlignedBB.getBoundingBox(xCoord - TileReactorCell.RADIUS * 2, yCoord - TileReactorCell.RADIUS * 2, zCoord - TileReactorCell.RADIUS * 2, xCoord + TileReactorCell.RADIUS * 2, yCoord + TileReactorCell.RADIUS * 2, zCoord + TileReactorCell.RADIUS * 2)) val entities: List[EntityLiving] = worldObj.getEntitiesWithinAABB(classOf[EntityLiving], AxisAlignedBB.getBoundingBox(xCoord - TileReactorCell.RADIUS * 2, yCoord - TileReactorCell.RADIUS * 2, zCoord - TileReactorCell.RADIUS * 2, xCoord + TileReactorCell.RADIUS * 2, yCoord + TileReactorCell.RADIUS * 2, zCoord + TileReactorCell.RADIUS * 2)).asInstanceOf[List[EntityLiving]]
for (entity <- entities) { for (entity <- entities) {
PoisonRadiation.INSTANCE.poisonEntity(new Vector3(this), entity) PoisonRadiation.INSTANCE.poisonEntity(new Vector3(this), entity)
} }
@ -161,21 +149,21 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
} }
} }
} }
temperature = ThermalGrid.getTemperature(new Nothing(this)) temperature = ThermalGrid.getTemperature(new VectorWorld(this))
if (internalEnergy - prevInternalEnergy > 0) { if (internalEnergy - prevInternalEnergy > 0) {
var deltaT: Float = ThermalPhysics.getTemperatureForEnergy(mass, specificHeatCapacity, ((internalEnergy - prevInternalEnergy) * 0.15).asInstanceOf[Long]) var deltaT: Float = ThermalPhysics.getTemperatureForEnergy(mass, specificHeatCapacity, ((internalEnergy - prevInternalEnergy) * 0.15).asInstanceOf[Long])
var rods: Int = 0 var rods: Int = 0
for(i <- 6) { for(i <- 0 to 5) {
{ {
val checkAdjacent: Vector3 = new Vector3(this).add(ForgeDirection.getOrientation(i)) val checkAdjacent: Vector3 = new Vector3(this).add(ForgeDirection.getOrientation(i))
if (checkAdjacent.getBlock(worldObj) == Atomic.blockControlRod) { if (checkAdjacent.getBlock(worldObj) == AtomicContent.blockControlRod) {
deltaT /= 1.1 deltaT /= 1.1f
rods += 1 rods += 1
} }
} }
} }
ThermalGrid.addTemperature(new Nothing(this), deltaT) ThermalGrid.addTemperature(new VectorWorld(this), deltaT)
if (worldObj.rand.nextInt(80) == 0 && this.getTemperature >= 373) { if (worldObj.rand.nextInt(80) == 0 && this.getTemperature >= 373) {
worldObj.playSoundEffect(this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, "Fluid.lava", 0.5F, 2.1F + (worldObj.rand.nextFloat - worldObj.rand.nextFloat) * 0.85F) worldObj.playSoundEffect(this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, "Fluid.lava", 0.5F, 2.1F + (worldObj.rand.nextFloat - worldObj.rand.nextFloat) * 0.85F)
} }
@ -208,12 +196,12 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
val leakPos: VectorWorld = new VectorWorld(this).add(worldObj.rand.nextInt(20) - 10, worldObj.rand.nextInt(20) - 10, worldObj.rand.nextInt(20) - 10) val leakPos: VectorWorld = new VectorWorld(this).add(worldObj.rand.nextInt(20) - 10, worldObj.rand.nextInt(20) - 10, worldObj.rand.nextInt(20) - 10)
val block : Block = leakPos.getBlock val block : Block = leakPos.getBlock
if (block == Blocks.grass) { if (block == Blocks.grass) {
leakPos.setBlock(worldObj, Atomic.blockRadioactive) leakPos.setBlock(world, AtomicContent.blockRadioactive)
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true) tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
} }
else if (block == null) { else if (block == null) {
if (tank.getFluid != null) { if (tank.getFluid != null) {
leakPos.setBlock(worldObj, tank.getFluid.getFluid.getBlock) leakPos.setBlock(world, tank.getFluid.getFluid.getBlock)
tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true) tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true)
} }
} }
@ -222,7 +210,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
if (ticks % 60 == 0 || shouldUpdate) { if (ticks % 60 == 0 || shouldUpdate) {
shouldUpdate = false shouldUpdate = false
notifyChange notifyChange
PacketManager.sendPacketToClients(getDescriptionPacket, worldObj, new Vector3(this), 50) sendPacket(getDescPacket)
} }
} }
else { else {
@ -234,7 +222,7 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
} }
def isOverToxic: Boolean = { def isOverToxic: Boolean = {
return tank.getFluid != null && tank.getFluid.fluidID == Atomic.FLUID_TOXIC_WASTE.getID && tank.getFluid.amount >= tank.getCapacity return tank.getFluid != null && tank.getFluid.fluidID == AtomicContent.FLUID_TOXIC_WASTE.getID && tank.getFluid.amount >= tank.getCapacity
} }
/** Multiblock Methods */ /** Multiblock Methods */
@ -324,9 +312,9 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
private def meltDown { private def meltDown {
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.lava) this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.lava)
val reactorExplosion: ReactorExplosion = new ReactorExplosion(worldObj, null, xCoord, yCoord, zCoord, 9f) //val reactorExplosion: ReactorExplosion = new ReactorExplosion(worldObj, null, xCoord, yCoord, zCoord, 9f)
reactorExplosion.doExplosionA //reactorExplosion.doExplosionA
reactorExplosion.doExplosionB(true) //reactorExplosion.doExplosionB(true)
} }
} }
@ -388,20 +376,20 @@ class TileReactorCell extends TileInventory(Material.iron) with IMultiBlockStruc
} }
override def canFill(from: ForgeDirection, fluid: Fluid): Boolean = { override def canFill(from: ForgeDirection, fluid: Fluid): Boolean = {
return fluid eq Atomic.FLUID_PLASMA return fluid == AtomicContent.FLUID_PLASMA
} }
override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = { override def canDrain(from: ForgeDirection, fluid: Fluid): Boolean = {
return fluid eq Atomic.FLUID_TOXIC_WASTE return fluid == AtomicContent.FLUID_TOXIC_WASTE
} }
override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = { override def getTankInfo(from: ForgeDirection): Array[FluidTankInfo] = {
return Array[FluidTankInfo](tank.getInfo) return Array[FluidTankInfo](tank.getInfo)
} }
@SideOnly(Side.CLIENT) def getRenderBoundingBox: AxisAlignedBB = { @SideOnly(Side.CLIENT) override def getRenderBoundingBox: AxisAlignedBB = {
if (getMultiBlock.isPrimary && getMultiBlock.isConstructed) { if (getMultiBlock.isPrimary && getMultiBlock.isConstructed) {
return INFINITE_EXTENT_AABB return AxisAlignedBB.getBoundingBox(x - 5, y - 5, z - 5, x + 5, y + 5, z + 5);
} }
return super.getRenderBoundingBox return super.getRenderBoundingBox
} }

View file

@ -1,46 +1,27 @@
package resonantinduction.electrical package resonantinduction.electrical
import cpw.mods.fml.common.Mod.{EventHandler, Instance}
import cpw.mods.fml.common.event.{FMLInitializationEvent, FMLPostInitializationEvent, FMLPreInitializationEvent}
import cpw.mods.fml.common.network.NetworkRegistry
import cpw.mods.fml.common.registry.GameRegistry
import cpw.mods.fml.common.{Loader, Mod, ModMetadata, SidedProxy}
import ic2.api.item.IC2Items import ic2.api.item.IC2Items
import net.minecraft.block.Block import net.minecraft.init.{Blocks, Items}
import net.minecraft.init.Blocks
import net.minecraft.init.Items
import net.minecraft.item.Item
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraftforge.oredict.OreDictionary import net.minecraftforge.oredict.{OreDictionary, ShapedOreRecipe, ShapelessOreRecipe}
import net.minecraftforge.oredict.ShapedOreRecipe
import net.minecraftforge.oredict.ShapelessOreRecipe
import resonant.content.loader.ModManager import resonant.content.loader.ModManager
import resonant.lib.loadable.LoadableHandler import resonant.lib.loadable.LoadableHandler
import resonant.lib.recipe.UniversalRecipe import resonant.lib.recipe.UniversalRecipe
import resonantinduction.core.Reference import resonantinduction.atomic.gate.ItemQuantumGlyph
import resonantinduction.core.ResonantInduction
import resonantinduction.core.ResonantTab
import resonantinduction.core.Settings
import resonantinduction.core.resource.ItemResourcePart import resonantinduction.core.resource.ItemResourcePart
import resonantinduction.electrical.battery.BlockBattery import resonantinduction.core.{Reference, ResonantTab, Settings}
import resonantinduction.electrical.battery.ItemBlockBattery import resonantinduction.electrical.battery.{BlockBattery, ItemBlockBattery, TileBattery}
import resonantinduction.electrical.battery.TileBattery import resonantinduction.electrical.generator.{TileMotor, TileSolarPanel, TileThermopile}
import resonantinduction.electrical.generator.TileMotor
import resonantinduction.electrical.generator.TileSolarPanel
import resonantinduction.electrical.generator.TileThermopile
import resonantinduction.electrical.levitator.ItemLevitator import resonantinduction.electrical.levitator.ItemLevitator
import resonantinduction.electrical.multimeter.ItemMultimeter import resonantinduction.electrical.multimeter.ItemMultimeter
import resonantinduction.electrical.tesla.TileTesla import resonantinduction.electrical.tesla.TileTesla
import resonantinduction.electrical.transformer.ItemTransformer import resonantinduction.electrical.transformer.ItemTransformer
import resonantinduction.electrical.wire.EnumWireMaterial import resonantinduction.electrical.wire.{EnumWireMaterial, ItemWire}
import resonantinduction.electrical.wire.ItemWire
import resonantinduction.atomic.gate.ItemQuantumGlyph
import cpw.mods.fml.common.Loader
import cpw.mods.fml.common.Mod
import cpw.mods.fml.common.Mod.EventHandler
import cpw.mods.fml.common.Mod.Instance
import cpw.mods.fml.common.ModMetadata
import cpw.mods.fml.common.SidedProxy
import cpw.mods.fml.common.event.FMLInitializationEvent
import cpw.mods.fml.common.event.FMLPostInitializationEvent
import cpw.mods.fml.common.event.FMLPreInitializationEvent
import cpw.mods.fml.common.network.NetworkRegistry
import cpw.mods.fml.common.registry.GameRegistry
/** Resonant Induction Electrical Module /** Resonant Induction Electrical Module
* *
@ -49,54 +30,37 @@ object Electrical {
/** Mod Information */ /** Mod Information */
final val ID: String = "ResonantInduction|Electrical" final val ID: String = "ResonantInduction|Electrical"
final val NAME: String = Reference.name + " Electrical" final val NAME: String = Reference.name + " Electrical"
@Instance(ID) var INSTANCE: Electrical = null @Instance("ResonantInduction|Electrical") var INSTANCE: Electrical = null
@SidedProxy(clientSide = "ClientProxy", serverSide = "CommonProxy") var proxy: CommonProxy = null @SidedProxy(clientSide = "ClientProxy", serverSide = "CommonProxy") var proxy: CommonProxy = null
@Mod.Metadata(ID) var metadata: ModMetadata = null @Mod.Metadata("ResonantInduction|Electrical") var metadata: ModMetadata = null
final val contentRegistry: ModManager = new ModManager().setPrefix(Reference.prefix).setTab(ResonantTab.tab) final val contentRegistry: ModManager = new ModManager().setPrefix(Reference.prefix).setTab(ResonantTab.tab)
var itemWire: Item = null
var itemMultimeter: Item = null
var itemTransformer: Item = null
var itemCharger: Item = null
var blockTesla: Block = null
var blockBattery: Block = null
var blockEncoder: Block = null
var itemRailing: Item = null
var blockSolarPanel: Block = null
var blockMotor: Block = null
var blockThermopile: Block = null
var itemLevitator: Item = null
var blockArmbot: Block = null
var itemDisk: Item = null
var itemInsulation: Item = null
var blockQuantumGate: Block = null
var itemQuantumGlyph: Item = null
var itemLaserGun: Item = null
} }
@Mod(modid = Electrical.ID, name = Electrical.NAME, version = Reference.version, dependencies = "before:ThermalExpansion;before:Mekanism;after:ResonantInduction|Mechanical;required-after:" + Reference.coreID) class Electrical { @Mod(modid = "ResonantInduction|Electrical", name = "Resonant Induction Electrical", version = Reference.version, dependencies = "before:ThermalExpansion;before:Mekanism;after:ResonantInduction|Mechanical;required-after:" + Reference.coreID) class Electrical {
@EventHandler def preInit(evt: FMLPreInitializationEvent) { @EventHandler def preInit(evt: FMLPreInitializationEvent) {
modproxies = new LoadableHandler modproxies = new LoadableHandler
NetworkRegistry.INSTANCE.registerGuiHandler(this, Electrical.proxy) NetworkRegistry.INSTANCE.registerGuiHandler(this, Electrical.proxy)
Settings.config.load Settings.config.load
Electrical.itemWire = Electrical.contentRegistry.newItem(classOf[ItemWire]) ElectricalContent.itemWire = Electrical.contentRegistry.newItem(classOf[ItemWire])
Electrical.itemMultimeter = Electrical.contentRegistry.newItem(classOf[ItemMultimeter]) ElectricalContent.itemMultimeter = Electrical.contentRegistry.newItem(classOf[ItemMultimeter])
Electrical.itemTransformer = Electrical.contentRegistry.newItem(classOf[ItemTransformer]) ElectricalContent.itemTransformer = Electrical.contentRegistry.newItem(classOf[ItemTransformer])
Electrical.blockTesla = Electrical.contentRegistry.newBlock(classOf[TileTesla]) ElectricalContent.blockTesla = Electrical.contentRegistry.newBlock(classOf[TileTesla])
Electrical.blockBattery = Electrical.contentRegistry.newBlock(classOf[BlockBattery], classOf[ItemBlockBattery], classOf[TileBattery]) ElectricalContent.blockBattery = Electrical.contentRegistry.newBlock(classOf[BlockBattery], classOf[ItemBlockBattery], classOf[TileBattery])
Electrical.itemLevitator = Electrical.contentRegistry.newItem(classOf[ItemLevitator]) ElectricalContent.itemLevitator = Electrical.contentRegistry.newItem(classOf[ItemLevitator])
Electrical.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[ItemResourcePart]) ElectricalContent.itemInsulation = Electrical.contentRegistry.newItem("insulation", classOf[ItemResourcePart])
Electrical.blockSolarPanel = Electrical.contentRegistry.newBlock(classOf[TileSolarPanel]) ElectricalContent.blockSolarPanel = Electrical.contentRegistry.newBlock(classOf[TileSolarPanel])
Electrical.blockMotor = Electrical.contentRegistry.newBlock(classOf[TileMotor]) ElectricalContent.blockMotor = Electrical.contentRegistry.newBlock(classOf[TileMotor])
Electrical.blockThermopile = Electrical.contentRegistry.newBlock(classOf[TileThermopile]) ElectricalContent.blockThermopile = Electrical.contentRegistry.newBlock(classOf[TileThermopile])
Electrical.itemQuantumGlyph = Electrical.contentRegistry.newItem(classOf[ItemQuantumGlyph]) ElectricalContent.itemQuantumGlyph = Electrical.contentRegistry.newItem(classOf[ItemQuantumGlyph])
Settings.config.save Settings.config.save
OreDictionary.registerOre("wire", Electrical.itemWire) OreDictionary.registerOre("wire", ElectricalContent.itemWire)
OreDictionary.registerOre("motor", Electrical.blockMotor) OreDictionary.registerOre("motor", ElectricalContent.blockMotor)
OreDictionary.registerOre("battery", ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte])) OreDictionary.registerOre("battery", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte]))
OreDictionary.registerOre("batteryBox", ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte])) OreDictionary.registerOre("batteryBox", ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte]))
ResonantTab.itemStack(new ItemStack(Electrical.itemTransformer)) ResonantTab.itemStack(new ItemStack(ElectricalContent.itemTransformer))
for (material <- EnumWireMaterial.values) { for (material <- EnumWireMaterial.values) {
material.setWire(Electrical.itemWire) material.setWire(ElectricalContent.itemWire)
} }
Electrical.proxy.preInit Electrical.proxy.preInit
modproxies.preInit modproxies.preInit
@ -109,11 +73,11 @@ object Electrical {
} }
@EventHandler def postInit(evt: FMLPostInitializationEvent) { @EventHandler def postInit(evt: FMLPostInitializationEvent) {
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockTesla, "WEW", " C ", "DID", 'W', "wire", 'E', Items.ender_eye, 'C', UniversalRecipe.BATTERY.get, 'D', Items.diamond, 'I', UniversalRecipe.PRIMARY_PLATE.get)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockTesla, "WEW", " C ", "DID", 'W', "wire", 'E', Items.ender_eye, 'C', UniversalRecipe.BATTERY.get, 'D', Items.diamond, 'I', UniversalRecipe.PRIMARY_PLATE.get))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemMultimeter, "WWW", "ICI", 'W', "wire", 'C', UniversalRecipe.BATTERY.get, 'I', UniversalRecipe.PRIMARY_METAL.get)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemMultimeter, "WWW", "ICI", 'W', "wire", 'C', UniversalRecipe.BATTERY.get, 'I', UniversalRecipe.PRIMARY_METAL.get))
val tierOneBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte]) val tierOneBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 0.asInstanceOf[Byte])
val tierTwoBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 1.asInstanceOf[Byte]) val tierTwoBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 1.asInstanceOf[Byte])
val tierThreeBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 2.asInstanceOf[Byte]) val tierThreeBattery: ItemStack = ItemBlockBattery.setTier(new ItemStack(ElectricalContent.blockBattery, 1, 0), 2.asInstanceOf[Byte])
GameRegistry.addRecipe(new ShapedOreRecipe(tierOneBattery, "III", "IRI", "III", 'R', Blocks.redstone_block, 'I', UniversalRecipe.PRIMARY_METAL.get)) GameRegistry.addRecipe(new ShapedOreRecipe(tierOneBattery, "III", "IRI", "III", 'R', Blocks.redstone_block, 'I', UniversalRecipe.PRIMARY_METAL.get))
GameRegistry.addRecipe(new ShapedOreRecipe(tierTwoBattery, "RRR", "RIR", "RRR", 'R', tierOneBattery, 'I', UniversalRecipe.PRIMARY_PLATE.get)) GameRegistry.addRecipe(new ShapedOreRecipe(tierTwoBattery, "RRR", "RIR", "RRR", 'R', tierOneBattery, 'I', UniversalRecipe.PRIMARY_PLATE.get))
GameRegistry.addRecipe(new ShapedOreRecipe(tierThreeBattery, "RRR", "RIR", "RRR", 'R', tierTwoBattery, 'I', Blocks.diamond_block)) GameRegistry.addRecipe(new ShapedOreRecipe(tierThreeBattery, "RRR", "RIR", "RRR", 'R', tierTwoBattery, 'I', Blocks.diamond_block))
@ -124,16 +88,16 @@ object Electrical {
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SILVER.getWire, "MMM", 'M', "ingotSilver")) GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SILVER.getWire, "MMM", 'M', "ingotSilver"))
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", 'M', "ingotSuperconductor")) GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", 'M', "ingotSuperconductor"))
GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", "MEM", "MMM", 'M', Items.gold_ingot, 'E', Items.ender_eye)) GameRegistry.addRecipe(new ShapedOreRecipe(EnumWireMaterial.SUPERCONDUCTOR.getWire(3), "MMM", "MEM", "MMM", 'M', Items.gold_ingot, 'E', Items.ender_eye))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get, 'C', UniversalRecipe.CIRCUIT_T1.get)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemCharger, "WWW", "ICI", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get, 'C', UniversalRecipe.CIRCUIT_T1.get))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemTransformer, "WWW", "WWW", "III", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemTransformer, "WWW", "WWW", "III", 'W', "wire", 'I', UniversalRecipe.PRIMARY_METAL.get))
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 0), " CT", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 0), " CT", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla))
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 1), "TCT", "LBL", " CT", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 1), "TCT", "LBL", " CT", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla))
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 2), "TC ", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 2), "TC ", "LBL", "TCT", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla))
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Electrical.itemQuantumGlyph, 1, 3), "TCT", "LBL", "TC ", 'B', Blocks.diamond_block, 'L', Electrical.itemLevitator, 'C', Electrical.itemCharger, 'T', Electrical.blockTesla)) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ElectricalContent.itemQuantumGlyph, 1, 3), "TCT", "LBL", "TC ", 'B', Blocks.diamond_block, 'L', ElectricalContent.itemLevitator, 'C', ElectricalContent.itemCharger, 'T', ElectricalContent.blockTesla))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockSolarPanel, "CCC", "WWW", "III", 'W', "wire", 'C', Items.coal, 'I', UniversalRecipe.PRIMARY_METAL.get)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockSolarPanel, "CCC", "WWW", "III", 'W', "wire", 'C', Items.coal, 'I', UniversalRecipe.PRIMARY_METAL.get))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockMotor, "SRS", "SMS", "SWS", 'W', "wire", 'R', Items.redstone, 'M', Blocks.iron_block, 'S', UniversalRecipe.PRIMARY_METAL.get)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockMotor, "SRS", "SMS", "SWS", 'W', "wire", 'R', Items.redstone, 'M', Blocks.iron_block, 'S', UniversalRecipe.PRIMARY_METAL.get))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.blockThermopile, "ORO", "OWO", "OOO", 'W', "wire", 'O', Blocks.obsidian, 'R', Items.redstone)) GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.blockThermopile, "ORO", "OWO", "OOO", 'W', "wire", 'O', Blocks.obsidian, 'R', Items.redstone))
GameRegistry.addRecipe(new ShapedOreRecipe(Electrical.itemLaserGun, "RDR", "RDR", "ICB", 'R', Items.redstone, 'D', Items.diamond, 'I', Items.gold_ingot, 'C', UniversalRecipe.CIRCUIT_T2.get, 'B', ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte]))) //GameRegistry.addRecipe(new ShapedOreRecipe(ElectricalContent.itemLaserGun, "RDR", "RDR", "ICB", 'R', Items.redstone, 'D', Items.diamond, 'I', Items.gold_ingot, 'C', UniversalRecipe.CIRCUIT_T2.get, 'B', ItemBlockBattery.setTier(new ItemStack(Electrical.blockBattery, 1, 0), 0.asInstanceOf[Byte])))
if (Loader.isModLoaded("IC2")) { if (Loader.isModLoaded("IC2")) {
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.COPPER.getWire, IC2Items.getItem("copperCableItem"))) GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.COPPER.getWire, IC2Items.getItem("copperCableItem")))
GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.TIN.getWire, IC2Items.getItem("tinCableItem"))) GameRegistry.addRecipe(new ShapelessOreRecipe(EnumWireMaterial.TIN.getWire, IC2Items.getItem("tinCableItem")))

View file

@ -0,0 +1,37 @@
package resonantinduction.electrical
import net.minecraft.block.Block
import net.minecraft.item.Item
import resonant.content.loader.ContentHolder
/**
* Created by robert on 8/11/2014.
*/
object ElectricalContent extends ContentHolder {
var itemWire: Item = null
var itemMultimeter: Item = null
var itemTransformer: Item = null
var itemCharger: Item = null
var blockTesla: Block = null
var blockBattery: Block = null
var blockEncoder: Block = null
var itemRailing: Item = null
var blockSolarPanel: Block = null
var blockMotor: Block = null
var blockThermopile: Block = null
var itemLevitator: Item = null
var blockArmbot: Block = null
var itemDisk: Item = null
var itemInsulation: Item = null
var blockQuantumGate: Block = null
var itemQuantumGlyph: Item = null
var itemLaserGun: Item = null
override def postInit
{
}
}

View file

@ -2,28 +2,27 @@ package resonantinduction.electrical.battery;
import java.util.List; import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonant.lib.render.EnumColor; import resonant.lib.render.EnumColor;
import resonant.lib.utility.LanguageUtility; import resonant.lib.utility.LanguageUtility;
import universalelectricity.api.CompatibilityModule; import universalelectricity.api.UnitDisplay;
import universalelectricity.api.UniversalClass; import universalelectricity.api.UniversalClass;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.item.IEnergyItem; import universalelectricity.api.item.IEnergyItem;
import universalelectricity.api.item.IVoltageItem; import universalelectricity.compatibility.Compatibility;
@UniversalClass @UniversalClass
public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltageItem public class ItemBlockBattery extends ItemBlock implements IEnergyItem
{ {
public ItemBlockBattery(int id) public ItemBlockBattery(Block block)
{ {
super(id); super(block);
this.setMaxStackSize(1); this.setMaxStackSize(1);
this.setMaxDamage(100); this.setMaxDamage(100);
this.setNoRepair(); this.setNoRepair();
@ -36,7 +35,7 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage
list.add(LanguageUtility.getLocal("tooltip.tier") + ": " + (getTier(itemStack) + 1)); list.add(LanguageUtility.getLocal("tooltip.tier") + ": " + (getTier(itemStack) + 1));
String color = ""; String color = "";
long joules = this.getEnergy(itemStack); double joules = this.getEnergy(itemStack);
if (joules <= this.getEnergyCapacity(itemStack) / 3) if (joules <= this.getEnergyCapacity(itemStack) / 3)
{ {
@ -51,7 +50,7 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage
color = "\u00a76"; color = "\u00a76";
} }
itemStack.getItemDamageForDisplay(); itemStack.getItemDamageForDisplay();
list.add(LanguageUtility.getLocal("tooltip.battery.energy").replace("%0", color).replace("%1", EnumColor.GREY.toString()).replace("%v0", UnitDisplay.getDisplayShort(joules, Unit.JOULES)).replace("%v1", UnitDisplay.getDisplayShort(this.getEnergyCapacity(itemStack), Unit.JOULES))); list.add(LanguageUtility.getLocal("tooltip.battery.energy").replace("%0", color).replace("%1", EnumColor.GREY.toString()).replace("%v0", new UnitDisplay(UnitDisplay.Unit.JOULES, joules).toString()).replace("%v1", new UnitDisplay(UnitDisplay.Unit.JOULES, this.getEnergyCapacity(itemStack), true).toString()));
} }
/** /**
@ -65,10 +64,10 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage
} }
@Override @Override
public long recharge(ItemStack itemStack, long energy, boolean doReceive) public double recharge(ItemStack itemStack, double energy, boolean doReceive)
{ {
long rejectedElectricity = Math.max((this.getEnergy(itemStack) + energy) - this.getEnergyCapacity(itemStack), 0); double rejectedElectricity = Math.max((this.getEnergy(itemStack) + energy) - this.getEnergyCapacity(itemStack), 0);
long energyToReceive = Math.min(energy - rejectedElectricity, getTransferRate(itemStack)); double energyToReceive = Math.min(energy - rejectedElectricity, getTransferRate(itemStack));
if (doReceive) if (doReceive)
{ {
@ -79,9 +78,9 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage
} }
@Override @Override
public long discharge(ItemStack itemStack, long energy, boolean doTransfer) public double discharge(ItemStack itemStack, double energy, boolean doTransfer)
{ {
long energyToExtract = Math.min(Math.min(this.getEnergy(itemStack), energy), getTransferRate(itemStack)); double energyToExtract = Math.min(Math.min(this.getEnergy(itemStack), energy), getTransferRate(itemStack));
if (doTransfer) if (doTransfer)
{ {
@ -92,31 +91,31 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage
} }
@Override @Override
public long getVoltage(ItemStack itemStack) public double getVoltage(ItemStack itemStack)
{ {
return UniversalElectricity.DEFAULT_VOLTAGE; return 240;
} }
@Override @Override
public void setEnergy(ItemStack itemStack, long joules) public void setEnergy(ItemStack itemStack, double joules)
{ {
if (itemStack.getTagCompound() == null) if (itemStack.getTagCompound() == null)
{ {
itemStack.setTagCompound(new NBTTagCompound()); itemStack.setTagCompound(new NBTTagCompound());
} }
long electricityStored = Math.max(Math.min(joules, this.getEnergyCapacity(itemStack)), 0); double electricityStored = Math.max(Math.min(joules, this.getEnergyCapacity(itemStack)), 0);
itemStack.getTagCompound().setLong("electricity", electricityStored); itemStack.getTagCompound().setDouble("electricity", electricityStored);
} }
public long getTransfer(ItemStack itemStack) public double getTransfer(ItemStack itemStack)
{ {
return this.getEnergyCapacity(itemStack) - this.getEnergy(itemStack); return this.getEnergyCapacity(itemStack) - this.getEnergy(itemStack);
} }
/** Gets the energy stored in the item. Energy is stored using item NBT */ /** Gets the energy stored in the item. Energy is stored using item NBT */
@Override @Override
public long getEnergy(ItemStack itemStack) public double getEnergy(ItemStack itemStack)
{ {
if (itemStack.getTagCompound() == null) if (itemStack.getTagCompound() == null)
{ {
@ -154,24 +153,24 @@ public class ItemBlockBattery extends ItemBlock implements IEnergyItem, IVoltage
} }
@Override @Override
public long getEnergyCapacity(ItemStack theItem) public double getEnergyCapacity(ItemStack theItem)
{ {
return TileBattery.getEnergyForTier(getTier(theItem)); return TileBattery.getEnergyForTier(getTier(theItem));
} }
public long getTransferRate(ItemStack itemStack) public double getTransferRate(ItemStack itemStack)
{ {
return this.getEnergyCapacity(itemStack) / 100; return this.getEnergyCapacity(itemStack) / 100;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{ {
for (byte tier = 0; tier <= TileBattery.MAX_TIER; tier++) for (byte tier = 0; tier <= TileBattery.MAX_TIER; tier++)
{ {
par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), tier), 0)); par3List.add(Compatibility.getItemWithCharge(setTier(new ItemStack(this), tier), 0));
par3List.add(CompatibilityModule.getItemWithCharge(setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier))); par3List.add(Compatibility.getItemWithCharge(setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier)));
} }
} }
} }