Sirens now function electrically

This commit is contained in:
Calclavia 2015-01-27 17:05:20 +08:00
parent cb3e2de7f8
commit b090a1c933
49 changed files with 276 additions and 984 deletions

View File

@ -10,5 +10,11 @@
"sounds": [
"gearCrank"
]
},
"siren": {
"category": "ambient",
"sounds": [
"siren"
]
}
}

View File

@ -31,8 +31,7 @@ object BasicContent extends ContentHolder
var itemHammer: Item = new ItemHammer
var itemHandCrank: Item = new ItemHandCrank
// var blockEngineeringTable: Block = new TileEngineeringTable
//manager.newBlock(classOf[BlockCrate])
var blockWorkbench: Block = new TileWorkbench
var blockImprinter: Block = new TileImprinter
var blockTurntable: Block = new TileTurntable
var blockFirebox: Block = new TileFirebox
@ -41,10 +40,8 @@ object BasicContent extends ContentHolder
var blockCast: Block = new TileCastingMold
var blockGutter: Block = new TileGutter
var blockTank: Block = new TileTank
var blockWorkbench: Block = new TileWorkbench
var blockGlassJar: Block = new TileGlassJar
//var blockFilter: Block = contentRegistry.newBlock( classOf[ TileFilter ] )
var blockGrate: Block = new TileGrate
//Constructor
@ -53,13 +50,6 @@ object BasicContent extends ContentHolder
override def postInit()
{
//recipes += shaped(ArchaicContent.blockEngineeringTable, "P", "C", 'P', Blocks.wooden_pressure_plate, 'C', Blocks.crafting_table)
//recipes += shaped(ArchaicBlocks.blockFilter, "B", "P", "B", 'B', Blocks.iron_bars, 'P', Items.paper)
//recipes += shaped(new ItemStack(ArchaicBlocks.blockCrate, 1, 0), "WWW", "WSW", "WWW", 'S', "stickWood", 'W', "logWood")
//recipes += new CrateRecipe(new ItemStack(ArchaicBlocks.blockCrate, 1, 1), "WWW", "WSW", "WWW", 'S', new ItemStack(ArchaicBlocks.blockCrate, 1, 0), 'W', "ingotIron")
//recipes +=new CrateRecipe(new ItemStack(ArchaicBlocks.blockCrate, 1, 2), "WWW", "WSW", "WWW", 'S', new ItemStack(ArchaicBlocks.blockCrate, 1, 1), 'W', UniversalRecipe.PRIMARY_METAL.get)
recipes += shaped(BasicContent.blockFirebox, "III", "SFS", "SSS", 'I', Items.iron_ingot, 'F', Blocks.furnace, 'S', Blocks.stone)
recipes += shaped(new ItemStack(BasicContent.blockFirebox, 1, 1), "III", "SFS", "SSS", 'I', UniversalRecipe.PRIMARY_METAL.get, 'F', new ItemStack(BasicContent.blockFirebox, 1, 0), 'S', UniversalRecipe.WIRE.get)
recipes += shaped(BasicContent.blockImprinter, "SSS", "W W", "PPP", 'S', Blocks.stone, 'P', Blocks.piston, 'W', "logWood")

View File

@ -1,686 +0,0 @@
package edx.basic.engineering
import java.util.ArrayList
import codechicken.multipart.ControlKeyModifer
import cpw.mods.fml.common.network.ByteBufUtils
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.basic.blocks.ItemImprint
import edx.basic.process.grinding.ItemHammer
import edx.core.{Electrodynamics, Reference}
import io.netty.buffer.ByteBuf
import net.minecraft.block.Block
import net.minecraft.block.material.Material
import net.minecraft.client.renderer.texture.IIconRegister
import net.minecraft.entity.player.{EntityPlayer, EntityPlayerMP, InventoryPlayer}
import net.minecraft.inventory.{IInventory, ISidedInventory, InventoryCrafting}
import net.minecraft.item.crafting.CraftingManager
import net.minecraft.item.{Item, ItemStack}
import net.minecraft.nbt.{NBTTagCompound, NBTTagList}
import net.minecraft.network.Packet
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.{ChatComponentText, IIcon}
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.oredict.OreDictionary
import org.apache.commons.lang3.ArrayUtils
import org.lwjgl.opengl.GL11
import resonantengine.api.edx.recipe.{MachineRecipes, RecipeResource, RecipeType}
import resonantengine.api.gui.ISlotPickResult
import resonantengine.api.network.IPacketReceiver
import resonantengine.api.tile.IRotatable
import resonantengine.core.ResonantEngine
import resonantengine.core.network.discriminator.{PacketTile, PacketType}
import resonantengine.lib.collection.Pair
import resonantengine.lib.render.RenderItemOverlayUtility
import resonantengine.lib.transform.region.Cuboid
import resonantengine.lib.transform.vector.{Vector2, Vector3}
import resonantengine.lib.utility.LanguageUtility
import resonantengine.lib.utility.inventory.AutoCraftingManager.IAutoCrafter
import resonantengine.lib.utility.inventory.{AutoCraftingManager, InventoryUtility}
import resonantengine.prefab.block.itemblock.ItemBlockSaved
import resonantengine.prefab.block.mixed.TileInventory
import resonantengine.prefab.gui.ContainerDummy
import scala.collection.JavaConversions._
/**
* Advanced crafting table that stores its crafting grid, can craft out of the player's inv, and be
* configed to auto craft.
*
* @author DarkGuardsman, Calclavia
*/
object TileEngineeringTable
{
val CRAFTING_MATRIX_END: Int = 9
val CRAFTING_OUTPUT_END: Int = CRAFTING_MATRIX_END + 1
val PLAYER_OUTPUT_END: Int = CRAFTING_OUTPUT_END + 40
val CENTER_SLOT: Int = 4
val CRAFTING_OUTPUT_SLOT: Int = 0
/**
* 9 slots for crafting, 1 slot for a output.
*/
val CRAFTING_MATRIX_SIZE: Int = 9
val craftingSlots: Array[Int] = Array(0, 1, 2, 3, 4, 5, 6, 7, 8)
@SideOnly(Side.CLIENT) private var iconTop: IIcon = null
@SideOnly(Side.CLIENT) private var iconFront: IIcon = null
@SideOnly(Side.CLIENT) private var iconSide: IIcon = null
}
class TileEngineeringTable extends TileInventory(Material.wood) with IPacketReceiver with IRotatable with ISidedInventory with ISlotPickResult with IAutoCrafter
{
var craftingMatrix: Array[ItemStack] = new Array[ItemStack](TileEngineeringTable.CRAFTING_MATRIX_SIZE)
/**
* The output inventory containing slots.
*/
var outputInventory: Array[ItemStack] = new Array[ItemStack](1)
/**
* The ability for the engineering table to search nearby inventories.
*/
var searchInventories: Boolean = true
private var craftManager: AutoCraftingManager = null
/**
* Temporary player inventory stored to draw the player's items.
*/
private var invPlayer: InventoryPlayer = null
private var playerSlots: Array[Int] = null
//Constructor
bounds = new Cuboid(0, 0, 0, 1, 0.9f, 1)
isOpaqueCube = false
itemBlock(classOf[ItemBlockSaved])
@SideOnly(Side.CLIENT)
override def getIcon(side: Int, meta: Int): IIcon =
{
return if (side == 1) TileEngineeringTable.iconTop else (if (side == meta) TileEngineeringTable.iconFront else TileEngineeringTable.iconSide)
}
@SideOnly(Side.CLIENT)
override def registerIcons(iconRegister: IIconRegister)
{
TileEngineeringTable.iconTop = iconRegister.registerIcon(getTextureName + "_top")
TileEngineeringTable.iconFront = iconRegister.registerIcon(getTextureName + "_front")
TileEngineeringTable.iconSide = iconRegister.registerIcon(getTextureName + "_side")
}
override def click(player: EntityPlayer)
{
if (!world.isRemote && ControlKeyModifer.isControlDown(player))
{
{
var i: Int = 0
while (i < getSizeInventory - 1)
{
{
if (getStackInSlot(i) != null)
{
InventoryUtility.dropItemStack(world, new Vector3(player), getStackInSlot(i))
setInventorySlotContents(i, null)
}
}
({
i += 1;
i
})
}
}
}
}
override def getSizeInventory: Int =
{
return 10 + (if (this.invPlayer != null) this.invPlayer.getSizeInventory else 0)
}
override def setInventorySlotContents(slot: Int, itemStack: ItemStack)
{
if (slot < TileEngineeringTable.CRAFTING_MATRIX_END)
{
craftingMatrix(slot) = itemStack
}
else if (slot < TileEngineeringTable.CRAFTING_OUTPUT_END)
{
outputInventory(slot - TileEngineeringTable.CRAFTING_MATRIX_END) = itemStack
}
else if (slot < TileEngineeringTable.PLAYER_OUTPUT_END && this.invPlayer != null)
{
this.invPlayer.setInventorySlotContents(slot - TileEngineeringTable.CRAFTING_OUTPUT_END, itemStack)
val player: EntityPlayer = this.invPlayer.player
if (player.isInstanceOf[EntityPlayerMP])
{
(player.asInstanceOf[EntityPlayerMP]).sendContainerToPlayer(player.inventoryContainer)
}
}
else if (searchInventories)
{
var idDisplacement: Int = TileEngineeringTable.PLAYER_OUTPUT_END
for (dir <- ForgeDirection.VALID_DIRECTIONS)
{
val tile: TileEntity = position.add(dir).getTileEntity
if (tile.isInstanceOf[IInventory])
{
val inventory: IInventory = tile.asInstanceOf[IInventory]
val slotID: Int = slot - idDisplacement
if (slotID >= 0 && slotID < inventory.getSizeInventory)
{
inventory.setInventorySlotContents(slotID, itemStack)
}
idDisplacement += inventory.getSizeInventory
}
}
}
onInventoryChanged
}
/**
* Updates all the output slots. Call this to update the Engineering Table.
*/
override def onInventoryChanged
{
if (worldObj != null)
{
if (!worldObj.isRemote)
{
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = null
var didCraft: Boolean = false
val inventoryCrafting: InventoryCrafting = this.getCraftingMatrix
val matrixOutput: ItemStack = CraftingManager.getInstance.findMatchingRecipe(inventoryCrafting, this.worldObj)
if (matrixOutput != null && this.getCraftingManager.getIdealRecipe(matrixOutput) != null)
{
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = matrixOutput
didCraft = true
}
if (!didCraft)
{
val filterStack: ItemStack = craftingMatrix(TileEngineeringTable.CENTER_SLOT)
if (filterStack != null && filterStack.getItem.isInstanceOf[ItemImprint])
{
val filters: java.util.List[ItemStack] = ItemImprint.getFilters(filterStack)
for (o <- filters)
{
val outputStack: ItemStack = o
if (outputStack != null)
{
val idealRecipe: Pair[ItemStack, Array[ItemStack]] = this.getCraftingManager.getIdealRecipe(outputStack)
if (idealRecipe != null)
{
val recipeOutput: ItemStack = idealRecipe.left
if (recipeOutput != null & recipeOutput.stackSize > 0)
{
this.outputInventory(TileEngineeringTable.CRAFTING_OUTPUT_SLOT) = recipeOutput
didCraft = true
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
return
}
}
}
}
}
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
}
}
}
/**
* Gets the AutoCraftingManager that does all the crafting results
*/
def getCraftingManager: AutoCraftingManager =
{
if (craftManager == null)
{
craftManager = new AutoCraftingManager(this)
}
return craftManager
}
/**
* Construct an InventoryCrafting Matrix on the fly.
*
* @return
*/
def getCraftingMatrix: InventoryCrafting =
{
val inventoryCrafting: InventoryCrafting = new InventoryCrafting(new ContainerDummy(this), 3, 3)
for (i <- 0 until this.craftingMatrix.length)
{
inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix(i))
}
return inventoryCrafting
}
override def use(player: EntityPlayer, hitSide: Int, hit: Vector3): Boolean =
{
if (player.getCurrentEquippedItem != null && player.getCurrentEquippedItem.getItem.isInstanceOf[ItemHammer])
{
for (slot <- 0 to TileEngineeringTable.CRAFTING_OUTPUT_END)
{
val inputStack: ItemStack = getStackInSlot(slot)
if (inputStack != null)
{
val oreName: String = OreDictionary.getOreName(OreDictionary.getOreID(inputStack))
if (oreName != null && !(oreName == "Unknown"))
{
val outputs: Array[RecipeResource] = MachineRecipes.instance.getOutput(RecipeType.GRINDER.name, oreName)
if (outputs != null && outputs.length > 0)
{
if (!world.isRemote && world.rand.nextFloat < 0.2)
{
for (resource <- outputs)
{
val outputStack: ItemStack = resource.getItemStack.copy
if (outputStack != null)
{
InventoryUtility.dropItemStack(world, new Vector3(player), outputStack, 0)
setInventorySlotContents(slot, if (({
inputStack.stackSize -= 1;
inputStack.stackSize
}) <= 0) null
else inputStack)
}
}
}
Electrodynamics.proxy.renderBlockParticle(world, new Vector3(x + 0.5, y + 0.5, z + 0.5), new Vector3((Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3, (Math.random - 0.5f) * 3), Item.getIdFromItem(inputStack.getItem), 1)
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Reference.prefix + "hammer", 0.5f, 0.8f + (0.2f * world.rand.nextFloat))
player.addExhaustion(0.1f)
player.getCurrentEquippedItem.damageItem(1, player)
return true
}
}
}
}
return true
}
if (hitSide == 1)
{
if (!world.isRemote)
{
val hitVector: Vector3 = new Vector3(hit.x, 0, hit.z)
val regionLength: Double = 1d / 3d
for (j <- 0 to 3)
{
for (k <- 0 to 3)
{
val check: Vector2 = new Vector2(j, k).multiply(regionLength)
if (check.distance(hitVector.toVector2) < regionLength)
{
val slotID: Int = j * 3 + k
interactCurrentItem(this, slotID, player)
onInventoryChanged
return true
}
}
}
onInventoryChanged
}
return true
}
else if (hitSide != 0)
{
if (!world.isRemote)
{
setPlayerInventory(player.inventory)
var output: ItemStack = getStackInSlot(9)
var firstLoop: Boolean = true
while (output != null && (firstLoop || ControlKeyModifer.isControlDown(player)))
{
onPickUpFromSlot(player, 9, output)
if (output.stackSize > 0)
{
InventoryUtility.dropItemStack(world, new Vector3(player), output, 0)
}
setInventorySlotContents(9, null)
onInventoryChanged
output = getStackInSlot(9)
firstLoop = false
}
setPlayerInventory(null)
}
return true
}
return false
}
/**
* Creates a "fake inventory" and hook the player up to the crafter to use the player's items.
*/
def setPlayerInventory(invPlayer: InventoryPlayer)
{
if (searchInventories)
{
if (invPlayer != null)
{
playerSlots = new Array[Int](invPlayer.getSizeInventory)
for (i <- 0 until playerSlots.length)
{
playerSlots(i) = i + TileEngineeringTable.CRAFTING_OUTPUT_END
}
}
else
{
playerSlots = null
}
this.invPlayer = invPlayer
}
}
def onPickUpFromSlot(entityPlayer: EntityPlayer, slotID: Int, itemStack: ItemStack)
{
if (!worldObj.isRemote)
{
if (itemStack != null)
{
val idealRecipeItem: Pair[ItemStack, Array[ItemStack]] = getCraftingManager.getIdealRecipe(itemStack)
if (idealRecipeItem != null)
{
getCraftingManager.consumeItems(idealRecipeItem.right.clone: _*)
}
else
{
itemStack.stackSize = 0
}
}
}
}
override def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
{
if (player.isSneaking)
{
searchInventories = !searchInventories
if (!world.isRemote)
{
if (searchInventories)
{
player.addChatMessage(new ChatComponentText(LanguageUtility.getLocal("engineerTable.config.inventory.true")))
}
else
{
player.addChatMessage(new ChatComponentText(LanguageUtility.getLocal("engineerTable.config.inventory.false")))
}
}
markUpdate
return true
}
return super.configure(player, side, hit)
}
override def getDrops(metadata: Int, fortune: Int): ArrayList[ItemStack] = new ArrayList[ItemStack]
override def onRemove(block: Block, par6: Int)
{
val stack: ItemStack = ItemBlockSaved.getItemStackWithNBT(block, world, x, y, z)
InventoryUtility.dropItemStack(world, center, stack)
}
override def canUpdate: Boolean =
{
return false
}
override def getDescriptionPacket: Packet =
{
val nbt: NBTTagCompound = new NBTTagCompound
this.writeToNBT(nbt)
return ResonantEngine.packetHandler.toMCPacket(new PacketTile(this, nbt))
}
/**
* Writes a tile entity to NBT.
*/
override def writeToNBT(nbt: NBTTagCompound)
{
super.writeToNBT(nbt)
val nbtList: NBTTagList = new NBTTagList
for (i <- 0 to this.getSizeInventory)
{
if (this.getStackInSlot(i) != null)
{
val var4: NBTTagCompound = new NBTTagCompound
var4.setByte("Slot", i.asInstanceOf[Byte])
this.getStackInSlot(i).writeToNBT(var4)
nbtList.appendTag(var4)
}
}
nbt.setTag("Items", nbtList)
nbt.setBoolean("searchInventories", this.searchInventories)
}
def read(data: ByteBuf, player: EntityPlayer, `type`: PacketType)
{
try
{
readFromNBT(ByteBufUtils.readTag(data))
}
catch
{
case e: Exception =>
{
e.printStackTrace
}
}
}
/**
* NBT Data
*/
override def readFromNBT(nbt: NBTTagCompound)
{
super.readFromNBT(nbt)
val nbtList: NBTTagList = nbt.getTagList("Items", 0)
this.craftingMatrix = new Array[ItemStack](9)
this.outputInventory = new Array[ItemStack](1)
for (i <- 0 to nbtList.tagCount)
{
val stackTag: NBTTagCompound = nbtList.getCompoundTagAt(i)
val id: Byte = stackTag.getByte("Slot")
if (id >= 0 && id < this.getSizeInventory)
{
this.setInventorySlotContents(id, ItemStack.loadItemStackFromNBT(stackTag))
}
}
this.searchInventories = nbt.getBoolean("searchInventories")
}
override def decrStackSize(i: Int, amount: Int): ItemStack =
{
if (getStackInSlot(i) != null)
{
var stack: ItemStack = null
if (getStackInSlot(i).stackSize <= amount)
{
stack = getStackInSlot(i)
setInventorySlotContents(i, null)
return stack
}
else
{
stack = getStackInSlot(i).splitStack(amount)
if (getStackInSlot(i).stackSize == 0)
{
setInventorySlotContents(i, null)
}
return stack
}
}
else
{
return null
}
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as
* an EntityItem - like when you close a workbench GUI.
*/
override def getStackInSlotOnClosing(slot: Int): ItemStack =
{
if (this.getStackInSlot(slot) != null)
{
val var2: ItemStack = this.getStackInSlot(slot)
this.setInventorySlotContents(slot, null)
return var2
}
else
{
return null
}
}
override def isItemValidForSlot(i: Int, itemstack: ItemStack): Boolean =
{
return true
}
override def getInventoryStackLimit: Int =
{
return 64
}
override def isUseableByPlayer(entityplayer: EntityPlayer): Boolean =
{
return if (this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) ne this) false else entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D
}
override def getAccessibleSlotsFromSide(side: Int): Array[Int] =
{
return new Array[Int](0)
}
/**
* Auto-crafting methods.
*/
override def canInsertItem(slot: Int, itemstack: ItemStack, side: Int): Boolean =
{
if (getStackInSlot(4) != null && getStackInSlot(4).getItem.isInstanceOf[ItemImprint])
{
return true
}
var minSize: Int = 64
var optimalSlot: Int = -1
for (i <- 0 to craftingMatrix.length)
{
val checkStack: ItemStack = getStackInSlot(i)
if (checkStack != null && checkStack.isItemEqual(itemstack))
{
if (checkStack.stackSize < minSize || optimalSlot < 0)
{
optimalSlot = i
minSize = checkStack.stackSize
}
}
}
return slot == optimalSlot
}
/**
* DO NOT USE THIS INTERNALLY. FOR EXTERNAL USE ONLY!
*/
override def getStackInSlot(slot: Int): ItemStack =
{
if (slot < TileEngineeringTable.CRAFTING_MATRIX_END)
{
return this.craftingMatrix(slot)
}
else if (slot < TileEngineeringTable.CRAFTING_OUTPUT_END)
{
return outputInventory(slot - TileEngineeringTable.CRAFTING_MATRIX_END)
}
else if (slot < TileEngineeringTable.PLAYER_OUTPUT_END && invPlayer != null)
{
return this.invPlayer.getStackInSlot(slot - TileEngineeringTable.CRAFTING_OUTPUT_END)
}
else if (searchInventories)
{
var idDisplacement: Int = TileEngineeringTable.PLAYER_OUTPUT_END
for (dir <- ForgeDirection.VALID_DIRECTIONS)
{
val tile: TileEntity = position.add(dir).getTileEntity
if (tile.isInstanceOf[IInventory])
{
val inventory: IInventory = tile.asInstanceOf[IInventory]
val slotID: Int = slot - idDisplacement
if (slotID >= 0 && slotID < inventory.getSizeInventory)
{
return inventory.getStackInSlot(slotID)
}
idDisplacement += inventory.getSizeInventory
}
}
}
return null
}
override def canExtractItem(slot: Int, itemstack: ItemStack, side: Int): Boolean =
{
val outputStack: ItemStack = getStackInSlot(TileEngineeringTable.CRAFTING_MATRIX_END)
if (outputStack != null)
{
val idealRecipeItem: Pair[ItemStack, Array[ItemStack]] = this.getCraftingManager.getIdealRecipe(outputStack)
val doubleResults: Array[ItemStack] = ArrayUtils.addAll(idealRecipeItem.right, idealRecipeItem.right: _*)
if (!getCraftingManager.consumeItems(false, doubleResults: _*))
{
return false
}
}
return slot == TileEngineeringTable.CRAFTING_MATRIX_END
}
def getCraftingInv: Array[Int] =
{
var slots: Array[Int] = TileEngineeringTable.craftingSlots
if (playerSlots != null)
{
slots = ArrayUtils.addAll(playerSlots, slots: _*)
}
if (searchInventories)
{
var temporaryInvID: Int = TileEngineeringTable.PLAYER_OUTPUT_END
for (dir <- ForgeDirection.VALID_DIRECTIONS)
{
val tile: TileEntity = position.add(dir).getTileEntity(worldObj)
if (tile.isInstanceOf[IInventory])
{
val inventory: IInventory = tile.asInstanceOf[IInventory]
val nearbySlots: Array[Int] = new Array[Int](inventory.getSizeInventory)
for (i <- 0 to inventory.getSizeInventory)
{
temporaryInvID = temporaryInvID + 1;
nearbySlots(i) = temporaryInvID;
}
slots = ArrayUtils.addAll(nearbySlots, slots: _*)
}
}
}
return slots
}
override def renderDynamic(position: Vector3, frame: Float, pass: Int)
{
GL11.glPushMatrix
RenderItemOverlayUtility.renderItemOnSides(TileEngineeringTable.this, getStackInSlot(9), position.x, position.y, position.z)
RenderItemOverlayUtility.renderTopOverlay(TileEngineeringTable.this, craftingMatrix, getDirection, position.x, position.y - 0.1, position.z)
GL11.glPopMatrix
}
override def getDirection: ForgeDirection =
{
return null
}
override def setDirection(direction: ForgeDirection)
{
}
}

View File

@ -10,9 +10,10 @@ import edx.basic.process.smelting.firebox.{RenderHotPlate, TileHotPlate}
import edx.basic.process.smelting.{RenderCastingMold, TileCastingMold}
import edx.core.fx.FXElectricBolt
import edx.electrical.ElectricalContent
import edx.electrical.circuit.component.laser.fx.{EntityBlockParticleFX, EntityLaserFX, EntityScorchFX}
import edx.electrical.circuit.component.tesla.{RenderTesla, TileTesla}
import edx.electrical.circuit.transformer.RenderTransformer
import edx.electrical.multimeter.{GuiMultimeter, PartMultimeter, RenderMultimeter}
import edx.electrical.tesla.{RenderTesla, TileTesla}
import edx.electrical.transformer.RenderTransformer
import edx.mechanical.MechanicalContent
import edx.mechanical.fluid.pipe.RenderPipe
import edx.mechanical.mech.gear.RenderGear
@ -20,7 +21,6 @@ import edx.mechanical.mech.gearshaft.RenderGearShaft
import edx.mechanical.mech.process.crusher.{RenderMechanicalPiston, TileMechanicalPiston}
import edx.mechanical.mech.turbine._
import edx.quantum.gate.RenderQuantumGlyph
import edx.quantum.laser.fx.{EntityBlockParticleFX, EntityLaserFX, EntityScorchFX}
import edx.quantum.machine.accelerator.{EntityParticle, RenderParticle}
import edx.quantum.machine.boiler.{GuiNuclearBoiler, RenderNuclearBoiler, TileNuclearBoiler}
import edx.quantum.machine.centrifuge.{GuiCentrifuge, RenderCentrifuge, TileCentrifuge}

View File

@ -1,7 +1,7 @@
package edx.core.prefab.part.connector
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import edx.core.util.ResonantUtil
import edx.core.util.ColorUtil
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
@ -33,7 +33,7 @@ trait TColorable extends PartAbstract
{
if (itemStack != null)
{
val dyeColor = ResonantUtil.isDye(itemStack)
val dyeColor = ColorUtil.isDye(itemStack)
if (dyeColor != -1)
{

View File

@ -7,7 +7,7 @@ import net.minecraftforge.oredict.OreDictionary
* General Utility
* @author Calclavia
*/
object ResonantUtil
object ColorUtil
{
val dyes = Array("dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite")
val dyeColors = Array[Int](1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320)

View File

@ -5,18 +5,19 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent
import cpw.mods.fml.common.registry.GameRegistry
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.{EDXCreativeTab, Reference, ResonantPartFactory}
import edx.electrical.battery.{ItemBlockBattery, TileBattery}
import edx.electrical.generator.{TileMotor, TileSolarPanel, TileThermopile}
import edx.electrical.circuit.component.TileSiren
import edx.electrical.circuit.component.laser.focus.{ItemFocusingMatrix, TileFocusCrystal, TileMirror}
import edx.electrical.circuit.component.laser.{TileLaserEmitter, TileLaserReceiver}
import edx.electrical.circuit.component.tesla.TileTesla
import edx.electrical.circuit.source.battery.{ItemBlockBattery, TileBattery}
import edx.electrical.circuit.source.{TileMotor, TileSolarPanel, TileThermopile}
import edx.electrical.circuit.transformer.{ItemElectricTransformer, PartElectricTransformer}
import edx.electrical.circuit.wire.ItemWire
import edx.electrical.circuit.wire.base.WireMaterial
import edx.electrical.circuit.wire.flat.{PartFlatWire, RenderFlatWire}
import edx.electrical.circuit.wire.framed.{PartFramedWire, RenderFramedWire}
import edx.electrical.multimeter.{ItemMultimeter, PartMultimeter}
import edx.electrical.tesla.TileTesla
import edx.electrical.transformer.{ItemElectricTransformer, PartElectricTransformer}
import edx.electrical.wire.ItemWire
import edx.electrical.wire.base.WireMaterial
import edx.electrical.wire.flat.{PartFlatWire, RenderFlatWire}
import edx.electrical.wire.framed.{PartFramedWire, RenderFramedWire}
import edx.quantum.gate.{ItemQuantumGlyph, PartQuantumGlyph}
import edx.quantum.laser.focus.{ItemFocusingMatrix, TileFocusCrystal, TileMirror}
import edx.quantum.laser.{TileLaserEmitter, TileLaserReceiver}
import ic2.api.item.IC2Items
import net.minecraft.block.Block
import net.minecraft.init.{Blocks, Items}
@ -36,7 +37,8 @@ object ElectricalContent extends ContentHolder
var itemWire = new ItemWire
var itemMultimeter = new ItemMultimeter
var itemTransformer = new ItemElectricTransformer
@ExplicitContentName("insulation") var itemInsulation = new Item
@ExplicitContentName("insulation")
var itemInsulation = new Item
var itemQuantumGlyph = new ItemQuantumGlyph
var itemFocusingMatrix: ItemFocusingMatrix = new ItemFocusingMatrix
@ -51,6 +53,7 @@ object ElectricalContent extends ContentHolder
var blockLaserReceiver: Block = new TileLaserReceiver
var blockMirror: Block = new TileMirror
var blockFocusCrystal: Block = new TileFocusCrystal
var blockSiren: Block = new TileSiren
var tierOneBattery: ItemStack = null
var tierTwoBattery: ItemStack = null
@ -88,6 +91,7 @@ object ElectricalContent extends ContentHolder
override def postInit()
{
recipes += shaped(new ItemStack(blockSiren, 2), "NPN", 'N', Blocks.noteblock, 'P', UniversalRecipe.SECONDARY_PLATE.get)
recipes += shaped(blockTesla, "WEW", " C ", "DID", 'W', "wire", 'E', Items.ender_eye, 'C', UniversalRecipe.BATTERY.get, 'D', Items.diamond, 'I', UniversalRecipe.PRIMARY_PLATE.get)
recipes += shaped(itemMultimeter, "WWW", "ICI", 'W', "wire", 'C', UniversalRecipe.BATTERY.get, 'I', UniversalRecipe.PRIMARY_METAL.get)
recipes += shaped(tierOneBattery, "III", "IRI", "III", 'R', Blocks.redstone_block, 'I', UniversalRecipe.PRIMARY_METAL.get)

View File

@ -0,0 +1,72 @@
package edx.electrical.circuit.component
import edx.core.Reference
import net.minecraft.block.material.Material
import net.minecraft.entity.player.EntityPlayer
import net.minecraftforge.common.util.ForgeDirection
import resonantengine.lib.grid.energy.electric.NodeElectricComponent
import resonantengine.lib.modcontent.block.ResonantTile
import resonantengine.lib.transform.vector.Vector3
import resonantengine.prefab.block.impl.TBlockNodeProvider
import scala.collection.convert.wrapAll._
/**
* Siren block
*/
class TileSiren extends ResonantTile(Material.wood) with TBlockNodeProvider
{
val electricNode = new NodeElectricComponent(this)
nodes.add(electricNode)
electricNode.dynamicTerminals = true
electricNode.setPositives(Set(ForgeDirection.NORTH, ForgeDirection.UP, ForgeDirection.EAST))
electricNode.setNegatives(Set(ForgeDirection.SOUTH, ForgeDirection.DOWN, ForgeDirection.WEST))
override def update()
{
super.update()
if (ticks % 30 == 0)
{
if (world != null)
{
val metadata: Int = world.getBlockMetadata(x, y, z)
if (world.getBlockPowerInput(x, y, z) > 0)
{
var volume: Float = 0.5f
for (i <- 0 to 6)
{
val check: Vector3 = position.add(ForgeDirection.getOrientation(i))
if (check.getBlock(world) == getBlockType)
{
volume *= 1.5f
}
}
world.playSoundEffect(x, y, z, Reference.prefix + "siren", volume, 1f - 0.18f * (metadata / 15f))
}
}
if (!world.isRemote)
{
val volume = electricNode.power.toFloat / 1000f
world.playSoundEffect(x, y, z, Reference.prefix + "siren", volume, 1f - 0.18f * (metadata / 15f))
}
}
}
override def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
{
var metadata: Int = world.getBlockMetadata(x, y, z)
if (player.isSneaking)
{
metadata -= 1
}
else
{
metadata += 1
}
metadata = Math.max(metadata % 16, 0)
world.setBlockMetadataWithNotify(x, y, z, metadata, 2)
return true
}
}

View File

@ -1,4 +1,4 @@
package edx.quantum.laser;
package edx.electrical.circuit.component.laser;
import net.minecraft.util.MovingObjectPosition;
import resonantengine.lib.transform.vector.Vector3;

View File

@ -1,4 +1,4 @@
package edx.quantum.laser
package edx.electrical.circuit.component.laser
import java.awt.Color

View File

@ -1,4 +1,4 @@
package edx.quantum.laser
package edx.electrical.circuit.component.laser
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}

View File

@ -1,4 +1,4 @@
package edx.quantum.laser
package edx.electrical.circuit.component.laser
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}

View File

@ -1,4 +1,4 @@
package edx.quantum.laser.focus;
package edx.electrical.circuit.component.laser.focus;
import resonantengine.lib.transform.vector.Vector3;

View File

@ -1,4 +1,4 @@
package edx.quantum.laser.focus
package edx.electrical.circuit.component.laser.focus
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.{EDXCreativeTab, Reference}

View File

@ -1,4 +1,4 @@
package edx.quantum.laser.focus
package edx.electrical.circuit.component.laser.focus
import net.minecraft.block.material.Material
import net.minecraft.entity.EntityLivingBase

View File

@ -1,8 +1,8 @@
package edx.quantum.laser.focus
package edx.electrical.circuit.component.laser.focus
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.{Electrodynamics, Reference}
import edx.quantum.laser.{ILaserHandler, Laser}
import edx.electrical.circuit.component.laser.{ILaserHandler, Laser}
import net.minecraft.block.material.Material
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound

View File

@ -1,9 +1,9 @@
package edx.quantum.laser.focus
package edx.electrical.circuit.component.laser.focus
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.{Electrodynamics, Reference}
import edx.quantum.laser.{ILaserHandler, Laser}
import edx.electrical.circuit.component.laser.{ILaserHandler, Laser}
import net.minecraft.block.material.Material
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound

View File

@ -1,4 +1,4 @@
package edx.quantum.laser.fx
package edx.electrical.circuit.component.laser.fx
import net.minecraft.block.Block
import net.minecraft.client.particle.EntityFX

View File

@ -1,10 +1,10 @@
package edx.quantum.laser.fx
package edx.electrical.circuit.component.laser.fx
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.Reference
import edx.electrical.ElectricalContent
import edx.quantum.laser.Laser
import edx.electrical.circuit.component.laser.Laser
import net.minecraft.client.particle.EntityFX
import net.minecraft.client.renderer.Tessellator
import net.minecraft.util.ResourceLocation

View File

@ -1,4 +1,4 @@
package edx.quantum.laser.fx
package edx.electrical.circuit.component.laser.fx
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}

View File

@ -1,7 +1,7 @@
/**
*
*/
package edx.electrical.tesla
package edx.electrical.circuit.component.tesla
import net.minecraft.tileentity.TileEntity

View File

@ -1,4 +1,4 @@
package edx.electrical.tesla
package edx.electrical.circuit.component.tesla
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.Reference

View File

@ -1,7 +1,7 @@
/**
*
*/
package edx.electrical.tesla;
package edx.electrical.circuit.component.tesla;
import net.minecraft.tileentity.TileEntity;
import resonantengine.api.mffs.fortron.IServerThread;

View File

@ -1,9 +1,9 @@
package edx.electrical.tesla
package edx.electrical.circuit.component.tesla
import java.util.{ArrayList, Comparator, HashSet, List, PriorityQueue, Set}
import cpw.mods.fml.common.network.ByteBufUtils
import edx.core.util.ResonantUtil
import edx.core.util.ColorUtil
import edx.core.{Electrodynamics, Reference, Settings}
import io.netty.buffer.ByteBuf
import net.minecraft.block.Block
@ -381,6 +381,12 @@ class TileTesla extends ResonantTile(Material.iron) with TBlockNodeProvider with
getMultiBlock.load(nbt)
}
def getMultiBlock: MultiBlockHandler[TileTesla] =
{
if (multiBlock == null) multiBlock = new MultiBlockHandler[TileTesla](this)
return multiBlock
}
/**
* Writes a tile entity to NBT.
*/
@ -400,12 +406,6 @@ class TileTesla extends ResonantTile(Material.iron) with TBlockNodeProvider with
getMultiBlock.save(nbt)
}
def getMultiBlock: MultiBlockHandler[TileTesla] =
{
if (multiBlock == null) multiBlock = new MultiBlockHandler[TileTesla](this)
return multiBlock
}
def setLink(vector3: Vector3, dimID: Int, setOpponent: Boolean)
{
if (!worldObj.isRemote)
@ -507,7 +507,7 @@ class TileTesla extends ResonantTile(Material.iron) with TBlockNodeProvider with
{
if (entityPlayer.getCurrentEquippedItem != null)
{
val dyeColor: Int = ResonantUtil.isDye(entityPlayer.getCurrentEquippedItem)
val dyeColor: Int = ColorUtil.isDye(entityPlayer.getCurrentEquippedItem)
if (dyeColor != -1)
{
getMultiBlock.get.setDye(dyeColor)

View File

@ -1,4 +1,4 @@
package edx.electrical.generator
package edx.electrical.circuit.source
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.Reference
@ -72,15 +72,6 @@ class TileMotor extends ResonantTile(Material.iron) with TIO with TBlockNodeProv
super.start()
}
def updateConnections()
{
electricNode.setPositives(getInputDirections())
electricNode.setNegatives(getOutputDirections())
electricNode.reconstruct()
notifyChange()
markUpdate()
}
override def update()
{
super.update()
@ -118,6 +109,15 @@ class TileMotor extends ResonantTile(Material.iron) with TIO with TBlockNodeProv
}
}
def updateConnections()
{
electricNode.setPositives(getInputDirections())
electricNode.setNegatives(getOutputDirections())
electricNode.reconstruct()
notifyChange()
markUpdate()
}
@SideOnly(Side.CLIENT)
override def renderDynamic(pos: Vector3, frame: Float, pass: Int): Unit =
{

View File

@ -1,4 +1,4 @@
package edx.electrical.generator
package edx.electrical.circuit.source
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.Reference

View File

@ -1,4 +1,4 @@
package edx.electrical.generator
package edx.electrical.circuit.source
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.Reference

View File

@ -1,4 +1,4 @@
package edx.electrical.battery
package edx.electrical.circuit.source.battery
import java.util.{Arrays, LinkedHashSet, Set}

View File

@ -1,4 +1,4 @@
package edx.electrical.battery
package edx.electrical.circuit.source.battery
import java.util.List
@ -55,6 +55,22 @@ class ItemBlockBattery(block: Block) extends ItemBlock(block) with TEnergyItem
this.setEnergy(itemStack, 0)
}
override def setEnergy(itemStack: ItemStack, joules: Double): ItemStack =
{
if (itemStack.getTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound)
}
val energy: Double = Math.max(Math.min(joules, this.getEnergyCapacity(itemStack)), 0)
itemStack.getTagCompound.setDouble("energy", energy)
return itemStack
}
def getEnergyCapacity(theItem: ItemStack): Double =
{
return TileBattery.getEnergyForTier(ItemBlockBattery.getTier(theItem))
}
override def recharge(itemStack: ItemStack, energy: Double, doReceive: Boolean): Double =
{
val rejectedElectricity: Double = Math.max((this.getEnergy(itemStack) + energy) - this.getEnergyCapacity(itemStack), 0)
@ -89,20 +105,4 @@ class ItemBlockBattery(block: Block) extends ItemBlock(block) with TEnergyItem
list.add(setEnergy(ItemBlockBattery.setTier(new ItemStack(this), tier), TileBattery.getEnergyForTier(tier)))
}
}
override def setEnergy(itemStack: ItemStack, joules: Double): ItemStack =
{
if (itemStack.getTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound)
}
val energy: Double = Math.max(Math.min(joules, this.getEnergyCapacity(itemStack)), 0)
itemStack.getTagCompound.setDouble("energy", energy)
return itemStack
}
def getEnergyCapacity(theItem: ItemStack): Double =
{
return TileBattery.getEnergyForTier(ItemBlockBattery.getTier(theItem))
}
}

View File

@ -1,4 +1,4 @@
package edx.electrical.battery
package edx.electrical.circuit.source.battery
import java.util.ArrayList
@ -68,15 +68,6 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr
updateConnectionMask()
}
def updateConnectionMask()
{
electricNode.setPositives(getInputDirections())
electricNode.setNegatives(getOutputDirections())
electricNode.reconstruct()
markUpdate()
notifyChange()
}
override def update()
{
super.update()
@ -140,6 +131,15 @@ class TileBattery extends ResonantTile(Material.iron) with TIO with TBlockNodePr
updateConnectionMask()
}
def updateConnectionMask()
{
electricNode.setPositives(getInputDirections())
electricNode.setNegatives(getOutputDirections())
electricNode.reconstruct()
markUpdate()
notifyChange()
}
override def onPlaced(entityLiving: EntityLivingBase, itemStack: ItemStack)
{
if (!world.isRemote && itemStack.getItem.isInstanceOf[ItemBlockBattery])

View File

@ -1,4 +1,4 @@
package edx.electrical.transformer
package edx.electrical.circuit.transformer
import net.minecraftforge.common.util.ForgeDirection
import resonantengine.api.graph.INodeProvider

View File

@ -1,4 +1,4 @@
package edx.electrical.transformer
package edx.electrical.circuit.transformer
import codechicken.lib.vec.{BlockCoord, Vector3}
import codechicken.microblock.FacePlacementGrid

View File

@ -1,4 +1,4 @@
package edx.electrical.transformer
package edx.electrical.circuit.transformer
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.lib.vec.Vector3

View File

@ -1,4 +1,4 @@
package edx.electrical.transformer
package edx.electrical.circuit.transformer
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.relauncher.{Side, SideOnly}

View File

@ -1,4 +1,4 @@
package edx.electrical.wire
package edx.electrical.circuit.wire
import java.awt.Color
import java.util.List
@ -8,9 +8,9 @@ import codechicken.multipart._
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.util.MultipartUtil
import edx.core.{Reference, ResonantPartFactory}
import edx.electrical.wire.base.WireMaterial
import edx.electrical.wire.flat.PartFlatWire
import edx.electrical.wire.framed.PartFramedWire
import edx.electrical.circuit.wire.base.WireMaterial
import edx.electrical.circuit.wire.flat.PartFlatWire
import edx.electrical.circuit.wire.framed.PartFramedWire
import net.minecraft.creativetab.CreativeTabs
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.{Item, ItemStack}

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.base
package edx.electrical.circuit.wire.base
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import edx.core.prefab.part.connector._

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.base;
package edx.electrical.circuit.wire.base;
/**
* An enumerator for different wire materials. The metadata of the wire determines the type of the

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.flat
package edx.electrical.circuit.wire.flat
import java.lang.{Iterable => JIterable}
@ -12,7 +12,7 @@ import edx.core.prefab.node.TMultipartNode
import edx.core.prefab.part.ChickenBonesWrapper._
import edx.core.prefab.part.connector.{PartAbstract, TColorable}
import edx.core.util.MultipartUtil
import edx.electrical.wire.base.TWire
import edx.electrical.circuit.wire.base.TWire
import net.minecraft.client.renderer.RenderBlocks
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack
@ -116,6 +116,8 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
return wire.getThickness > getThickness
}
def getThickness: Int = if (insulated) 1 else 0
/**
* Packet Methods
*/
@ -219,28 +221,6 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
super.onChunkLoad()
}
def dropIfCantStay: Boolean =
{
if (!canStay)
{
drop
return true
}
return false
}
def canStay: Boolean =
{
val pos: BlockCoord = new BlockCoord(tile).offset(side)
return MultipartUtil.canPlaceWireOnSide(world, pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side ^ 1), false)
}
def drop
{
TileMultipart.dropItem(getItem, world, Vector3.fromTileEntityCenter(tile))
tile.remPart(this)
}
override def onAdded()
{
super.onAdded()
@ -269,6 +249,28 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
sendPacket(3)
}
def dropIfCantStay: Boolean =
{
if (!canStay)
{
drop
return true
}
return false
}
def canStay: Boolean =
{
val pos: BlockCoord = new BlockCoord(tile).offset(side)
return MultipartUtil.canPlaceWireOnSide(world, pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side ^ 1), false)
}
def drop
{
TileMultipart.dropItem(getItem, world, Vector3.fromTileEntityCenter(tile))
tile.remPart(this)
}
def maskOpen(r: Int): Boolean =
{
return (connectionMask & 0x1000 << r) != 0
@ -283,8 +285,6 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
override def getSubParts: JIterable[IndexedCuboid6] = Seq(new IndexedCuboid6(0, PartFlatWire.selectionBounds(getThickness)(side)))
def getThickness: Int = if (insulated) 1 else 0
def getOcclusionBoxes: JIterable[Cuboid6] = Seq(PartFlatWire.occlusionBounds(getThickness)(side))
override def solid(arg0: Int) = false
@ -308,6 +308,8 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
return false
}
def useStaticRenderer: Boolean = true
@SideOnly(Side.CLIENT)
override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
{
@ -323,8 +325,6 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
}
}
def useStaticRenderer: Boolean = true
@SideOnly(Side.CLIENT)
override def drawBreaking(renderBlocks: RenderBlocks)
{

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.flat
package edx.electrical.circuit.wire.flat
import java.util.LinkedList
@ -6,7 +6,7 @@ import codechicken.lib.lighting.LightModel
import codechicken.lib.render._
import codechicken.lib.render.uv._
import codechicken.lib.vec.{Cuboid6, Rotation, Transformation, Translation, Vector3}
import edx.core.util.ResonantUtil
import edx.core.util.ColorUtil
import net.minecraft.util.IIcon
object RenderFlatWire
@ -48,45 +48,12 @@ object RenderFlatWire
def render(wire: PartFlatWire, pos: Vector3)
{
//If it is insulated, render the insulation color. Otherwise, render the material color.
val colorCode = if (wire.insulated) ResonantUtil.convertRGBtoRGBA(ResonantUtil.getColorHex(wire.getColor)) else ResonantUtil.convertRGBtoRGBA(wire.material.color)
val colorCode = if (wire.insulated) ColorUtil.convertRGBtoRGBA(ColorUtil.getColorHex(wire.getColor)) else ColorUtil.convertRGBtoRGBA(wire.material.color)
val model = getOrGenerateModel(modelKey(wire))
model.render(new Translation(pos), new IconTransformation(wire.getIcon), new ColourMultiplier(colorCode))
}
def modelKey(w: PartFlatWire): Int =
{
return modelKey(w.side, w.getThickness, w.connectionMask)
}
/**
* Returns a tightly packed unique index for the specific model represented
* by this wire. The mask is split into 3 sections the combination of
* corresponding bits from the two lowest nybbles gives the connection type
* in that direction.
* 00 = none
* 01 = corner
* 10 = straight
* 11 = internal The
* second byte contains the thickness*6+side
*
* @param side The side the wire is attached to
* @param thickness The thickness of the wire -1 in 1/8th blocks. Supported
* values 0, 1, 2
* @param connMap The connection mask of the wire
*/
def modelKey(side: Int, thickness: Int, connMap: Int): Int =
{
var key: Int = connMap & 0xFF
val renderCorner: Int = connMap >> 20 & 0xF
key |= (renderCorner ^ key & 0xF) << 4
key &= ~0xF | renderCorner
val internal: Int = (connMap & 0xF00) >> 8
key |= internal << 4 | internal
key |= side + thickness * 6 << 8
return key
}
def getOrGenerateModel(key: Int): CCModel =
{
var m: CCModel = wireModels(key)
@ -138,6 +105,39 @@ object RenderFlatWire
}
}
def modelKey(w: PartFlatWire): Int =
{
return modelKey(w.side, w.getThickness, w.connectionMask)
}
/**
* Returns a tightly packed unique index for the specific model represented
* by this wire. The mask is split into 3 sections the combination of
* corresponding bits from the two lowest nybbles gives the connection type
* in that direction.
* 00 = none
* 01 = corner
* 10 = straight
* 11 = internal The
* second byte contains the thickness*6+side
*
* @param side The side the wire is attached to
* @param thickness The thickness of the wire -1 in 1/8th blocks. Supported
* values 0, 1, 2
* @param connMap The connection mask of the wire
*/
def modelKey(side: Int, thickness: Int, connMap: Int): Int =
{
var key: Int = connMap & 0xFF
val renderCorner: Int = connMap >> 20 & 0xF
key |= (renderCorner ^ key & 0xF) << 4
key &= ~0xF | renderCorner
val internal: Int = (connMap & 0xF00) >> 8
key |= internal << 4 | internal
key |= side + thickness * 6 << 8
return key
}
class UVT(t: Transformation) extends UVTransformation
{
val vec = new Vector3

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.flat
package edx.electrical.circuit.wire.flat
import java.util.Arrays

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.framed
package edx.electrical.circuit.wire.framed
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.lib.render.CCRenderState
@ -6,7 +6,7 @@ import codechicken.lib.vec.Vector3
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.prefab.node.TMultipartNode
import edx.core.prefab.part.connector.PartFramedNode
import edx.electrical.wire.base.TWire
import edx.electrical.circuit.wire.base.TWire
import net.minecraft.client.renderer.RenderBlocks
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.util.ForgeDirection

View File

@ -1,4 +1,4 @@
package edx.electrical.wire.framed
package edx.electrical.circuit.wire.framed
import codechicken.lib.lighting.LightModel
import codechicken.lib.render.uv.IconTransformation
@ -7,7 +7,7 @@ import codechicken.lib.vec.{Rotation, Translation}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.Reference
import edx.core.render.InvertX
import edx.core.util.ResonantUtil
import edx.core.util.ColorUtil
import net.minecraft.util.{IIcon, ResourceLocation}
import net.minecraftforge.common.util.ForgeDirection
import resonantengine.lib.wrapper.BitmaskWrapper._
@ -51,10 +51,10 @@ object RenderFramedWire
var name: String = side.name.toLowerCase
name = if (name == "unknown") "center" else name
renderPart(wireIcon, models(name), wire.x, wire.y, wire.z, ResonantUtil.convertRGBtoRGBA(wire.material.color))
renderPart(wireIcon, models(name), wire.x, wire.y, wire.z, ColorUtil.convertRGBtoRGBA(wire.material.color))
if (wire.insulated)
renderPart(insulationIcon, models(name + "Insulation"), wire.x, wire.y, wire.z, ResonantUtil.convertRGBtoRGBA(ResonantUtil.getColorHex(wire.getColor)))
renderPart(insulationIcon, models(name + "Insulation"), wire.x, wire.y, wire.z, ColorUtil.convertRGBtoRGBA(ColorUtil.getColorHex(wire.getColor)))
}
def renderPart(icon: IIcon, cc: CCModel, x: Double, y: Double, z: Double, color: Int)

View File

@ -64,13 +64,11 @@ object QuantumContent extends ContentHolder
var blockPlasma: Block = new TilePlasma
var blockElectromagnet: Block = new TileElectromagnet
var blockChemicalExtractor: Block = new TileChemicalExtractor
var blockSiren: Block = new TileSiren
var blockSteamFunnel: Block = new TileFunnel
var blockAccelerator: Block = new TileAccelerator
var blockFulmination: Block = new TileFulmination
var blockQuantumAssembler: Block = new TileQuantumAssembler
var blockReactorCell: Block = new TileReactorCell
var blockUraniumOre: Block = new BlockUraniumOre
var blockToxicWaste: Block = new BlockToxicWaste().setCreativeTab(null)
//Cells
@ -231,6 +229,19 @@ object QuantumContent extends ContentHolder
return fluid
}
def fluidSteam: Fluid =
{
var fluid = FluidRegistry.getFluid("steam")
if (fluid == null)
{
fluid = new Fluid("steam").setGaseous(true)
FluidRegistry.registerFluid(fluid)
}
return fluid
}
override def postInit()
{
super.postInit()
@ -281,7 +292,6 @@ object QuantumContent extends ContentHolder
recipes += shaped(blockNuclearBoiler, "S S", "FBF", "SMS", 'F', Blocks.furnace, 'S', UniversalRecipe.PRIMARY_PLATE.get, 'B', Items.bucket, 'M', UniversalRecipe.MOTOR.get)
recipes += shaped(blockChemicalExtractor, "BSB", "MCM", "BSB", 'C', UniversalRecipe.CIRCUIT_T3.get, 'S', UniversalRecipe.PRIMARY_PLATE.get, 'B', UniversalRecipe.SECONDARY_METAL.get, 'M', UniversalRecipe.MOTOR.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(blockFusionCore, "CPC", "PFP", "CPC", 'P', UniversalRecipe.PRIMARY_PLATE.get, 'F', QuantumContent.blockReactorCell, 'C', UniversalRecipe.CIRCUIT_T3.get)
recipes += shaped(new ItemStack(itemCell, 16), " T ", "TGT", " T ", 'T', "ingotTin", 'G', Blocks.glass)
@ -371,16 +381,6 @@ object QuantumContent extends ContentHolder
return isItemStackOreDictionaryCompatible(itemStack, "cellEmpty")
}
def isItemStackWaterCell(itemStack: ItemStack): Boolean =
{
return isItemStackOreDictionaryCompatible(itemStack, "cellWater")
}
def isItemStackUraniumOre(itemStack: ItemStack): Boolean =
{
return isItemStackOreDictionaryCompatible(itemStack, "dropUranium", "oreUranium")
}
/** Compare to Ore Dict
*
* @param itemStack
@ -402,6 +402,16 @@ object QuantumContent extends ContentHolder
return false
}
def isItemStackWaterCell(itemStack: ItemStack): Boolean =
{
return isItemStackOreDictionaryCompatible(itemStack, "cellWater")
}
def isItemStackUraniumOre(itemStack: ItemStack): Boolean =
{
return isItemStackOreDictionaryCompatible(itemStack, "dropUranium", "oreUranium")
}
def isItemStackDeuteriumCell(itemStack: ItemStack): Boolean =
{
return isItemStackOreDictionaryCompatible(itemStack, "molecule_1d", "molecule_1h2", "cellDeuterium")
@ -427,19 +437,6 @@ object QuantumContent extends ContentHolder
def fluidStackSteam: FluidStack = new FluidStack(fluidSteam, 0)
def fluidSteam: Fluid =
{
var fluid = FluidRegistry.getFluid("steam")
if (fluid == null)
{
fluid = new Fluid("steam").setGaseous(true)
FluidRegistry.registerFluid(fluid)
}
return fluid
}
def FLUIDSTACK_DEUTERIUM: FluidStack = new FluidStack(FLUID_DEUTERIUM, 0)
def getFluidStackTritium: FluidStack = new FluidStack(getFluidTritium, 0)

View File

@ -1,39 +0,0 @@
package edx.quantum.blocks
import java.util.Random
import cpw.mods.fml.relauncher.{Side, SideOnly}
import edx.core.{Reference, Settings}
import net.minecraft.block.material.Material
import net.minecraft.world.World
/**
* Uranium ore block
*/
class BlockUraniumOre extends BlockRadioactive(Material.rock)
{
//Constructor
this.setBlockName(Reference.prefix + "oreUranium")
this.setStepSound(net.minecraft.block.Block.soundTypeStone)
this.setHardness(2f)
this.setBlockTextureName(Reference.prefix + "oreUranium")
this.isRandomlyRadioactive = Settings.allowRadioactiveOres
this.canWalkPoison = Settings.allowRadioactiveOres
this.canSpread = false
this.radius = 1f
this.amplifier = 0
this.spawnParticle = true
@SideOnly(Side.CLIENT) override def randomDisplayTick(world: World, x: Int, y: Int, z: Int, par5Random: Random)
{
if (Settings.allowRadioactiveOres)
{
super.randomDisplayTick(world, x, y, z, par5Random)
}
}
override def quantityDropped(par1Random: Random): Int =
{
return 1
}
}

View File

@ -1,54 +0,0 @@
package edx.quantum.blocks
import edx.core.Reference
import net.minecraft.block.material.Material
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.world.World
import net.minecraftforge.common.util.ForgeDirection
import resonantengine.lib.modcontent.block.ResonantBlock
import resonantengine.lib.transform.vector.Vector3
/**
* Siren block
*/
class TileSiren extends ResonantBlock(Material.wood)
{
override def update
{
val world: World = worldObj
if (world != null)
{
val metadata: Int = world.getBlockMetadata(x, y, z)
if (world.getBlockPowerInput(x, y, z) > 0)
{
var volume: Float = 0.5f
for (i <- 0 to 6)
{
val check: Vector3 = position.add(ForgeDirection.getOrientation(i))
if (check.getBlock(world) eq getBlockType)
{
volume *= 1.5f
}
}
world.playSoundEffect(x, y, z, Reference.prefix + "alarm", volume, 1f - 0.18f * (metadata / 15f))
}
}
}
override def configure(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
{
var metadata: Int = world.getBlockMetadata(x, y, z)
if (player.isSneaking)
{
metadata -= 1
}
else
{
metadata += 1
}
metadata = Math.max(metadata % 16, 0)
world.setBlockMetadataWithNotify(x, y, z, metadata, 2)
return true
}
}

View File

@ -22,7 +22,7 @@ class ContainerNuclearBoiler(player: EntityPlayer, tileEntity: TileNuclearBoiler
this.addSlotToContainer(new SlotEnergyItem(tileEntity.asInstanceOf[IInventory], 0, 56, 26))
this.addSlotToContainer(new Slot(tileEntity.asInstanceOf[IInventory], 1, 25, 50))
this.addSlotToContainer(new Slot(tileEntity.asInstanceOf[IInventory], 2, 136, 50))
this.addSlotToContainer(new SlotSpecific(tileEntity.asInstanceOf[IInventory], 3, 81, 26, new ItemStack(QuantumContent.itemYellowCake), new ItemStack(QuantumContent.blockUraniumOre)))
this.addSlotToContainer(new SlotSpecific(tileEntity.asInstanceOf[IInventory], 3, 81, 26, new ItemStack(QuantumContent.itemYellowCake)))
this.addPlayerInventory(player)
override def canInteractWith(par1EntityPlayer: EntityPlayer): Boolean =

View File

@ -2,6 +2,7 @@ package edx.quantum.schematic
import java.util.HashMap
import edx.electrical.ElectricalContent
import edx.quantum.QuantumContent
import net.minecraft.block.Block
import net.minecraft.init.Blocks
@ -42,7 +43,7 @@ class SchematicBreedingReactor extends Schematic
if (!((x == -r || x == r) && (z == -r || z == r)))
{
returnMap.put(new Vector3(x, 0, z), new Pair[Block, Integer](QuantumContent.blockReactorCell, 0))
returnMap.put(new Vector3(x, -3, z), new Pair[Block, Integer](QuantumContent.blockSiren, 0))
returnMap.put(new Vector3(x, -3, z), new Pair[Block, Integer](ElectricalContent.blockSiren, 0))
returnMap.put(new Vector3(x, -2, z), new Pair[Block, Integer](Blocks.redstone_wire, 0))
}
else

View File

@ -2,6 +2,7 @@ package edx.quantum.schematic
import java.util.HashMap
import edx.electrical.ElectricalContent
import edx.quantum.QuantumContent
import net.minecraft.block.Block
import net.minecraft.init.Blocks
@ -42,7 +43,7 @@ class SchematicFissionReactor extends Schematic
}
}
returnMap.put(new Vector3(0, -3, 0), new Pair[Block, Integer](QuantumContent.blockSiren, 0))
returnMap.put(new Vector3(0, -3, 0), new Pair[Block, Integer](ElectricalContent.blockSiren, 0))
returnMap.put(new Vector3(0, -2, 0), new Pair[Block, Integer](Blocks.redstone_wire, 0))
returnMap.put(new Vector3, new Pair[Block, Integer](QuantumContent.blockReactorCell, 0))
}