Fixed gear shaft connections
This commit is contained in:
parent
b9e53b59e8
commit
bdf458b84c
9 changed files with 185 additions and 177 deletions
|
@ -54,7 +54,7 @@ import resonantinduction.mechanical.mech.turbine._
|
|||
{
|
||||
//Mech content TODO no-load if mech content is not loaded
|
||||
ItemRenderHandler.register(MechanicalContent.itemGear, RenderGear)
|
||||
ItemRenderHandler.register(MechanicalContent.itemGearShaft, RenderGearShaft.INSTANCE)
|
||||
ItemRenderHandler.register(MechanicalContent.itemGearShaft, RenderGearShaft)
|
||||
ItemRenderHandler.register(MechanicalContent.itemPipe, RenderPipe)
|
||||
ItemRenderHandler.register(Item.getItemFromBlock(MechanicalContent.blockWaterTurbine), new RenderWaterTurbine)
|
||||
ItemRenderHandler.register(Item.getItemFromBlock(MechanicalContent.blockWindTurbine), new RenderWindTurbine)
|
||||
|
|
|
@ -2,9 +2,12 @@ package resonantinduction.mechanical.mech
|
|||
|
||||
import codechicken.lib.data.{MCDataInput, MCDataOutput}
|
||||
import codechicken.multipart._
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.MovingObjectPosition
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.lib.transform.vector.{Vector3, VectorWorld}
|
||||
import resonant.lib.transform.vector.VectorWorld
|
||||
import resonantinduction.core.prefab.part.connector.{PartAbstract, TPartNodeProvider}
|
||||
import resonantinduction.mechanical.mech.grid.MechanicalNode
|
||||
|
||||
|
@ -16,12 +19,14 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
|
|||
/** Node that handles resonantinduction.mechanical action of the machine */
|
||||
private var _mechanicalNode: MechanicalNode = null
|
||||
|
||||
protected var markVelocityUpdate = false
|
||||
|
||||
def mechanicalNode = _mechanicalNode
|
||||
|
||||
def mechanicalNode_=(mech: MechanicalNode)
|
||||
{
|
||||
_mechanicalNode = mech
|
||||
mechanicalNode.onVelocityChanged = () => sendVelocityPacket()
|
||||
mechanicalNode.onVelocityChanged = () => markVelocityUpdate = true
|
||||
nodes.add(mechanicalNode)
|
||||
}
|
||||
|
||||
|
@ -31,12 +36,34 @@ abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TF
|
|||
/** The tier of this mechanical part */
|
||||
var tier = 0
|
||||
|
||||
override def update()
|
||||
{
|
||||
super.update()
|
||||
|
||||
if (markVelocityUpdate)
|
||||
{
|
||||
sendVelocityPacket()
|
||||
markVelocityUpdate = false
|
||||
}
|
||||
}
|
||||
|
||||
def preparePlacement(side: Int, itemDamage: Int)
|
||||
{
|
||||
this.placementSide = ForgeDirection.getOrientation((side).asInstanceOf[Byte])
|
||||
this.tier = itemDamage
|
||||
}
|
||||
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, item: ItemStack): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
println(mechanicalNode)
|
||||
println(mechanicalNode.getMechanicalGrid)
|
||||
}
|
||||
|
||||
super.activate(player, hit, item)
|
||||
}
|
||||
|
||||
/** Packet Code. */
|
||||
def sendVelocityPacket()
|
||||
{
|
||||
|
|
|
@ -19,23 +19,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
{
|
||||
teethDisplacement = 0.01D
|
||||
|
||||
protected def gear: PartGear = getParent.asInstanceOf[PartGear]
|
||||
|
||||
/*
|
||||
override def update(deltaTime: Double)
|
||||
{
|
||||
super.update(deltaTime)
|
||||
if (!gear.getMultiBlock.isPrimary)
|
||||
{
|
||||
torque = 0
|
||||
angularVelocity = 0
|
||||
}
|
||||
else if (gear.tier == 10)
|
||||
{
|
||||
torque = 100
|
||||
angularVelocity = 100
|
||||
}
|
||||
}*/
|
||||
protected def gear = getParent.asInstanceOf[PartGear]
|
||||
|
||||
override def getTorqueLoad: Double =
|
||||
{
|
||||
|
@ -43,7 +27,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
{
|
||||
case 0 => 0.1
|
||||
case 1 => 0.2
|
||||
case 2 => 0.15
|
||||
case 2 => 0.1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +37,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
{
|
||||
case 0 => 0.1
|
||||
case 1 => 0.2
|
||||
case 2 => 0.15
|
||||
case 2 => 0.1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,15 +109,17 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
}
|
||||
if (other.isInstanceOf[MechanicalNode])
|
||||
{
|
||||
val parent: INodeProvider = (other.asInstanceOf[MechanicalNode]).getParent
|
||||
val parent: INodeProvider = other.asInstanceOf[MechanicalNode].getParent
|
||||
if (from == gear.placementSide.getOpposite)
|
||||
{
|
||||
if (parent.isInstanceOf[PartGear] || parent.isInstanceOf[PartGearShaft])
|
||||
{
|
||||
if (parent.isInstanceOf[PartGearShaft])
|
||||
{
|
||||
val shaft: PartGearShaft = parent.asInstanceOf[PartGearShaft]
|
||||
return shaft.tile.partMap(from.getOpposite.ordinal) != gear && Math.abs(shaft.placementSide.offsetX) == Math.abs(gear.placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear.placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear.placementSide.offsetZ)
|
||||
//We are connecting to a shaft.
|
||||
val shaft = parent.asInstanceOf[PartGearShaft]
|
||||
//Check if the shaft is directing connected to the center of the gear (multiblock cases) and also its direction to make sure the shaft is facing the gear itself
|
||||
return /*shaft.tile.partMap(from.getOpposite.ordinal) != gear && */Math.abs(shaft.placementSide.offsetX) == Math.abs(gear.placementSide.offsetX) && Math.abs(shaft.placementSide.offsetY) == Math.abs(gear.placementSide.offsetY) && Math.abs(shaft.placementSide.offsetZ) == Math.abs(gear.placementSide.offsetZ)
|
||||
}
|
||||
else if (parent.isInstanceOf[PartGear])
|
||||
{
|
||||
|
@ -170,7 +156,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
val sourceTile: TileEntity = toVectorWorld.add(from.getOpposite).getTileEntity(world)
|
||||
if (sourceTile.isInstanceOf[INodeProvider])
|
||||
{
|
||||
val sourceInstance: MechanicalNode = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], from).asInstanceOf[MechanicalNode]
|
||||
val sourceInstance: MechanicalNode = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], from)
|
||||
return sourceInstance == other
|
||||
}
|
||||
}
|
||||
|
@ -179,21 +165,21 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
|
|||
val sourceTile: TileEntity = toVectorWorld.add(from).getTileEntity(world)
|
||||
if (sourceTile.isInstanceOf[INodeProvider])
|
||||
{
|
||||
val sourceInstance: MechanicalNode = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], from.getOpposite).asInstanceOf[MechanicalNode]
|
||||
val sourceInstance: MechanicalNode = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], from.getOpposite)
|
||||
return sourceInstance == other
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val destinationTile: TileEntity = (other.asInstanceOf[MechanicalNode]).toVectorWorld.add(from.getOpposite).getTileEntity(world)
|
||||
val destinationTile: TileEntity = other.asInstanceOf[MechanicalNode].toVectorWorld.add(from.getOpposite).getTileEntity(world)
|
||||
if (destinationTile.isInstanceOf[INodeProvider] && destinationTile.isInstanceOf[TileMultipart])
|
||||
{
|
||||
val destinationPart: TMultiPart = (destinationTile.asInstanceOf[TileMultipart]).partMap(gear.placementSide.ordinal)
|
||||
val destinationPart: TMultiPart = destinationTile.asInstanceOf[TileMultipart].partMap(gear.placementSide.ordinal)
|
||||
if (destinationPart.isInstanceOf[PartGear])
|
||||
{
|
||||
if (gear ne destinationPart)
|
||||
{
|
||||
return (destinationPart.asInstanceOf[PartGear]).isCenterMultiBlock
|
||||
return destinationPart.asInstanceOf[PartGear].isCenterMultiBlock
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -17,45 +17,44 @@ import resonantinduction.mechanical.mech.gearshaft.PartGearShaft
|
|||
|
||||
class ItemGear extends JItemMultiPart with IHighlight
|
||||
{
|
||||
//Constructor
|
||||
setHasSubtypes(true)
|
||||
setHasSubtypes(true)
|
||||
|
||||
override def getUnlocalizedName(itemStack: ItemStack): String =
|
||||
override def getUnlocalizedName(itemStack: ItemStack): String =
|
||||
{
|
||||
return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage
|
||||
}
|
||||
|
||||
override def newPart(itemStack: ItemStack, player: EntityPlayer, world: World, pos: BlockCoord, s: Int, hit: Vector3): TMultiPart =
|
||||
{
|
||||
|
||||
val part: PartGear = ResonantPartFactory.create(classOf[PartGear])
|
||||
var side: Int = FacePlacementGrid.getHitSlot(hit, s)
|
||||
val tile: TileEntity = world.getTileEntity(pos.x, pos.y, pos.z)
|
||||
if (tile.isInstanceOf[TileMultipart])
|
||||
{
|
||||
return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage
|
||||
val occupyingPart: TMultiPart = (tile.asInstanceOf[TileMultipart]).partMap(side)
|
||||
val centerPart: TMultiPart = (tile.asInstanceOf[TileMultipart]).partMap(PartMap.CENTER.ordinal)
|
||||
val clickedCenter: Boolean = hit.mag < 0.4
|
||||
if ((clickedCenter && centerPart.isInstanceOf[PartGearShaft]))
|
||||
{
|
||||
side ^= 1
|
||||
}
|
||||
}
|
||||
part.preparePlacement(side, itemStack.getItemDamage)
|
||||
return part
|
||||
}
|
||||
|
||||
override def newPart(itemStack: ItemStack, player: EntityPlayer, world: World, pos: BlockCoord, s: Int, hit: Vector3): TMultiPart =
|
||||
override def getSubItems(itemID: Item, tab: CreativeTabs, listToAddTo: List[_])
|
||||
{
|
||||
for (i <- 0 to 2)
|
||||
{
|
||||
|
||||
val part: PartGear = ResonantPartFactory.create(classOf[PartGear])
|
||||
var side: Int = FacePlacementGrid.getHitSlot(hit, s)
|
||||
val tile: TileEntity = world.getTileEntity(pos.x, pos.y, pos.z)
|
||||
if (tile.isInstanceOf[TileMultipart])
|
||||
{
|
||||
val occupyingPart: TMultiPart = (tile.asInstanceOf[TileMultipart]).partMap(side)
|
||||
val centerPart: TMultiPart = (tile.asInstanceOf[TileMultipart]).partMap(PartMap.CENTER.ordinal)
|
||||
val clickedCenter: Boolean = hit.mag < 0.4
|
||||
if ((clickedCenter && centerPart.isInstanceOf[PartGearShaft]))
|
||||
{
|
||||
side ^= 1
|
||||
}
|
||||
}
|
||||
part.preparePlacement(side, itemStack.getItemDamage)
|
||||
return part
|
||||
listToAddTo.add(new ItemStack(itemID, 1, i))
|
||||
}
|
||||
listToAddTo.add(new ItemStack(itemID, 1, 10))
|
||||
}
|
||||
|
||||
override def getSubItems(itemID: Item, tab: CreativeTabs, listToAddTo: List[_])
|
||||
{
|
||||
for (i <- 0 to 2)
|
||||
{
|
||||
listToAddTo.add(new ItemStack(itemID, 1, i))
|
||||
}
|
||||
listToAddTo.add(new ItemStack(itemID, 1, 10))
|
||||
}
|
||||
|
||||
def getHighlightType: Int =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
def getHighlightType: Int =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
}
|
|
@ -36,7 +36,11 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
|
||||
//Constructor
|
||||
mechanicalNode = new GearNode(this)
|
||||
mechanicalNode.onVelocityChanged = () => if (getMultiBlock.isPrimary) sendVelocityPacket()
|
||||
mechanicalNode.onVelocityChanged = () =>
|
||||
{
|
||||
if (getMultiBlock.isPrimary)
|
||||
markVelocityUpdate = true
|
||||
}
|
||||
|
||||
//TODO: Can we not have update ticks here?
|
||||
override def update()
|
||||
|
@ -57,12 +61,6 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
|
||||
override def activate(player: EntityPlayer, hit: MovingObjectPosition, itemStack: ItemStack): Boolean =
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
println(mechanicalNode)
|
||||
println(mechanicalNode.getMechanicalGrid)
|
||||
}
|
||||
|
||||
if (itemStack != null && itemStack.getItem.isInstanceOf[ItemHandCrank])
|
||||
{
|
||||
if (!world.isRemote && ControlKeyModifer.isControlDown(player))
|
||||
|
@ -123,12 +121,11 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
|
|||
return new ItemStack(MechanicalContent.itemGear, 1, tier)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||
{
|
||||
if (pass == 0)
|
||||
{
|
||||
RenderGear.renderDynamic(this, pos.x, pos.y, pos.z, tier)
|
||||
}
|
||||
}
|
||||
|
||||
override def load(nbt: NBTTagCompound)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package resonantinduction.mechanical.mech.gearshaft
|
||||
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import resonant.api.grid.INodeProvider
|
||||
import resonant.lib.transform.vector.Vector3
|
||||
|
@ -19,34 +18,44 @@ class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
|
|||
}
|
||||
}
|
||||
|
||||
override def getAngularVelocityLoad: Double = 0
|
||||
override def getAngularVelocityLoad: Double =
|
||||
{
|
||||
return shaft.tier match
|
||||
{
|
||||
case 0 => 0.03
|
||||
case 1 => 0.02
|
||||
case 2 => 0.01
|
||||
}
|
||||
}
|
||||
|
||||
override def rebuild()
|
||||
{
|
||||
for (ch <- List(shaft.placementSide, shaft.placementSide.getOpposite))
|
||||
//Check only two possible sides for connections
|
||||
for (toDir <- Seq(shaft.placementSide, shaft.placementSide.getOpposite))
|
||||
{
|
||||
val checkDir: ForgeDirection = ch
|
||||
if (checkDir == shaft.placementSide || checkDir == shaft.placementSide.getOpposite)
|
||||
{
|
||||
if (shaft.tile.isInstanceOf[INodeProvider])
|
||||
{
|
||||
val instance: MechanicalNode = (shaft.tile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], checkDir).asInstanceOf[MechanicalNode]
|
||||
var found = false
|
||||
|
||||
if (instance != null && instance != this && instance.canConnect(this, checkDir.getOpposite))
|
||||
{
|
||||
connect(instance, checkDir)
|
||||
}
|
||||
}
|
||||
else
|
||||
///Check within this block for another gear plate that will move this shaft
|
||||
val otherNode = shaft.tile.asInstanceOf[INodeProvider].getNode(classOf[MechanicalNode], toDir)
|
||||
|
||||
if (otherNode != null && otherNode != this && canConnect(otherNode, toDir) && otherNode.canConnect(this, toDir.getOpposite))
|
||||
{
|
||||
connect(otherNode, toDir)
|
||||
found = true
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
///Check for other gear shafts outside this tile
|
||||
val checkTile = new Vector3(shaft.tile).add(toDir).getTileEntity(world)
|
||||
|
||||
if (checkTile.isInstanceOf[INodeProvider])
|
||||
{
|
||||
val checkTile: TileEntity = new Vector3(shaft.tile).add(checkDir).getTileEntity(world)
|
||||
if (checkTile.isInstanceOf[INodeProvider])
|
||||
val instance = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], toDir.getOpposite)
|
||||
|
||||
if (instance != null && instance != this && instance.getParent.isInstanceOf[PartGearShaft] && instance.canConnect(this, toDir.getOpposite))
|
||||
{
|
||||
val instance: MechanicalNode = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], checkDir.getOpposite).asInstanceOf[MechanicalNode]
|
||||
if (instance != null && instance != this && instance.getParent.isInstanceOf[PartGearShaft] && instance.canConnect(this, checkDir.getOpposite))
|
||||
{
|
||||
connect(instance, checkDir)
|
||||
}
|
||||
connect(instance, toDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,44 +3,38 @@ package resonantinduction.mechanical.mech.gearshaft
|
|||
import java.util.List
|
||||
|
||||
import codechicken.lib.vec.{BlockCoord, Vector3}
|
||||
import codechicken.multipart.{JItemMultiPart, MultiPartRegistry, TMultiPart}
|
||||
import codechicken.multipart.{TItemMultiPart, TMultiPart}
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.{Item, ItemStack}
|
||||
import net.minecraft.world.World
|
||||
import resonant.lib.wrapper.WrapList._
|
||||
import resonantinduction.core.ResonantPartFactory
|
||||
import resonantinduction.core.prefab.part.IHighlight
|
||||
|
||||
class ItemGearShaft extends JItemMultiPart with IHighlight
|
||||
class ItemGearShaft extends Item with TItemMultiPart with IHighlight
|
||||
{
|
||||
//Constructor
|
||||
setHasSubtypes(true)
|
||||
setHasSubtypes(true)
|
||||
|
||||
override def getUnlocalizedName(itemStack: ItemStack): String =
|
||||
{
|
||||
return super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage
|
||||
}
|
||||
override def getUnlocalizedName(itemStack: ItemStack): String = super.getUnlocalizedName(itemStack) + "." + itemStack.getItemDamage
|
||||
|
||||
def newPart(itemStack: ItemStack, player: EntityPlayer, world: World, pos: BlockCoord, side: Int, hit: Vector3): TMultiPart =
|
||||
def newPart(itemStack: ItemStack, player: EntityPlayer, world: World, pos: BlockCoord, side: Int, hit: Vector3): TMultiPart =
|
||||
{
|
||||
val part = ResonantPartFactory.create(classOf[PartGearShaft])
|
||||
if (part != null)
|
||||
{
|
||||
val part: PartGearShaft = MultiPartRegistry.createPart("resonant_induction_gear_shaft", false).asInstanceOf[PartGearShaft]
|
||||
if (part != null)
|
||||
{
|
||||
part.preparePlacement(side, itemStack.getItemDamage)
|
||||
}
|
||||
return part
|
||||
part.preparePlacement(side, itemStack.getItemDamage)
|
||||
}
|
||||
return part
|
||||
}
|
||||
|
||||
override def getSubItems(itemID: Item, tab: CreativeTabs, listToAddTo: List[_])
|
||||
override def getSubItems(itemID: Item, tab: CreativeTabs, listToAddTo: List[_])
|
||||
{
|
||||
for (i <- 0 until 3)
|
||||
{
|
||||
for (i <- 0 until 3)
|
||||
{
|
||||
listToAddTo.add(new ItemStack(itemID, 1, i))
|
||||
}
|
||||
listToAddTo.add(new ItemStack(itemID, 1, i))
|
||||
}
|
||||
}
|
||||
|
||||
def getHighlightType: Int =
|
||||
{
|
||||
return 0
|
||||
}
|
||||
override def getHighlightType: Int = 0
|
||||
}
|
|
@ -36,7 +36,7 @@ class PartGearShaft extends PartMechanical
|
|||
|
||||
override def preparePlacement(side: Int, itemDamage: Int)
|
||||
{
|
||||
val dir: ForgeDirection = ForgeDirection.getOrientation((side ^ 1).asInstanceOf[Byte])
|
||||
val dir = ForgeDirection.getOrientation(side ^ 1)
|
||||
this.placementSide = ForgeDirection.getOrientation(if (!(dir.ordinal % 2 == 0)) dir.ordinal - 1 else dir.ordinal)
|
||||
tier = itemDamage
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class PartGearShaft extends PartMechanical
|
|||
override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||
{
|
||||
if (pass == 0)
|
||||
RenderGearShaft.INSTANCE.renderDynamic(this, pos.x, pos.y, pos.z, frame)
|
||||
RenderGearShaft.renderDynamic(this, pos.x, pos.y, pos.z, frame)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.{Side, SideOnly}
|
|||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.IItemRenderer
|
||||
import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL11.glRotatef
|
||||
|
@ -12,65 +12,61 @@ import resonant.content.prefab.scal.render.ISimpleItemRenderer
|
|||
import resonant.lib.render.RenderUtility
|
||||
import resonantinduction.core.Reference
|
||||
|
||||
@SideOnly(Side.CLIENT) object RenderGearShaft
|
||||
@SideOnly(Side.CLIENT)
|
||||
object RenderGearShaft extends ISimpleItemRenderer
|
||||
{
|
||||
final val INSTANCE: RenderGearShaft = new RenderGearShaft
|
||||
}
|
||||
final val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "gears.obj"))
|
||||
|
||||
@SideOnly(Side.CLIENT) class RenderGearShaft extends ISimpleItemRenderer
|
||||
{
|
||||
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
|
||||
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
|
||||
{
|
||||
GL11.glRotatef(90, 1, 0, 0)
|
||||
|
||||
if (itemStack.getItemDamage == 1)
|
||||
{
|
||||
GL11.glRotatef(90, 1, 0, 0)
|
||||
|
||||
if (itemStack.getItemDamage == 1)
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "cobblestone.png")
|
||||
}
|
||||
else if (itemStack.getItemDamage == 2)
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "iron_block.png")
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "planks_oak.png")
|
||||
}
|
||||
MODEL.renderOnly("Shaft")
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "cobblestone.png")
|
||||
}
|
||||
|
||||
def renderDynamic(part: PartGearShaft, x: Double, y: Double, z: Double, frame: Float)
|
||||
else if (itemStack.getItemDamage == 2)
|
||||
{
|
||||
GL11.glPushMatrix
|
||||
GL11.glTranslatef(x.asInstanceOf[Float] + 0.5f, y.asInstanceOf[Float] + 0.5f, z.asInstanceOf[Float] + 0.5f)
|
||||
GL11.glPushMatrix
|
||||
val dir: ForgeDirection = part.placementSide
|
||||
|
||||
if (dir == ForgeDirection.NORTH)
|
||||
{
|
||||
glRotatef(90, 1, 0, 0)
|
||||
}
|
||||
else if (dir == ForgeDirection.WEST)
|
||||
{
|
||||
glRotatef(90, 0, 0, 1)
|
||||
}
|
||||
GL11.glRotatef(Math.toDegrees(part.mechanicalNode.angle).asInstanceOf[Float], 0, 1, 0)
|
||||
|
||||
if (part.tier == 1)
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "cobblestone.png")
|
||||
}
|
||||
else if (part.tier == 2)
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "iron_block.png")
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "planks_oak.png")
|
||||
}
|
||||
MODEL.renderOnly("Shaft")
|
||||
GL11.glPopMatrix
|
||||
GL11.glPopMatrix
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "iron_block.png")
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "planks_oak.png")
|
||||
}
|
||||
model.renderOnly("Shaft")
|
||||
}
|
||||
|
||||
final val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "gears.obj"))
|
||||
def renderDynamic(part: PartGearShaft, x: Double, y: Double, z: Double, frame: Float)
|
||||
{
|
||||
GL11.glPushMatrix()
|
||||
GL11.glTranslatef(x.asInstanceOf[Float] + 0.5f, y.asInstanceOf[Float] + 0.5f, z.asInstanceOf[Float] + 0.5f)
|
||||
GL11.glPushMatrix()
|
||||
val dir: ForgeDirection = part.placementSide
|
||||
|
||||
if (dir == ForgeDirection.NORTH)
|
||||
{
|
||||
glRotatef(90, 1, 0, 0)
|
||||
}
|
||||
else if (dir == ForgeDirection.WEST)
|
||||
{
|
||||
glRotatef(90, 0, 0, 1)
|
||||
}
|
||||
GL11.glRotatef(Math.toDegrees(part.mechanicalNode.angle).asInstanceOf[Float], 0, 1, 0)
|
||||
|
||||
if (part.tier == 1)
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "cobblestone.png")
|
||||
}
|
||||
else if (part.tier == 2)
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "iron_block.png")
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderUtility.bind(Reference.blockTextureDirectory + "planks_oak.png")
|
||||
}
|
||||
model.renderOnly("Shaft")
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopMatrix()
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue