Merged RenderBattery with TileBattery
This commit is contained in:
parent
32e9e3a8c4
commit
7658924f8e
4 changed files with 142 additions and 167 deletions
|
@ -15,6 +15,7 @@ import net.minecraft.tileentity.TileEntity
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
import resonant.content.wrapper.ItemRenderHandler
|
import resonant.content.wrapper.ItemRenderHandler
|
||||||
import resonant.lib.render.fx.FXElectricBolt2
|
import resonant.lib.render.fx.FXElectricBolt2
|
||||||
|
import resonant.lib.transform.vector.Vector3
|
||||||
import resonantinduction.archaic.firebox.{RenderHotPlate, TileHotPlate}
|
import resonantinduction.archaic.firebox.{RenderHotPlate, TileHotPlate}
|
||||||
import resonantinduction.archaic.process.{RenderCastingMold, RenderMillstone, TileCastingMold, TileMillstone}
|
import resonantinduction.archaic.process.{RenderCastingMold, RenderMillstone, TileCastingMold, TileMillstone}
|
||||||
import resonantinduction.atomic.gate.RenderQuantumGlyph
|
import resonantinduction.atomic.gate.RenderQuantumGlyph
|
||||||
|
@ -27,7 +28,6 @@ import resonantinduction.atomic.machine.quantum.{GuiQuantumAssembler, RenderQuan
|
||||||
import resonantinduction.atomic.machine.reactor.{GuiReactorCell, RenderReactorCell, TileReactorCell}
|
import resonantinduction.atomic.machine.reactor.{GuiReactorCell, RenderReactorCell, TileReactorCell}
|
||||||
import resonantinduction.atomic.machine.thermometer.{RenderThermometer, TileThermometer}
|
import resonantinduction.atomic.machine.thermometer.{RenderThermometer, TileThermometer}
|
||||||
import resonantinduction.electrical.ElectricalContent
|
import resonantinduction.electrical.ElectricalContent
|
||||||
import resonantinduction.electrical.battery.{RenderBattery, TileBattery}
|
|
||||||
import resonantinduction.electrical.generator.{RenderMotor, TileMotor}
|
import resonantinduction.electrical.generator.{RenderMotor, TileMotor}
|
||||||
import resonantinduction.electrical.laser.fx.{EntityBlockParticleFX, EntityLaserFX, EntityScorchFX}
|
import resonantinduction.electrical.laser.fx.{EntityBlockParticleFX, EntityLaserFX, EntityScorchFX}
|
||||||
import resonantinduction.electrical.multimeter.{GuiMultimeter, PartMultimeter, RenderMultimeter}
|
import resonantinduction.electrical.multimeter.{GuiMultimeter, PartMultimeter, RenderMultimeter}
|
||||||
|
@ -41,7 +41,6 @@ import resonantinduction.mechanical.mech.gearshaft.RenderGearShaft
|
||||||
import resonantinduction.mechanical.mech.process.crusher.{RenderMechanicalPiston, TileMechanicalPiston}
|
import resonantinduction.mechanical.mech.process.crusher.{RenderMechanicalPiston, TileMechanicalPiston}
|
||||||
import resonantinduction.mechanical.mech.process.grinder.{RenderGrindingWheel, TileGrindingWheel}
|
import resonantinduction.mechanical.mech.process.grinder.{RenderGrindingWheel, TileGrindingWheel}
|
||||||
import resonantinduction.mechanical.mech.turbine._
|
import resonantinduction.mechanical.mech.turbine._
|
||||||
import resonant.lib.transform.vector.Vector3
|
|
||||||
|
|
||||||
/** @author Calclavia */
|
/** @author Calclavia */
|
||||||
@SideOnly(Side.CLIENT) class ClientProxy extends CommonProxy
|
@SideOnly(Side.CLIENT) class ClientProxy extends CommonProxy
|
||||||
|
@ -73,7 +72,6 @@ import resonant.lib.transform.vector.Vector3
|
||||||
|
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMotor], new RenderMotor)
|
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMotor], new RenderMotor)
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileTesla], new RenderTesla)
|
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileTesla], new RenderTesla)
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileBattery], new RenderBattery)
|
|
||||||
|
|
||||||
//Atomic content
|
//Atomic content
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileCentrifuge], new RenderCentrifuge)
|
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileCentrifuge], new RenderCentrifuge)
|
||||||
|
|
|
@ -1,154 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package resonantinduction.electrical.battery
|
|
||||||
|
|
||||||
import java.util.{ArrayList, Arrays, List}
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
|
||||||
import net.minecraft.item.ItemStack
|
|
||||||
import net.minecraft.tileentity.TileEntity
|
|
||||||
import net.minecraft.util.ResourceLocation
|
|
||||||
import net.minecraftforge.client.IItemRenderer
|
|
||||||
import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
|
||||||
import org.lwjgl.opengl.GL11
|
|
||||||
import org.lwjgl.opengl.GL11.{glPopMatrix, glPushMatrix, glRotatef}
|
|
||||||
import resonant.content.prefab.scal.render.ISimpleItemRenderer
|
|
||||||
import resonant.lib.render.RenderUtility
|
|
||||||
import resonantinduction.core.Reference
|
|
||||||
import resonant.lib.transform.vector.Vector3
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Make this more efficient.
|
|
||||||
*
|
|
||||||
* @author Calclavia
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT) object RenderBattery
|
|
||||||
{
|
|
||||||
var INSTANCE: RenderBattery = new RenderBattery
|
|
||||||
final val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "battery/battery.tcn"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT) class RenderBattery extends TileEntitySpecialRenderer with ISimpleItemRenderer
|
|
||||||
{
|
|
||||||
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
|
|
||||||
{
|
|
||||||
glPushMatrix
|
|
||||||
GL11.glTranslated(0, 0, 0)
|
|
||||||
val energyLevel: Int = (((itemStack.getItem.asInstanceOf[ItemBlockBattery]).getEnergy(itemStack).asInstanceOf[Double] / (itemStack.getItem.asInstanceOf[ItemBlockBattery]).getEnergyCapacity(itemStack).asInstanceOf[Double]) * 8).asInstanceOf[Int]
|
|
||||||
RenderUtility.bind(Reference.domain, Reference.modelPath + "battery/battery.png")
|
|
||||||
val disabledParts: List[String] = new ArrayList[String]
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("connector", "connectorIn", "connectorOut"): _*))
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8"): _*))
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit"): _*))
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("frame1con", "frame2con", "frame3con", "frame4con"): _*))
|
|
||||||
RenderBattery.MODEL.renderAllExcept(disabledParts.toArray(new Array[String](0)): _*)
|
|
||||||
|
|
||||||
for (i <- 1 until 8)
|
|
||||||
{
|
|
||||||
if (i != 1 || !disabledParts.contains("coil1"))
|
|
||||||
{
|
|
||||||
if ((8 - i) <= energyLevel) RenderBattery.MODEL.renderOnly("coil" + i + "lit")
|
|
||||||
else RenderBattery.MODEL.renderOnly("coil" + i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glPopMatrix
|
|
||||||
}
|
|
||||||
|
|
||||||
def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float)
|
|
||||||
{
|
|
||||||
val partToDisable: Array[Array[String]] = Array[Array[String]](Array[String]("bottom"), Array[String]("top"), Array[String]("frame1", "frame2"), Array[String]("frame3", "frame4"), Array[String]("frame4", "frame1"), Array[String]("frame2", "frame3"))
|
|
||||||
val connectionPartToEnable: Array[Array[String]] = Array[Array[String]](null, null, Array[String]("frame1con", "frame2con"), Array[String]("frame3con", "frame4con"), Array[String]("frame4con", "frame1con"), Array[String]("frame2con", "frame3con"))
|
|
||||||
GL11.glPushMatrix
|
|
||||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
|
||||||
val tile: TileBattery = t.asInstanceOf[TileBattery]
|
|
||||||
val energyLevel: Int = Math.round((tile.energy.getEnergy / TileBattery.getEnergyForTier(tile.getBlockMetadata).asInstanceOf[Double]) * 8).asInstanceOf[Int]
|
|
||||||
RenderUtility.bind(Reference.domain, Reference.modelPath + "battery/battery.png")
|
|
||||||
val disabledParts: List[String] = new ArrayList[String]
|
|
||||||
val enabledParts: List[String] = new ArrayList[String]
|
|
||||||
for (check <- ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
if (new Vector3(t).add(check).getTileEntity(t.getWorldObj).isInstanceOf[TileBattery])
|
|
||||||
{
|
|
||||||
disabledParts.addAll(Arrays.asList(partToDisable(check.ordinal): _*))
|
|
||||||
if (check eq ForgeDirection.UP)
|
|
||||||
{
|
|
||||||
enabledParts.addAll(Arrays.asList(partToDisable(check.ordinal): _*))
|
|
||||||
enabledParts.add("coil1")
|
|
||||||
}
|
|
||||||
else if (check eq ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
val connectionParts: List[String] = new ArrayList[String]
|
|
||||||
for (sideCheck <- ForgeDirection.VALID_DIRECTIONS) if (sideCheck.offsetY == 0) connectionParts.addAll(Arrays.asList(connectionPartToEnable(sideCheck.ordinal): _*))
|
|
||||||
for (sideCheck <- ForgeDirection.VALID_DIRECTIONS)
|
|
||||||
{
|
|
||||||
if (sideCheck.offsetY == 0)
|
|
||||||
{
|
|
||||||
if (new Vector3(t).add(sideCheck).getTileEntity(t.getWorldObj).isInstanceOf[TileBattery])
|
|
||||||
{
|
|
||||||
connectionParts.removeAll(Arrays.asList(connectionPartToEnable(sideCheck.ordinal)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enabledParts.addAll(connectionParts)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (check.offsetY == 0)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix
|
|
||||||
RenderUtility.rotateBlockBasedOnDirection(check)
|
|
||||||
|
|
||||||
if (check == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
glRotatef(0, 0, 1, 0)
|
|
||||||
}
|
|
||||||
if (check == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
glRotatef(0, 0, 1, 0)
|
|
||||||
}
|
|
||||||
else if (check == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
glRotatef(-180, 0, 1, 0)
|
|
||||||
}
|
|
||||||
else if (check == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
glRotatef(180, 0, 1, 0)
|
|
||||||
}
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0)
|
|
||||||
val io: Int = tile.getIO(check)
|
|
||||||
if (io == 1)
|
|
||||||
{
|
|
||||||
RenderBattery.MODEL.renderOnly("connectorIn")
|
|
||||||
}
|
|
||||||
else if (io == 2)
|
|
||||||
{
|
|
||||||
RenderBattery.MODEL.renderOnly("connectorOut")
|
|
||||||
}
|
|
||||||
GL11.glPopMatrix
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enabledParts.removeAll(disabledParts)
|
|
||||||
|
|
||||||
for (i <- 1 to 8)
|
|
||||||
{
|
|
||||||
if (i != 1 || enabledParts.contains("coil1"))
|
|
||||||
{
|
|
||||||
if ((8 - i) < energyLevel) RenderBattery.MODEL.renderOnly("coil" + i + "lit")
|
|
||||||
else RenderBattery.MODEL.renderOnly("coil" + i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("connector", "connectorIn", "connectorOut") :_*))
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8"):_*))
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit"):_*))
|
|
||||||
disabledParts.addAll(Arrays.asList(Array[String]("frame1con", "frame2con", "frame3con", "frame4con"):_*))
|
|
||||||
enabledParts.removeAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8")))
|
|
||||||
RenderBattery.MODEL.renderAllExcept(disabledParts.toArray(new Array[String](0)) :_*)
|
|
||||||
RenderBattery.MODEL.renderOnly(enabledParts.toArray(new Array[String](0)):_*)
|
|
||||||
GL11.glPopMatrix
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +1,27 @@
|
||||||
package resonantinduction.electrical.battery
|
package resonantinduction.electrical.battery
|
||||||
|
|
||||||
import java.util.ArrayList
|
import java.util.{ArrayList, Arrays, List}
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||||
import io.netty.buffer.ByteBuf
|
import io.netty.buffer.ByteBuf
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
import net.minecraft.entity.EntityLivingBase
|
import net.minecraft.entity.EntityLivingBase
|
||||||
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.util.ResourceLocation
|
||||||
|
import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
|
||||||
import net.minecraftforge.common.util.ForgeDirection
|
import net.minecraftforge.common.util.ForgeDirection
|
||||||
|
import org.lwjgl.opengl.GL11
|
||||||
|
import org.lwjgl.opengl.GL11._
|
||||||
import resonant.api.electric.EnergyStorage
|
import resonant.api.electric.EnergyStorage
|
||||||
import resonant.content.prefab.java.TileAdvanced
|
import resonant.content.prefab.java.TileAdvanced
|
||||||
import resonant.lib.content.prefab.{TElectric, TEnergyStorage}
|
import resonant.lib.content.prefab.{TElectric, TEnergyStorage}
|
||||||
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
import resonant.lib.network.discriminator.{PacketTile, PacketType}
|
||||||
import resonant.lib.network.handle.IPacketReceiver
|
import resonant.lib.network.handle.IPacketReceiver
|
||||||
import resonant.lib.network.netty.AbstractPacket
|
import resonant.lib.network.netty.AbstractPacket
|
||||||
|
import resonant.lib.render.RenderUtility
|
||||||
import resonant.lib.transform.vector.Vector3
|
import resonant.lib.transform.vector.Vector3
|
||||||
|
import resonantinduction.core.Reference
|
||||||
|
|
||||||
/** A modular battery box that allows shared connections with boxes next to it.
|
/** A modular battery box that allows shared connections with boxes next to it.
|
||||||
*
|
*
|
||||||
|
@ -28,13 +35,16 @@ object TileBattery
|
||||||
*/
|
*/
|
||||||
def getEnergyForTier(tier: Int): Long =
|
def getEnergyForTier(tier: Int): Long =
|
||||||
{
|
{
|
||||||
return Math.round(Math.pow(500000000, (tier / (maxTier + 0.7f)) + 1) / (500000000)) * (500000000)
|
return Math.round(Math.pow(500000000, (tier / (maxTier + 0.7f)) + 1) / 500000000) * 500000000
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Tiers: 0, 1, 2 */
|
/** Tiers: 0, 1, 2 */
|
||||||
final val maxTier: Int = 2
|
final val maxTier = 2
|
||||||
/** The transfer rate **/
|
/** The transfer rate **/
|
||||||
final val defaultPower: Long = getEnergyForTier(0)
|
final val defaultPower = getEnergyForTier(0)
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "battery/battery.tcn"))
|
||||||
}
|
}
|
||||||
|
|
||||||
class TileBattery extends TileAdvanced(Material.iron) with TElectric with IPacketReceiver with TEnergyStorage
|
class TileBattery extends TileAdvanced(Material.iron) with TElectric with IPacketReceiver with TEnergyStorage
|
||||||
|
@ -94,10 +104,7 @@ class TileBattery extends TileAdvanced(Material.iron) with TElectric with IPacke
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getDescPacket: AbstractPacket =
|
override def getDescPacket: AbstractPacket = new PacketTile(this) <<< renderEnergyAmount <<< ioMap
|
||||||
{
|
|
||||||
return new PacketTile(this) <<< renderEnergyAmount <<< ioMap
|
|
||||||
}
|
|
||||||
|
|
||||||
override def read(buf: ByteBuf, player: EntityPlayer, packet: PacketType)
|
override def read(buf: ByteBuf, player: EntityPlayer, packet: PacketType)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +132,7 @@ class TileBattery extends TileAdvanced(Material.iron) with TElectric with IPacke
|
||||||
if (!world.isRemote && itemStack.getItem.isInstanceOf[ItemBlockBattery])
|
if (!world.isRemote && itemStack.getItem.isInstanceOf[ItemBlockBattery])
|
||||||
{
|
{
|
||||||
energy.setCapacity(TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack)))
|
energy.setCapacity(TileBattery.getEnergyForTier(ItemBlockBattery.getTier(itemStack)))
|
||||||
energy.setEnergy((itemStack.getItem.asInstanceOf[ItemBlockBattery]).getEnergy(itemStack))
|
energy.setEnergy(itemStack.getItem.asInstanceOf[ItemBlockBattery].getEnergy(itemStack))
|
||||||
world.setBlockMetadataWithNotify(xi, yi, zi, ItemBlockBattery.getTier(itemStack), 3)
|
world.setBlockMetadataWithNotify(xi, yi, zi, ItemBlockBattery.getTier(itemStack), 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,6 +148,127 @@ class TileBattery extends TileAdvanced(Material.iron) with TElectric with IPacke
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
override def renderInventory(itemStack: ItemStack)
|
||||||
|
{
|
||||||
|
glPushMatrix()
|
||||||
|
val energyLevel = ((itemStack.getItem.asInstanceOf[ItemBlockBattery].getEnergy(itemStack) / itemStack.getItem.asInstanceOf[ItemBlockBattery].getEnergyCapacity(itemStack)) * 8).toInt
|
||||||
|
RenderUtility.bind(Reference.domain, Reference.modelPath + "battery/battery.png")
|
||||||
|
val disabledParts: List[String] = new ArrayList[String]
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("connector", "connectorIn", "connectorOut"): _*))
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8"): _*))
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit"): _*))
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("frame1con", "frame2con", "frame3con", "frame4con"): _*))
|
||||||
|
TileBattery.model.renderAllExcept(disabledParts.toArray(new Array[String](0)): _*)
|
||||||
|
|
||||||
|
for (i <- 1 until 8)
|
||||||
|
{
|
||||||
|
if (i != 1 || !disabledParts.contains("coil1"))
|
||||||
|
{
|
||||||
|
if ((8 - i) <= energyLevel) TileBattery.model.renderOnly("coil" + i + "lit")
|
||||||
|
else TileBattery.model.renderOnly("coil" + i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glPopMatrix()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||||
|
{
|
||||||
|
val partToDisable: Array[Array[String]] = Array[Array[String]](Array[String]("bottom"), Array[String]("top"), Array[String]("frame1", "frame2"), Array[String]("frame3", "frame4"), Array[String]("frame4", "frame1"), Array[String]("frame2", "frame3"))
|
||||||
|
val connectionPartToEnable: Array[Array[String]] = Array[Array[String]](null, null, Array[String]("frame1con", "frame2con"), Array[String]("frame3con", "frame4con"), Array[String]("frame4con", "frame1con"), Array[String]("frame2con", "frame3con"))
|
||||||
|
glPushMatrix()
|
||||||
|
glTranslated(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5)
|
||||||
|
val energyLevel: Int = Math.round((energy.getEnergy / TileBattery.getEnergyForTier(getBlockMetadata).asInstanceOf[Double]) * 8).asInstanceOf[Int]
|
||||||
|
RenderUtility.bind(Reference.domain, Reference.modelPath + "battery/battery.png")
|
||||||
|
|
||||||
|
val disabledParts = new ArrayList[String]
|
||||||
|
val enabledParts = new ArrayList[String]
|
||||||
|
|
||||||
|
for (check <- ForgeDirection.VALID_DIRECTIONS)
|
||||||
|
{
|
||||||
|
if (center.add(check).getTileEntity.isInstanceOf[TileBattery])
|
||||||
|
{
|
||||||
|
disabledParts.addAll(Arrays.asList(partToDisable(check.ordinal): _*))
|
||||||
|
if (check eq ForgeDirection.UP)
|
||||||
|
{
|
||||||
|
enabledParts.addAll(Arrays.asList(partToDisable(check.ordinal): _*))
|
||||||
|
enabledParts.add("coil1")
|
||||||
|
}
|
||||||
|
else if (check eq ForgeDirection.DOWN)
|
||||||
|
{
|
||||||
|
val connectionParts = new ArrayList[String]
|
||||||
|
for (sideCheck <- ForgeDirection.VALID_DIRECTIONS) if (sideCheck.offsetY == 0) connectionParts.addAll(Arrays.asList(connectionPartToEnable(sideCheck.ordinal): _*))
|
||||||
|
for (sideCheck <- ForgeDirection.VALID_DIRECTIONS)
|
||||||
|
{
|
||||||
|
if (sideCheck.offsetY == 0)
|
||||||
|
{
|
||||||
|
if (center.add(sideCheck).isInstanceOf[TileBattery])
|
||||||
|
{
|
||||||
|
connectionParts.removeAll(Arrays.asList(connectionPartToEnable(sideCheck.ordinal)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enabledParts.addAll(connectionParts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check.offsetY == 0)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix()
|
||||||
|
RenderUtility.rotateBlockBasedOnDirection(check)
|
||||||
|
|
||||||
|
if (check == ForgeDirection.NORTH)
|
||||||
|
{
|
||||||
|
glRotatef(0, 0, 1, 0)
|
||||||
|
}
|
||||||
|
if (check == ForgeDirection.SOUTH)
|
||||||
|
{
|
||||||
|
glRotatef(0, 0, 1, 0)
|
||||||
|
}
|
||||||
|
else if (check == ForgeDirection.WEST)
|
||||||
|
{
|
||||||
|
glRotatef(-180, 0, 1, 0)
|
||||||
|
}
|
||||||
|
else if (check == ForgeDirection.EAST)
|
||||||
|
{
|
||||||
|
glRotatef(180, 0, 1, 0)
|
||||||
|
}
|
||||||
|
GL11.glRotatef(-90, 0, 1, 0)
|
||||||
|
val io: Int = getIO(check)
|
||||||
|
if (io == 1)
|
||||||
|
{
|
||||||
|
TileBattery.model.renderOnly("connectorIn")
|
||||||
|
}
|
||||||
|
else if (io == 2)
|
||||||
|
{
|
||||||
|
TileBattery.model.renderOnly("connectorOut")
|
||||||
|
}
|
||||||
|
GL11.glPopMatrix()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enabledParts.removeAll(disabledParts)
|
||||||
|
|
||||||
|
for (i <- 1 to 8)
|
||||||
|
{
|
||||||
|
if (i != 1 || enabledParts.contains("coil1"))
|
||||||
|
{
|
||||||
|
if ((8 - i) < energyLevel) TileBattery.model.renderOnly("coil" + i + "lit")
|
||||||
|
else TileBattery.model.renderOnly("coil" + i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("connector", "connectorIn", "connectorOut"): _*))
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8"): _*))
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit"): _*))
|
||||||
|
disabledParts.addAll(Arrays.asList(Array[String]("frame1con", "frame2con", "frame3con", "frame4con"): _*))
|
||||||
|
enabledParts.removeAll(Arrays.asList(Array[String]("coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8")))
|
||||||
|
TileBattery.model.renderAllExcept(disabledParts.toArray(new Array[String](0)): _*)
|
||||||
|
TileBattery.model.renderOnly(enabledParts.toArray(new Array[String](0)): _*)
|
||||||
|
GL11.glPopMatrix()
|
||||||
|
}
|
||||||
|
|
||||||
override def toString: String =
|
override def toString: String =
|
||||||
{
|
{
|
||||||
return "[TileBattery]" + x + "x " + y + "y " + z + "z "
|
return "[TileBattery]" + x + "x " + y + "y " + z + "z "
|
||||||
|
|
|
@ -4,18 +4,21 @@ import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||||
import net.minecraft.block.material.Material
|
import net.minecraft.block.material.Material
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister
|
import net.minecraft.client.renderer.texture.IIconRegister
|
||||||
import net.minecraft.util.IIcon
|
import net.minecraft.util.IIcon
|
||||||
|
import resonant.content.prefab.RenderConnectedTexture
|
||||||
import resonant.content.spatial.block.SpatialBlock
|
import resonant.content.spatial.block.SpatialBlock
|
||||||
import resonant.lib.content.prefab.java.TileElectric
|
import resonant.lib.content.prefab.java.TileElectric
|
||||||
import resonantinduction.core.{Reference, Settings}
|
import resonantinduction.core.{Reference, Settings}
|
||||||
import resonant.lib.transform.region.Cuboid
|
import resonant.lib.transform.region.Cuboid
|
||||||
|
|
||||||
class TileSolarPanel extends TileElectric(Material.iron)
|
class TileSolarPanel extends TileElectric(Material.iron) with RenderConnectedTexture
|
||||||
{
|
{
|
||||||
ioMap = 728
|
ioMap = 728
|
||||||
textureName = "solarPanel_top"
|
textureName = "solarPanel_top"
|
||||||
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1)
|
bounds = new Cuboid(0, 0, 0, 1, 0.3f, 1)
|
||||||
isOpaqueCube = false
|
isOpaqueCube = false
|
||||||
|
|
||||||
|
override val edgeTexture = Reference.prefix + "tankEdge"
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
override def registerIcons(iconReg: IIconRegister)
|
override def registerIcons(iconReg: IIconRegister)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue